private void btnUpdatePT_Click(object sender, EventArgs e) { correct = true; try { if (txtBrandDesc.Text == "") { lblBrand.Visible = true; //MessageBox.Show("Please Enter a brand Description"); correct = false; } if (correct == true) { var query = db.Product_Brand.Where(co => co.Product_Brand_ID == tempID).FirstOrDefault(); query.Product_Brand_Name = txtBrandDesc.Text; db.SaveChanges(); MessageBox.Show("Product Type Successfully Updated"); this.Close(); } } catch { //MessageBox.Show("Product type not updated"); } }
private void btnUpdatePT_Click(object sender, EventArgs e) { correct = true; try { if (txtProductTypeDesc.Text == "") { lblSheet.Visible = true; //MessageBox.Show("Please Enter a product sheet number"); correct = false; } if (correct == true) { var query = db.Sheets.Where(co => co.Sheet_ID == tempID).FirstOrDefault(); query.Number_Of_Sheet = Convert.ToInt32(txtProductTypeDesc.Text); db.SaveChanges(); MessageBox.Show("Product Sheet Number Successfully Updated"); this.Close(); } } catch { //MessageBox.Show("Sheet Number not updated, c"); } }
private void btnUpdate_Click(object sender, EventArgs e) { correct = true; if (rtxtDescription.Text == "") { lblDescription.Visible = true; //MessageBox.Show("Please Enter an Employee Type Description"); correct = false; } else if (rtxtDescription.Text == "") { lblDescription.Visible = true; //MessageBox.Show("Please Enter employee type Text"); correct = false; } if (correct == true) { var query = db.Employee_Type.Where(co => co.Employee_Type_ID == tempID).First(); query.Employees_Type_Description = rtxtDescription.Text; db.SaveChanges(); MessageBox.Show("Employee Type Successfully Updated"); this.Close(); } }
private void btnUpdateSheet_Click(object sender, EventArgs e) { correct = true; try { if (txtProductSheetDesc.Text == "") { lblPackSi.Visible = true; //MessageBox.Show("Please Enter a product pack size"); correct = false; } if (correct == true) { var query = db.Pack_Size.Where(co => co.Pack_Size_ID == tempID).FirstOrDefault(); query.Pack_Size_Description = txtProductSheetDesc.Text; db.SaveChanges(); MessageBox.Show("Product Pack Size Successfully Updated"); this.Close(); } } catch { } }
private void button1_Click(object sender, EventArgs e) { try { correct = true; if (txtMake.Text == "") { MessageBox.Show("Please Enter a Vehicle Make"); correct = false; } if (txtModel.Text == "") { MessageBox.Show("Please Enter a Vehicle Model"); correct = false; } if (txtRegNo.Text == "") { MessageBox.Show("Please Enter a Vehicle Registration Number"); correct = false; } if (txtVIN.Text == "") { MessageBox.Show("Please Enter a Vehicle VIN Code"); correct = false; } if (correct == true) { var query = db.Vehicles.Where(co => co.Vehicle_ID == tempID).FirstOrDefault(); query.Vehicle_Make = txtMake.Text; query.Vehicle_Model = txtModel.Text; query.Vehicle_Registration_Number = txtRegNo.Text; query.VIN_Number = txtVIN.Text; query.Last_Serviced = dtpLastServiced.Value; query.Vehicle_Status_ID = Convert.ToInt32(cbxStatus.SelectedValue); //var query2 = db.Vehicle_Status.Where(co => co.Vehicle_Status_ID == tempID).FirstOrDefault(); //query.Vehicle_Status_ID = query2.Vehicle_Status_ID; //query.Vehicle_Status_ID = cbxStatus.SelectedIndex + 1; //query.Last_Serviced = dtpLastServiced.Value; db.SaveChanges(); MessageBox.Show("Vehicle Successfully Updated"); this.Close(); } } catch { } }
private void Add_Click(object sender, EventArgs e) { correct = true; Email_Notice_Template newTemplate = new Email_Notice_Template(); if (txtDescription.Text == "") { MessageBox.Show("Please enter a Template Description"); correct = false; } if (txtText.Text == "") { MessageBox.Show("Please enter Template Text"); correct = false; } if (correct == true) { newTemplate.Template_Description = txtDescription.Text; newTemplate.Template_Text = txtText.Text; db.Email_Notice_Template.Add(newTemplate); db.SaveChanges(); int Template_ID = newTemplate.Template_Id; string Template_Value = Convert.ToString(newTemplate); Audit_Log Current_Audit = new Audit_Log(); Current_Audit.Table_Name = "Notification Template"; Current_Audit.Active_User_ID = clsGlobals.Userlogin.Active_User_Id; Current_Audit.Date_Time = DateTime.Now; db.Audit_Log.Add(Current_Audit); db.SaveChanges(); int Log_ID = Current_Audit.Audit_Log_Id; Audit_Create_Delete Current_Create = new Audit_Create_Delete(); Current_Create.Audit_Log_Id = Log_ID; Current_Create.Created = true; Current_Create.PK_Row_Effected = Template_ID; Current_Create.Value = Template_Value; db.Audit_Create_Delete.Add(Current_Create); db.SaveChanges(); MessageBox.Show("Notification template created successfully"); this.Close(); } }
private void button1_Click(object sender, EventArgs e) { correct = true; if (correct == true) { try { var query = db.Company_Information.FirstOrDefault(); query.Company_Name = txtName.Text; query.Company_Address = txtCompnyAddress.Text; query.VAT_Percentage = Convert.ToDecimal(txtPercent.Text); query.VAT_Number = txtVatNmber.Text; query.Registration_Number = txtRegNumber.Text; query.Email_Address = txtEmailAdress.Text; query.Telephone_Number = txtTelephone.Text; db.SaveChanges(); MessageBox.Show("Company information updated successfully"); } catch (Exception ex) { MessageBox.Show("An error occured" + ex); } // MessageBox.Show("Please fill in all required fields"); //MessageBox.Show("Please fill in all required fields"); //MessageBox.Show("Company information updated successfully"); } }
private void button4_Click(object sender, EventArgs e) { frmScanQR scan = new frmScanQR(); scan.ShowDialog(); var q = db.Client_Purchase_Order.Where(po => po.PO_Number == scan.DecodeID).First(); q.Purchase_Order_Status_ID = 2; var q2 = db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q.PO_Number).First(); var q3 = db.Getpoduct().Where(x => x.Product_Description == q2.Product).First(); //int w = Convert.ToInt32(q.Available_Quantity); //q3.Available_Quantity +; db.Products.Where(x => x.Product_ID == q3.Product_ID).First().Available_Quantity -= q2.Quantity; db.SaveChanges(); frmPOLine f = new frmPOLine(scan.DecodeID); var q1 = db.Purchase_Order_Status.Where(pos => pos.Purchase_Order_Status_ID == q.Purchase_Order_Status_ID).First(); dgvPackaged.DataSource = db.Load_Purchase_Order_1(). Where(lpo => lpo.Purchase_Order_Status_Description == q1.Purchase_Order_Status_Description).ToList(); dataGridView1.DataSource = db.Load_Purchase_Order_1().Where(lpo => lpo.Purchase_Order_Status_Description == "Placed").ToList(); }
private void btnUpdatePT_Click(object sender, EventArgs e) { correct = true; try { if (txtWidthDesc.Text == "") { lblLength.Visible = true; correct = false; } if (txtUnit.Text == "") { lblUnit.Visible = true; correct = false; } if (txtWidthDesc.Text == "" || txtUnit.Text == "") { lblLength.Visible = true; lblUnit.Visible = true; //MessageBox.Show("Please Enter a product length"); correct = false; } if (txtWidthDesc.Text != "" && txtUnit.Text != "") { var query = db.pLengths.Where(co => co.Length_ID == tempID).FirstOrDefault(); query.Length_Size = Convert.ToInt32(txtWidthDesc.Text); query.Length_Measurement_Unit = txtUnit.Text; db.SaveChanges(); MessageBox.Show("Product Length Successfully Updated"); this.Close(); } } catch { } }
private void button1_Click(object sender, EventArgs e) { label4.Visible = false; label5.Visible = false; label6.Visible = false; label7.Visible = false; correct = true; string username = txtUsername.Text; var query1 = db.Active_User.Where(co => co.Username == username /* && co.User_Type.User_Type_Description != "Customer"*/).FirstOrDefault(); if (txtUsername.Text == "") { label4.Visible = true; label4.Text = "Please Provide the username you wish to reset"; correct = false; } if (textBox1.Text == "") { label5.Visible = true; label5.Text = "Please Provide New Password"; correct = false; } if (textBox2.Text == "") { label6.Visible = true; label6.Text = "Please Confirm Password"; correct = false; } if (textBox1.Text != textBox2.Text) { label7.Visible = true; label7.Text = "Passwords provided do not match"; correct = false; } if (correct == true) { byte[] bit = new byte[25]; bit = StrToByteArray(textBox2.Text); query1.pass = Convert.ToString(bit); db.SaveChanges(); MessageBox.Show("Password Successfully Updated"); this.Close(); } }
private void btnAdd_Click(object sender, EventArgs e) { correct = true; Employee_Type EmT = new Employee_Type(); try { foreach (var item in db.Employee_Type) { if (item.Employees_Type_Description == rtxtDescription.Text) { MessageBox.Show("Employee Type already exists"); correct = false; } } //if (ValidateIfEmployeeTypeExists(rtxtDescription.Text) == true) //{ // MessageBox.Show("Employee Type already exists"); // correct = false; //} if (rtxtDescription.Text == "") { lblDescription.Visible = true; //MessageBox.Show("Please Enter Employee type details"); correct = false; } else if (rtxtDescription.Text == "") { lblDescription.Visible = true; // MessageBox.Show("Please Enter Employee type details"); correct = false; } else { correct = true; EmT.Employees_Type_Description = rtxtDescription.Text; //EmT.Employees_Type1 = txtEmployeeType.Text; db.Employee_Type.Add(EmT); db.SaveChanges(); MessageBox.Show("Employee Type Added Successfully"); this.Close(); } } catch { } }
private void btnAdd_Click(object sender, EventArgs e) { try { if (ValidateIfLengthExists(txtLengthDescription.Text) == true) { MessageBox.Show("Product Length exists"); correct = false; } correct = true; pLength PL = new pLength(); if (txtLengthDescription.Text == "") { lblLength.Visible = true; //MessageBox.Show("Please Enter Product Widths"); correct = false; } if (txtMeasurement.Text == "") { lblUnit.Visible = true; correct = false; } if (correct == true) { PL.Length_Size = Convert.ToInt32(txtLengthDescription.Text); PL.Length_Measurement_Unit = txtMeasurement.Text; db.pLengths.Add(PL); db.SaveChanges(); int Length_ID = PL.Length_ID; string Length_value = Convert.ToString(PL); MessageBox.Show("Product Length Successfully Added"); this.Close(); } } catch (NullReferenceException) { MessageBox.Show("Product Length Added"); } }
private void btnConfirm_Click(object sender, EventArgs e) { correct = false; try { Employee_Logsheet empL = new Employee_Logsheet(); if (chbxTimeIN.Checked == true) { empL.Time_In = (txtTimeIN.Text); } else if (chbxTimeOut.Checked == true) { empL.Time_Out = (txtTimeOut.Text); } else if (chbxLunchO.Checked == true) { empL.Lunch_Out = (txtLunchOut.Text); } else { empL.Lunch_In = (txtLunchIn.Text); } empL.Employee_Id = Convert.ToInt32(comboBox1.SelectedValue); empL.Day_Of_The_Week = DateTime.Now; db.Employee_Logsheet.Add(empL); // string employee_value = Convert.ToString(empL); db.SaveChanges(); MessageBox.Show("Time Logged Successfully"); this.Close(); } catch { } }
private void btnAdd_Click(object sender, EventArgs e) { try { if (ValidateIfWidthExists(WidthDescription.Text) == true) { MessageBox.Show("Widths already exists"); correct = false; } correct = true; Width PWidth = new Width(); if (WidthDescription.Text == "") { lblWidth.Visible = true; //MessageBox.Show("Please Enter Product Widths"); correct = false; } if (txtMeasurement.Text == "") { lblUnit.Visible = true; } if (correct == true) { PWidth.Width_Size = Convert.ToInt32(WidthDescription.Text); PWidth.Width_Measurement_Unit = txtMeasurement.Text; db.Widths.Add(PWidth); db.SaveChanges(); int Width_ID = PWidth.Width_ID; string Width_value = Convert.ToString(PWidth); MessageBox.Show("Product Widths Successfully Added"); this.Close(); } } catch { } }
private void btnAdd_Click(object sender, EventArgs e) { try { correct = true; Product_Brand prodB = new Product_Brand(); if (ValidateIfBrandExists(rtxtDescription.Text) == true) { MessageBox.Show("Product Brand exists"); } if (rtxtDescription.Text == "") { lblBrandDes.Visible = true; //essageBox.Show("Please Enter brand details"); correct = false; } if (correct == true) { prodB.Product_Brand_Name = rtxtDescription.Text; MessageBox.Show("Product Successfully Added"); db.Product_Brand.Add(prodB); db.SaveChanges(); int Product_Type_ID = prodB.Product_Brand_ID; string ProdT_value = Convert.ToString(prodB); //MessageBox.Show("Product Successfully Added"); this.Close(); } else { MessageBox.Show("Please enter valid details"); } } catch (NullReferenceException) { //MessageBox.Show("Product Type Not Added"); } }
private void btnAdd_Click(object sender, EventArgs e) { try { correct = true; Product_Type prodT = new Product_Type(); frmAddProduct frm = new frmAddProduct(); if (ValidateIfProductTypeExists(rtxtDescription.Text) == true) { MessageBox.Show("Product Type exists"); correct = false; } if (rtxtDescription.Text == "") { lblProdDesc.Visible = true; //MessageBox.Show("Please Enter Product type details"); correct = false; } if (correct == true) { prodT.Product_Type_Name = rtxtDescription.Text; db.Product_Type.Add(prodT); db.SaveChanges(); int Product_Type_ID = prodT.Product_Type_ID; string ProdT_value = Convert.ToString(prodT); MessageBox.Show("Product Successfully Added"); this.Close(); } } catch { } }
private void btnUpdate_Click(object sender, EventArgs e) { try { var query = db.Access_Level.Where(co => co.Access_Level_Id == AccessId).FirstOrDefault(); var UserRole = db.User_Role.Where(co => co.User_Role_Id == query.Access_Level_Id).FirstOrDefault(); Access_Level CurrentAccessLevel = new Access_Level(); User_Role CurrentRole = new User_Role(); CurrentAccessLevel = db.Access_Level.Where(co => co.Access_Level_Id == AccessId).FirstOrDefault(); CurrentRole = db.User_Role.Where(co => co.User_Role_Id == query.Access_Level_Id).FirstOrDefault(); var Newquery = db.Access_Level.Where(co => co.Access_Level_Id == AccessId).FirstOrDefault(); var NewUserRole = db.User_Role.Where(co => co.User_Role_Id == query.Access_Level_Id).FirstOrDefault(); query.Access_Level_Name = txtAccessName.Text; UserRole.Admin_Role = cbxAdminScreen.Checked; UserRole.User_And_Access_Level_Role = cbxUserAccessLevelScreen.Checked; UserRole.Employee_Role = cbxEmployeeScreen.Checked; UserRole.Supplier_Order_Role = cbxSupplierOrderScreen.Checked; UserRole.Client_Order_Role = cbxPurchaseOrderScreen.Checked; UserRole.Product_Role = cbxProductScreen.Checked; UserRole.Client_Role = cbxClient.Checked; UserRole.Reports_Role = cbxReportsScreen.Checked; UserRole.Website_Role = cbWebsite.Checked; UserRole.Sale_Role = cbxSaleScreen.Checked; UserRole.Vehicle_Role = cbxVehicleScreen.Checked; db.SaveChanges(); MessageBox.Show("Access Level Updated Successfully"); } catch (Exception) { MessageBox.Show("An error occured, please try again"); } }
private void btnAdd_Click(object sender, EventArgs e) { try { if (ValidateIfPackSizeExists(rtxtDescription.Text) == true) { MessageBox.Show("Pack Size exists"); correct = false; } correct = true; Pack_Size packS = new Pack_Size(); if (rtxtDescription.Text == "") { lblPackSize.Visible = true; //MessageBox.Show("Please Enter Product pack size details"); correct = false; } if (correct == true) { packS.Pack_Size_Description = rtxtDescription.Text; db.Pack_Size.Add(packS); db.SaveChanges(); int Pack_Size_ID = packS.Pack_Size_ID; string ProdT_value = Convert.ToString(packS); MessageBox.Show("Product Pack Size Successfully Added"); this.Close(); } } catch { } }
private void btnAdd_Click(object sender, EventArgs e) { try { correct = true; Sheet Sheet = new Sheet(); if (rtxtDescription.Text == "") { lblSheet.Visible = true; // MessageBox.Show("Please Enter Product sheet number details"); correct = false; } if (ValidateIfSheetExists(rtxtDescription.Text) == true) { MessageBox.Show("Number of Sheets already exists"); correct = false; } if (correct == true) { Sheet.Number_Of_Sheet = Convert.ToInt32(rtxtDescription.Text); } db.Sheets.Add(Sheet); db.SaveChanges(); int Sheet_ID = Sheet.Sheet_ID; string ProdT_value = Convert.ToString(Sheet); MessageBox.Show("Product Sheets Number Successfully Added"); this.Close(); } catch { } }
private void btnUpdate_Click(object sender, EventArgs e) { correct = true; try { if (txtDescription.Text == "" || txtQuantity.Text == "" || cbxprodT.Items == null || cbxbrand.Items == null || cbxPly.Items == null || cbxPackSize.Items == null || cbxSheet.Items == null || cbxLength.Items == null || cbxWidth.Items == null) { MessageBox.Show("Please Enter all fields on the product Form"); correct = false; } if (txtDescription.Text == "") { lblProdDescr.Visible = true; correct = false; } if (correct == true) { var query0 = db.Products.Where(co => co.Product_ID == tempID).First(); query0.Product_Description = txtDescription.Text; var query = db.Products.Where(co => co.Product_ID == tempID).First(); int new1 = Convert.ToInt32(cbxbrand.SelectedValue); var query2 = db.Product_Brand.Where(co => co.Product_Brand_ID == new1).First(); query.Product_Brand_ID = query2.Product_Brand_ID; int new2 = Convert.ToInt32(cbxprodT.SelectedValue); var query3 = db.Product_Type.Where(co => co.Product_Type_ID == new2).First(); query.Product_Type_ID = query3.Product_Type_ID; int new3 = Convert.ToInt32(cbxPackSize.SelectedValue); var query4 = db.Pack_Size.Where(co => co.Pack_Size_ID == new3).First(); query.Pack_Size_ID = query4.Pack_Size_ID; int new4 = Convert.ToInt32(cbxLength.SelectedValue); var query5 = db.pLengths.Where(co => co.Length_ID == new4).First(); query.Length_ID = Convert.ToInt32(query5.Length_ID); int new5 = Convert.ToInt32(cbxWidth.SelectedValue); var query6 = db.Widths.Where(co => co.Width_ID == new5).First(); query.Width_ID = query6.Width_ID; int value = Convert.ToInt32(cbxPly.Text); var query7 = db.Plies.Where(co => co.Number_Of_Ply == (value)).First(); query.Ply_ID = query7.Ply_ID; int val2 = Convert.ToInt32(cbxSheet.Text); var query8 = db.Sheets.Where(co => co.Number_Of_Sheet == val2).First(); query.Sheet_ID = query8.Sheet_ID; query.Sales_Price = Convert.ToDecimal(txtPrice.Text); query.Image = txtImage.Text; db.SaveChanges(); // db.SaveChangesAsync(); MessageBox.Show("Product Successfully Updated"); this.Close(); } } catch (Exception ex) { MessageBox.Show("" + ex); } }
private void btnAdd_Click(object sender, EventArgs e) { correct = true; Vehicle vehicle = new Vehicle(); try { if (ValidateIfVehicleExists(txtRegNo.Text) == true) { MessageBox.Show("Vehicles registration number already exists"); correct = false; } if (txtMake.Text == "" || txtModel.Text == "" || txtRegNo.Text == "" || txtVIN.Text == "") { MessageBox.Show("Please Enter Vehicles details"); correct = false; } if (txtRegNo.Text == "") { lblReg.Visible = true; correct = false; } if (txtModel.Text == "") { lblModel.Visible = true; correct = false; } if (txtVIN.Text == "") { lblVIN.Visible = true; correct = false; } if (txtMake.Text == "") { lblMake.Visible = true; correct = false; } if (correct == true) { vehicle.Vehicle_Make = txtMake.Text; vehicle.Vehicle_Model = txtModel.Text; vehicle.Vehicle_Registration_Number = txtRegNo.Text; Vehicle_Status st = cbxStatus.SelectedItem as Vehicle_Status; vehicle.Vehicle_Status_ID = st.Vehicle_Status_ID; vehicle.Last_Serviced = dtpLastServiced.Value; //vehicle.Vehicle_Status.Vehicle_Status_Description = "Active";// cbxStatus.Text; vehicle.VIN_Number = txtVIN.Text; db.Vehicles.Add(vehicle); string Vehicle_value = Convert.ToString(vehicle); db.SaveChanges(); MessageBox.Show("Vehicles Added Successfully"); //Audit Log int avehicle = vehicle.Vehicle_ID; string vehicle_Value = Convert.ToString(vehicle); Audit_Log Current_Audit5 = new Audit_Log(); Current_Audit5.Table_Name = "Vehicle"; // Current_Audit3.Users_Id = Globals.Users_Id; Current_Audit5.Date_Time = DateTime.Now; db.Audit_Log.Add(Current_Audit5); db.SaveChanges(); int Log_ID5 = Current_Audit5.Audit_Log_Id; Audit_Create_Delete Current_Create5 = new Audit_Create_Delete(); Current_Create5.Audit_Log_Id = Log_ID5; Current_Create5.Created = true; Current_Create5.PK_Row_Effected = avehicle; Current_Create5.Value = vehicle_Value; db.Audit_Create_Delete.Add(Current_Create5); db.SaveChanges(); this.Close(); this.Hide(); this.Close(); } } catch { } }
private void btnAddUser_Click(object sender, EventArgs e) { if (txtUsername.Text == "" || txtPassword.Text == "") { MessageBox.Show("Please enter all fields"); } else if (txtPassword.Text == txtConfirmPassword.Text) { try { SHA1CryptoServiceProvider sh = new SHA1CryptoServiceProvider(); UTF8Encoding utf8 = new UTF8Encoding(); string hash = BitConverter.ToString(sh.ComputeHash(utf8.GetBytes(txtConfirmPassword.Text))); SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=SP;Integrated Security=True"); SqlCommand cmd = new SqlCommand("insert into Active_User(Username,pass, Access)values(@User_Name,@Password,@access)", con); cmd.Parameters.AddWithValue("@User_Name", txtUsername.Text); cmd.Parameters.AddWithValue("@Password", hash); cmd.Parameters.AddWithValue("@access", (cbAccessLevelName.SelectedValue)); con.Open(); //var q = db.Access_L.Where(u => u.Access_Level_Name == cbAccessLevelName.Text).FirstOrDefault(); //int Aid = Convert.ToInt32(q.Access_Level_Id.ToString()); //NewUser.Access = Aid; //db.Active_User.Add(NewUser); string check = @"(Select count(*) from Active_User where Username='******')"; SqlCommand cmda = new SqlCommand(check, con); int count = (int)cmda.ExecuteScalar(); if (count > 0) { MessageBox.Show("A user with that username already exists"); } else { try { //int description = 0; //var AccessL = db.Access_L.Where(emp => emp.Access_Level_Name == cbAccessLevelName.Text).Select(u => u.Access_Level_Id).FirstOrDefault(); //description = AccessL; //NewUser.Access = AccessL; //NewAccess.Access_Level_Id = description; //NewUser.Access = NewAccess.Access_Level_Id; cmd.ExecuteNonQuery(); //db.Active_User.Add(NewUser); //int myUser = NewUser.Active_User_Id; } catch (Exception ex) { MessageBox.Show("" + ex); } Active_User newuser = new Active_User(); MessageBox.Show("User successfully registered!"); this.Hide(); this.Close(); //Audit Log int accessidz = newuser.Active_User_Id; string user_Value = Convert.ToString(newuser); Audit_Log Current_Audit6 = new Audit_Log(); Current_Audit6.Table_Name = "User"; // Current_Audit3.Users_Id = Globals.Users_Id; Current_Audit6.Date_Time = DateTime.Now; db.Audit_Log.Add(Current_Audit6); db.SaveChanges(); int Log_ID6 = Current_Audit6.Audit_Log_Id; Audit_Create_Delete Current_Create6 = new Audit_Create_Delete(); Current_Create6.Audit_Log_Id = Log_ID6; Current_Create6.Created = true; Current_Create6.PK_Row_Effected = accessidz; Current_Create6.Value = user_Value; db.Audit_Create_Delete.Add(Current_Create6); db.SaveChanges(); this.Close(); this.Hide(); } } catch (SqlException ex) { if (ex.Number == 2627) { } else { MessageBox.Show("An Error:" + ex.Message); } } } else if (txtPassword.Text != txtConfirmPassword.Text) { MessageBox.Show("Password and confirm Password fields do not match"); } }
private void btnContinue_Click(object sender, EventArgs e) { string Hashb; List <Active_User> myUser = new List <Active_User>(); try { myUser = db.Active_User.Where(someuser => someuser.Username == txtEmail.Text).ToList(); } catch (Exception) { throw; } try { Active_User emp = myUser[0]; clsGlobals.Userlogin = myUser[0]; } catch (Exception) { throw; } db.SaveChanges(); try { SHA1CryptoServiceProvider sh = new SHA1CryptoServiceProvider(); UTF8Encoding utf8 = new UTF8Encoding(); string hash = BitConverter.ToString(sh.ComputeHash(utf8.GetBytes(txtPassword.Text))); SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=SP;Integrated Security=True"); SqlCommand cmd = new SqlCommand("select pass from Active_User where Username=@Username", con); cmd.Parameters.AddWithValue("@Username", txtEmail.Text); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); Hashb = dr[0].ToString(); con.Close(); if (txtEmail.Text == "") { lbWarningEmail.Visible = true; //label4.Text = "Please Provide the username you wish to reset"; //correct = false; } if (txtPassword.Text == "") { lbWarningPassword.Visible = true; //label4.Text = "Please Provide the username you wish to reset"; //correct = false; } if (hash == Hashb) { MessageBox.Show("Authorization was successful"); this.Dispose(); Users.FrmResetPassword rs = new Users.FrmResetPassword(3); rs.ShowDialog(); rs.Focus(); } else { MessageBox.Show("Authorization failed, please try again"); lbWarningEmail.Visible = true; lbWarningPassword.Visible = true; } } catch (InvalidOperationException ex) { MessageBox.Show("Error has occured:" + ex.Message); } }
private void btnUpdate_Click(object sender, EventArgs e) { correct = true; if (txtDescription.Text == "") { MessageBox.Show("Please enter a Template Description"); correct = false; } else if (txtText.Text == "") { MessageBox.Show("Please enter a Template Text"); correct = false; } DialogResult dialogResult = MessageBox.Show("Would you like to update this Template?", "Update Template", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (correct == true) { try { if (correct == true) { var query = db.Email_Notice_Template.Where(co => co.Template_Id == tempID).FirstOrDefault(); query.Template_Description = txtDescription.Text; query.Template_Text = txtText.Text; db.SaveChanges(); Audit_Log Current_Audit = new Audit_Log(); Current_Audit.Table_Name = "Notification Template"; Current_Audit.Active_User_ID = clsGlobals.Userlogin.Active_User_Id; Current_Audit.Date_Time = DateTime.Now; db.Audit_Log.Add(Current_Audit); db.SaveChanges(); int Log_ID = Current_Audit.Audit_Log_Id; if (txtText.Text != iText) { Audit_Update Update_Name1 = new Audit_Update(); Update_Name1.PK_Row_Effected = Convert.ToInt32(query.Template_Id); Update_Name1.Field_Effected = "Text"; Update_Name1.Before_Value = iText.ToString(); Update_Name1.After_Value = txtText.Text.ToString(); Update_Name1.Audit_Log_Id = Log_ID; db.Audit_Update.Add(Update_Name1); db.SaveChanges(); } if (txtDescription.Text != Desc) { Audit_Update Update_Name2 = new Audit_Update(); Update_Name2.PK_Row_Effected = Convert.ToInt32(query.Template_Id); Update_Name2.Field_Effected = "Description"; Update_Name2.Before_Value = Desc.ToString(); Update_Name2.After_Value = txtDescription.Text.ToString(); Update_Name2.Audit_Log_Id = Log_ID; db.Audit_Update.Add(Update_Name2); db.SaveChanges(); } MessageBox.Show("Marketing Template Successfully Updated"); this.Close(); } } catch (Exception ex) { MessageBox.Show("Error has occured, and template was not updated successfully" + ex); } } } }
private void btnAddEmployee_Click(object sender, EventArgs e) { correct = true; Employee emp = new Employee(); try { if (ValidateIfEmployeeExists(txtContactNumber.Text) == true) { MessageBox.Show("Employee contact number exists"); } if (txtEName.Text == "" || txtAccountNum.Text == "" || txtContactNumber.Text == "" || (txtEmailAddress.Text == "") || txtESurname.Text == "" || txtID.Text == "" || pictureBox1 == null) { MessageBox.Show("Please Enter all fields on the employee Form"); correct = false; } if (pictureBox1.Image == null) { lblPicture.Visible = true; lblPicture.Text = "Please insert the employee's ID photo by making use of the Browse button"; pictureBox1.Visible = true; } else if (pictureBox1.Image != null) { lblPicture.Visible = false; pictureBox1.Visible = false; } if (txtEName.Text == "") { lblName.Visible = true; } if (txtESurname.Text == "") { lblSurname.Visible = true; } if (txtAddress.Text == "") { lblAddress.Visible = true; } if (txtID.Text == "") { lblidentityNumber.Visible = true; } if (txtAccountNum.Text == "") { lblAccountNumber.Visible = true; } if (txtTaxumber.Text == "") { lblTaxN.Visible = true; } if (txtContactNumber.Text == "") { lblContact.Visible = true; } if (txtEmailAddress.Text.Contains("@") == false || txtEmailAddress.Text == "") { lblEmailAddress.Visible = true; } if (cbxEmployeeType.ValueMember == "") { lblEmployeetype.Visible = true; } else if (txtEmailAddress.Text.Contains("@") == true && correct == true) { byte[] binaryPic = new byte[100000]; binaryPic = imageToByteArray(pi.Image); emp.Employee_Id = 0; emp.Employee_Name = txtEName.Text; emp.Employee_Surname = txtESurname.Text; emp.Employee_Address = txtAddress.Text; emp.Employee_Id_Number = Convert.ToInt64(txtID.Text); emp.Employee_Account_Number = Convert.ToDecimal(txtContactNumber.Text); emp.Employee_Name = txtEName.Text; //Employee_Type et = cbxEmployeeType.SelectedValue as Employee_Type; emp.Employee_Type_ID = Convert.ToInt32(cbxEmployeeType.SelectedValue); emp.Employee_Cellphone_Number = txtContactNumber.Text; emp.Employee_Email_Address = txtEmailAddress.Text; emp.Employee_Tax_Number = txtTaxumber.Text; //User us = cbxUser.SelectedValue as User; //emp.Users_Id = Convert.ToInt32(cbxUser.SelectedValue); //Title title = cbxTitle.SelectedValue as Title; emp.Title_Id = Convert.ToInt32(cbxTitle.SelectedValue); emp.Employee_Image = binaryPic; db.Employees.Add(emp); db.SaveChanges(); MessageBox.Show("Employee Added Successfully"); this.Close(); } else { MessageBox.Show("Please insert valid email address"); } } catch (NullReferenceException) { //MessageBox.Show("Employee not added"); } }
private void btnUpdateEmployee_Click(object sender, EventArgs e) { correct = true; try { if (txtEName.Text == "" || txtAccountNum.Text == "" || txtContactNumber.Text == "" || txtEmailAddress.Text == "" || txtESurname.Text == "" || txtID.Text == "" || cbxEmployeeType.SelectedValue == null) { MessageBox.Show("Please Enter all fields on the employee Form"); correct = false; } if (txtEName.Text == "") { lblName.Visible = true; } if (txtESurname.Text == "") { lblSurname.Visible = true; } if (txtAddress.Text == "") { lblAddress.Visible = true; } if (txtID.Text == "") { lblidentityNumber.Visible = true; } if (txtAccountNum.Text == "") { lblAccountNumber.Visible = true; } if (txtTaxumber.Text == "") { lblTaxN.Visible = true; } if (txtContactNumber.Text == "") { lblContact.Visible = true; } if (txtEmailAddress.Text.Contains("@") == false || txtEmailAddress.Text == "") { lblEmailAddress.Visible = true; } if (pi.Image == null) { lblPicture.Visible = true; lblPicture.Text = "Please upload a valid ID picture"; } if (txtEmailAddress.Text.Contains("@") == true && correct == true) { //byte[] binaryPic = new byte[100000]; //binaryPic = imageToByteArray(pi.Image); var query = db.Employees.Where(co => co.Employee_Id == tempID).First(); //query.Employee_Id = 0; query.Employee_Name = txtEName.Text; query.Employee_Surname = txtESurname.Text; query.Employee_Address = txtAddress.Text; query.Employee_Id_Number = Convert.ToDecimal(txtID.Text); query.Employee_Account_Number = Convert.ToDecimal(txtAccountNum.Text); query.Employee_Name = txtEName.Text; query.Employee_Type_ID = Convert.ToInt32(cbxEmployeeType.SelectedValue); query.Employee_Cellphone_Number = txtContactNumber.Text; query.Employee_Email_Address = txtEmailAddress.Text; query.Employee_Tax_Number = txtTaxumber.Text; // Title us = cbxTitle.SelectedIndex as Title; query.Title_Id = Convert.ToInt32(cbxTitle.SelectedValue); query.Employee_Image = imageToByteArray(pi.Image); //pictureBox1.Image = byteArrayToImage(emp.Profile_Picture); db.SaveChanges(); MessageBox.Show("Employee Successfully Updated"); this.Close(); } } catch (NullReferenceException) { //MessageBox.Show("Employee not updated"); } }
private void btnConfirm_Click(object sender, EventArgs e) { if (txtAccessName.Text == "") { MessageBox.Show("Please enter Access Level Name"); } else { try { if (cbxAdminScreen.Checked == true || cbxUserAccessLevelScreen.Checked == true || cbxEmployeeScreen.Checked == true || cbxSupplierOrderScreen.Checked == true || cbxPurchaseOrderScreen.Checked == true || cbxProductScreen.Checked == true || cbxClient.Checked == true || cbxReportsScreen.Checked == true || cbxSaleScreen.Checked == true || cbxVehicleScreen.Checked == true) { if (db.Access_Level.Where(al => al.Access_Level_Name == txtAccessName.Text.ToUpper()).Count() == 0) { NewRole.Admin_Role = cbxAdminScreen.Checked; NewRole.Client_Role = cbxClient.Checked; NewRole.Employee_Role = cbxEmployeeScreen.Checked; NewRole.Product_Role = cbxProductScreen.Checked; NewRole.Reports_Role = cbxReportsScreen.Checked; NewRole.Sale_Role = cbxSaleScreen.Checked; NewRole.Supplier_Order_Role = cbxSupplierOrderScreen.Checked; NewRole.Client_Order_Role = cbxPurchaseOrderScreen.Checked; NewRole.Vehicle_Role = cbxVehicleScreen.Checked; NewRole.User_And_Access_Level_Role = cbxUserAccessLevelScreen.Checked; NewRole.Website_Role = false; db.User_Role.Add(NewRole); NewAccess.Access_Level_Name = txtAccessName.Text.ToUpper(); NewAccess.Role_Id = NewRole.User_Role_Id; db.Access_Level.Add(NewAccess); db.SaveChanges(); MessageBox.Show("Access level added successfully"); //Audit Log int accessidz = NewAccess.Access_Level_Id; string access_Value = Convert.ToString(NewAccess); Audit_Log Current_Audit4 = new Audit_Log(); Current_Audit4.Table_Name = "Access Level"; // Current_Audit3.Users_Id = Globals.Users_Id; Current_Audit4.Date_Time = DateTime.Now; db.Audit_Log.Add(Current_Audit4); db.SaveChanges(); int Log_ID4 = Current_Audit4.Audit_Log_Id; Audit_Create_Delete Current_Create4 = new Audit_Create_Delete(); Current_Create4.Audit_Log_Id = Log_ID4; Current_Create4.Created = true; Current_Create4.PK_Row_Effected = accessidz; Current_Create4.Value = access_Value; db.Audit_Create_Delete.Add(Current_Create4); db.SaveChanges(); this.Close(); this.Hide(); } else { MessageBox.Show("Access level already exists"); } } else { MessageBox.Show("Please select atleast one access level"); } } catch (Exception ex) { MessageBox.Show("Whoops, An Error Occured, Please try again" + ex); } } }
private void button2_Click(object sender, EventArgs e) { try { if (newPO != null) { int prid = Convert.ToInt32(comboBox1.SelectedValue); var q = db.Products.Where(p => p.Product_ID == prid).FirstOrDefault(); var q1 = db.Client_Purchase_Order_Line.Where(cpol => cpol.Product_ID == prid && cpol.Client_Purchase_Id == newPO.Client_Purchase_Id).FirstOrDefault(); if (pol == null) { pol = new Client_Purchase_Order_Line() { Client_Purchase_Id = newPO.Client_Purchase_Id, Product_ID = Convert.ToInt32(comboBox1.SelectedValue), Quantity = Convert.ToInt32(txtQuantity.Text), }; db.Client_Purchase_Order_Line.Add(pol); db.SaveChanges(); var q3 = db.Client_Purchase_Order.Where(x => x.Client_Purchase_Id == newPO.Client_Purchase_Id).First(); dataGridView1.DataSource = db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number).ToList(); var q2 = db.Company_Information.Select(ci => ci.VAT_Percentage).First(); txtCreditBalance.Text = (Convert.ToDecimal(txtCreditBalance.Text) + pa).ToString(); txtGrossTotalVI.Text = Convert.ToDecimal(db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number).Sum(pol => pol.Subtotal)).ToString(); txtGrossTotalVE.Text = Decimal.Round(Convert.ToDecimal(db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number). Sum(pol => pol.Subtotal)) * (1 - (q2 / 100)), 2).ToString(); txtVAT.Text = Decimal.Round(Convert.ToDecimal(db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number).Sum(pol => pol.Subtotal)) * (q2 / 100), 2).ToString(); ca = Convert.ToDecimal(txtGrossTotalVI.Text); txtCreditBalance.Text = (Convert.ToDecimal(txtCreditBalance.Text) - ca).ToString(); pa = ca; } else { var q3 = db.Client_Purchase_Order.Where(x => x.Client_Purchase_Id == newPO.Client_Purchase_Id).First(); if (q1 == null) { pol = new Client_Purchase_Order_Line() { Client_Purchase_Id = newPO.Client_Purchase_Id, Product_ID = Convert.ToInt32(comboBox1.SelectedValue), Quantity = Convert.ToInt32(txtQuantity.Text), }; db.Client_Purchase_Order_Line.Add(pol); db.SaveChanges(); dataGridView1.DataSource = db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number).ToList(); var q2 = db.Company_Information.Select(ci => ci.VAT_Percentage).FirstOrDefault(); txtCreditBalance.Text = (Convert.ToDecimal(txtCreditBalance.Text) + pa).ToString(); txtGrossTotalVI.Text = Convert.ToDecimal(db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number).Sum(pol => pol.Subtotal)).ToString(); txtGrossTotalVE.Text = Decimal.Round(Convert.ToDecimal(db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number). Sum(pol => pol.Subtotal)) * (1 - (q2 / 100)), 2).ToString(); txtVAT.Text = Decimal.Round(Convert.ToDecimal(db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number).Sum(pol => pol.Subtotal)) * (q2 / 100), 2).ToString(); ca = Convert.ToDecimal(txtGrossTotalVI.Text); txtCreditBalance.Text = (Convert.ToDecimal(txtCreditBalance.Text) - ca).ToString(); pa = ca; } else { var q4 = db.Client_Purchase_Order_Line.Where(cpol => cpol.Client_Purchase_Id == newPO.Client_Purchase_Id && cpol.Client_Purchase_Order_Line_ID == q1.Client_Purchase_Order_Line_ID). FirstOrDefault(); q4.Quantity += Convert.ToInt32(txtQuantity.Text); db.SaveChanges(); dataGridView1.DataSource = db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number).ToList(); var q2 = db.Company_Information.Select(ci => ci.VAT_Percentage).FirstOrDefault(); txtCreditBalance.Text = (Convert.ToDecimal(txtCreditBalance.Text) + pa).ToString(); txtGrossTotalVI.Text = Decimal.Round(Convert.ToDecimal(db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number).Sum(pol => pol.Subtotal)), 2).ToString(); txtGrossTotalVE.Text = Decimal.Round(Convert.ToDecimal(db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number). Sum(pol => pol.Subtotal)) * (1 - (q2 / 100)), 2).ToString(); txtVAT.Text = Decimal.Round(Convert.ToDecimal(db.Load_Purcase_Order_Line().Where(x => x.Purhcase_Order_Number == q3.PO_Number).Sum(pol => pol.Subtotal)) * (q2 / 100), 2).ToString(); ca = Convert.ToDecimal(txtGrossTotalVI.Text); txtCreditBalance.Text = (Convert.ToDecimal(txtCreditBalance.Text) - ca).ToString(); pa = ca; } } } else if (xPO != null) { int prid = Convert.ToInt32(comboBox1.SelectedValue); pol = new Client_Purchase_Order_Line() { Client_Purchase_Id = newPO.Client_Purchase_Id, Product_ID = Convert.ToInt32(comboBox1.SelectedValue), Quantity = Convert.ToInt32(txtQuantity.Text), }; db.Client_Purchase_Order_Line.Add(pol); } else { MessageBox.Show("Please select a client"); } } catch (Exception ex) { MessageBox.Show("Something went wrong!,Please try again " + ex.ToString()); } groupBox3.Enabled = true; }