private bool Validation() { if (string.IsNullOrWhiteSpace(TextBoxFirstName.Text)) { MessageBox.Show("Enter first name"); TextBoxFirstName.Focus(); return(false); } if (string.IsNullOrWhiteSpace(TextBoxLastName.Text)) { MessageBox.Show("Enter last name"); TextBoxLastName.Focus(); return(false); } if (string.IsNullOrWhiteSpace(DataPicker1.Text)) { MessageBox.Show("Enter date"); DataPicker1.Focus(); return(false); } return(true); }
private void buttonSubmit_Click(object sender, EventArgs e) { if (checkBoxAgreement.Checked == false) { MessageBox.Show("Please indicate that you agree to the Terms"); checkBoxAgreement.Focus(); return; } if (TextBoxFirstName.Text == "") { MessageBox.Show("Please complete all sections before submitting"); TextBoxFirstName.Focus(); return; } if (this.ValidateChildren(ValidationConstraints.Enabled)) { string successline = "Thank you for your application " + TextBoxFirstName.Text + Environment.NewLine + "A confirmation of your submission will be sent to " + textBoxEmail.Text; MessageBox.Show(successline); } else { MessageBox.Show("There are missing details in the form. Please complete all sections before submitting."); this.DialogResult = System.Windows.Forms.DialogResult.None; return; } }
private void TextBoxCardID_KeyDown(object sender, KeyEventArgs e) { // check for user or scanner 'pressing' enter if (e.KeyData.ToString().Equals("Return")) { // don't let the textbox handle it further e.SuppressKeyPress = true; // automatically go to the next text box TextBoxFirstName.Focus(); } }
protected void Page_Load(object sender, EventArgs e) { this.accountContactId = Common.GetEncryptedQueryStringValue("AccountContactId", 0); this.accountId = Common.GetEncryptedQueryStringValue("AccountId", 0); LabelPageTitle.Text = "Account Contact"; Page.Form.DefaultFocus = TextBoxFirstName.ClientID; Page.Form.DefaultButton = ButtonSave.UniqueID; if (!IsPostBack) { TextBoxFirstName.Focus(); ButtonSave.Visible = true; ButtonSaveNew.Visible = true; if (ViewState["AccountContactId"] != null) { this.accountContactId = Convert.ToInt32(ViewState["AccountContactId"].ToString()); } if (ViewState["AccountId"] != null) { this.accountId = Convert.ToInt32(ViewState["AccountId"].ToString()); } if (this.accountContactId != 0) { BindAccountContact(); } if (this.accountId != 0) { ButtonSave.Visible = false; ButtonSaveNew.Visible = false; ButtonSaveLink.Visible = true; BindAccountContactGridView(); } else { ButtonSave.Visible = true; ButtonSaveNew.Visible = true; ButtonSaveLink.Visible = false; } } }
private bool CheckAllFields() { ErrMsg errMsg; errMsg = Check.CheckField(FieldName.IsInsured, TextBoxInsured.Text); if (errMsg.ErrorId != "00") { SetOnErrMsg(errMsg); TextBoxInsured.Focus(); TextBoxInsured.ForeColor = Color.Red; return(false); } errMsg = Check.CheckField(FieldName.FirstName, TextBoxFirstName.Text); if (errMsg.ErrorId != "00") { SetOnErrMsg(errMsg); TextBoxFirstName.Focus(); TextBoxFirstName.ForeColor = Color.Red; return(false); } errMsg = Check.CheckField(FieldName.LastName, TextBoxLastName.Text); if (errMsg.ErrorId != "00") { SetOnErrMsg(errMsg); TextBoxLastName.Focus(); TextBoxLastName.ForeColor = Color.Red; return(false); } // Sterrenbeeld moet kloppen: errMsg = Check.CheckField(FieldName.Zodiac, TextBoxZodiac.Text); if (errMsg.ErrorId != "00") { SetOnErrMsg(errMsg); TextBoxZodiac.Focus(); TextBoxZodiac.ForeColor = Color.Red; return(false); } return(true); }
//Update Customer table data private void UpdateCustomer_Click(object sender, EventArgs e) { try { string custId = tbxCustomerID.Text; string FirstName, LastName, fatherName, address, phone; LastName = textBoxLastName.Text; FirstName = TextBoxFirstName.Text; address = textBoxAddress.Text; phone = textBoxPhone.Text; fatherName = textBox1FatherName.Text; if (FirstName == "") { MessageBox.Show("First name required!"); TextBoxFirstName.Focus(); } else if (LastName == "") { MessageBox.Show("Last name required!"); textBoxLastName.Focus(); } else if (fatherName == "") { MessageBox.Show("Father's name required!"); textBox1FatherName.Focus(); } else if (address == "") { MessageBox.Show("Address required!"); textBoxAddress.Focus(); } else if (phone == "") { MessageBox.Show("Phone number required!"); textBoxPhone.Focus(); } else { CustomerDataTbl data = new CustomerDataTbl(); data.FirstName = FirstName; data.LastName = LastName; data.Address = address; data.Phone = phone; data.fatherName = fatherName; data.CustId = int.Parse(custId); if (new Customer().UpdateCustomerInformation(data)) { AddCustomer.Enabled = true; BindDdlWithCustomer(); // Bind comboBox with Customer table BindGridCustomersTbl(); // BindGridView with Customer table MessageBox.Show("Customer Data Updated!"); TextBoxFirstName.Text = ""; textBoxLastName.Text = ""; textBoxAddress.Text = ""; textBox1FatherName.Text = ""; textBoxPhone.Text = ""; tbxCustomerID.Text = ""; } else { MessageBox.Show("Unable to update this customer!!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); DataBaseConnection.CloseConnection(); // close connection with database when error occured } }
//Add Customers to database private void AddCustomer_Click(object sender, EventArgs e) { try { string Firstname, Lastname, address, phone, fatherName; Firstname = TextBoxFirstName.Text; Lastname = textBoxLastName.Text; address = textBoxAddress.Text; phone = textBoxPhone.Text; fatherName = textBox1FatherName.Text; if (Firstname == "") { MessageBox.Show("First name required!"); TextBoxFirstName.Focus(); } else if (Lastname == "") { MessageBox.Show("Last name required!"); textBoxLastName.Focus(); } else if (fatherName == "") { MessageBox.Show("Father's name required!"); textBox1FatherName.Focus(); } else if (address == "") { MessageBox.Show("Address required!"); textBoxAddress.Focus(); } else if (phone == "") { MessageBox.Show("Phone number required!"); textBoxPhone.Focus(); } else { CustomerDataTbl data = new CustomerDataTbl(); data.FirstName = Firstname; data.LastName = Lastname; data.fatherName = fatherName; data.Address = address; data.Phone = phone; if (new Customer().AddCustomerData(data)) { BindDdlWithCustomer(); // bind customer table to combobox BindGridCustomersTbl(); // Bind GridView with Customer table MessageBox.Show("Customer Saved to Database!!"); TextBoxFirstName.Text = ""; textBoxLastName.Text = ""; textBoxAddress.Text = ""; textBox1FatherName.Text = ""; textBoxPhone.Text = ""; } else { MessageBox.Show("Unable to add this customer!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); DataBaseConnection.CloseConnection(); // close DB connection when error occured } }
protected void Page_Load(object sender, EventArgs e) { this.insightSupplierContactId = Common.GetEncryptedQueryStringValue("InsightSupplierContactId", 0); this.insightSupplierId = Common.GetEncryptedQueryStringValue("InsightSupplierId", 0); LabelPageTitle.Text = "User"; Page.Form.DefaultFocus = TextBoxFirstName.ClientID; Page.Form.DefaultButton = ButtonSave.UniqueID; if (!IsPostBack) { TextBoxFirstName.Focus(); BindGift(); BindRegion(); BindAccessMethod(); BindLink(); BindOption(); BindModel(); //BindAccount(); BindLicense(); BindLicenseAllocated(); BindQlikviewVersion(); ButtonSave.Visible = true; ButtonSaveNew.Visible = true; PanelInstall.Visible = false; PanelOnline.Visible = false; PanelInSparMapper.Visible = false; if (ViewState["InsightSupplierContactId"] != null) { this.insightSupplierContactId = Convert.ToInt32(ViewState["InsightSupplierContactId"].ToString()); } if (ViewState["InsightSupplierId"] != null) { this.insightSupplierId = Convert.ToInt32(ViewState["InsightSupplierId"].ToString()); } if (this.insightSupplierId != 0) { ButtonSave.Visible = false; ButtonSaveNew.Visible = false; ButtonSaveLink.Visible = true; BindInsightSupplierContactGridView(); } else { ButtonSave.Visible = true; ButtonSaveNew.Visible = true; ButtonSaveLink.Visible = false; } if (this.insightSupplierContactId != 0) { BindInsightSupplierContact(); PanelAccessMethod.Visible = true; PanelDistributionConfig.Visible = true; if (this.insightSupplierId != 0) { ButtonSaveLink.Visible = true; } ButtonSaveEdit.Visible = false; } else { PanelAccessMethod.Visible = false; PanelDistributionConfig.Visible = false; ButtonSaveLink.Visible = false; ButtonSaveEdit.Visible = true; //PanelInstall.Visible = false; } //PanelViewLicenseDropdown.Visible = false; } }
//Update Customer Information private void UpdateCustomer_Click(object sender, EventArgs e) { try { string custId = tbxCustomerID.Text; string FirstName, LastName, address, phone; LastName = textBoxLastName.Text; FirstName = TextBoxFirstName.Text; address = textBoxAddress.Text; phone = textBoxPhone.Text; if (FirstName == "") { MessageBox.Show("First name is required!"); TextBoxFirstName.Focus(); } else if (LastName == "") { MessageBox.Show("Last name is required!"); textBoxLastName.Focus(); } else if (address == "") { MessageBox.Show("Address is required!"); textBoxAddress.Focus(); } else if (phone == "") { MessageBox.Show("Phone number is required!"); textBoxPhone.Focus(); } else { CustomerData data = new CustomerData { FirstName = FirstName, LastName = LastName, Address = address, Phone = phone, CustId = int.Parse(custId) }; if (new Customer().UpdateCustomerInformation(data)) { AddCustomer.Enabled = true; BindDdlCustomer(); // method calling to Bind comboBox Customer BindGridCustomersInfo(); // method calling to Bind GridView Customer MessageBox.Show("Customer Updated Successfully!"); TextBoxFirstName.Text = "First Name..."; textBoxLastName.Text = "Last Name..."; textBoxAddress.Text = "Address..."; textBoxPhone.Text = "Phone..."; tbxCustomerID.Text = ""; } else { MessageBox.Show("Unable to update this customer!"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); DataBaseConnection.CloseConnection(); // close connection with database when error occured } }
/// <summary> /// Event that fires on Page Load Event /// </summary> protected void Page_Load(object sender, EventArgs eventArgument) { DataProvider.AuthorizeUser(); MasterPage masterPage = this.Page.Master; Header headerPage = (Header)masterPage; headerPage.DisplayDataFromMasterPage(Session["UserName"].ToString()); // Disable the Product selection DropdownList in Master Page Session["EnableProductSelection"] = false; string actionType = Request.Params["action"]; if (!Page.IsPostBack) { LabelRequiredFields.Text = Resources.Labels.RequiredFields; GetDataForDropDownLists(); DropDownListCountry.Attributes.Add("onChange", "javascript:GetStates('" + DropDownListCountry.ClientID + "', '" + HiddenFieldStateSource.ClientID + "', '" + HiddenFieldStateOthers.ClientID + "', '" + HiddenFieldState.ClientID + "')"); //DropDownListCountry.Attributes.Add("onFocus", "javascript:GetStates('" + DropDownListCountry.ClientID + "', '" + HiddenFieldStateSource.ClientID + "', '" + HiddenFieldStateOthers.ClientID + "', '" + HiddenFieldState.ClientID + "')"); ButtonAdd.Attributes.Add("onClick", "javascript:return ValidateInputData()"); ButtonUpdate.Attributes.Add("onClick", "javascript:return ValidateInputData()"); BuildCountriesAndStates(); } ButtonReset.Attributes.Add("onClick", "javascript:return ConfirmReset()"); // Set the focus to first editable control #region Display Registration Details if (!string.IsNullOrEmpty(actionType)) { if (actionType == "add") { DropDownListRegistrationType.Focus(); ButtonUpdate.Visible = false; ButtonAdd.Visible = true; TableManageRegistration.Rows[5].Visible = false; GetCustomfields(null); } else if (actionType == "update") { TextBoxFirstName.Focus(); ButtonAdd.Visible = false; ButtonUpdate.Visible = true; TableManageRegistration.Rows[5].Visible = true; if (Request["REC_ID"] != null) { string recordId = Request["REC_ID"].ToString(); HiddenRecordId.Value = recordId; if (!string.IsNullOrEmpty(Request.Params["pid"])) { HiddenProductId.Value = Request.Params["pid"]; } // Don't call GetRegistrationDetails when Update button is clicked if (Request.Form[ButtonUpdate.ClientID.Replace("_", "$")] == null && Page.IsPostBack == false) { GetRegistrationDetails(); } } } } #endregion }
private void TextBoxCardID_KeyDown(object sender, KeyEventArgs e) { // vars bool found = false; // check for user or scanner 'pressing' enter if (e.KeyData.ToString().Equals("Return")) { // don't let the textbox handle it further e.SuppressKeyPress = true; // don't allow changing the card id TextBoxCardID.ReadOnly = true; dt = sql.GetDataTable("select * from employees where employeeID=" + TextBoxCardID.Text.Trim() + ";"); // check if this is the card we're looking for if (dt.Rows.Count == 1) { // make note of card's position found = true; // enable editing and saving TextBoxFirstName.Enabled = true; TextBoxLastName.Enabled = true; TextBoxMI.Enabled = true; NumericUpDownHrRate.Enabled = true; RadioButtonFWS.Enabled = true; RadioButtonSWS.Enabled = true; RadioButtonMST.Enabled = true; RadioButtonHED.Enabled = true; RadioButtonHelp.Enabled = true; RadioButtonTutor1.Enabled = true; RadioButtonTutor2.Enabled = true; RadioButtonTANF.Enabled = true; ButtonSave.Enabled = true; try { // first name TextBoxFirstName.Text = dt.Rows[0].ItemArray[1].ToString(); // last name TextBoxLastName.Text = dt.Rows[0].ItemArray[2].ToString(); // middle initial TextBoxMI.Text = dt.Rows[0].ItemArray[3].ToString(); // hourly rate NumericUpDownHrRate.Value = Decimal.Parse(dt.Rows[0].ItemArray[4].ToString()); // position type switch (dt.Rows[0].ItemArray[5].ToString()) { case "FWS": RadioButtonFWS.Checked = true; break; case "SWS": RadioButtonSWS.Checked = true; break; case "MST": RadioButtonMST.Checked = true; break; case "HED": RadioButtonHED.Checked = true; break; case "Help": RadioButtonHelp.Checked = true; break; case "Tutor1": RadioButtonTutor1.Checked = true; break; case "Tutor2": RadioButtonTutor2.Checked = true; break; case "TANF": RadioButtonTANF.Checked = true; break; } // automatically go to the next text box TextBoxFirstName.Focus(); } catch (Exception err) { MessageBox.Show(this, "There was an error while trying to load your info.\nWas someone playing with the database files?\n\n" + err.Message, "Clocked Time Calculation Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } // notify user if card wasn't found if (!found) { MessageBox.Show(this, "The card you entered wasn't found. Are you sure you typed it in correctly?", "Card Not Found!", MessageBoxButtons.OK, MessageBoxIcon.Error); TextBoxCardID.Clear(); TextBoxCardID.ReadOnly = false; TextBoxCardID.Focus(); } } }