Пример #1
0
        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);
        }
Пример #2
0
        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));
        }
Пример #3
0
 public void UpdateBill(Bill bill)
 {
     (Task as SaleTask).TriggerBillsChanged(null, new BillChangeEventArg(bill, ModelChangeEventArg.UPDATE));
 }
Пример #4
0
 public void SetCurrentBill(Bill bill)
 {
     (Task as SaleTask).CurrentBill = bill;
 }
Пример #5
0
 /*
  * 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));
 }
Пример #6
0
 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;
     }
 }
Пример #7
0
 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();
     }
 }
Пример #8
0
 //--------------------------------------------
 private void bill_productsGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     //解决SetCurrentCellAddressCore函数的可重入调用.交给billProductsGridViewTimer来处理
     billProductsGridViewTimer.Enabled = true;
     lastModifiedBill = CurrentBill;
 }
Пример #9
0
 private void billsGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     lastModifiedBill = CurrentBill;
     this.billsGridViewTimer.Enabled = true;
 }
Пример #10
0
        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();
        }
Пример #11
0
 public BillChangeEventArg(Bill changedBill, int changingType)
 {
     this.ChangedBill = changedBill;
     this.ChangingType = changingType;
 }
Пример #12
0
 public static void Delete(Bill bill)
 {
     DatabaseHelper.BillCollection.Remove(Query<Bill>.EQ(e => e.Id, bill.Id));
 }
Пример #13
0
 public static void Update(Bill bill)
 {
     DatabaseHelper.BillCollection.Save<Bill>(bill);
 }
Пример #14
0
 public static void Insert(Bill bill)
 {
     DatabaseHelper.BillCollection.Insert<Bill>(bill);
 }