private void button3_Click(object sender, EventArgs e) { errorProvider1.Clear(); if (txtUCode.Text.Trim() == "") { errorProvider1.SetError(txtUCode, "User code cannot be a null value."); commonFunctions.SetMDIStatusMessage("User code cannot be a null value.", 1); return; } if (txtUCode.Text.Trim().Length < 5) { errorProvider1.SetError(txtUCode, "User code must be more than 6 charactors."); commonFunctions.SetMDIStatusMessage("User code must be more than 6 charactors", 1); return; } if (U_UserxDL.ExistingU_User(txtUserID.Text.Trim())) { errorProvider1.SetError(txtUCode, "User code already exists."); commonFunctions.SetMDIStatusMessage("User code already exists.", 1); return; } if (txtUName.Text.Trim() == "") { errorProvider1.SetError(txtUName, "User name cannot be a null value."); commonFunctions.SetMDIStatusMessage("User name cannot be a null value.", 1); return; } if (txtPw.Text == "") { errorProvider1.SetError(txtPw, "Password cannot be a null value."); commonFunctions.SetMDIStatusMessage("Password cannot be a null value.", 1); return; } if (txtPw.Text != txtRePw.Text) { errorProvider1.SetError(txtPw, "Password and the confirmation password must be same"); commonFunctions.SetMDIStatusMessage("Password and the confirmation password must be same.", 1); return; } if (!U_UserRolexDL.ExistingU_UserRole(txtusergroup.Text.Trim())) { errorProvider1.SetError(txtusergroup, "User group already exists."); commonFunctions.SetMDIStatusMessage("User group already exists.", 1); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { try { //u_Userxcc obju_User = new u_Userxcc(); //obju_User.userId = txtUserID.Text.Trim(); //obju_User.userName = txtUCode.Text.Trim(); //obju_User.password = commonFunctions.CreateCheckPassword(true, txtPw.Text.Trim()); //obju_User.roleId = txtusergroup.Text.Trim(); //obju_User.userCreated = commonFunctions.Loginuser; //obju_User.dateCreated = DateTime.Now; //obju_User.userModified = ""; //obju_User.dateModified = DateTime.Now; //obju_User.isActive = 1; //obju_User.empId = ""; //obju_User.signOnTime = DateTime.Now; //obju_User.signOnDate = DateTime.Now; //obju_User.shiftNo = 1; //obju_User.isSignOn = 1; //obju_User.isSignOff = 1; //obju_User.signOffDate = DateTime.Now; //obju_User.signOffTime = DateTime.Now; //obju_User.dateTimeFormat = "dd/MM/yyyy"; //obju_User.mobile = txtmobile.Text; //obju_User.terminalID = ""; //obju_User.shiftOnLocation = commonFunctions.GlobalLocation; //U_UserxDL bal = new U_UserxDL(); //bal.Saveu_UserSP(obju_User, 1); UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_Save_Sucess, commonFunctions.Softwarename.Trim()); } catch (Exception ex) { LogFile.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.Name, ex.Message.ToString(), "Exception"); commonFunctions.SetMDIStatusMessage("Genaral Error on updating data", 1); } } }
private void performButtons(xEnums.PerformanceType xenum) { switch (xenum) { case xEnums.PerformanceType.View: if (ActiveControl.Name.Trim() == txt_SalesmanID.Name.Trim()) { int length = Convert.ToInt32(ConfigurationManager.AppSettings["SalesmanFieldLength"]); string[] strSearchField = new string[length]; string strSQL = ConfigurationManager.AppSettings["SalesmanSQL"].ToString(); for (int i = 0; i < length; i++) { string m; m = i.ToString(); strSearchField[i] = ConfigurationManager.AppSettings["SalesmanField" + m + ""].ToString(); } frmU_Search find = new frmU_Search(strSQL, strSearchField, this); find.ShowDialog(this); } break; case xEnums.PerformanceType.New: FunctionButtonStatus(xEnums.PerformanceType.New); //txt_IDX.Text = commonFunctions.GetSerial("A0009"); formMode = 1; txt_SalesmanID.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Edit: FunctionButtonStatus(xEnums.PerformanceType.Edit); formMode = 3; txt_SalesmanID.Enabled = false; txt_SalesmanName.Focus(); errorProvider1.Clear(); break; case xEnums.PerformanceType.Save: errorProvider1.Clear(); if (txt_SalesmanID.Text.Trim().ToUpper() == "ADMIN") { errorProvider1.SetError(txt_SalesmanID, "This user is the system administrator. you cannot change the details."); commonFunctions.SetMDIStatusMessage("This user is the system administrator. you cannot change the details.", 1); return; } if (txt_SalesmanID.Text.Trim() == "") { errorProvider1.SetError(txt_SalesmanID, "User code cannot be a null value."); commonFunctions.SetMDIStatusMessage("User code cannot be a null value.", 1); return; } if (txt_SalesmanID.Text.Trim().Length < 5) { errorProvider1.SetError(txt_SalesmanID, "User code must be more than 6 charactors."); commonFunctions.SetMDIStatusMessage("User code must be more than 6 charactors", 1); return; } if (txt_SalesmanName.Text.Trim() == "") { errorProvider1.SetError(txt_SalesmanName, "User name cannot be a null value."); commonFunctions.SetMDIStatusMessage("User name cannot be a null value.", 1); return; } if (txtPw.Text == "") { errorProvider1.SetError(txtPw, "Password cannot be a null value."); commonFunctions.SetMDIStatusMessage("Password cannot be a null value.", 1); return; } if (txtPw.Text != txtRePw.Text) { errorProvider1.SetError(txtPw, "Password and the confirmation password must be same"); commonFunctions.SetMDIStatusMessage("Password and the confirmation password must be same.", 1); return; } if (!U_UserRolexDL.ExistingU_UserRole(txtusergroup.Text.Trim())) { errorProvider1.SetError(txtusergroup, "User group already exists."); commonFunctions.SetMDIStatusMessage("User group already exists.", 1); return; } if (txt_SalesmanName.Text.Trim() == "") { errorProvider1.SetError(txt_SalesmanName, "Please enter a employee name !"); commonFunctions.SetMDIStatusMessage("Please enter a employee name.", 1); return; } if (txt_SalesmanID.Text.Trim() == "") { errorProvider1.SetError(txt_SalesmanID, "Please enter a employee name !"); commonFunctions.SetMDIStatusMessage("Please enter a employee name.", 1); return; } if (formMode == 1) { if (U_UserxDL.ExistingU_User(txt_SalesmanID.Text.Trim())) { errorProvider1.SetError(txt_SalesmanID, "User code already exists."); commonFunctions.SetMDIStatusMessage("User code already exists.", 1); return; } if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { u_Userxcc obju_User = new u_Userxcc(); obju_User.userId = txt_SalesmanID.Text.Trim(); obju_User.userName = txt_SalesmanName.Text.Trim(); obju_User.password = commonFunctions.CreateCheckPassword(true, txtPw.Text.Trim()); obju_User.roleId = txtusergroup.Text.Trim(); obju_User.userCreated = commonFunctions.Loginuser; obju_User.dateCreated = DateTime.Now; obju_User.userModified = ""; obju_User.dateModified = DateTime.Now; obju_User.isActive = 1; obju_User.Type = txt_paymeth.Text.Trim().ToUpper(); obju_User.Compcode = commonFunctions.GlobalCompany; obju_User.Locacode = commonFunctions.GlobalLocation; obju_User.TP = txt_TP.Text.Trim(); obju_User.Fax = txt_Fax.Text.Trim(); obju_User.Email = txt_Email.Text.Trim(); obju_User.Address1 = txt_Address1.Text.Trim(); obju_User.Address2 = txt_Address2.Text.Trim(); obju_User.Address3 = txt_Address3.Text.Trim(); obju_User.ContactPerson = txt_ContactPerson.Text.Trim(); obju_User.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); obju_User.CurrentStatus = "Active"; obju_User.Gradex = "Good"; obju_User.NICNo = txt_nic.Text.Trim(); new U_UserxDL().Saveu_UserSP(obju_User, 1); GetData(); txt_SalesmanID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Save_Sucess_string, 2); } } else if (formMode == 3) { if (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Update, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { u_Userxcc obju_User = new u_Userxcc(); obju_User.userId = txt_SalesmanID.Text.Trim(); obju_User = new U_UserxDL().Selectu_User(obju_User); obju_User.userId = txt_SalesmanID.Text.Trim(); obju_User.userName = txt_SalesmanName.Text.Trim(); obju_User.password = commonFunctions.CreateCheckPassword(true, txtPw.Text.Trim()); obju_User.roleId = txtusergroup.Text.Trim(); obju_User.userCreated = commonFunctions.Loginuser; obju_User.dateCreated = DateTime.Now; obju_User.userModified = ""; obju_User.dateModified = DateTime.Now; obju_User.isActive = 1; obju_User.Type = txt_paymeth.Text.Trim().ToUpper(); obju_User.Compcode = commonFunctions.GlobalCompany; obju_User.Locacode = commonFunctions.GlobalLocation; obju_User.TP = txt_TP.Text.Trim(); obju_User.Fax = txt_Fax.Text.Trim(); obju_User.Email = txt_Email.Text.Trim(); obju_User.Address1 = txt_Address1.Text.Trim(); obju_User.Address2 = txt_Address2.Text.Trim(); obju_User.Address3 = txt_Address3.Text.Trim(); obju_User.ContactPerson = txt_ContactPerson.Text.Trim(); obju_User.ContactPersonNo = txt_ContactPersonNo.Text.Trim(); obju_User.CurrentStatus = "Active"; obju_User.Gradex = "Good"; obju_User.NICNo = txt_nic.Text.Trim(); new U_UserxDL().Saveu_UserSP(obju_User, 3); GetData(); txt_SalesmanID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Save); commonFunctions.SetMDIStatusMessage(UserDefineMessages.Msg_Update_Sucess_string, 2); } } break; case xEnums.PerformanceType.Cancel: txt_SalesmanID.Enabled = true; FunctionButtonStatus(xEnums.PerformanceType.Default); errorProvider1.Clear(); break; case xEnums.PerformanceType.Print: UserDefineMessages.ShowMsg1("Print still in process", UserDefineMessages.Msg_Information); break; } }