Let’s see the code of the LIBRARY MANAGEMENT SYSTEM project in C#.
frmOverdue.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using LibrarySystem.Includes; using LibrarySystem.Properties; namespace LibrarySystem { public partial class frmOverdue : Form { public frmOverdue() { InitializeComponent(); } SQLConfig config = new SQLConfig(); usableFunction funct = new usableFunction(); string sql; private void btnPenNew_Click(object sender, EventArgs e) { funct.clearTxt(GroupBox7); funct.clearTxt(GroupBox10); sql = "SELECT br.`BorrowerId`, `BookTitle`,`DateBorrowed`, `Purpose`, `DueDate` , BorrowId,br.AccessionNo " + " FROM `tblborrow` br,`tblbooks` b,`tblborrower` bw " + " WHERE br.AccessionNo=b.AccessionNo AND br.`BorrowerId`=bw.`BorrowerId` AND br.Status='Borrowed' AND Due=1 "; config.Load_ResultList(sql, dtgPenalties); dtgPenalties.Columns[5].Visible = false; dtgPenalties.Columns[6].Visible = false; } private void frmOverdue_Load(object sender, EventArgs e) { btnPenNew_Click(sender, e); } private void txtSearchPborrower_TextChanged(object sender, EventArgs e) { sql = "SELECT br.`BorrowerId`, `BookTitle`,`DateBorrowed`, `Purpose`, `DueDate` , BorrowId,br.AccessionNo " + " FROM `tblborrow` br,`tblbooks` b,`tblborrower` bw " + " WHERE br.AccessionNo=b.AccessionNo AND br.`BorrowerId`=bw.`BorrowerId` AND br.Status='Borrowed' AND Due=1 AND br.`BorrowerId` Like '%" + txtSearchPborrower.Text + "%'"; config.Load_ResultList(sql, dtgPenalties); dtgPenalties.Columns[5].Visible = false; dtgPenalties.Columns[6].Visible = false; } private void dtgPenalties_CellClick(object sender, DataGridViewCellEventArgs e) { sql = "SELECT TIMEDIFF( NOW( ) , `DueDate` ),`AccessionNo` " + "FROM `tblborrow` WHERE `BorrowId` = '" + dtgPenalties.CurrentRow.Cells[5].Value.ToString() + "'"; config.singleResult(sql); if (config.dt.Rows.Count > 0) { TimeSpan ts = config.dt.Rows[0].Field<TimeSpan>(0); int tsdays, hourperday, tshours, totalhours; //MessageBox.Show(ts.Hours.ToString()); tsdays = ts.Days; hourperday = tsdays * 24; tshours = ts.Hours; totalhours = hourperday + tshours; txtOverdueTime.Text = ts.ToString(); txttothours.Text = totalhours.ToString(); } } private void txtamount_TextChanged(object sender, EventArgs e) { try { int totalpayments; totalpayments = int.Parse(txttothours.Text) * int.Parse(txtamount.Text); } catch (Exception ex) { } //totalhours = condays + tValueHour //totalhours = totalhours / Val(frmPayments.txthours.Text) //frmPayments.txtTotPay.Text = totalhours * Val(frmPayments.txtamount.Text) } private void txthours_ValueChanged(object sender, EventArgs e) { try { double total_hours, total_payments; total_hours = int.Parse(txttothours.Text) / int.Parse(txthours.Text); total_payments = total_hours * double.Parse(txtamount.Text); txtTotPay.Text = total_payments.ToString(); } catch (Exception ex) { } } private void txthours_KeyPress(object sender, KeyPressEventArgs e) { try { double total_hours, total_payments; total_hours = int.Parse(txttothours.Text) / int.Parse(txthours.Text); total_payments = total_hours * double.Parse(txtamount.Text); txtTotPay.Text = total_payments.ToString(); } catch (Exception ex) { } } private void txttenderedAmount_TextChanged(object sender, EventArgs e) { double change; change = double.Parse(txttenderedAmount.Text) - double.Parse(txtTotPay.Text); txtChange.Text = change.ToString(); } private void btnPSave_Click(object sender, EventArgs e) { if (txtamount.Text == "" || txthours.Text == "" || txttenderedAmount.Text == "" || txtOverdueTime.Text == "") { MessageBox.Show("You must fill all the fields inorder to save.", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if(int.Parse(txtChange.Text) < 0) { MessageBox.Show("The tendered amount is less than the total payments. Its not valid", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } sql = "INSERT INTO `tblpayment` (`BorrowId`, `Payment`, `Change`, `DatePayed`, `BorrowerId`, `Remarks`) " + " VALUES (" + dtgPenalties.CurrentRow.Cells[6].Value + ",'" + txtTotPay.Text + "','" + txtChange.Text + "',Now(),'" + dtgPenalties.CurrentRow.Cells[0].Value + "','Settled')"; config.Execute_Query(sql); sql = "INSERT INTO `tblreturn` (`BorrowId`, `NoCopies`, `DateReturned`, `Remarks`)" + " VALUES (" + dtgPenalties.CurrentRow.Cells[6].Value + ",1,NOW(),'Returned')"; config.Execute_Query(sql); sql = "UPDATE `tblbooks` SET `Status` = 'Available' WHERE `AccessionNo` = '" + dtgPenalties.CurrentRow.Cells[6].Value + "'"; config.Execute_Query(sql); sql = "UPDATE `tblborrow` SET `Status` = 'Returned', Due = 0 WHERE `BorrowId` = " + dtgPenalties.CurrentRow.Cells[5].Value; config.Execute_Query(sql); MessageBox.Show("Book has been returned and settled in the library"); btnPenNew_Click(sender, e); } private void btnPenClose_Click(object sender, EventArgs e) { this.Close(); } } } |
frmCategories.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using LibrarySystem.Includes; using LibrarySystem.Properties; using System.IO; namespace LibrarySystem { public partial class frmCategories : Form { public frmCategories() { InitializeComponent(); } SQLConfig config = new SQLConfig(); usableFunction funct = new usableFunction(); string sql,categoryid; private void frmCategories_Load(object sender, EventArgs e) { btnnew_Click(sender, e); } private void btnnew_Click(object sender, EventArgs e) { categoryid = "0"; txtCategory.Clear(); txtDeweyDecimal.Clear(); sql = "Select CategoryId,`Category`,`DDecimal` as 'DeweyDecimal' From tblcategory WHERE Category !='ALL'"; config.Load_DTG(sql, dtglist); btndelete.Enabled = false; } private void btnsave_Click(object sender, EventArgs e) { if( txtCategory.Text == "") { funct.emptymessage(); } sql = "Select * From tblcategory WHERE CategoryId = '" + categoryid + "'"; config.singleResult(sql); if (config.dt.Rows.Count > 0) { sql = "UPDATE `tblcategory` SET `Category`='" + txtCategory.Text + "',`DDecimal`='" + txtDeweyDecimal.Text + "' WHERE CategoryId='" + categoryid + "'"; config.Execute_CUD(sql, "error to execute the query.", "Category has been updated in the database."); } else { sql = "INSERT INTO `tblcategory` (`Category`,`DDecimal`) VALUES ('" + txtCategory.Text + "','" + txtDeweyDecimal.Text + "')"; config.Execute_CUD(sql, "error to execute the query.", "New category has been saved in the database."); } btnnew_Click(sender, e); } private void btndelete_Click(object sender, EventArgs e) { sql = "Delete From tblcategory WHERE CategoryId = " + dtglist.CurrentRow.Cells[0].Value; config.Execute_Query(sql); MessageBox.Show("Data has been deleted."); btnnew_Click(sender, e); } private void dtglist_CellClick(object sender, DataGridViewCellEventArgs e) { categoryid = dtglist.CurrentRow.Cells[0].Value.ToString(); txtCategory.Text = dtglist.CurrentRow.Cells[1].Value.ToString(); txtDeweyDecimal.Text = dtglist.CurrentRow.Cells[2].Value.ToString(); btndelete.Enabled = true; } } } |
frmReport.Designer.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
namespace LibrarySystem { partial class frmReport { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.dtp_endDate = new System.Windows.Forms.DateTimePicker(); this.btn_preview = new System.Windows.Forms.Button(); this.btnTotalbooks = new System.Windows.Forms.Button(); this.btnListBooks = new System.Windows.Forms.Button(); this.rdoMonthly = new System.Windows.Forms.RadioButton(); this.rdoWeekly = new System.Windows.Forms.RadioButton(); this.rdoDaily = new System.Windows.Forms.RadioButton(); this.dtp_strtDate = new System.Windows.Forms.DateTimePicker(); this.Label2 = new System.Windows.Forms.Label(); this.Label3 = new System.Windows.Forms.Label(); this.Label1 = new System.Windows.Forms.Label(); this.cboStatus = new System.Windows.Forms.ComboBox(); this.GroupBox1 = new System.Windows.Forms.GroupBox(); this.FlowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.GroupBox2 = new System.Windows.Forms.GroupBox(); this.crystalReportViewer1 = new CrystalDecisions.Windows.Forms.CrystalReportViewer(); this.GroupBox1.SuspendLayout(); this.FlowLayoutPanel1.SuspendLayout(); this.GroupBox2.SuspendLayout(); this.SuspendLayout(); // // dtp_endDate // this.dtp_endDate.CustomFormat = "yyyy-MM-dd"; this.dtp_endDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom; this.dtp_endDate.Location = new System.Drawing.Point(10, 89); this.dtp_endDate.Name = "dtp_endDate"; this.dtp_endDate.Size = new System.Drawing.Size(132, 20); this.dtp_endDate.TabIndex = 17; // // btn_preview // this.btn_preview.Location = new System.Drawing.Point(64, 120); this.btn_preview.Name = "btn_preview"; this.btn_preview.Size = new System.Drawing.Size(78, 28); this.btn_preview.TabIndex = 15; this.btn_preview.Text = "Preview"; this.btn_preview.UseVisualStyleBackColor = true; this.btn_preview.Click += new System.EventHandler(this.btn_preview_Click); // // btnTotalbooks // this.btnTotalbooks.Location = new System.Drawing.Point(10, 53); this.btnTotalbooks.Name = "btnTotalbooks"; this.btnTotalbooks.Size = new System.Drawing.Size(133, 22); this.btnTotalbooks.TabIndex = 3; this.btnTotalbooks.Text = "Total No. of Books"; this.btnTotalbooks.UseVisualStyleBackColor = true; this.btnTotalbooks.Click += new System.EventHandler(this.btnTotalbooks_Click); // // btnListBooks // this.btnListBooks.Location = new System.Drawing.Point(9, 25); this.btnListBooks.Name = "btnListBooks"; this.btnListBooks.Size = new System.Drawing.Size(133, 22); this.btnListBooks.TabIndex = 2; this.btnListBooks.Text = "List of Books"; this.btnListBooks.UseVisualStyleBackColor = true; this.btnListBooks.Click += new System.EventHandler(this.btnListBooks_Click); // // rdoMonthly // this.rdoMonthly.AutoSize = true; this.rdoMonthly.Location = new System.Drawing.Point(24, 186); this.rdoMonthly.Name = "rdoMonthly"; this.rdoMonthly.Size = new System.Drawing.Size(97, 17); this.rdoMonthly.TabIndex = 2; this.rdoMonthly.TabStop = true; this.rdoMonthly.Text = "Monthly Report"; this.rdoMonthly.UseVisualStyleBackColor = true; this.rdoMonthly.CheckedChanged += new System.EventHandler(this.rdoMonthly_CheckedChanged); // // rdoWeekly // this.rdoWeekly.AutoSize = true; this.rdoWeekly.Location = new System.Drawing.Point(24, 163); this.rdoWeekly.Name = "rdoWeekly"; this.rdoWeekly.Size = new System.Drawing.Size(96, 17); this.rdoWeekly.TabIndex = 2; this.rdoWeekly.TabStop = true; this.rdoWeekly.Text = "Weekly Report"; this.rdoWeekly.UseVisualStyleBackColor = true; this.rdoWeekly.CheckedChanged += new System.EventHandler(this.rdoWeekly_CheckedChanged); // // rdoDaily // this.rdoDaily.AutoSize = true; this.rdoDaily.Location = new System.Drawing.Point(24, 140); this.rdoDaily.Name = "rdoDaily"; this.rdoDaily.Size = new System.Drawing.Size(83, 17); this.rdoDaily.TabIndex = 2; this.rdoDaily.TabStop = true; this.rdoDaily.Text = "Daily Report"; this.rdoDaily.UseVisualStyleBackColor = true; this.rdoDaily.CheckedChanged += new System.EventHandler(this.rdoDaily_CheckedChanged); // // dtp_strtDate // this.dtp_strtDate.CustomFormat = "yyyy-MM-dd"; this.dtp_strtDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom; this.dtp_strtDate.Location = new System.Drawing.Point(10, 41); this.dtp_strtDate.Name = "dtp_strtDate"; this.dtp_strtDate.Size = new System.Drawing.Size(132, 20); this.dtp_strtDate.TabIndex = 14; // // Label2 // this.Label2.AutoSize = true; this.Label2.Location = new System.Drawing.Point(10, 26); this.Label2.Name = "Label2"; this.Label2.Size = new System.Drawing.Size(61, 13); this.Label2.TabIndex = 16; this.Label2.Text = "Start Date :"; // // Label3 // this.Label3.AutoSize = true; this.Label3.Location = new System.Drawing.Point(10, 73); this.Label3.Name = "Label3"; this.Label3.Size = new System.Drawing.Size(58, 13); this.Label3.TabIndex = 18; this.Label3.Text = "End Date :"; // // Label1 // this.Label1.AutoSize = true; this.Label1.Location = new System.Drawing.Point(7, 84); this.Label1.Name = "Label1"; this.Label1.Size = new System.Drawing.Size(43, 13); this.Label1.TabIndex = 1; this.Label1.Text = "Status :"; // // cboStatus // this.cboStatus.FormattingEnabled = true; this.cboStatus.Items.AddRange(new object[] { "Borrowed", "Returned", "Overdue"}); this.cboStatus.Location = new System.Drawing.Point(6, 103); this.cboStatus.Name = "cboStatus"; this.cboStatus.Size = new System.Drawing.Size(137, 21); this.cboStatus.TabIndex = 0; this.cboStatus.Text = "Borrowed"; // // GroupBox1 // this.GroupBox1.Controls.Add(this.btnTotalbooks); this.GroupBox1.Controls.Add(this.btnListBooks); this.GroupBox1.Controls.Add(this.rdoMonthly); this.GroupBox1.Controls.Add(this.rdoWeekly); this.GroupBox1.Controls.Add(this.rdoDaily); this.GroupBox1.Controls.Add(this.Label1); this.GroupBox1.Controls.Add(this.cboStatus); this.GroupBox1.Location = new System.Drawing.Point(3, 3); this.GroupBox1.Name = "GroupBox1"; this.GroupBox1.Size = new System.Drawing.Size(152, 229); this.GroupBox1.TabIndex = 0; this.GroupBox1.TabStop = false; this.GroupBox1.Text = "Books"; // // FlowLayoutPanel1 // this.FlowLayoutPanel1.Controls.Add(this.GroupBox1); this.FlowLayoutPanel1.Controls.Add(this.GroupBox2); this.FlowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Left; this.FlowLayoutPanel1.Location = new System.Drawing.Point(0, 0); this.FlowLayoutPanel1.Name = "FlowLayoutPanel1"; this.FlowLayoutPanel1.Size = new System.Drawing.Size(161, 551); this.FlowLayoutPanel1.TabIndex = 3; // // GroupBox2 // this.GroupBox2.Controls.Add(this.dtp_strtDate); this.GroupBox2.Controls.Add(this.Label2); this.GroupBox2.Controls.Add(this.Label3); this.GroupBox2.Controls.Add(this.dtp_endDate); this.GroupBox2.Controls.Add(this.btn_preview); this.GroupBox2.Location = new System.Drawing.Point(3, 238); this.GroupBox2.Name = "GroupBox2"; this.GroupBox2.Size = new System.Drawing.Size(152, 162); this.GroupBox2.TabIndex = 2; this.GroupBox2.TabStop = false; this.GroupBox2.Text = "Date Filter"; // // crystalReportViewer1 // this.crystalReportViewer1.ActiveViewIndex = -1; this.crystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.crystalReportViewer1.Cursor = System.Windows.Forms.Cursors.Default; this.crystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill; this.crystalReportViewer1.Location = new System.Drawing.Point(161, 0); this.crystalReportViewer1.Name = "crystalReportViewer1"; this.crystalReportViewer1.Size = new System.Drawing.Size(727, 551); this.crystalReportViewer1.TabIndex = 4; // // frmReport // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(888, 551); this.Controls.Add(this.crystalReportViewer1); this.Controls.Add(this.FlowLayoutPanel1); this.Name = "frmReport"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Inventory Reports"; this.Load += new System.EventHandler(this.frmReport_Load); this.GroupBox1.ResumeLayout(false); this.GroupBox1.PerformLayout(); this.FlowLayoutPanel1.ResumeLayout(false); this.GroupBox2.ResumeLayout(false); this.GroupBox2.PerformLayout(); this.ResumeLayout(false); } #endregion internal System.Windows.Forms.DateTimePicker dtp_endDate; internal System.Windows.Forms.Button btn_preview; internal System.Windows.Forms.Button btnTotalbooks; internal System.Windows.Forms.Button btnListBooks; internal System.Windows.Forms.RadioButton rdoMonthly; internal System.Windows.Forms.RadioButton rdoWeekly; internal System.Windows.Forms.RadioButton rdoDaily; internal System.Windows.Forms.DateTimePicker dtp_strtDate; internal System.Windows.Forms.Label Label2; internal System.Windows.Forms.Label Label3; internal System.Windows.Forms.Label Label1; internal System.Windows.Forms.ComboBox cboStatus; internal System.Windows.Forms.GroupBox GroupBox1; internal System.Windows.Forms.FlowLayoutPanel FlowLayoutPanel1; internal System.Windows.Forms.GroupBox GroupBox2; private CrystalDecisions.Windows.Forms.CrystalReportViewer crystalReportViewer1; } } |
frmBorrower.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using LibrarySystem.Includes; using LibrarySystem.Properties; using System.IO; namespace LibrarySystem { public partial class frmBorrower : Form { public frmBorrower() { InitializeComponent(); } SQLConfig config = new SQLConfig(); usableFunction funct = new usableFunction(); string sql; int inc, maxrow; private void navigate_records(int inc) { sql = "SELECT BorrowerId FROM tblborrower"; config.singleResult(sql); if (config.dt.Rows.Count > 0) { txt_bid.Text = config.dt.Rows[inc].Field<string>(0); } } private void btn_New_Click(object sender, EventArgs e) { funct.clearTxt(this); sql = "SELECT BorrowerId,`Firstname`, `Lastname`, `MiddleName`, `Address`, `Sex`, `ContactNo`, `CourseYear` as 'Course/Year' FROM `tblborrower` WHERE Stats='Active'"; config.Load_ResultList(sql, dtg_ABorrowLists); PictureBox1.ImageLocation = ""; btn_delete.Enabled = false; sql = "SELECT * FROM `tblborrower` WHERE Stats='Active'"; config.singleResult(sql); if (config.dt.Rows.Count > 0) { maxrow = config.dt.Rows.Count - 1; } inc = 0; } private void frmBorrower_Load(object sender, EventArgs e) { btn_New_Click(sender, e); } private void txt_bid_TextChanged(object sender, EventArgs e) { sql = "SELECT * FROM `tblborrower` WHERE `BorrowerId` = '" + txt_bid.Text + "'"; config.singleResult(sql); if(config.dt.Rows.Count > 0) { txt_fname.Text = config.dt.Rows[0].Field<string>("Firstname"); txt_lname.Text = config.dt.Rows[0].Field<string>("Lastname"); txt_mname.Text = config.dt.Rows[0].Field<string>("MiddleName"); rch_address.Text = config.dt.Rows[0].Field<string>("Address"); txtContact.Text = config.dt.Rows[0].Field<string>("ContactNo"); txtCourse.Text = config.dt.Rows[0].Field<string>("CourseYear"); PictureBox1.ImageLocation = Application.StartupPath + "\\BorrowerPhoto\\" + config.dt.Rows[0].Field<string>("BorrowerPhoto"); if (config.dt.Rows[0].Field<string>("Sex") == "Female") { rdio_female.Checked = true; } else { rdio_male.Checked = true; } btn_delete.Enabled = true; } else { btn_delete.Enabled = false; clearme(); } } private void clearme() { txt_fname.Clear(); txt_lname.Clear(); txt_mname.Clear(); rch_address.Clear(); txtContact.Clear(); txtCourse.Clear(); txtPhoto.Clear(); } private void btn_save_Click(object sender, EventArgs e) { if( txt_bid.Text == "" || txt_fname.Text == "" || txt_lname.Text == "" || txt_mname.Text == "" || txtCourse.Text == "" ){ funct.emptymessage(); } string gender; if (rdio_female.Checked) { gender = "Female"; } else { gender = "Male"; } sql = "SELECT * FROM `tblborrower` WHERE `BorrowerId`=" + txt_bid.Text; config.singleResult(sql); if (config.dt.Rows.Count > 0) { sql = "update tblborrower set `Firstname`='" + txt_fname.Text + "', `Lastname`='" + txt_lname.Text + "', `MiddleName`='" + txt_mname.Text + "', `Address`='" + rch_address.Text + "', `Sex`='" + gender + "', `ContactNo` ='" + txtContact.Text + "', `CourseYear`='" + txtCourse.Text.ToUpper() + "', `BorrowerPhoto`='" + Path.GetFileName(PictureBox1.ImageLocation) + "', `BorrowerType`='Student' where `BorrowerId`='" + txt_bid.Text + "'"; config.Execute_CUD(sql, "error to execute the query", "Borrower has been updated in the database."); } else { sql = "insert into tblborrower (`BorrowerId`, `Firstname`, `Lastname`, `MiddleName`, `Address`, " + "`Sex`, `ContactNo`, `CourseYear`, `BorrowerPhoto`,`BorrowerType`,Stats)" + "values ('" + txt_bid.Text + "','" + txt_fname.Text + "','" + txt_lname.Text + "','" + txt_mname.Text + "','" + rch_address.Text + "','" + gender + "','" + txtContact.Text + "','" + txtCourse.Text + "','" + Path.GetFileName(PictureBox1.ImageLocation) + "','Student','Active')"; config.Execute_CUD(sql, "error to execute the query", "New borrower has been added in the database."); } if(txtPhoto.Text!= "") { File.Copy(txtPhoto.Text, Application.StartupPath + "\\BorrowerPhoto\\" + Path.GetFileName(PictureBox1.ImageLocation),true); } btn_New_Click(sender, e); } private void PictureBox1_Click(object sender, EventArgs e) { //With OpenFileDialog1 // 'CHECK THE SELECTED FILE IF IT EXIST OTHERWISE THE DIALOG BOX WILL DISPLAY A WARNING. OpenFileDialog1.CheckFileExists = true; // 'CHECK THE SELECTED PATH IF IT EXIST OTHERWISE THE DIALOG BOX WILL DISPLAY A WARNING. OpenFileDialog1.CheckPathExists = true; // 'GET AND SET THE DEFAULT EXTENSION OpenFileDialog1.DefaultExt = "jpg"; // 'RETURN THE FILE LINKED TO THE LNK FILE OpenFileDialog1.DereferenceLinks = true; // 'SET THE FILE NAME TO EMPTY OpenFileDialog1.FileName = ""; // 'FILTERING THE FILES OpenFileDialog1.Filter = "(*.jpg)|*.jpg|(*.png)|*.png|(*.jpg)|*.jpg|All files|*.*"; // 'SET THIS FOR ONE FILE SELECTION ONLY. OpenFileDialog1.Multiselect = false; // 'SET THIS TO PUT THE CURRENT FOLDER BACK TO WHERE IT HAS STARTED. OpenFileDialog1.RestoreDirectory = true; // 'SET THE TITLE OF THE DIALOG BOX. OpenFileDialog1.Title = "Select a file to open"; // 'ACCEPT ONLY THE VALID WIN32 FILE NAMES. OpenFileDialog1.ValidateNames = true; if (OpenFileDialog1.ShowDialog() == DialogResult.OK) { txtPhoto.Text = OpenFileDialog1.FileName; PictureBox1.ImageLocation = OpenFileDialog1.FileName; PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage; } } private void btn_delete_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to delete this borrower?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { sql = "UPDATE `tblborrower` SET `Stats` = 'NotActive' WHERE `BorrowerId` ='" + dtg_ABorrowLists.CurrentRow.Cells[0].Value + "'"; config.Execute_Query(sql); MessageBox.Show("Borrower has been deleted in the database.", "Success", MessageBoxButtons.OK); btn_New_Click(sender, e); } } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void btn_last_Click(object sender, EventArgs e) { inc = maxrow; navigate_records(inc); } private void btn_prev_Click(object sender, EventArgs e) { if(inc == 0) { MessageBox.Show("First Records.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if(inc <= maxrow) { inc = inc - 1; navigate_records(inc); } } private void btn_next_Click(object sender, EventArgs e) { if (inc == maxrow) { MessageBox.Show("Last Records.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (inc >= 0) { inc = inc + 1; navigate_records(inc); } } private void dtg_ABorrowLists_CellClick(object sender, DataGridViewCellEventArgs e) { txt_bid.Text = dtg_ABorrowLists.CurrentRow.Cells[0].Value.ToString(); } private void btn_first_Click(object sender, EventArgs e) { inc = 0; navigate_records(inc); } } } |
Free- Download Source code OF LIBRARY MANAGEMENT SYSTEM Project (FYP) Full file in C#
Library Management System Software Documentation
- FUNCTIONAL REQUIREMENTS OF LIBRARY MANAGEMENT SYSTEM
- Non FUNCTIONAL REQUIREMENTS OF LIBRARY MANAGEMENT SYSTEM
- Use Case Diagram of Library Management System
- Class Diagram of Library Management System
- Sequence Diagram of Library Management System
- Entity relationship Diagram of LIBRARY MANAGEMENT SYSTEM ERD
- Use Case Descriptions of LIBRARY MANAGEMENT SYSTEM
- Project MILESTONE, Deliverable, and Risk Management of Library Management System
- Testing of Library Management System with Test Cases