/// <summary> /// Save function, Checking the Invalid entries /// </summary> public void SaveFunction() { try { UserInfo infoUser = new UserInfo(); UserBll bllUser = new UserBll(); string strUserName = txtUserName.Text.Trim(); string strPassword = bllUser.LoginCheck(strUserName); if (txtOldPassword.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter password"); txtOldPassword.Focus(); } else if (txtNewPassword.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter new password"); txtNewPassword.Focus(); } else if (txtRetype.Text.Trim() == string.Empty) { Messages.InformationMessage("Enter confirmation password"); txtRetype.Focus(); } else if (txtNewPassword.Text != txtRetype.Text) { Messages.InformationMessage("Password and confirm password should match"); txtRetype.Focus(); txtRetype.SelectAll(); } else if (strPassword == txtOldPassword.Text.Trim()) { if (PublicVariables.isMessageAdd) { if (Messages.SaveMessage()) { infoUser.UserId = PublicVariables._decCurrentUserId; infoUser.UserName = txtUserName.Text.Trim(); infoUser.Password = txtNewPassword.Text.Trim(); bllUser.ChangePasswordEdit(infoUser); Clear(); Messages.SavedMessage(); this.Close(); } } else { infoUser.UserId = PublicVariables._decCurrentUserId; infoUser.UserName = txtUserName.Text.Trim(); infoUser.Password = txtNewPassword.Text.Trim(); bllUser.ChangePasswordEdit(infoUser); Clear(); Messages.SavedMessage(); this.Close(); } } else { Messages.InformationMessage("Invalid password"); txtOldPassword.Focus(); txtOldPassword.SelectAll(); } } catch (Exception ex) { MessageBox.Show("CHGPWD:2" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Start a login /// </summary> public void Login() { try { UserBll bllUser = new UserBll(); CompanyCreationBll bllCompanyCreation = new CompanyCreationBll(); CompanyInfo infoCompany = new CompanyInfo(); string strUserName = txtUserName.Text.Trim(); string strPassword = bllUser.LoginCheck(strUserName); if (strPassword == txtPassword.Text.Trim() && strPassword != string.Empty) { int inUserId = bllUser.GetUserIdAfterLogin(strUserName, strPassword); PublicVariables._decCurrentUserId = inUserId; infoCompany = bllCompanyCreation.CompanyView(1); PublicVariables._decCurrencyId = infoCompany.CurrencyId; formMDI.MDIObj.CallFromLogin(); SettingsCheck(); //for Quock Launch menu formMDI.MDIObj.ShowQuickLaunchMenu(); formMDI.MDIObj.CurrentSettings(); //Display ChangeCurrentDate form// frmChangeCurrentDate frmCurrentDateChangeObj = new frmChangeCurrentDate(); frmCurrentDateChangeObj.MdiParent = formMDI.MDIObj; frmCurrentDateChangeObj.CallFromLogin(this); formMDI.MDIObj.Text = "OpenMiracle " + infoCompany.CompanyName + " [ " + PublicVariables._dtFromDate.ToString("dd-MMM-yyyy") + " To " + PublicVariables._dtToDate.ToString("dd-MMM-yyyy") + " ]"; // For showing the OpenMiracle message from the website formMDI.MDIObj.logoutToolStripMenuItem.Enabled = true; if (PublicVariables.MessageToShow != string.Empty) { frmMessage frmMsg = new frmMessage(); frmMsg.lblHeading.Text = PublicVariables.MessageHeadear; frmMsg.lblMessage.Text = PublicVariables.MessageToShow; frmMsg.MdiParent = formMDI.MDIObj; frmMsg.Show(); frmMsg.Location = new Point(0, formMDI.MDIObj.Height - 270); foreach (Form form in Application.OpenForms) { if (form.GetType() == typeof(frmChangeCurrentDate)) { form.Focus(); } } } } else { Messages.InformationMessage("Invalid username or password"); Clear(); } } catch (Exception ex) { MessageBox.Show("LOGIN02:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }