public void UpdateVariables(DataRow aCustomerDataRow) { try { IsLoading = true; Phone1ComboBox.Text = aCustomerDataRow["Phone1"].ToString(); Phone1ComboBox.SelectedValue = aCustomerDataRow["ID"].ToString(); CustomerID = int.Parse(aCustomerDataRow["ID"].ToString()); NameTxtBox.Text = aCustomerDataRow["Name"].ToString(); EmailTxtBox.Text = aCustomerDataRow["Email"].ToString(); AddressTxtBox.Text = aCustomerDataRow["Address"].ToString(); Phone1TxtBox.Text = aCustomerDataRow["Phone1"].ToString(); DataRow CusAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID); if (CusAccount != null) { MakeUserAccountChkBox.Checked = true; } else { MakeUserAccountChkBox.Checked = false; } UpdateCustomerBtn.Show(); IsLoading = false; } catch (Exception ex) { MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [UpdateVariables] \n Exception: \n" + ex.ToString() + "\n" + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); } }
private void Phone1ComboBox_TextChanged(object sender, EventArgs e) { if (!IsLoading && !OnExit) { if (Validators.TxtBoxNotEmpty(Phone1ComboBox.Text)) { Phone1ComboBox.BackColor = Color.White; DataRow DR = CustomerMgmt.SelectCustomerByPhone1(Phone1ComboBox.Text); if (DR != null) { UpdateCustomerBtn.Show(); CustomerID = int.Parse(DR["ID"].ToString()); NameTxtBox.Text = DR["Name"].ToString(); AddressTxtBox.Text = DR["Address"].ToString(); EmailTxtBox.Text = DR["Email"].ToString(); Phone1TxtBox.Text = DR["Phone1"].ToString(); DataRow CusAccount = CustomersAccountsMgmt.SelectCustomerAccountRowByCusID(CustomerID); if (CusAccount != null) { MakeUserAccountChkBox.Checked = true; } else { MakeUserAccountChkBox.Checked = false; } } else { UpdateCustomerBtn.Hide(); // MessageBox.Show(MsgTxt.UnexpectedError + "\n IN [Phone1ComboBox_TextChanged:SelectCustomerByPhone1 ==null] \n Exception: " + MsgTxt.FormWillCloseNowTxt, MsgTxt.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { UpdateCustomerBtn.Hide(); MessageBox.Show(MsgTxt.PleaseAddAllRequiredFields, MsgTxt.WarningCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning); Phone1ComboBox.BackColor = SharedVariables.TxtBoxRequiredColor; Phone1ComboBox.Focus(); } } }