Example #1
0
 public int AddReceiptPlan(BllReceiptPlanTable model)
 {
     return(dal.AddReceiptPlan(model));
 }
Example #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            List <BllReceiptTable> receiptList  = new List <BllReceiptTable>();
            BllReceiptTable        receiptTable = null;
            string currentPoSlipNumber          = "";
            bool   IsInstallments = false;

            foreach (DataGridViewRow dgvr in dgvData.Rows)
            {
                if (Convert.ToBoolean(dgvr.Cells["RECEIPT_CHK"].Value) && (dgvr.Cells["RECEIPT_QUANTITY"].Value != null))
                {
                    string poSlipNumber = CConvert.ToString(dgvr.Cells["PURCHASE_ORDER_SLIP_NUMBER"].Value);

                    if (currentPoSlipNumber != poSlipNumber)
                    {
                        if (currentPoSlipNumber != "")
                        {
                            receiptList.Add(receiptTable);
                        }
                        receiptTable = new BllReceiptTable();
                        receiptTable.PO_SLIP_NUMBER   = poSlipNumber;
                        receiptTable.STATUS_FLAG      = CConstant.INIT_STATUS;
                        receiptTable.COMPANY_CODE     = UserTable.COMPANY_CODE;
                        receiptTable.CREATE_USER      = UserTable.CODE;
                        receiptTable.LAST_UPDATE_USER = UserTable.CODE;
                        currentPoSlipNumber           = poSlipNumber;
                    }


                    //RECEIPT_PLAN_QUANTITY

                    BllReceiptLineTable receiptLineTable = new BllReceiptLineTable();

                    //入库数量
                    decimal receiptQuantity = CConvert.ToDecimal(dgvr.Cells["RECEIPT_QUANTITY"].Value);

                    //预定数量
                    decimal receiptPlanQuantity = CConvert.ToDecimal(dgvr.Cells["RECEIPT_PLAN_QUANTITY"].Value);


                    if (receiptPlanQuantity > receiptQuantity)
                    {
                        IsInstallments = true;
                    }

                    BllReceiptPlanTable RPTable = bReceipt.GetReceiptPlanModel(CConvert.ToInt32(dgvr.Cells["SLIP_NUMBER"].Value));

                    //Receipt_Line 表中数据

                    receiptLineTable.RECEIPT_PLAN_NUMBER    = RPTable.SLIP_NUMBER;
                    receiptLineTable.RECEIPT_WAREHOUSE_CODE = RPTable.RECEIPT_WAREHOUSE_CODE;
                    receiptLineTable.PRODUCT_CODE           = RPTable.PRODUCT_CODE;
                    receiptLineTable.QUANTITY  = receiptQuantity;
                    receiptLineTable.UNIT_CODE = RPTable.UNIT_CODE;
                    receiptLineTable.PRICE     = RPTable.PRICE;

                    if (CConstant.PRICE_INCLUDED_TAX.Equals(CConvert.ToString(RPTable.INCLUDED_TAX_STATUS)))
                    {
                        receiptLineTable.AMOUNT_INCLUDED_TAX = receiptLineTable.QUANTITY * receiptLineTable.PRICE;
                        receiptLineTable.AMOUNT_WITHOUT_TAX  = WithoutAmount(receiptLineTable.AMOUNT_INCLUDED_TAX, CConstant.DEFAULT_TAX);
                        receiptLineTable.TAX_AMOUNT          = receiptLineTable.AMOUNT_INCLUDED_TAX - receiptLineTable.AMOUNT_WITHOUT_TAX;
                    }
                    else
                    {
                        receiptLineTable.AMOUNT_WITHOUT_TAX  = receiptLineTable.QUANTITY * receiptLineTable.PRICE;
                        receiptLineTable.TAX_AMOUNT          = receiptLineTable.AMOUNT_WITHOUT_TAX * CConstant.DEFAULT_TAX;
                        receiptLineTable.AMOUNT_INCLUDED_TAX = receiptLineTable.AMOUNT_WITHOUT_TAX + receiptLineTable.TAX_AMOUNT;
                    }

                    receiptLineTable.SUPPLIER_CODE  = RPTable.SUPPLIER_CODE;
                    receiptLineTable.CURRENCY_CODE  = RPTable.CURRENCY_CODE;
                    receiptLineTable.TAX_RATE       = RPTable.TAX_RATE;
                    receiptLineTable.INVOICE_NUMBER = CConvert.ToString(dgvr.Cells["InvoiceNo"].Value);
                    receiptTable.AddItem(receiptLineTable);
                }
            }

            if (receiptTable != null)
            {
                receiptList.Add(receiptTable);
            }

            if (receiptList.Count > 0)
            {
                DateTime time = DateTime.Now;
                if (IsInstallments)
                {
                    FrmChoseReceipt frm    = new FrmChoseReceipt();
                    DialogResult    resule = frm.ShowDialog(this);
                    IsInstallments = frm.IsInstallments;
                    time           = frm.time;
                    if (resule == DialogResult.Cancel)
                    {
                        //分纳取消,取消入库
                        return;
                    }
                }

                try
                {
                    if (bReceipt.Receipt(receiptList, IsInstallments, time) > 0)
                    {
                        MessageBox.Show("采购入库成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Search(1);
                    }
                    else
                    {
                        MessageBox.Show("采购入库失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                { }
            }
            else
            {
                MessageBox.Show("请选择需要入库的采购订单。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }