private void LogIn_Click_1(object sender, EventArgs e) { if ((textBox1.Text.Equals(user)) && (textBox2.Text.Equals(pass)) && (isAbleToLogIn())) { dbConnect.Update("update tblAdmin set boolAdmIsLoggedIn = true;"); AdminPanel admin = new AdminPanel(); admin.Show(); this.Hide(); } else if (!isAbleToLogIn()) { MessageBox.Show("Admin account already logged in"); } else { MessageBox.Show("Wrong Username or Password"); } }
private void UpdateInfo_Click(object sender, EventArgs e) { if (Notification.allow != 1) { string BFname = BorFname.Text; string BMname = BorMidName.Text; string BLname = BorLname.Text; string emailAd = BorEmail.Text; string fullname = BLname + ", " + BFname + " " + BMname; if (emailIsValid(emailAd) == false) { MessageBox.Show("Invalid Email"); } else { if (isStudent()) { try { string BorAdvi = ""; string BorSec = ""; try { BorAdvi = BorAdvisorbox.SelectedItem.ToString(); BorSec = BorSecBox.SelectedItem.ToString(); } catch { MessageBox.Show("Please Select a advisor and section"); } //starts here if (BorFname.Text != "" && BorMidName.Text != "" && BorLname.Text != "" && BorEmail.Text != "" && BorAdvi != "" && BorSec != "" && emailIsValid(emailAd) == true) { if (IsnospecialChar(BFname) && IsnospecialChar(BMname) && IsnospecialChar(BLname)) { dbConnect.Update("update tblName set strNameFName = '" + BFname + "',strNameMName = '" + BMname + "',strNameLName = '" + BLname + "',strNameEmail = '" + emailAd + "' where strNameCode = '" + biBorrowerCode + "';"); dbConnect.Update("update tblStudent set strStudSectCode = '" + secToCode(BorSec) + "' where strStudNameCode = '" + biBorrowerCode + "';"); BorAdvisorbox.Enabled = false; BorSecBox.Enabled = false; BorFname.Enabled = false; BorMidName.Enabled = false; BorLname.Enabled = false; BorEmail.Enabled = false; Bitmap bmp1 = new Bitmap(resizeImage(IDpicturee.Image, new Size(103, 107))); Bitmap bmp2 = new Bitmap(ID.Image); IDpicturee.Image.Dispose(); System.GC.Collect(); System.GC.WaitForPendingFinalizers(); File.Delete(source7 + BorNoInfo.Text + ".jpg"); ID.Image.Dispose(); System.GC.Collect(); System.GC.WaitForPendingFinalizers(); File.Delete(source3 + BorNoInfo.Text + ".jpg"); bmp1.Save(source7 + BorNoInfo.Text + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); IDpicturee.Image = Image.FromFile(source7 + BorNoInfo.Text + ".jpg"); // // Dispose of the image files. using (Image image = Image.FromFile(source1)) using (Image watermarkImage = Image.FromFile(source7 + BorNoInfo.Text + ".jpg")) using (Image watermarkImage2 = Image.FromFile(source4 + BorNoInfo.Text + ".jpg")) using (Graphics imageGraphics = Graphics.FromImage(image)) using (TextureBrush watermarkBrush = new TextureBrush(watermarkImage)) using (TextureBrush watermarkBrush2 = new TextureBrush(watermarkImage2)) { int x = (16); int y = (12); int o = (323); int p = (102); int f = 14; if (fullname.Length > 15) { f = 12; } watermarkBrush.TranslateTransform(x, y); imageGraphics.FillRectangle(watermarkBrush, new Rectangle(new System.Drawing.Point(x, y), new Size(watermarkImage.Width + 1, watermarkImage.Height))); watermarkBrush2.TranslateTransform(o, p); imageGraphics.FillRectangle(watermarkBrush2, new Rectangle(new System.Drawing.Point(o, p), new Size(watermarkImage2.Width + 1, watermarkImage2.Height))); imageGraphics.DrawString(BorNoInfo.Text, new Font("Tahoma", f, FontStyle.Bold), Brushes.Black, new PointF(60, 137)); imageGraphics.DrawString(BLname + ",", new Font("Tahoma", f, FontStyle.Bold), Brushes.Black, new PointF(82, 181)); imageGraphics.DrawString(BFname + " " + BMname, new Font("Tahoma", f, FontStyle.Bold), Brushes.Black, new PointF(37, 204)); imageGraphics.DrawString(BorSec, new Font("Tahoma", f, FontStyle.Bold), Brushes.Black, new PointF(147, 247)); image.Save(source3 + BorNoInfo.Text + ".jpg"); } ID.Image = Image.FromFile(source3 + BorNoInfo.Text + ".jpg"); MessageBox.Show("Update Successful!"); CloseInfo.Enabled = true; this.UpdateInfo.Visible = false; this.EditInfo.Visible = true; CancelEdit.Visible = false; pictureBox3.Visible = false; } else { MessageBox.Show("Name format is invalid"); } } else { MessageBox.Show("You must fill all the requirements"); } } catch (Exception ex) { MessageBox.Show(fullname + " already registered!", "Warning", MessageBoxButtons.OK); } } if (!isStudent()) { try { string BorDep = ""; string Borpos = ""; try { BorDep = BorDepBox.SelectedItem.ToString(); Borpos = BorPosBox.SelectedItem.ToString(); } catch { MessageBox.Show("Please Select Department and position"); } if (BorFname.Text != "" && BorMidName.Text != "" && BorLname.Text != "" && BorEmail.Text != "" && BorDepBox.SelectedItem != null && BorPosBox.SelectedItem != null && emailIsValid(emailAd) == true) { if (IsnospecialChar(BFname) && IsnospecialChar(BMname) && IsnospecialChar(BLname)) { //starts here dbConnect.Update("update tblName set strNameFName = '" + BFname + "',strNameMName = '" + BMname + "',strNameLName = '" + BLname + "',strNameEmail = '" + emailAd + "' where strNameCode = '" + biBorrowerCode + "';"); dbConnect.Update("update tblFaculty set strFacuPosiCode = '" + posToCode(Borpos, depToCode(BorDep)) + "',strFacuPosiDepCode = '" + depToCode(BorDep) + "' where strFacuNameCode = '" + biBorrowerCode + "';"); BorDepBox.Enabled = false; BorPosBox.Enabled = false; BorFname.Enabled = false; BorMidName.Enabled = false; BorLname.Enabled = false; BorEmail.Enabled = false; Bitmap bmp1 = new Bitmap(resizeImage(IDpicturee.Image, new Size(103, 107))); Bitmap bmp2 = new Bitmap(ID.Image); IDpicturee.Image.Dispose(); System.GC.Collect(); System.GC.WaitForPendingFinalizers(); File.Delete(source7 + BorNoInfo.Text + ".jpg"); ID.Image.Dispose(); System.GC.Collect(); System.GC.WaitForPendingFinalizers(); File.Delete(source5 + BorNoInfo.Text + ".jpg"); bmp1.Save(source7 + BorNoInfo.Text + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); IDpicturee.Image = Image.FromFile(source7 + BorNoInfo.Text + ".jpg"); // // Dispose of the image files. using (Image image = Image.FromFile(source1)) using (Image watermarkImage = Image.FromFile(source7 + BorNoInfo.Text + ".jpg")) using (Image watermarkImage2 = Image.FromFile(source6 + BorNoInfo.Text + ".jpg")) using (Graphics imageGraphics = Graphics.FromImage(image)) using (TextureBrush watermarkBrush = new TextureBrush(watermarkImage)) using (TextureBrush watermarkBrush2 = new TextureBrush(watermarkImage2)) { int x = (16); int y = (12); int o = (323); int p = (102); int f = 14; if (fullname.Length > 15) { f = 12; } watermarkBrush.TranslateTransform(x, y); imageGraphics.FillRectangle(watermarkBrush, new Rectangle(new System.Drawing.Point(x, y), new Size(watermarkImage.Width + 1, watermarkImage.Height))); watermarkBrush2.TranslateTransform(o, p); imageGraphics.FillRectangle(watermarkBrush2, new Rectangle(new System.Drawing.Point(o, p), new Size(watermarkImage2.Width + 1, watermarkImage2.Height))); imageGraphics.DrawString(BorNoInfo.Text, new Font("Tahoma", f, FontStyle.Bold), Brushes.Black, new PointF(60, 137)); imageGraphics.DrawString(BLname + ",", new Font("Tahoma", f, FontStyle.Bold), Brushes.Black, new PointF(82, 181)); imageGraphics.DrawString(BFname + " " + BMname, new Font("Tahoma", f, FontStyle.Bold), Brushes.Black, new PointF(37, 204)); imageGraphics.DrawString(BorDep + ", " + Borpos, new Font("Tahoma", f, FontStyle.Bold), Brushes.Black, new PointF(147, 247)); image.Save(source5 + BorNoInfo.Text + ".jpg"); MessageBox.Show("Done"); } ID.Image = Image.FromFile(source5 + BorNoInfo.Text + ".jpg"); MessageBox.Show("Update Successful!"); CloseInfo.Enabled = true; this.UpdateInfo.Visible = false; this.EditInfo.Visible = true; pictureBox3.Visible = false; CancelEdit.Visible = false; } else { MessageBox.Show("Name format is invalid"); } } else { MessageBox.Show("You must fill all the requirements"); } } catch (Exception ex) { MessageBox.Show(fullname + " already registered!", "Warning", MessageBoxButtons.OK); } } } } else { MessageBox.Show("Manage first all the notifications before updating individual information"); } }
private void DeleteCateg_Click(object sender, EventArgs e) { try { string a = this.CategoryList.SelectedRows[0].Cells[0].Value.ToString(); DialogResult dialogResult = MessageBox.Show("Are you you want to delete " + CategoryName.Text + "?", "Delete?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { foreach (DataGridViewRow row in this.CategoryList.SelectedRows) { //Logical delete in database dbConnect.Update("Update tblCategory set boolCategIsDel = true where strCategCode = '" + row.Cells[0].Value.ToString() + "';"); } refreshCategories(); this.CategoryName.Clear(); AddCateg.Visible = true; button2.Visible = false; CancelCateg.Visible = false; this.CategoryCode.Text = codeGenerator.generateCodeParent("tblCategory", "strCategCode", "Categ"); refreshCategories(); } else if (dialogResult == DialogResult.No) { } } catch (ArgumentOutOfRangeException) { MessageBox.Show("No selected item"); } }
//----Generated Codes----- private void ReturnIT_Click(object sender, EventArgs e) { bool isInputValid = false; try { string dateNow = DateTime.Now.ToString("yyyy-MM-dd"); string assetCode = this.ItemList.SelectedRows[0].Cells[0].Value.ToString(); string borHCode = this.ItemList.SelectedRows[0].Cells[1].Value.ToString(); string borDCode = this.ItemList.SelectedRows[0].Cells[2].Value.ToString(); string fine = this.ItemList.SelectedRows[0].Cells[6].Value.ToString(); string notes = this.Notes.Text; string status = ""; if (Good.Checked == true) { status = "1"; isInputValid = true; } else if (Damage.Checked == true) { status = "2"; isInputValid = true; } else if (Others.Checked == true) { status = "3"; if (notes == "") { MessageBox.Show("Notes is required."); } else { isInputValid = true; } } //check if input valid if (isInputValid) { DialogResult dialogResult = MessageBox.Show("Continue?", "Return?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { //Update Borrower Header dbConnect.Update("update tblBorrowHeader set dblBorHFine = dblBorHFine + " + fine + " where strBorHCode = '" + borHCode + "';"); //Update Borrower Detail dbConnect.Update("update tblBorrowDetail set dtmBorDDateReturned = '" + dateNow + "',strBorDRemarks = '" + notes + "' where strBorDBorHCode = '" + borHCode + "' and strBorDCode = '" + borDCode + "';"); //Update Asset dbConnect.Update("update tblAsset set txtAsseNotes = '" + notes + "',intAsseStatus = " + status + " where strAsseCode = '" + assetCode + "';"); //if damaged or others if (status.Equals("2") || status.Equals("3")) { dbConnect.Update("update tblAsset set txtAsseNotes = '" + notes + " By: " + getNameAndCode() + "' where strAsseCode = '" + assetCode + "';"); } Notes.Clear(); MessageBox.Show("Successfully Returned"); } else if (dialogResult == DialogResult.No) { } } else { MessageBox.Show("Please choose returning condition"); } } catch { MessageBox.Show("No selected item"); } //refresh ItemList refreshItemList(); }
//------------------------------------------------GENERATED CODE-------------------------------------------------------------------- private void UpdateIT_Click(object sender, EventArgs e) { bool isInputValid = false; if (ItemName.Text != "") { string assetcode = AssetCode.Text; string itemname = ItemName.Text; string itemcateg = CategoryBox.SelectedItem.ToString(); string itemvendor = VendorBox.SelectedItem.ToString(); string itemmodel = ModelBox.SelectedItem.ToString(); string datepurchased = this.DatePurchased.Value.Date.ToString("yyyy-MM-dd"); string status = statusToInt(ItemStatus.SelectedItem.ToString()); string notes = Notes.Text; if (status == "1") { Notes.Clear(); isInputValid = true; } if (status != "1") { if (notes != "") { isInputValid = true; } else { MessageBox.Show("Please input notes."); } } if (isInputValid) { try { DialogResult dialogResult = MessageBox.Show("Are you you want to save your current changes?", "Update?", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { dbConnect.Update("update tblItemType set strItemName = '" + itemname + "',strItemCategCode = '" + getCategCodeFromList(itemcateg) + "' where strItemCode = '" + itemTypeCodeSelected + "'"); dbConnect.Update("update tblAsset set strAsseVendCode = '" + getVendorCodeFromList(itemvendor) + "',strAsseModeCode = '" + getModelCodeFromList(itemmodel) + "',dtmAssePurchased = '" + datepurchased + "',txtAsseNotes = '" + notes + "',intAsseStatus = " + status + " where strAsseCode = '" + assetCodeSelected + "';"); MessageBox.Show("Successfully Updated!"); EditIT.Visible = true; UpdateIT.Visible = false; ItemInfor.Enabled = false; CloseInfo.Enabled = true; CancelEdit.Visible = false; } else if (dialogResult == DialogResult.No) { Display(); } //for itemtype } catch (Exception ex) { MessageBox.Show("Error Catched! \n" + ex.ToString()); } } else { MessageBox.Show("Please input the fields correctly"); } } else { MessageBox.Show("Item name is required"); } }