private void btnFindCustomer_Click(object sender, EventArgs e) { if (txtCustomerName.Text == "" || txtCustomerName.Text.Length < 1) { return; } try { CCustomerManager tempCustomerManager = new CCustomerManager(); CCustomerInfo tempCustomerInfo = new CCustomerInfo(); CResult oResult = tempCustomerManager.GetCustomerInfoByName(txtCustomerName.Text); tempCustomerInfo = (CCustomerInfo)oResult.Data; DataTable dtCustomerList = (DataTable)tempCustomerInfo.CustomerDataTable; if (dtCustomerList.Rows.Count > 1) { CustomerListForm objCustomerList = new CustomerListForm(dtCustomerList); objCustomerList.ShowDialog(this); } else if (dtCustomerList.Rows.Count == 1) { string phoneNumber = dtCustomerList.Rows[0]["phone"].ToString(); txtPhoneNumber.Text = phoneNumber; btnSearchByPhone_Click(sender, e); } else { MessageBox.Show("No customer has been found",RMSGlobal.MessageBoxTitle,MessageBoxButtons.OK,MessageBoxIcon.Information); } } catch (Exception exp) { Console.Write(exp.Message); } }
private void SearchCustomer(int searchType) { if (searchType == 1) { if (txtCustomerName.Text == "" || txtCustomerName.Text.Length < 1) { return; } } else if (searchType == 2) { if (txtPhoneNumber.Text == "" || txtPhoneNumber.Text.Length < 1) { return; } } try { CCustomerManager tempCustomerManager = new CCustomerManager(); CCustomerInfo tempCustomerInfo = new CCustomerInfo(); CResult oResult; if (searchType == 1) { oResult = tempCustomerManager.GetCustomerInfoByName(txtCustomerName.Text); tempCustomerInfo = (CCustomerInfo)oResult.Data; DataTable dtCustomerList = (DataTable)tempCustomerInfo.CustomerDataTable; if (dtCustomerList.Rows.Count > 1) { CustomerListForm objCustomerList = new CustomerListForm(dtCustomerList); objCustomerList.ShowDialog(this); string phoneNumber = CustomerListForm.m_phoneNumber; if (phoneNumber != null && !phoneNumber.ToString().Equals("")) { oResult = tempCustomerManager.CustomerInfoGetByPhone(phoneNumber); if (oResult.IsSuccess && oResult.Data != null) { tempCustomerInfo = (CCustomerInfo)oResult.Data; FillCustomerInfo(tempCustomerInfo); } } } else if (dtCustomerList.Rows.Count == 1) { string phoneNumber = dtCustomerList.Rows[0]["phone"].ToString(); oResult = tempCustomerManager.CustomerInfoGetByPhone(phoneNumber); if (oResult.IsSuccess && oResult.Data != null) { tempCustomerInfo = (CCustomerInfo)oResult.Data; FillCustomerInfo(tempCustomerInfo); } } else { MessageBox.Show("No customer has been found", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } else if (searchType == 2) { string phoneNumber = txtPhoneNumber.Text; oResult = tempCustomerManager.CustomerInfoGetByPhone(phoneNumber); if (oResult.IsSuccess && oResult.Data != null) { tempCustomerInfo = (CCustomerInfo)oResult.Data; FillCustomerInfo(tempCustomerInfo); } else { MessageBox.Show("No customer has been found", RMSGlobal.MessageBoxTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception exp) { Console.Write(exp.Message); } }