public ControllerParent(ControllerParent callingController, ArrayList list_customers) { this.callingController = callingController; if (list_customers == null) this.list_customers = new ArrayList(); else this.list_customers = list_customers; this.db = new Database(); currentCustomer = null; }
public void UpdateCustomer(Customer c) { try { connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;"); connection.Open(); command = new SQLiteCommand(connection); command.CommandText = "UPDATE customer SET name=@name, street=@street, streetnumber=@streetnumber, city=@city, zip=@zip WHERE customerNumber=@cnr ;"; command.Parameters.AddWithValue("@cnr", c.Cnumber); command.Parameters.AddWithValue("@name", c.Name); command.Parameters.AddWithValue("@street", c.Street); command.Parameters.AddWithValue("@streetnumber", c.Streetnumber); command.Parameters.AddWithValue("@city", c.City); command.Parameters.AddWithValue("@zip", c.Zip); command.ExecuteNonQuery(); } catch (Exception e) { MessageBox.Show("Error SQL Change Customer", "", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.WriteLog(e.Message); } connection.Close(); }
public void SaveCustomer(Customer c) { try { connection = new SQLiteConnection("Data Source=" + dbpath + ";Version=3; foreign keys=true;"); connection.Open(); command = new SQLiteCommand(connection); command.CommandText = "INSERT INTO customer (customerNumber, name, street, streetnumber, city, zip) VALUES(@customerNumber, @name, @street, @streetnumber, @city, @zip);"; command.Parameters.AddWithValue("@customerNumber", c.Cnumber); command.Parameters.AddWithValue("@name", c.Name); command.Parameters.AddWithValue("@street", c.Street); command.Parameters.AddWithValue("@streetnumber", c.Streetnumber); command.Parameters.AddWithValue("@city", c.City); command.Parameters.AddWithValue("@zip", c.Zip); command.ExecuteNonQuery(); } catch (Exception e) { MessageBox.Show("Error SQL Write Customer", "", MessageBoxButtons.OK, MessageBoxIcon.Error); Log.WriteLog(e.Message); } connection.Close(); }
public override void AddCustomer(Customer customer) { lstCustomer.Items.Add(customer); }
//Functions public void AddCustomer(int nr, string name, string street, string streetnr, string city, string zip) { Customer c = new Customer(nr, name, street, streetnr, city, zip); list_customers.Add(c); db.SaveCustomer(c); }
public virtual void SelectedCustomerChanged(Object customer) { currentCustomer = (Customer)customer; UpdateView(false); }
public virtual void AddCustomer(Customer customer) { cmbCustomer.Items.Add(customer); }
public void SetCustomer(Customer customer) { cmbCustomer.SelectedItem = customer; }