private void dgvCustomers_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { VendorAddress objVendorAddress = dgvVendors.CurrentRow.DataBoundItem as VendorAddress; SelectedVendorAddress = objVendorAddress; this.Dispose(); }
private void btnOK_Click(object sender, EventArgs e) { VendorAddress objVendorAddress; if (dgvVendors.SelectedRows.Count == 0) MessageBox.Show("No Customer selected!", "Job", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); else { objVendorAddress = dgvVendors.CurrentRow.DataBoundItem as VendorAddress; SelectedVendorAddress = objVendorAddress; this.Dispose(); } }
public VendorAddress(string strVendorNumber) { VendorAddress objTemp = Search(strVendorNumber, 1).First(); VendorNumber = objTemp.VendorNumber; Name = objTemp.Name; AddressLine1 = objTemp.AddressLine1; AddressLine2 = objTemp.AddressLine2; AddressLine3 = objTemp.AddressLine3; AddressLine4 = objTemp.AddressLine4; City = objTemp.City; State = objTemp.State; ZipCode = objTemp.ZipCode; }
public static SortableSearchableBindingList<VendorAddress> Search(string strVendorNumber, int intMaxRecordCount = 100, string strSearchBy = "vend_num")//Retrieves a list of customers that match the customer number { SortableSearchableBindingList<VendorAddress> objVendorAddressList; SL8_WTF_DataBaseSettings objSL8_WTF_DataBaseSettings; DataTable objDataTable = new DataTable(); SqlDataAdapter objDataAdapter; SqlCommand objSQLCommand; VendorAddress objVendorAddress; string strSQL; objSL8_WTF_DataBaseSettings = new SL8_WTF_DataBaseSettings(); strSQL = QueryDefinitions.GetQuery("SelectTopNVendorAddresses", new string[] { intMaxRecordCount.ToString(), strSearchBy, strVendorNumber, strSearchBy }); objSL8_WTF_DataBaseSettings.SQLConnection.Open(); objSQLCommand = new SqlCommand(strSQL, objSL8_WTF_DataBaseSettings.SQLConnection); objDataAdapter = new SqlDataAdapter(objSQLCommand); objDataAdapter.Fill(objDataTable); objVendorAddressList = new SortableSearchableBindingList<VendorAddress>(); if (objDataTable.Rows.Count > 0) { foreach (DataRow objRow in objDataTable.Rows) { objVendorAddress = new VendorAddress(); objVendorAddress.VendorNumber = objRow["vend_num"].ToString(); objVendorAddress.Name = objRow["Name"].ToString(); objVendorAddress.AddressLine1 = objRow["Addr##1"].ToString(); objVendorAddress.AddressLine2 = objRow["Addr##2"].ToString(); objVendorAddress.AddressLine3 = objRow["Addr##3"].ToString(); objVendorAddress.AddressLine4 = objRow["Addr##4"].ToString(); objVendorAddress.City = objRow["City"].ToString(); objVendorAddress.State = objRow["State"].ToString(); objVendorAddress.ZipCode = objRow["ZIP"].ToString(); objVendorAddress.Country = objRow["country"].ToString(); objVendorAddressList.Add(objVendorAddress); } } return objVendorAddressList; }
//Retrieves a list of customers that match the customer number public static SortableSearchableBindingList<VendorAddress> Search(string strVendorNumber, int intMaxRecordCount = 100, string strSearchBy = "vend_num") { SortableSearchableBindingList<VendorAddress> objVendorAddressList; SL8_WTF_DataBaseSettings objSL8_WTF_DataBaseSettings; DataTable objDataTable = new DataTable(); SqlDataAdapter objDataAdapter; SqlCommand objSQLCommand; VendorAddress objVendorAddress; string strSQL; objSL8_WTF_DataBaseSettings = new SL8_WTF_DataBaseSettings(); strSQL = QueryDefinitions.GetQuery("SelectTopNVendorAddresses", new string[] { intMaxRecordCount.ToString(), strSearchBy, strVendorNumber, strSearchBy }); objSL8_WTF_DataBaseSettings.SQLConnection.Open(); objSQLCommand = new SqlCommand(strSQL, objSL8_WTF_DataBaseSettings.SQLConnection); objDataAdapter = new SqlDataAdapter(objSQLCommand); objDataAdapter.Fill(objDataTable); objVendorAddressList = new SortableSearchableBindingList<VendorAddress>(); if (objDataTable.Rows.Count > 0) { foreach (DataRow objRow in objDataTable.Rows) { objVendorAddress = new VendorAddress(); objVendorAddress.VendorNumber = objRow["vend_num"].ToString(); objVendorAddress.Name = objRow["Name"].ToString(); objVendorAddress.AddressLine1 = objRow["Addr##1"].ToString(); objVendorAddress.AddressLine2 = objRow["Addr##2"].ToString(); objVendorAddress.AddressLine3 = objRow["Addr##3"].ToString(); objVendorAddress.AddressLine4 = objRow["Addr##4"].ToString(); objVendorAddress.City = objRow["City"].ToString(); objVendorAddress.State = objRow["State"].ToString(); objVendorAddress.ZipCode = objRow["ZIP"].ToString(); objVendorAddress.Country = objRow["country"].ToString(); objVendorAddressList.Add(objVendorAddress); } } return objVendorAddressList; }
private void txtNo_KeyDown(object sender, KeyEventArgs e) { switch (e.KeyCode) { case Keys.Enter: try { if (!string.IsNullOrEmpty(txtNo.Text)) { switch (((ComboBoxItem)cmbAddressType.SelectedItem).Value) { case CUSTOMERVALUE: var objCustomerAddress = new CustomerAddress(txtNo.Text); mintCustomerOrVendorNumber = int.Parse(objCustomerAddress.CustomerNumber); LoadCustomerAddresses(); break; case VENDORVALUE: var objVendorAddress = new VendorAddress(txtNo.Text); mintCustomerOrVendorNumber = int.Parse(objVendorAddress.VendorNumber); LoadVendorAddresses(); break; } txtNo.Text = mintCustomerOrVendorNumber.ToString(); } } catch { switch (((ComboBoxItem)cmbAddressType.SelectedItem).Value) { case CUSTOMERVALUE: MessageBox.Show("Customer " + txtNo.Text + " Not Found", "No Customer Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); break; case VENDORVALUE: MessageBox.Show("Vendor " + txtNo.Text + " Not Found", "No Vendor Found", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); break; } } break; } }