public bool AddItem(string AddName, string AddType) { if (BillShipExists(AddName,AddType)) { return false; } else { CustBillShip c = new CustBillShip(cID); c.AddressName = AddName; c.AddressType = AddType; cList.Add(c); return true; } }
public static CustBillShip PopulateCustBillShipsFromSqlDataReader(SqlDataReader dr) { CustBillShip custBS = new CustBillShip(); custBS.ID = Convert.ToInt32(dr["ID"]); custBS.CustomerID = Convert.ToInt32(dr["CUSTOMERID"]); custBS.AddressName = Convert.ToString(dr["ADDRESSNAME"]); custBS.AddressType = Convert.ToString(dr["ADDRESSTYPE"]); custBS.Address1 = Convert.ToString(dr["ADDRESS1"]); custBS.Address2 = Convert.ToString(dr["ADDRESS2"]); custBS.City = Convert.ToString(dr["CITY"]); custBS.State = Convert.ToString(dr["STATE"]); custBS.Zip = Convert.ToString(dr["ZIP"]); return custBS; }
private void button27_Click(object sender, EventArgs e) { //Save or Update BillShipList cBSList = new BillShipList(cID); if (FormMode == "NEW") { cBSList.AddCustBillShip(Form2Object()); } else if (FormMode == "EDIT") { CustBillShip c = new CustBillShip(); c = Form2Object(); c.ID = ShipID; cBSList.UpdateCustBillShip(c); } this.Hide(); }
public void AddCustBillShip(CustBillShip CustBS) { // Initialize SPROC SqlConnection conn = new SqlConnection(ConnectionString); SqlCommand cmd = new SqlCommand("SPBillShipInsert", conn); cmd.CommandType = CommandType.StoredProcedure; // Add Parameters cmd.Parameters.AddWithValue("@ADDRESSNAME", CustBS.AddressName); cmd.Parameters.AddWithValue("@ADDRESSTYPE", CustBS.AddressType); cmd.Parameters.AddWithValue("@ADDRESS1", CustBS.Address1); cmd.Parameters.AddWithValue("@ADDRESS2", CustBS.Address2); cmd.Parameters.AddWithValue("@CITY", CustBS.City); cmd.Parameters.AddWithValue("@STATE", CustBS.State); cmd.Parameters.AddWithValue("@ZIP", CustBS.Zip); cmd.Parameters.AddWithValue("@CUSTOMERID", CustBS.CustomerID); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); reload(); }
public Form10(ref CustBillShip CustBS, String Mode) { string[] AddrType ={ "Shipping", "Billing" }; InitializeComponent(); FormMode = Mode.ToUpper(); cID = CustBS.CustomerID; if (FormMode == "NEW") { AddrType[0] = "Shipping"; AddrType[1] = "Billing"; button27.Text = "Save"; comboBox1.DataSource = AddrType; comboBox19.DataSource = cStates; } else { ShipID = CustBS.ID; comboBox19.DataSource = cStates; Object2Form(CustBS); FormMode = "EDIT"; button27.Text = "Modify"; } }
private void Object2Form(CustBillShip c) { string[] AddrType ={ "Shipping", "Billing" }; if (c.AddressType.ToUpper() == "SHIPPING") { AddrType[0] = "Shipping"; AddrType[1] = "Billing"; } else { AddrType[0] = "Billing"; AddrType[1] = "Shipping"; } comboBox1.DataSource = AddrType; /*0 ID 1 Name 2 Type 3 Address1 4 Address2 5 City 6 State 7 ZIP*/ textBox26.Text = c.Address1; textBox1.Text = c.Address2; textBox25.Text = c.AddressName; textBox27.Text = c.City; int Index = comboBox19.FindString(c.State); comboBox19.SelectedIndex = Index; textBox28.Text = c.Zip; }
private CustBillShip Form2Object() { CustBillShip c = new CustBillShip(0,textBox25.Text,comboBox1.Text,textBox26.Text,textBox1.Text,textBox27.Text,comboBox19.Text,textBox28.Text,cID); return c; }
public CustBillShip SearchBillShip(string AddName, string AddType) { foreach (CustBillShip custBS in cList) { if ((custBS.AddressName == AddName) && (custBS.AddressType == AddType)) { return (custBS); } } CustBillShip c = new CustBillShip(cID); return (c); }
//ADD NEW Shipping Address private void button68_Click(object sender, EventArgs e) { //Add A New Shipping or Billing Address //Saves Current Customer button27_Click(sender, e); //Creates a new BillShip calls the form2 to edit further Customer c1 = CustList.SearchCustomer(CustIDcombo.Text); CustBillShip cBS = new CustBillShip(c1.ID); //Add Address form Form10 f = new Form10(ref cBS, "NEW"); f.ShowDialog(); LoadBillShip(c1.ID); //poplist(); }