private void StockEntry_Load(object sender, EventArgs e) { Login.ValidateLogin(this); dataGridView1.AutoGenerateColumns = false; BindUnits(); ControlValidation.DisableGridSort(this.dataGridView1, DataGridViewColumnSortMode.NotSortable); }
private void btnAdd_Click(object sender, EventArgs e) { if (txtUnit.Text.Trim() == "" || ControlValidation.IsReserveWord(txtUnit.Text.Trim().ToLower())) { lblError.Text = "Please Enter a valid Unit..."; lblError.ForeColor = Color.Red; } else { var result = AddUnit(); if (result.Result == true) { ProductEntry prodEntry = (ProductEntry)Owner.ActiveControl; prodEntry.BindUnits(); lblError.Text = result.Message; lblError.ForeColor = Color.Green; } else { lblError.Text = result.Message; lblError.ForeColor = Color.Red; } } }
}//ManufacturerTextBox_Leave //Проверить вылеты. private void MeasureUnitComboBox_Leave(object sender, EventArgs e) { if (MeasureUnitComboBox.SelectedIndex == -1) ControlValidation.WrongValueInput(toolTip, MeasureUnitComboBox, "Выберите ед. изм."); else ControlValidation.CorrectValueInput(toolTip, MeasureUnitComboBox); }//MeasureUnitComboBox_Leave
private void btnUpdate_Click(object sender, EventArgs e) { if (ControlValidation.Isblank(txtPassword.Text.Trim()) == true || ControlValidation.IsReserveWord(txtPassword.Text.Trim().ToLower())) { lblError.Text = "Pleasse enter Password !"; txtPassword.Text = ""; txtPassword.Focus(); } else if (txtPassword.Text.Trim() != txtConfirmPassword.Text.Trim()) { lblError.Text = "Password Mismatch !"; txtPassword.Text = ""; txtPassword.Focus(); txtConfirmPassword.Text = "ConfirmNewPassword"; } else { var result = new Results(); result = UpdatePassword(); if (result.Result) { MessageBox.Show("Password Reset Successfully!!!!"); Login loginform = new Login(); loginform.Show(); this.Hide(); } else { lblError.Text = result.Message; } } }
}//codeMaskedTextBox_MouseClick private void codeMaskedTextBox_Leave(object sender, EventArgs e) { if (codeMaskedTextBox.Text != String.Empty) { //Проверяем корректность ввода. if (codeMaskedTextBox.MaskCompleted == true && codeMaskedTextBox.Text.Length != 9) { //Проверяем существует ли уже такой code в базе. if ((_contragent.ContragentId != 0 && _contragent.Code == codeMaskedTextBox.Text) || PartsDAL.IsSupplierCodeExist(codeMaskedTextBox.Text) == false) { ControlValidation.CorrectValueInput(toolTip, codeMaskedTextBox); } else { ControlValidation.WrongValueInput(toolTip, codeMaskedTextBox, String.Format("Такой ИНН/ОКПО уже есть в базе!", _contragentType)); } }//if else { ControlValidation.WrongValueInput(toolTip, codeMaskedTextBox, String.Format("Введенный ИНН/ОКПО является некорректным!", _contragentType)); } //else } //if else { ControlValidation.CorrectValueInput(toolTip, codeMaskedTextBox); } }//codeMaskedTextBox_Leave
private void txtConfirmPassword_Leave(object sender, EventArgs e) { if (txtConfirmPassword.Text.Trim() == "" || ControlValidation.IsReserveWord(txtConfirmPassword.Text.Trim().ToLower())) { txtConfirmPassword.UseSystemPasswordChar = false; txtConfirmPassword.Text = "ConfirmNewPassword"; } }
/// <summary> /// Sets control validation state /// </summary> /// <param name="cv"></param> void SetControlState(ControlValidation cv) { if (!_controlValidations.ContainsKey(cv.ValidatedControl.ClientID)) { _controlValidations.Add(cv.ValidatedControl.ClientID, cv); } else { _controlValidations[cv.ValidatedControl.ClientID] = cv; } }
private void btnOK_Click(object sender, EventArgs e) { decimal discount; if (txtDiscount.Text.Trim() == "") { discount = 0; } else { discount = Convert.ToDecimal(txtDiscount.Text.Trim()); } if (txtCustomerName.Text.Trim() == "" || ControlValidation.IsReserveWord(txtCustomerName.Text.Trim().ToLower())) { lblError.Text = "Please Enter Customer Name"; lblError.ForeColor = Color.Red; } else { var custDetails = new CustomerInfoDetails(); if (txtAddress.Text == "" || ControlValidation.IsReserveWord(txtAddress.Text.Trim().ToLower())) { custDetails.custAddress = "XXXX"; } else { custDetails.custAddress = txtAddress.Text; } custDetails.custName = txtCustomerName.Text; custDetails.custMobile = "9999999999"; custDetails.custEmail = "*****@*****.**"; custDetails.billDate = dateTimeBillDate.Value.Date; custDetails.custDiscount = discount; this.Hide(); if (sellerEntry == 1) { this.Hide(); var stockEntry = new StockEntry(); stockEntry.CalllbackFromCustDetails(_glStockEntry, custDetails, _billnumber); this.Close(); } else { CustomerBillForm cust = new CustomerBillForm(productSale); cust.showBill(custBillInfoData, custDetails); cust.ShowDialog(this); this.Close(); } } }
}//ContragentTextBox_PreviewKeyDown private void ContragentTextBox_Leave(object sender, EventArgs e) { //Если такого клиента нет в базе, выдаём ошибку. string customer = ContragentTextBox.AutoCompleteCustomSource.Cast <string>().ToList().FirstOrDefault(c => c.ToLower() == ContragentTextBox.Text.Trim().ToLower()); if (customer != null) { ControlValidation.CorrectValueInput(toolTip, ContragentTextBox); ContragentTextBox.Text = customer; //Выводим корректное имя контрагента. }//if else { ControlValidation.WrongValueInput(toolTip, ContragentTextBox, "Поле \"Клиент\" заполнено некорректно"); } //else } //ContragentTextBox_Leave
private void btnReset_Click(object sender, EventArgs e) { if (ControlValidation.Isblank(txtUsername.Text.Trim()) == true || ControlValidation.IsReserveWord(txtUsername.Text.Trim().ToLower())) { lblError.Text = "Please enter Username !"; txtUsername.Text = ""; txtUsername.Focus(); } else if (ControlValidation.Isblank(txtAnswer1.Text.Trim()) == true || ControlValidation.IsReserveWord(txtAnswer1.Text.Trim().ToLower())) { lblError.Text = "Enter Answar for Question1 !"; txtAnswer1.Text = ""; txtAnswer1.Focus(); } else if (ControlValidation.Isblank(txtAnswer2.Text.Trim()) == true || ControlValidation.IsReserveWord(txtAnswer2.Text.Trim().ToLower())) { lblError.Text = "Enter Answar for Question2 !"; txtAnswer2.Text = ""; txtAnswer2.Focus(); } else { var result = CheckAnswer(); if (result.Result) { if ((MessageBox.Show("Are you Sure to Reset the Password ???", "Password Reset", MessageBoxButtons.YesNo) == DialogResult.Yes)) { NewPassword newpasswordform = new NewPassword(); newpasswordform.userName = txtUsername.Text.Trim(); newpasswordform.userID = Convert.ToInt32(txthiddenUserID.Text.Trim()); newpasswordform.Show(); this.Hide(); } else { ForgotPassword forgotPasswordform = new ForgotPassword(); forgotPasswordform.Show(); } } else { lblError.Text = result.Message; } } }
}//Form1_Load #region Методы проверки корректности ввода. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Валидация ввода артикула. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ArticulTextBox_Leave(object sender, EventArgs e) { //если артикул введен. if (!String.IsNullOrWhiteSpace(ArticulTextBox.Text)) { string text = ArticulTextBox.Text.Trim(); //Если введенный артикул уже есть в базе, выдаём предупреждение, но позволяем дальнейший ввод. if ((_sparePart.SparePartId != 0 && _sparePart.Articul.ToLower() == text.ToLower()) || PartsDAL.FindSparePartsByArticul(text).Count == 0) ControlValidation.CorrectValueInput(toolTip, ArticulTextBox); else ControlValidation.WrongValueInput(toolTip, ArticulTextBox, "Такой артикул уже есть в базе", Color.Yellow); }//if else //Если артикул не введен. { ControlValidation.WrongValueInput(toolTip, ArticulTextBox); }//else //Если Title не пустой, проверяем уникальность заполнения связки Артикул-Название. if (String.IsNullOrWhiteSpace(TitleTextBox.Text) == false) TitleTextBox_Leave(null, null); }//ArticulTextBox_Leave
private void btnLogin_Click(object sender, EventArgs e) { if (ControlValidation.Isblank(txtUsername.Text.Trim()) == true || ControlValidation.IsReserveWord(txtUsername.Text.Trim().ToLower())) { lblPasswordError.Text = ""; lblUsernameError.Text = "Please enter a valid Username"; txtUsername.Text = ""; txtUsername.Focus(); } else if (ControlValidation.Isblank(txtPassword.Text.Trim()) == true || ControlValidation.IsReserveWord(txtPassword.Text.Trim().ToLower())) { lblUsernameError.Text = ""; lblPasswordError.Text = "Pleasse enter a valid Password"; txtPassword.Text = ""; txtPassword.Focus(); } else { //After Password Validation Successful var login = _userAuthRepository.GetAll().Where(x => x.UserName == txtUsername.Text && x.Password == txtPassword.Text).FirstOrDefault(); if (login != null) { CacheItemPolicy policy = new CacheItemPolicy(); policy.AbsoluteExpiration = DateTimeOffset.Now.AddHours(12); _userInfoCache.Add("userinfo", login, policy); //Dashboard dashboardfrm = new Dashboard(); //dashboardfrm.Show(); //Accessing the Cache Value from Cache Memory var userInfo = (UserAuth)_userInfoCache.Get("userinfo"); string str = userInfo.UserName; this.Hide(); } else { lblLoginError.Text = "Invalid UserId and Password!"; } lblUsernameError.Text = ""; lblPasswordError.Text = ""; } }
}//ArticulTextBox_Leave private void TitleTextBox_Leave(object sender, EventArgs e) { //Если Title введен. if (!String.IsNullOrWhiteSpace(TitleTextBox.Text)) { //Если в базе есть ещё объекты с таким Артикулом. if (ArticulBackPanel.BackColor == Color.Yellow) { //Если связка Артикул-Название не уникальны, выводим сообщение об ошибке. if (PartsDAL.FindSparePartsByArticul(ArticulTextBox.Text.Trim()).Any(sp => sp.Title.ToLower() == TitleTextBox.Text.Trim().ToLower())) ControlValidation.WrongValueInput(toolTip, TitleTextBox, "Такая связка Артикул-Название уже есть в базе"); else ControlValidation.CorrectValueInput(toolTip, TitleTextBox); }//if else //если tilte введен правильно ControlValidation.CorrectValueInput(toolTip, TitleTextBox); }//if else //если Title не введен { ControlValidation.WrongValueInput(toolTip, TitleTextBox); }//else }//TitleTextBox_Leave
}//addContactInfoButton_Click private void contragentNameTextBox_Leave(object sender, EventArgs e) { if (!String.IsNullOrWhiteSpace(contragentNameTextBox.Text)) { IContragent contragent = (_contragent is Customer) ? PartsDAL.FindCustomers(contragentNameTextBox.Text.Trim()) : PartsDAL.FindSuppliers(contragentNameTextBox.Text.Trim()); string text = contragentNameTextBox.Text.Trim().ToLower(); //Если контрагент с таким именем уже есть в базе и это не его редактирование, выдаём ошибку. if ((_contragent.ContragentId != 0 && _contragent.ContragentName.ToLower() == text) || contragent == null) { ControlValidation.CorrectValueInput(toolTip, contragentNameTextBox); } else { ControlValidation.WrongValueInput(toolTip, contragentNameTextBox, String.Format("Введите другое название или ФИО {0}а", _contragentType)); } } //if else //если название введено некорректно { ControlValidation.WrongValueInput(toolTip, contragentNameTextBox); } }//contragentNameTextBox_Leave
private void btnAdd_Click(object sender, EventArgs e) { if (txtProductType.Text.Trim() == "" || ControlValidation.IsReserveWord(txtProductType.Text.Trim().ToLower())) { lblError.Text = "Please Enter a valid Item Type..."; lblError.ForeColor = Color.Red; } else { var result = AddNewType(); if (result.Result == true) { /* ProductEntry obj = null; * foreach( Object objj in Owner.Controls) * { * var test = (Panel)objj; * if (test.AccessibilityObject.Name == "Product Entry"){ * obj = (ProductEntry)test.AccessibilityObject; * } * } * //Owner.Controls.*/ ProductEntry prodEntry = (ProductEntry)Owner.ActiveControl; prodEntry.BindProductType(); txtProductType.Text = ""; lblError.Text = result.Message; lblError.ForeColor = Color.Green; } else { lblError.Text = result.Message; lblError.ForeColor = Color.Red; } } }
private void btnGenerar_Click(object sender, EventArgs e) { if (clbEmpleados.CheckedItems.Count > 0) { eprEmpleados.Clear(); if (ControlValidation.validarFechas(DateTime.Parse(dtpFechaInicio.Text), DateTime.Parse(dtpFechaFin.Text))) { eprFecInic.Clear(); SaveFileDialog m_Archivo = new SaveFileDialog(); m_Archivo.Filter = "XLS|*.xls"; m_Archivo.Title = string.Format(" {0} - {1} ", "Inari", "Reporte"); try { if (m_Archivo.ShowDialog() == DialogResult.OK) { m_RutaArchivo = m_Archivo.FileName; btnGenerar.Enabled = false; BackgroundWorker Procesar = new BackgroundWorker(); Procesar.DoWork += ProcesarReporte; Procesar.RunWorkerCompleted += ProcesarTerminado; Procesar.RunWorkerAsync(); } } catch { } } else { eprFecInic.SetError(dtpFechaInicio, "La fecha de inicio debe ser menor o igual que la fecha fin"); } } else { eprEmpleados.SetError(lblEmployee, "Seleccione por lo menos a un empleado"); } }
private void txtmessdays_TextChanged(object sender, EventArgs e) { bool b = ControlValidation.txtNumericStringIsValid(txtmessdays); }
private void txthostelfee_TextChanged(object sender, EventArgs e) { bool b = ControlValidation.txtNumericStringIsValid(txthostelfee); }
private void SpringConstantTextBox_LostFocus(object sender, RoutedEventArgs e) { ControlValidation.TextBoxLostFocus(SpringConstantTextBox, SpringConstantSlider); }
private void DampingTextBox_LostFocus(object sender, RoutedEventArgs e) { ControlValidation.TextBoxLostFocus(DampingTextBox, DampingSilder); }
private void MassTextBox_LostFocus(object sender, RoutedEventArgs e) { ControlValidation.TextBoxLostFocus(MassTextBox, BobMassSlider); }
/// <summary> /// Couple sliders and text boxes when the text boxes are changed or have lost focus. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LengthTextBox_TextChanged(object sender, TextChangedEventArgs e) { ControlValidation.TextBoxValueChanged(LengthTextBox, LengthSlider); }
/// <summary> /// Couple sliders and text boxes when the text boxes are changed or have lost focus. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// private void SpringConstantTextBox_TextChanged(object sender, TextChangedEventArgs e) { ControlValidation.TextBoxValueChanged(SpringConstantTextBox, SpringConstantSlider); }
private void GravitationalFieldStrengthTextBox_TextChanged(object sender, TextChangedEventArgs e) { ControlValidation.TextBoxValueChanged(GravitationalFieldStrengthTextBox, GravitationalFieldStrengthSlider); }
private void LengthTextBox_LostFocus(object sender, RoutedEventArgs e) { ControlValidation.TextBoxLostFocus(LengthTextBox, LengthSlider); }
private void GravitationalFieldStrength_LostFocus(object sender, RoutedEventArgs e) { ControlValidation.TextBoxLostFocus(GravitationalFieldStrengthTextBox, GravitationalFieldStrengthSlider); }
private void txtDiscount_KeyPress(object sender, KeyPressEventArgs e) { ControlValidation.IsPrice(sender, e); }
private void DampingTextBox_TextChanged(object sender, TextChangedEventArgs e) { ControlValidation.TextBoxValueChanged(DampingTextBox, DampingSilder); }
private void btnSignUp_Click(object sender, EventArgs e) { if (ControlValidation.Isblank(txtUsername.Text.Trim()) == true || ControlValidation.IsReserveWord(txtUsername.Text.Trim().ToLower())) { lblError.Text = "Please enter Username !"; txtUsername.Text = ""; txtUsername.Focus(); } else if (ControlValidation.Isblank(txtPassword.Text.Trim()) == true || ControlValidation.IsReserveWord(txtPassword.Text.Trim().ToLower())) { lblError.Text = "Pleasse enter Password !"; txtPassword.Text = ""; txtPassword.Focus(); } else if (txtPassword.Text.Trim() != txtConfirmPassword.Text.Trim()) { lblError.Text = "Password Mismatch !"; txtPassword.Text = ""; txtPassword.Focus(); txtConfirmPassword.Text = "ConfirmPassword"; } else if (ControlValidation.Isblank(txtFirstName.Text.Trim()) == true || ControlValidation.IsReserveWord(txtFirstName.Text.Trim().ToLower())) { lblError.Text = "Enter First Name !"; txtFirstName.Text = ""; txtFirstName.Focus(); } else if (ControlValidation.Isblank(txtLastName.Text.Trim()) == true || ControlValidation.IsReserveWord(txtLastName.Text.Trim().ToLower())) { lblError.Text = "Enter Last Name !"; txtLastName.Text = ""; txtLastName.Focus(); } else if (radioMale.Checked == false && radioFemale.Checked == false) { lblError.Text = "Select Gender !"; } else if (ControlValidation.Isblank(txtMobileNo.Text.Trim()) == true || txtMobileNo.Text.Trim() == "MobileNo" || ControlValidation.IsValidMobileNo(txtMobileNo.Text.Trim()) == false) { lblError.Text = "Enter valid Mobile Number !"; txtMobileNo.Text = ""; txtMobileNo.Focus(); } else if (ControlValidation.Isblank(txtEmail.Text.Trim()) == true || txtEmail.Text.Trim() == "E-mail" || ControlValidation.IsValidEmail(txtEmail.Text.Trim()) == false) { lblError.Text = "Enter a valid email id !"; txtEmail.Text = ""; txtEmail.Focus(); } else if (cmbQues1.SelectedIndex == 0) { lblError.Text = "Select Security Question 1 !"; } else if (ControlValidation.Isblank(txtAnswer1.Text.Trim()) == true || ControlValidation.IsReserveWord(txtAnswer1.Text.Trim().ToLower())) { lblError.Text = "Enter Answer for Question1 !"; txtAnswer1.Text = ""; txtAnswer1.Focus(); } else if (cmbQues2.SelectedIndex == 0) { lblError.Text = "Select Security Question 2 !"; } else if (ControlValidation.Isblank(txtAnswer2.Text.Trim()) == true || ControlValidation.IsReserveWord(txtAnswer2.Text.Trim().ToLower())) { lblError.Text = "Enter Answer for Question2 !"; txtAnswer2.Text = ""; txtAnswer2.Focus(); } else { InventoryEntities database = new InventoryEntities(); if (ControlValidation.IsReserveWord(txtMiddleName.Text.Trim())) { txtMiddleName.Text = ""; } var result = Register(); if (result.Result == true) { lblError.Text = ""; Login loginform = new Login(); loginform.Show(); this.Hide(); } else { lblError.Text = result.Message; } } }
private void MassTextBox_TextChanged(object sender, TextChangedEventArgs e) { ControlValidation.TextBoxValueChanged(MassTextBox, BobMassSlider); }