private string GetParentCustNumByCustNum(string code) { string returnV = ""; try { CustomerAdapter adapterCustomer = new CustomerAdapter(this.oTrans); adapterCustomer.BOConnect(); adapterCustomer.GetByCustID(code, false); if (adapterCustomer.CustomerData.Customer.Rows.Count == 1) { DataRow rRow = adapterCustomer.CustomerData.Customer[adapterCustomer.CustomerData.Customer.Rows.Count - 1]; if (rRow != null) { returnV = rRow["CustNum"].ToString(); } } adapterCustomer.Dispose(); } catch (Exception ex) { //ExceptionBox.Show(ex); return(""); } return(returnV); }
private void CustCnt_AfterFieldChange(object sender, DataColumnChangeEventArgs args) { // ** Argument Properties and Uses ** // args.Row["FieldName"] // args.Column, args.ProposedValue, args.Row // Add Event Handler Code EpiDataView edvCustomer = ((EpiDataView)(this.oTrans.EpiDataViews["Customer"])); System.Data.DataRow edvCustomerRow = edvCustomer.CurrentDataRow; string custID = edvCustomerRow["CustID"].ToString(); CustomerAdapter custAdapter = new CustomerAdapter(this.oTrans); custAdapter.BOConnect(); custAdapter.GetByCustID(custID, false); DataRow row = custAdapter.CustomerData.Customer[0]; int primB = int.Parse(row["PrimBCon"].ToString()); int primP = int.Parse(row["PrimPCon"].ToString()); int primS = int.Parse(row["PrimSCon"].ToString()); string leadType = ""; bool warning = false; switch (args.Column.ColumnName) { case "PrimaryBilling": if (primB != 0 && args.ProposedValue.ToString() == "True") { warning = true; leadType = "billing"; } break; case "PrimaryPurchasing": if (primP != 0 && args.ProposedValue.ToString() == "True") { warning = true; leadType = "purchasing"; } break; case "PrimaryShipping": if (primS != 0 && args.ProposedValue.ToString() == "True") { warning = true; leadType = "shipping"; } break; } if (warning) { DialogResult dialogResult = EpiMessageBox.Show("There exists another contact for " + leadType + "\nContinue?", "Cancel", MessageBoxButtons.YesNo); if ((dialogResult == DialogResult.No)) { oTrans.Undo(); } } }