Example #1
0
        /// <summary>
        /// 保存单据并修改库存
        /// </summary>
        public void DoSave()
        {
            //Do Verify
            if (this.cmbStorehouse.SelectedItem == null)
            {
                throw new ApplicationException("请指定仓库!");
            }
            if (this.cmbCompany.SelectedItem == null)
            {
                throw new ApplicationException("请指定管理单位!");
            }
            if (this.dgvGoodsList.Rows.Count <= 1)
            {
                throw new ApplicationException("请指定商品!");
            }

            //Contruct model
            StockBill bill = new StockBill();

            bill.BillType    = this.BillType;
            bill.Actived     = true;
            bill.Code        = DateTime.Now.ToString("yyyyMMddHHmmssddd");
            bill.Company     = (Company)this.cmbCompany.SelectedItem;
            bill.IsCancelOut = false;
            bill.IsRedBill   = false;
            bill.MakeDate    = this.dtpMakeDate.Value;
            bill.Remark      = this.txtRemark.Text.Trim();
            bill.Storehouse  = (Storehouse)this.cmbStorehouse.SelectedItem;
            bill.Maker       = this.txtMaker.Text.Trim();

            foreach (DataGridViewRow row in this.dgvGoodsList.Rows)
            {
                if (row.Tag != null)
                {
                    StockBillItem billItem = (StockBillItem)row.Tag;
                    bill.Items.Add(billItem);
                }
            }


            //Do Save
            StockBillService service = new StockBillService();

            service.MakeBill(bill);

            if (MessageBox.Show("是否打印?", "打印提示",
                                MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                PrintService.GetInstance().PrintBill(bill);
            }

            //Reset the form
            this.DoReset();
        }
Example #2
0
        /// <summary>
        /// 保存单据并修改库存
        /// </summary>
        public void DoSave()
        {
            //verify
            if (cmbCompany.SelectedItem == null)
            {
                throw new ApplicationException("请指定关联单位");
            }
            if (cmbStorehouse.SelectedItem == null)
            {
                throw new ApplicationException("请指定仓库");
            }
            if (dgvDrugsList.Rows.Count <= 1)
            {
                throw new ApplicationException("请指定药品");
            }
            //Contruct Model
            Bills bill = new Bills();

            bill.BillsType   = this.BillsType;
            bill.Actived     = true;
            bill.Code        = DateTime.Now.ToString("yyyyMMddHHmmssfff");
            bill.Company     = (Company)cmbCompany.SelectedItem;
            bill.IsCancelOut = false;
            bill.IsRedBill   = false;
            bill.MakeDate    = this.dtpMakeDate.Value;
            bill.CreateDate  = DateTime.Now;
            bill.Maker       = this.txtMaker.Text.Trim();
            bill.Storehouse  = (Storehouse)this.cmbStorehouse.SelectedItem;
            bill.Remark      = this.txtRemark.Text.Trim();
            foreach (DataGridViewRow row in dgvDrugsList.Rows)
            {
                if (row.Tag != null)
                {
                    BillsItem billsItem = (BillsItem)row.Tag;
                    if (billsItem.Remark == null)
                    {
                        billsItem.Remark = "没有备注";
                    }
                    bill.Items.Add(billsItem);
                }
            }
            //Do Save
            StockBillService stockBillService = new StockBillService();

            stockBillService.MakeBill(bill);
            if (MessageBox.Show("保存成功,是否打印单据?", "打印提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                new PrintService().PrintBill(bill);
            }
            this.DoReset();
        }