private bool val1(DevExpress.XtraEditors.TextEdit pz, DevExpress.XtraEditors.TextEdit cd, int pr) { bool b = true; if (cd.Text != "") { if (FindCodigosBarra(cbProducto.EditValue.ToString(), cd.Text) != 0) { MessageBox.Show(@"El código de barra de la presentacion " + pr.ToString() + @" esta siendo utilizada en otro producto."); cd.Focus(); b = false; } } if (double.Parse(pz.EditValue.ToString()) == 0 && cd.Text != "") { MessageBox.Show(@"La presentacion " + pr.ToString() + @" debe ser mayor a cero el numero de piezas."); pz.Focus(); b = false; } if (double.Parse(pz.EditValue.ToString()) > 0 && cd.Text == "") { MessageBox.Show(@"La presentacion " + pr.ToString() + @" debe contener un codigo o la cantidad de piezas en 0."); pz.Focus(); b = false; } return(!b); }
private void btnOK_Click(object sender, System.EventArgs e) { int nEmployeeID = -1; if (txtEmployeeID.EditValue.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please enter your Employee ID."); txtEmployeeID.Focus(); DialogResult = DialogResult.None; return; } try { nEmployeeID = Convert.ToInt32(txtEmployeeID.EditValue); } catch { UI.ShowErrorMessage(this, "Please enter a correct format of Employee ID.", "Error"); txtEmployeeID.Focus(); DialogResult = DialogResult.None; return; } if (myTimeCard.ValidatePassword(nEmployeeID, txtPassword.Text)) { if (!myTimeCard.SaveTimeCard(this.strBranchCode, nEmployeeID)) { UI.ShowMessage(this, "Punch In successfully at " + DateTime.Now.ToString("dddd, dd MMMM yyyy hh:mm tt" + ".")); } else { UI.ShowMessage(this, "Punch Out successfully at " + DateTime.Now.ToString("dddd, dd MMMM yyyy hh:mm tt" + ".")); } if (modInitForms.fBranch == null) { Application.Exit(); } else { this.Close(); } } else { UI.ShowErrorMessage(this, "Please enter a correct username or password.", "Error"); txtPassword.Focus(); DialogResult = DialogResult.None; return; } }
public Boolean grabar() { try { Boolean bolResult = true; txtIdSubCentro.Focus(); GetSubCentroCosto(); switch (enu) { case Cl_Enumeradores.eTipo_action.grabar: string ver = ""; string variable = (this.txtIdSubCentro.Text).TrimEnd(); bolResult = Guardar(); if (eCliente == Cl_Enumeradores.eCliente_Vzen.FJ) { if (bolResult) { if (Asociar_Activo_fijo) { //Get_scc_x_af(); //bus_scc_x_af.GuardarDB(info_scc_x_af); } } } break; case Cl_Enumeradores.eTipo_action.actualizar: bolResult = Actualizar(); break; case Cl_Enumeradores.eTipo_action.Anular: Anular(); break; default: break; } return(bolResult); } catch (Exception ex) { string NameMetodo = System.Reflection.MethodBase.GetCurrentMethod().Name; MessageBox.Show(param.Get_Mensaje_sys(enum_Mensajes_sys.Error_comunicarse_con_sistemas) + ex.Message + " ", param.Nombre_sistema, MessageBoxButtons.OK, MessageBoxIcon.Error); Log_Error_bus.Log_Error(NameMetodo + " - " + ex.ToString()); return(false); } }
/// <summary> /// 해당텍스트 박스에 숫자만 축출하여 단위별 구분 값을 출력한다 /// </summary> /// <param name="textBox"> 텍스트 박스 개체</param> /// <remarks> 123e34 -> 12,334 출력</remarks> /// <example> /// TextBox1.Text = GetNumberCheck(TextBox1.Text.Trim()); /// </example> public static void SetTextBoxNumber(DevExpress.XtraEditors.TextEdit textBox) { try { string strTxt = textBox.Text.Trim().Replace(",", ""); if (strTxt.Trim() == "") { return; } string Result = ""; for (int i = 0; i < strTxt.Length; i++) { if (IsNumeric(strTxt.Substring(i, 1))) { Result += strTxt.Substring(i, 1); } } if (Result != "") { textBox.Text = String.Format("{0:#,###}", long.Parse(Result)); } else { textBox.Text = ""; } textBox.Focus(); textBox.SelectionStart = textBox.Text.Length; } catch (Exception ex) { throw ex; } }
private bool ValidateBeforeSave() { if (txtContactPerson.Text.Length == 0) { UI.ShowErrorMessage("Please enter an Contact person name."); txtContactPerson.Focus(); return(false); } else if (txtOrganization.Text.Length == 0) { UI.ShowErrorMessage("Please enter an Organization."); txtOrganization.Focus(); return(false); } else if (txtOfficeNo.Text.Length == 0) { UI.ShowErrorMessage("Please enter an office phone no."); txtOfficeNo.Focus(); return(false); } else if (txtEmail.Text.Length == 0) { UI.ShowErrorMessage("Please enter an Email address."); txtEmail.Focus(); return(false); } return(true); }
private void sbtnSave_Click(object sender, System.EventArgs e) { if (txtReceipentGroupCode.Text.Length == 0) { UI.ShowErrorMessage("Please enter a Receipient Group Code."); txtReceipentGroupCode.Focus(); DialogResult = DialogResult.None; return; } if (txtDescription.Text.Length == 0) { UI.ShowErrorMessage("Please enter a description."); txtDescription.Focus(); DialogResult = DialogResult.None; return; } ACMSLogic.Staff.ReceipientGroup myReceipientGroup = new ACMSLogic.Staff.ReceipientGroup(); if (action == "New") { myReceipientGroup.NewReceipientGroup(txtReceipentGroupCode.Text, txtDescription.Text, nEmployeeID); DialogResult = DialogResult.OK; } else { myReceipientGroup.UpdateNewReceipientGroup(txtReceipentGroupCode.Text, txtDescription.Text, nMemoGroupID); DialogResult = DialogResult.OK; } }
/// <summary> /// 해당텍스트 박스에 숫자만 축출하여 단위별 구분 값을 출력한다 /// </summary> /// <param name="txt">텍스트박스 객체</param> public static void SetTextBoxNumberNotFormat(DevExpress.XtraEditors.TextEdit txt) { try { string strTxt = txt.Text.Trim().Replace(",", ""); if (strTxt.Trim() == "") { return; } string Result = ""; for (int i = 0; i < strTxt.Length; i++) { if (IsNumeric(strTxt.Substring(i, 1))) { Result += strTxt.Substring(i, 1); } } txt.Text = Result.Trim(); txt.Focus(); txt.SelectionStart = txt.Text.Trim().Length; } catch (Exception ex) { throw ex; } }
private void sbtnSave_Click(object sender, System.EventArgs e) { if (txtReason.EditValue.ToString().Length == 0) { UI.ShowErrorMessage("Please enter a reason."); txtReason.Focus(); DialogResult = DialogResult.None; return; } TimeSpan spanCheck = timeedtEndTime.Time - timeedtStartTime.Time; if (spanCheck.TotalHours <= 0.1 || spanCheck.TotalHours > 23.59) { UI.ShowErrorMessage("Please specify correct start time and end time range."); timeedtStartTime.Focus(); DialogResult = DialogResult.None; return; } TimeSpan span = timeedtEndTime.Time - timeedtStartTime.Time; timesheet.ApplyOvertime(employee.Id, dateedtDate.DateTime, timeedtStartTime.Time, timeedtEndTime.Time, span.TotalHours, txtReason.Text); DialogResult = DialogResult.OK; }
/// <summary> /// TextEdit驗證DateTime格式 /// </summary> /// <param name="textEdit"></param> /// <param name="inputText"></param> /// <param name="errorText"></param> /// <returns></returns> public static bool IsDate(this DevExpress.XtraEditors.TextEdit textEdit, string inputText, string errorText) { DateTime dateTime; string[] YMD = inputText.Split('/'); string formatInputTxt = inputText; switch (YMD.Length) { case 1: formatInputTxt = $"{YMD[0].PadLeft(4, '0')}/01/01"; //textEdit.Text = year; break; case 2: formatInputTxt = $"{YMD[0].PadLeft(4, '0')}/{YMD[1].PadLeft(2, '0')}/01"; //textEdit.Text = $"{year}/{month}"; break; case 3: formatInputTxt = $"{YMD[0].PadLeft(4, '0')}/{YMD[1].PadLeft(2, '0')}/{YMD[2].PadLeft(2, '0')}"; //textEdit.Text = $"{year}/{month}/{date}"; break; } if (!DateTime.TryParse(formatInputTxt, out dateTime)) { MessageDisplay.Error(errorText, GlobalInfo.ErrorText); textEdit.Focus(); return(false); } return(true); }
private void frmLogin_Activated(object sender, System.EventArgs e) { if (!this.isFinishInitialize) { txtUsername.Focus(); this.isFinishInitialize = true; } }
private void txtUsername_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode.ToString() == "Return") { //to add send key //SendKeys.Send("%{TAB}"); //this.isFinishInitialize = true; txtPassword.Focus(); } }
void txtNew_Leave(object sender, EventArgs e) { txtNew.Leave -= new EventHandler(txtNew_Leave); if (m_intFlags == 0) { if (string.IsNullOrEmpty(txtNew.Text)) { RemoveTextEdit(true); } else { if (DialogBox.Msg("是否保存?", MessageBoxIcon.Question) == DialogResult.Yes) { if (m_blnSaveNewData()) { RemoveTextEdit(false); } } else { RemoveTextEdit(true); } } } else { if (string.IsNullOrEmpty(txtNew.Text)) { DialogResult dlrResult = DialogBox.Msg("元素名称不能为空,是否继续?", MessageBoxIcon.Question, this.ParentForm); if (dlrResult == DialogResult.Yes) { txtNew.Focus(); return; } else { RemoveTextEdit(false); } } else { if (DialogBox.Msg("是否保存?", MessageBoxIcon.Question) == DialogResult.Yes) { if (m_blnUpdateOldData()) { RemoveTextEdit(false); } } else { RemoveTextEdit(false); } } } }
private bool ValidateBeforeSave() { if (txtSubject.Text.Length == 0) { UI.ShowErrorMessage(this, "Please enter a subject."); txtSubject.Focus(); return(false); } else if (dateEdit1.EditValue == null) { UI.ShowErrorMessage(this, "Please enter a date."); dateEdit1.Focus(); return(false); } else if (lkpEdtBranchCode.EditValue.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please select a Branch Code."); lkpEdtBranchCode.Focus(); return(false); } else if (Convert.ToInt32(lkpEdtDeptID.EditValue) == -1) { UI.ShowErrorMessage(this, "Please select a Department."); lkpEdtBranchCode.Focus(); return(false); } else if (Convert.ToInt32(lkpEdtCategory.EditValue) == -1) { UI.ShowErrorMessage(this, "Please select a Case Category."); lkpEdtCategory.Focus(); return(false); } else if (Convert.ToInt32(lkpEdtCaseType.EditValue) == -1) { UI.ShowErrorMessage(this, "Please select a Case Type."); lkpEdtCaseType.Focus(); return(false); } else if (ucMemberID1.EditValue.ToString().Length == 0) { UI.ShowErrorMessage(this, "Please select a Membership Id."); ucMemberID1.Focus(); return(false); } else if (mmEdtDetail.Text.Length == 0) { UI.ShowErrorMessage(this, "Please enter Detail."); mmEdtDetail.Focus(); return(false); } return(true); }
public new bool Focus() { if (txtMembershipID.CanFocus) { txtMembershipID.Focus(); return(true); } else { return(false); } }
private void frmLogin_Activated(object sender, System.EventArgs e) { if (!this.isFinishInitialize) { txtUsername.Focus(); this.isFinishInitialize = true; string allowUpdate = ConfigurationSettings.AppSettings["AllowVersionUpdate"]; if (allowUpdate.ToUpper() == "YES") { checksum(); } } }
/// <summary> /// Fills the username and database text boxes, and focuses the password box /// </summary> private void HistoryItemClick(object sender, System.EventArgs e) { string user = sender.ToString(); user = user.Substring(user.IndexOf("Text:") + 6); //separate Text from all properties string data = user; int comma = user.IndexOf(','); user = user.Substring(0, comma); data = data.Substring(comma + 2); userName.Text = user; server.Text = data; password.Focus(); }
private void lkpEdtPayment_EditValueChanged(object sender, System.EventArgs e) { decimal outStandingAmt = myPOS.MOutstandingAmount; if (lkpEdtPayment.Text == "CASHVOUCHER") { txtEdtPaymentAmt.Enabled = false; //txtEdtPaymentAmt.EditValue = "0"; txtEdtPaymentAmt.Focus(); } else { txtEdtPaymentAmt.Enabled = true; //txtEdtPaymentAmt.EditValue = outStandingAmt; } }
private void AddElement() { BindingListView <EntityElementTemplate> source = clstElement.DataSource as BindingListView <EntityElementTemplate>; if (source != null) { BindingListView <EntityElementTemplate> tempSource = new BindingListView <EntityElementTemplate>(); EntityElementTemplate objNew = new EntityElementTemplate(); objNew.serno = -1; objNew.colcontent = " "; tempSource.Add(objNew); foreach (EntityElementTemplate objCurrent in source) { tempSource.Add(objCurrent); } clstElement.DataSource = tempSource; } biAdd.Enabled = false; biDel.Enabled = false; biMultiChoose.Enabled = false; biEdit.Enabled = false; txtNew = new DevExpress.XtraEditors.TextEdit(); txtNew.Name = "txtNew"; int intCount = clstElement.ItemCount; int intHeight = (intCount + 1) * clstElement.ItemHeight; txtNew.Location = new Point(0, 0); if (clstElement.Height <= intHeight) { txtNew.Width = clstElement.Width - 17; } else { txtNew.Width = clstElement.Width; } txtNew.Height = clstElement.ItemHeight; txtNew.KeyDown += new KeyEventHandler(txtNew_KeyDown); txtNew.Leave += new EventHandler(txtNew_Leave); clstElement.Controls.Add(txtNew); txtNew.BringToFront(); txtNew.Focus(); }
private void PerformSearch() { //Clear tags selected selectedTags.Clear(); performTagSort = false; foreach (Control c in pnlItemSort.Controls) { try { CheckBox chk = c as CheckBox; chk.Checked = false; } catch { //do nothing } } performTagSort = true; List <KeyValuePair <Control, bool> > ItemControlUpdates = new List <KeyValuePair <Control, bool> >(); foreach (Control cItem in flowLayoutPanelItems2.Controls) { bool itemVisible = false; string cName = ((ChampionTags)cItem.Tag).ChampionName.ToLower(); string cName2 = cName.Replace("'", ""); if (cName.Contains(txtEditSearchBar.Text.ToLower()) || cName2.Contains(txtEditSearchBar.Text.ToLower())) { itemVisible = true; } ItemControlUpdates.Add(new KeyValuePair <Control, bool>(cItem, itemVisible)); } flowLayoutPanelItems2.SuspendLayout(); foreach (KeyValuePair <Control, bool> i in ItemControlUpdates) { i.Key.Visible = i.Value; } flowLayoutPanelItems2.ResumeLayout(); //Refocus search text bar txtEditSearchBar.Focus(); }
private void simpleButton1_Click(object sender, System.EventArgs e) { if (lkpEdtPromotionNo.Text.Length == 0) { MessageBox.Show(this, "Please select a Promotion No."); this.DialogResult = DialogResult.None; return; } else if (lkpEdtPackageCode.Text.Length == 0) { MessageBox.Show(this, "Please select a Package Code."); this.DialogResult = DialogResult.None; return; } if (txtEdtVoucherNo.Text.Length == 0) { MessageBox.Show(this, "Please enter the voucher no."); txtEdtVoucherNo.Focus(); this.DialogResult = DialogResult.None; return; } this.BindingContext[myDataTable].EndCurrentEdit(); // ACMSDAL.TblPackage sqlPackage = new ACMSDAL.TblPackage(); // sqlPackage.StrPackageCode = lkpEdtPackageCode.ToString(); // sqlPackage.SelectOne(); // myDataTable.Rows[0]["nCategoryID"] = ACMS.Convert.ToInt32(sqlPackage.NCategoryID); try { myMemberPackage.Save(myDataTable); } catch (System.Data.DataException ex) { MessageBox.Show(ex.Message); } finally { this.Close(); } }
private void sbtnOK_Click(object sender, System.EventArgs e) { if (txtNewPassword.EditValue.ToString() != txtConfirmNewPassword.EditValue.ToString()) { UI.ShowErrorMessage("New password and confirm new password is not match. Please enter again."); txtNewPassword.Focus(); DialogResult = DialogResult.None; return; } if (string.Compare(myEmployeeInfo["strPassword"].ToString(), txtCurrentPassword.EditValue.ToString(), true) != 0) { UI.ShowErrorMessage("Current password is not match. Please enter again."); txtCurrentPassword.Focus(); DialogResult = DialogResult.None; return; } ACMSLogic.Staff.Ultis.ChangePassword(nEmployeeID, txtNewPassword.EditValue.ToString()); UI.ShowMessage("Password change successfully."); }
private bool ValidateBeforeSave() { if (txtOrganization.Text.Length == 0) { UI.ShowErrorMessage("Please enter an Organization."); txtOrganization.Focus(); return(false); } else if (luedtAppointmetType.EditValue == null) { UI.ShowErrorMessage("Please select an Appointment Type."); luedtAppointmetType.Focus(); return(false); } else if (luedtContact.EditValue == null) { UI.ShowErrorMessage(this, "Please select a contact."); luedtContact.Focus(); return(false); } return(true); }
private void biElementEdit_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (clstElement.SelectedItem == null) { return; } m_intFlags = 1; Rectangle rtg = clstElement.GetItemRectangle(clstElement.SelectedIndex); biAdd.Enabled = false; biDel.Enabled = false; biMultiChoose.Enabled = false; biEdit.Enabled = false; txtNew = new DevExpress.XtraEditors.TextEdit(); txtNew.Name = "txtNew"; int intCount = clstElement.ItemCount; int intHeight = (intCount + 1) * clstElement.ItemHeight; txtNew.Location = new Point(0, 0); if (clstElement.Height <= intHeight) { txtNew.Width = clstElement.Width - 17; } else { txtNew.Width = clstElement.Width; } txtNew.Height = clstElement.ItemHeight; txtNew.KeyDown += new KeyEventHandler(txtNew_KeyDown); txtNew.Leave += new EventHandler(txtNew_Leave); txtNew.Location = rtg.Location; txtNew.Text = clstElement.GetItemText(clstElement.SelectedIndex); txtNew.Tag = clstElement.GetItemValue(clstElement.SelectedIndex); clstElement.Controls.Add(txtNew); txtNew.BringToFront(); txtNew.Focus(); }
private void btnSave_Click(object sender, System.EventArgs e) { if (lkpEdtBankCode.Text.Length == 0) { MessageBox.Show(this, "Please Select a Bank Code."); this.DialogResult = DialogResult.None; lkpEdtBankCode.Focus(); return; } else if (lkpEdtMerchantNo.EditValue == null || lkpEdtMerchantNo.EditValue.ToString().Length == 0) { MessageBox.Show(this, "No Have Merchant No"); this.DialogResult = DialogResult.None; //lkpEdtMerchantNo.Focus(); return; } else if (lkpEdtMonthOfInstallment.Text.Length == 0) { MessageBox.Show(this, "Please Select a Months of installment."); this.DialogResult = DialogResult.None; lkpEdtMonthOfInstallment.Focus(); return; } else if (txtCreditCard.EditValue.ToString().Length == 0) { MessageBox.Show(this, "Invalid credit card no."); this.DialogResult = DialogResult.None; txtCreditCard.Focus(); return; } string strBankCode = lkpEdtBankCode.Text; string strMerchantNo = lkpEdtMerchantNo.EditValue.ToString(); int nMonths = ACMS.Convert.ToInt32(lkpEdtMonthOfInstallment.EditValue); string strCreditCardNo = txtCreditCard.EditValue.ToString(); myPOS.AddNewIPP(strBankCode, nMonths, strCreditCardNo, strMerchantNo); }
private void val2(DevExpress.XtraEditors.TextEdit pz) { bool b = true; if (double.Parse(pz.EditValue.ToString()) == 0) { return; } b = !(txtNumPiezas1.Name != pz.Name && (double.Parse(txtNumPiezas1.EditValue.ToString()) == double.Parse(pz.EditValue.ToString()))) && !(txtNumPiezas2.Name != pz.Name && (double.Parse(txtNumPiezas2.EditValue.ToString()) == double.Parse(pz.EditValue.ToString()))) && !(txtNumPiezas3.Name != pz.Name && (double.Parse(txtNumPiezas3.EditValue.ToString()) == double.Parse(pz.EditValue.ToString()))) && !(txtNumPiezas4.Name != pz.Name && (double.Parse(txtNumPiezas4.EditValue.ToString()) == double.Parse(pz.EditValue.ToString()))) && !(txtNumPiezas5.Name != pz.Name && (double.Parse(txtNumPiezas5.EditValue.ToString()) == double.Parse(pz.EditValue.ToString()))) && !(txtNumPiezas6.Name != pz.Name && (double.Parse(txtNumPiezas6.EditValue.ToString()) == double.Parse(pz.EditValue.ToString()))) && !(txtNumPiezas7.Name != pz.Name && (double.Parse(txtNumPiezas7.EditValue.ToString()) == double.Parse(pz.EditValue.ToString()))) && !(txtNumPiezas8.Name != pz.Name && (double.Parse(txtNumPiezas8.EditValue.ToString()) == double.Parse(pz.EditValue.ToString()))) && !(txtNumPiezas9.Name != pz.Name && (double.Parse(txtNumPiezas9.EditValue.ToString()) == double.Parse(pz.EditValue.ToString()))); if (!b) { MessageBox.Show(@"La cantidad de piezas ya existe en otra presentacion."); pz.Focus(); } }
private void val3(DevExpress.XtraEditors.TextEdit cd) { bool b = true; if (cd.EditValue.ToString() == "") { return; } b = !(txtCodigoBarra1.Name != cd.Name && txtCodigoBarra1.Text == cd.EditValue.ToString()) && !(txtCodigoBarra2.Name != cd.Name && txtCodigoBarra2.Text == cd.EditValue.ToString()) && !(txtCodigoBarra3.Name != cd.Name && txtCodigoBarra3.Text == cd.EditValue.ToString()) && !(txtCodigoBarra4.Name != cd.Name && txtCodigoBarra4.Text == cd.EditValue.ToString()) && !(txtCodigoBarra5.Name != cd.Name && txtCodigoBarra5.Text == cd.EditValue.ToString()) && !(txtCodigoBarra6.Name != cd.Name && txtCodigoBarra6.Text == cd.EditValue.ToString()) && !(txtCodigoBarra7.Name != cd.Name && txtCodigoBarra7.Text == cd.EditValue.ToString()) && !(txtCodigoBarra8.Name != cd.Name && txtCodigoBarra8.Text == cd.EditValue.ToString()) && !(txtCodigoBarra9.Name != cd.Name && txtCodigoBarra9.Text == cd.EditValue.ToString()); if (!b) { MessageBox.Show(@"El código de barra ya existe en otra presentacion."); cd.Focus(); } }
/// <summary> /// 텍스트 박스에 대한 숫자를 확인하고 메세지를 출력한다 /// </summary> /// <param name="txtBox"> 유효성검사할 텍스트 박스 </param> public static void IsNumberCheck(DevExpress.XtraEditors.TextEdit txtBox) { try { string strTemp = txtBox.Text.Trim().Replace(",", ""); if (strTemp == "") { return; } if (IsNumeric(strTemp)) { return; } txtBox.Focus(); txtBox.SelectAll(); Basic.ShowMessage(2, "숫자로 입력 하세요"); } catch (Exception ex) { throw ex; } }
private void sbtnSave_Click(object sender, System.EventArgs e) { if (txtMemberName.Text.Length == 0) { UI.ShowErrorMessage(this, "Please fill in Member Name."); txtMemberName.Focus(); DialogResult = DialogResult.None; return; } if (txtNRICFIN.Text.Length == 0) { UI.ShowErrorMessage(this, "Please fill in NIRC/FIN."); txtNRICFIN.Focus(); DialogResult = DialogResult.None; return; } if (chkedtIsSg.Checked && !MemberRecord.ValidateNRICFormat(txtNRICFIN.Text)) { if (UI.ShowYesNoMessage(this, "NIRC is not in valid format. Do you want enter again?", "Reminder")) { txtNRICFIN.Focus(); DialogResult = DialogResult.None; return; } } if (chkedtIsSg.Checked) { if (myMemberRecord.CheckDuplicateNRIC(txtNRICFIN.Text, "") > 0) { ACMS.Utils.UI.ShowErrorMessage(this, "This NRIC already registed by other person.", "Duplicate NRIC"); txtNRICFIN.Focus(); DialogResult = DialogResult.None; return; } } if (dateedtDOB.EditValue == null || dateedtDOB.EditValue.ToString().Length == 0) { ACMS.Utils.UI.ShowErrorMessage(this, "Please enter Date of Birth."); dateedtDOB.Focus(); DialogResult = DialogResult.None; return; } try { if (chkedtMember.Checked) { strMembershipID = myMemberRecord.AddNewMember(chkedtMember.Checked, strTerminalBranchCode, txtMemberName.Text, chkedtIsSg.Checked, txtNRICFIN.Text, myUser.NEmployeeID(), dateedtDOB.DateTime, myUser); } else { strMembershipID = myMemberRecord.AddNewMember(chkedtMember.Checked, myUser.StrBranchCode(), txtMemberName.Text, chkedtIsSg.Checked, txtNRICFIN.Text, myUser.NEmployeeID(), dateedtDOB.DateTime, myUser); } } catch (Exception ex) { if (ex.InnerException.Message.IndexOf( "Violation of PRIMARY KEY constraint 'PK_tblMember'. Cannot insert duplicate key in object 'tblMember") != -1) { UI.ShowErrorMessage("Duplicate ID found. Please reset membership ID."); DialogResult = DialogResult.Cancel; } else { throw; } } DialogResult = DialogResult.OK; }
private void btnLogin_Click(object sender, EventArgs e) { if (focusedt.Text.Trim().ToString().Equals("")) { focusedt.Focus(); return; } else if (txtPwd.Text.Trim().ToString().Length <= 0) { txtPwd.Focus(); txtPwd.SelectAll(); focusedt = txtPwd; return; } try { this.Cursor = Cursors.WaitCursor; this.SetButtonEnable(false); this.Update();//必须 this.ShowLoginInfo("正在验证用户名及密码"); string userID = txtUser.Text; string password = CEncoder.GenerateMD5Hash(txtPwd.Text); /*常规加密*/ //string dataSetID = txtDataset.EditValue.ToString();//帐套编号 string dataSetDB = "user"; // GetDataSetDBName(); //LoginUser loginUser = new LoginUser(userID, password, dataSetID, dataSetDB); string loginReturn = RestClient.Login(userID, password, ((int)EnumRightType.Login).ToString()); if (loginReturn == "0") //调用登录策略 { //Msg.ShowError(loginReturn); if (chkSaveLoginInfo.Checked) { this.SaveLoginInfo(); //跟据选项保存登录信息 } Program.MainForm = new frmAllTable(); //登录成功创建主窗体 //登录成功,获取权限 getUserRigth(); if (!Globals.userRight.right6) { getUserRigth(); } this.DialogResult = DialogResult.OK; //成功 this.Close(); //关闭登陆窗体 } else if (loginReturn == "") { this.ShowLoginInfo("登录失败,请检查网络和后台服务!"); Warning("登录失败,请检查网络和后台服务!"); this.SetButtonEnable(true); txtPwd.Focus(); txtPwd.SelectAll(); } else { this.ShowLoginInfo(Globals.UserInfo.msg); //"登录失败,请检查用户名和密码!" Warning(Globals.UserInfo.msg); //"登录失败,请检查用户名和密码!" this.SetButtonEnable(true); txtPwd.Focus(); txtPwd.SelectAll(); } } catch (CustomException ex) { this.SetButtonEnable(true); this.ShowLoginInfo(ex.Message); Warning(ex.Message); txtPwd.Focus(); txtPwd.SelectAll(); } catch (Exception ex) { this.SetButtonEnable(true); this.ShowLoginInfo("登录失败,请检查用户名和密码!" + ex.Message); Warning("登录失败,请检查用户名和密码!"); txtPwd.Focus(); txtPwd.SelectAll(); } this.Cursor = Cursors.Default; }
private void LoginForm_Activated(object sender, EventArgs e) { edUsuario.Focus(); }