private void button3_Click(object sender, EventArgs e) { 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 (UserDefineMessages.ShowMsg("", UserDefineMessages.Msg_PerfmBtn_Save, commonFunctions.Softwarename.Trim()) == System.Windows.Forms.DialogResult.Yes) { u_Userxcc obju_User = new u_Userxcc(); obju_User.userId = commonFunctions.Loginuser; obju_User = new U_UserxDL().Selectu_User(obju_User); obju_User.password = commonFunctions.CreateCheckPassword(true, txtPw.Text.Trim()); new U_UserxDL().Saveu_UserSP(obju_User, 3); pnl_pass.Visible = false; } }
public static string FindExisitingUSer(string suppcode) { string str = ""; if (U_UserxDL.ExistingU_User(suppcode.Trim())) { u_Userxcc cat = new u_Userxcc(); cat.userId = suppcode.Trim(); str = new U_UserxDL().Selectu_User(cat).userName; } else { str = "<Error!!!>"; } return(str); }
/// <summary> /// Saves a record to the u_User table. /// </summary> public Boolean Saveu_UserSP(u_Userxcc u_User, int formMode) { SqlCommand scom; bool retvalue = false; try { scom = new SqlCommand(); scom.CommandType = CommandType.StoredProcedure; scom.CommandText = "U_UserSaveNew"; scom.Parameters.Add("@userId", SqlDbType.VarChar, 10).Value = u_User.userId; scom.Parameters.Add("@userName", SqlDbType.VarChar, 40).Value = u_User.userName; scom.Parameters.Add("@password", SqlDbType.VarChar, 20).Value = u_User.password; scom.Parameters.Add("@roleId", SqlDbType.VarChar, 10).Value = u_User.roleId; scom.Parameters.Add("@userCreated", SqlDbType.VarChar, 10).Value = u_User.userCreated; scom.Parameters.Add("@dateCreated", SqlDbType.DateTime, 8).Value = u_User.dateCreated; scom.Parameters.Add("@userModified", SqlDbType.VarChar, 10).Value = u_User.userModified; scom.Parameters.Add("@dateModified", SqlDbType.DateTime, 8).Value = u_User.dateModified; scom.Parameters.Add("@isActive", SqlDbType.Int, 4).Value = u_User.isActive; scom.Parameters.Add("@Type", SqlDbType.VarChar, 10).Value = u_User.Type; scom.Parameters.Add("@Compcode", SqlDbType.VarChar, 20).Value = u_User.Compcode; scom.Parameters.Add("@Locacode", SqlDbType.VarChar, 20).Value = u_User.Locacode; scom.Parameters.Add("@TP", SqlDbType.VarChar, 20).Value = u_User.TP; scom.Parameters.Add("@Fax", SqlDbType.VarChar, 20).Value = u_User.Fax; scom.Parameters.Add("@Email", SqlDbType.VarChar, 50).Value = u_User.Email; scom.Parameters.Add("@Address1", SqlDbType.VarChar, 50).Value = u_User.Address1; scom.Parameters.Add("@Address2", SqlDbType.VarChar, 50).Value = u_User.Address2; scom.Parameters.Add("@Address3", SqlDbType.VarChar, 50).Value = u_User.Address3; scom.Parameters.Add("@ContactPerson", SqlDbType.VarChar, 20).Value = u_User.ContactPerson; scom.Parameters.Add("@ContactPersonNo", SqlDbType.VarChar, 50).Value = u_User.ContactPersonNo; scom.Parameters.Add("@CurrentStatus", SqlDbType.VarChar, 20).Value = u_User.CurrentStatus; scom.Parameters.Add("@Gradex", SqlDbType.VarChar, 20).Value = u_User.Gradex; scom.Parameters.Add("@NICNo", SqlDbType.VarChar, 20).Value = u_User.NICNo; scom.Parameters.Add("@InsMode", SqlDbType.Int).Value = formMode; // For insert scom.Parameters.Add("@RtnValue", SqlDbType.Int).Value = 0; u_DBConnection dbcon = new u_DBConnection(); retvalue = dbcon.RunQuery(scom); return(retvalue); } catch (Exception ex) { throw (ex); } }
public List <u_Userxcc> SelectU_UserMultiAll() { List <u_Userxcc> retval = new List <u_Userxcc>(); try { strquery = @"SELECT * FROM dbo.u_User WHERE Type = 'SAL'"; DataTable dtu_User = u_DBConnection.ReturnDataTable(strquery, CommandType.Text); foreach (DataRow drType in dtu_User.Rows) { if (drType != null) { u_Userxcc obju_User = new u_Userxcc(); obju_User.userId = drType["userId"].ToString(); obju_User.userName = drType["userName"].ToString(); obju_User.password = drType["password"].ToString(); obju_User.roleId = drType["roleId"].ToString(); obju_User.userCreated = drType["userCreated"].ToString(); obju_User.dateCreated = DateTime.Parse(drType["dateCreated"].ToString()); obju_User.userModified = drType["userModified"].ToString(); obju_User.dateModified = DateTime.Parse(drType["dateModified"].ToString()); obju_User.isActive = int.Parse(drType["isActive"].ToString()); obju_User.Type = drType["Type"].ToString(); obju_User.Compcode = drType["Compcode"].ToString(); obju_User.Locacode = drType["Locacode"].ToString(); obju_User.TP = drType["TP"].ToString(); obju_User.Fax = drType["Fax"].ToString(); obju_User.Email = drType["Email"].ToString(); obju_User.Address1 = drType["Address1"].ToString(); obju_User.Address2 = drType["Address2"].ToString(); obju_User.Address3 = drType["Address3"].ToString(); obju_User.ContactPerson = drType["ContactPerson"].ToString(); obju_User.ContactPersonNo = drType["ContactPersonNo"].ToString(); obju_User.CurrentStatus = drType["CurrentStatus"].ToString(); obju_User.Gradex = drType["Gradex"].ToString(); obju_User.NICNo = drType["NICNo"].ToString(); retval.Add(obju_User); } } return(retval); } catch (Exception ex) { throw ex; } }
public u_Userxcc Selectu_User(u_Userxcc obju_User) { try { strquery = @"select * from u_User where userId = '" + obju_User.userId + "'"; DataRow drType = u_DBConnection.ReturnDataRow(strquery); if (drType != null) { obju_User.userId = drType["userId"].ToString(); obju_User.userName = drType["userName"].ToString(); obju_User.password = drType["password"].ToString(); obju_User.roleId = drType["roleId"].ToString(); obju_User.userCreated = drType["userCreated"].ToString(); obju_User.dateCreated = DateTime.Parse(drType["dateCreated"].ToString()); obju_User.userModified = drType["userModified"].ToString(); obju_User.dateModified = DateTime.Parse(drType["dateModified"].ToString()); obju_User.isActive = int.Parse(drType["isActive"].ToString()); obju_User.Type = drType["Type"].ToString(); obju_User.Compcode = drType["Compcode"].ToString(); obju_User.Locacode = drType["Locacode"].ToString(); obju_User.TP = drType["TP"].ToString(); obju_User.Fax = drType["Fax"].ToString(); obju_User.Email = drType["Email"].ToString(); obju_User.Address1 = drType["Address1"].ToString(); obju_User.Address2 = drType["Address2"].ToString(); obju_User.Address3 = drType["Address3"].ToString(); obju_User.ContactPerson = drType["ContactPerson"].ToString(); obju_User.ContactPersonNo = drType["ContactPersonNo"].ToString(); obju_User.CurrentStatus = drType["CurrentStatus"].ToString(); obju_User.Gradex = drType["Gradex"].ToString(); obju_User.NICNo = drType["NICNo"].ToString(); return(obju_User); } return(null); } catch (Exception ex) { throw ex; } }
private void SetValues(String sm_SalesMan) { try { U_UserxDL bdl = new U_UserxDL(); u_Userxcc objm_SalesMan = new u_Userxcc(); if (sm_SalesMan != "") { objm_SalesMan.userId = sm_SalesMan; objm_SalesMan = new U_UserxDL().Selectu_User(objm_SalesMan); if (objm_SalesMan != null) { txt_SalesmanID.Text = objm_SalesMan.userId.ToString(); txt_SalesmanName.Text = objm_SalesMan.userName.ToString(); txt_TP.Text = objm_SalesMan.TP.ToString(); txt_Fax.Text = objm_SalesMan.Fax.ToString(); txt_Email.Text = objm_SalesMan.Email.ToString(); txt_Address1.Text = objm_SalesMan.Address1.ToString(); txt_Address2.Text = objm_SalesMan.Address2.ToString(); txt_Address3.Text = objm_SalesMan.Address3.ToString(); txt_ContactPerson.Text = objm_SalesMan.ContactPerson.ToString(); txt_ContactPersonNo.Text = objm_SalesMan.ContactPersonNo.ToString(); txt_nic.Text = objm_SalesMan.NICNo; txt_paymeth.Text = objm_SalesMan.Type; txtusergroup.Text = objm_SalesMan.roleId; //txt_CurrentStatus.Text = objm_SalesMan.CurrentStatus.ToString(); //txt_Gradex.Text = objm_SalesMan.Gradex.ToString(); formMode = 3; } } } catch (Exception ex) { throw ex; } }
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; } }