示例#1
0
文件: BillForm.cs 项目: hanleyChu/prj
        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
文件: BillDao.cs 项目: hanleyChu/prj
 public static void Delete(Bill bill)
 {
     DatabaseHelper.BillCollection.Remove(Query<Bill>.EQ(e => e.Id, bill.Id));
 }
示例#13
0
文件: BillDao.cs 项目: hanleyChu/prj
 public static void Update(Bill bill)
 {
     DatabaseHelper.BillCollection.Save<Bill>(bill);
 }
示例#14
0
文件: BillDao.cs 项目: hanleyChu/prj
 public static void Insert(Bill bill)
 {
     DatabaseHelper.BillCollection.Insert<Bill>(bill);
 }