private void newBillButton_Click(object sender, EventArgs e) { String number = this.numberTextBox.Text; String phone = this.phoneTextBox.Text; DateTime deliveryDate = this.deliveryDateTimePicker.Value; String remark = this.remarkTextBox.Text; int oridnal; if(!int.TryParse(this.ordinalTextbox.Text,out oridnal)) { MessageBox.Show("序号必须为正数"); return; } Bill bill = new Bill() { Number = number, Phone = phone, DeliveryDate = deliveryDate, Remark = remark, Completed = false, Ordinal = oridnal }; (Controller as BillController).NewBill(bill); }
public void NewBill(Bill bill) { List<Bill> specificBill = (from b in (Task as BillTask).SalesTask.Bills where b.Equals(bill) select b).ToList(); if (specificBill.Count > 0) { MessageBox.Show("已经存在这个订单啦"); return; } SaleTask task = (Task as BillTask).SalesTask; task.Bills.Add(bill); task.TriggerBillsChanged(this, new BillChangeEventArg(bill, ModelChangeEventArg.INSERT)); }
public void UpdateBill(Bill bill) { (Task as SaleTask).TriggerBillsChanged(null, new BillChangeEventArg(bill, ModelChangeEventArg.UPDATE)); }
public void SetCurrentBill(Bill bill) { (Task as SaleTask).CurrentBill = bill; }
/* * bill modify method */ public void DeleteBill(Bill bill) { // since in the form view layer, we called bindingsource.remove method, it will also delete the object of model layer // here we just call the event trigger method to notify the observors to take actions (Task as SaleTask).TriggerBillsChanged(null, new BillChangeEventArg(bill, ModelChangeEventArg.REMOVE)); }
public void DatabaseBillPersist(Bill bill, int changingType) { //database operation switch (changingType) { case ModelChangeEventArg.INSERT: BillDao.Insert(bill); break; case ModelChangeEventArg.UPDATE: BillDao.Update(bill); break; case ModelChangeEventArg.REMOVE: BillDao.Delete(bill); break; } }
public void SelectBillInList(Bill bill) { int index = (this.billsGridView.DataSource as BindingSource).IndexOf(bill); int count = this.billsGridView.Rows.Count; if (index < count && index >= 0) { this.billsGridView.Rows[index].Selected = true; this.billsGridView.Refresh(); } }
//-------------------------------------------- private void bill_productsGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { //解决SetCurrentCellAddressCore函数的可重入调用.交给billProductsGridViewTimer来处理 billProductsGridViewTimer.Enabled = true; lastModifiedBill = CurrentBill; }
private void billsGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { lastModifiedBill = CurrentBill; this.billsGridViewTimer.Enabled = true; }
public void ShowBillInfo(Bill bill) { if (bill != null) { this.billRemarkTextBox.Text = bill.Remark; this.depositTextBox.Text = bill.Deposit.ToString(); BindingSource bs = new BindingSource(bill, "Products"); this.bill_productsGridView.DataSource = bs; CalculateAndShowTotalPrice(); } (Controller as BillsController).SetCurrentBillProduct(CurrentBillProduct); RefreshCurrentProduct(); }
public BillChangeEventArg(Bill changedBill, int changingType) { this.ChangedBill = changedBill; this.ChangingType = changingType; }
public static void Delete(Bill bill) { DatabaseHelper.BillCollection.Remove(Query<Bill>.EQ(e => e.Id, bill.Id)); }
public static void Update(Bill bill) { DatabaseHelper.BillCollection.Save<Bill>(bill); }
public static void Insert(Bill bill) { DatabaseHelper.BillCollection.Insert<Bill>(bill); }