Beispiel #1
0
        public void getReceipt(string SLIP_NUMBER)
        {
            int a = 0;
            int b = 0;
            BllPurchaseOrderLineTable OLTable = new BllPurchaseOrderLineTable();
            DataSet ds = bPurchaseOrder.GetReceivingPlanByPurchaseOrderSlipNumber(SLIP_NUMBER);

            foreach (DataRow rows in ds.Tables[0].Rows)
            {
                if (CConvert.ToInt32(rows["STATUS_FLAG"]) == 0)
                {
                    a++;
                }
                else if (CConvert.ToInt32(rows["STATUS_FLAG"]) == 1)
                {
                    b++;
                }
            }

            if (a == ds.Tables[0].Rows.Count)
            {
                Receipt = CConstant.UN_RECEIPT;
            }
            else if (b == ds.Tables[0].Rows.Count)
            {
                Receipt = CConstant.COMPLETE_RECEIPT;
            }
            else
            {
                Receipt = CConstant.PART_RECEIPT;
            }
        }
Beispiel #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!CheckHeaderInput())
            {
                return;
            }

            if (!CheckLineInput())
            {
                return;
            }

            BllPurchaseOrderTable     POTable = new BllPurchaseOrderTable();
            BllPurchaseOrderLineTable OLTable = null;

            //订单类型
            POTable.SLIP_TYPE = cboPurchaseSlipType.SelectedValue.ToString();
            //订单编号
            POTable.SLIP_NUMBER = txtPurchaseSlipNumber.Text.Trim();
            //类型编号
            POTable.ORDER_SLIP_NUMBER = txtOrderNumber.Text.Trim();
            //供应商编号
            POTable.SUPPLIER_CODE = txtSupplierCode.Text.Trim();
            //报价单号
            POTable.SUPPLIER_ORDER_NUMBER = txtSupplierOrderCode.Text.Trim();
            //入库仓库
            POTable.RECEIPT_WAREHOUSE_CODE = txtWarehouseCode.Text.Trim();
            //采购订单日期
            POTable.SLIP_DATE = CConvert.ToDateTime(entryDate.Value.ToString("yyyy-MM-dd"));
            //交货期限
            POTable.DUE_DATE = CConvert.ToDateTime(dueDate.Value.ToString("yyyy-MM-dd"));
            //税率
            POTable.TAX_RATE = CConvert.ToDecimal(cboTax.Text.Replace("%", "")) / 100;
            //通货
            POTable.CURRENCY_CODE = "01";
            //包装方式
            //POTable.PACKING_METHOD = txtPackingMethod.Text.Trim();
            //付款方式
            POTable.PAYMENT_CONDITION = txtPayment.Text.Trim();
            //备注
            POTable.MEMO = txtMemo.Text.Trim();
            //状态
            POTable.STATUS_FLAG = CConstant.PURCHASE_NEW;
            //创建人
            POTable.CREATE_USER = UserTable.CODE;
            //最后更新人
            POTable.LAST_UPDATE_USER = UserTable.CODE;
            //公司
            POTable.COMPANY_CODE = UserTable.COMPANY_CODE;
            //总金额
            POTable.TOTAL_AMOUNT = CConvert.ToDecimal(txtAmountIncludedTax.Text.Trim());
            //明细的整理
            foreach (DataGridViewRow row in dgvData.Rows)
            {
                OLTable                     = new BllPurchaseOrderLineTable();
                OLTable.SLIP_NUMBER         = POTable.SLIP_NUMBER;
                OLTable.LINE_NUMBER         = row.Index + 1;
                OLTable.PRODUCT_CODE        = row.Cells["PRODUCT_CODE"].Value.ToString();
                OLTable.QUANTITY            = CConvert.ToDecimal(row.Cells["QUANTITY"].Value.ToString());
                OLTable.UNIT_CODE           = row.Cells["UNIT_CODE"].Value.ToString();
                OLTable.PRICE               = CConvert.ToDecimal(row.Cells["PRICE"].Value.ToString());
                OLTable.AMOUNT_WITHOUT_TAX  = CConvert.ToDecimal(row.Cells["AMOUNT"].Value.ToString());
                OLTable.AMOUNT_INCLUDED_TAX = CConvert.ToDecimal(row.Cells["AMOUNT_INCLUDED_TAX"].Value.ToString());
                OLTable.TAX_AMOUNT          = OLTable.AMOUNT_INCLUDED_TAX - OLTable.AMOUNT_WITHOUT_TAX;
                OLTable.STATUS_FLAG         = CConstant.PURCHASE_NEW;
                POTable.AddItem(OLTable);
            }

            int result = 0;

            try
            {
                if (_currentPurchaseOrderTable != null)
                {
                    result = bPurchaseOrder.Update(POTable);
                }
                else
                {
                    result = bPurchaseOrder.Add(POTable);
                }

                if (result <= 0)
                {
                    MessageBox.Show("订单保存失败。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("订单保存成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (CConstant.PURCHASE_ORDER_NEW.Equals(CTag))
                    {
                        initPage();
                    }
                    else
                    {
                        _dialogResult = DialogResult.OK;
                        this.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("订单保存失败,系统错误,请与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                Logger.Error("订单保存失败!", ex);
            }
        }
Beispiel #3
0
        public void init()
        {
            if (_currentPurchaseOrderTable != null)
            {
                this.cboPurchaseSlipType.SelectedValue = _currentPurchaseOrderTable.SLIP_TYPE;
                this.txtPurchaseSlipNumber.Text        = _currentPurchaseOrderTable.SLIP_NUMBER;
                this.txtSupplierCode.Text = _currentPurchaseOrderTable.SUPPLIER_CODE;
                if (bCommon.GetBaseMaster("SUPPLIER", _currentPurchaseOrderTable.SUPPLIER_CODE) != null)
                {
                    this.txtSupplierName.Text = bCommon.GetBaseMaster("SUPPLIER", _currentPurchaseOrderTable.SUPPLIER_CODE).Name;
                }
                this.txtWarehouseCode.Text = _currentPurchaseOrderTable.RECEIPT_WAREHOUSE_CODE;
                if (bCommon.GetBaseMaster("WAREHOUSE", _currentPurchaseOrderTable.RECEIPT_WAREHOUSE_CODE) != null)
                {
                    this.txtWarehouseName.Text = bCommon.GetBaseMaster("WAREHOUSE", _currentPurchaseOrderTable.RECEIPT_WAREHOUSE_CODE).Name;
                }
                //this.txtPackingMethod.Text = _currentPurchaseOrderTable.PACKING_METHOD;
                this.txtMemo.Text              = _currentPurchaseOrderTable.MEMO;
                this.txtPayment.Text           = _currentPurchaseOrderTable.PAYMENT_CONDITION;
                this.txtOrderNumber.Text       = _currentPurchaseOrderTable.ORDER_SLIP_NUMBER;
                this.txtSupplierOrderCode.Text = _currentPurchaseOrderTable.SUPPLIER_ORDER_NUMBER;
                this.entryDate.Text            = Convert.ToString(_currentPurchaseOrderTable.SLIP_DATE);
                this.dueDate.Text              = Convert.ToString(_currentPurchaseOrderTable.DUE_DATE);
                foreach (DataRow dr in CCacheData.Taxation.Rows)
                {
                    if (CConvert.ToDecimal(dr["TAX_RATE"]) == CConvert.ToDecimal(_currentPurchaseOrderTable.TAX_RATE) * 100)
                    {
                        this.cboTax.SelectedValue = dr["CODE"];
                        break;
                    }
                }

                //this.cboCurrency.SelectedValue = _currentPurchaseOrderTable.CURRENCY_CODE;
                BllPurchaseOrderLineTable OLTable = new BllPurchaseOrderLineTable();
                DataSet ds = bPurchaseOrder.GetPurchaseOrderList(_currentPurchaseOrderTable.SLIP_NUMBER);
                decimal AmountIncludedTax = 0;

                try
                {
                    foreach (DataRow rows in ds.Tables[0].Rows)
                    {
                        int             currentRowIndex = dgvData.Rows.Add(1);
                        DataGridViewRow row             = dgvData.Rows[currentRowIndex];
                        row.Cells[1].Selected                  = false;
                        row.Cells["NO"].Value                  = rows["LINE_NUMBER"];
                        row.Cells["PRODUCT_CODE"].Value        = rows["PRODUCT_CODE"];
                        row.Cells["OLD_CODE"].Value            = rows["PRODUCT_CODE"];
                        row.Cells["NAME"].Value                = rows["NAME"];
                        row.Cells["SPEC"].Value                = rows["SPEC"];
                        row.Cells["QUANTITY"].Value            = rows["QUANTITY"];
                        row.Cells["UNIT_NAME"].Value           = rows["UNIT_NAME"];
                        row.Cells["UNIT_CODE"].Value           = rows["UNIT_CODE"];
                        row.Cells["PRICE"].Value               = rows["PRICE"];
                        row.Cells["AMOUNT"].Value              = rows["AMOUNT"];
                        row.Cells["AMOUNT_INCLUDED_TAX"].Value = rows["AMOUNT_INCLUDED_TAX"];
                        AmountIncludedTax = AmountIncludedTax + CConvert.ToDecimal(rows["AMOUNT_INCLUDED_TAX"]);
                    }
                    txtAmountIncludedTax.Text = CConvert.ToString(AmountIncludedTax);
                    btnOrderDelete.Visible    = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 自动采购
        /// </summary>
        private void btnAutoPurchase_Click(object sender, EventArgs e)
        {
            string slipNumbers = "";

            //订单编号的取得
            foreach (DataGridViewRow dr in dgvData.Rows)
            {
                if (CConvert.ToBoolean(dr.Cells["CHK"].Value))
                {
                    slipNumbers += "'" + CConvert.ToString(dr.Cells["SLIP_NUMBER"].Value) + "',";
                }
            }
            if (slipNumbers.Length > 0)
            {
                slipNumbers = slipNumbers.Substring(0, slipNumbers.Length - 1);
            }
            else
            {
                MessageBox.Show("请先选择订单。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //采购清单的取得
            DataTable poDt = bPurchaseOrder.GetAutoPurchaseList(slipNumbers, rdoNetPurchase.Checked).Tables[0];
            //数据的整理

            List <BllPurchaseOrderTable> poList   = new List <BllPurchaseOrderTable>();
            BllPurchaseOrderTable        poTable  = null;
            BllPurchaseOrderLineTable    polTable = null;
            DateTime currentTime = DateTime.Now;
            decimal  total       = 0;
            int      i           = 1;

            string currentSupplier = "";

            foreach (DataRow row in poDt.Rows)
            {
                if ("".Equals(currentSupplier) || !currentSupplier.Equals(row["BASIC_SUPPLIER"]))
                {
                    if (!"".Equals(currentSupplier))
                    {
                        poTable.TOTAL_AMOUNT = total;
                        poList.Add(poTable);
                        total = 0;
                        i     = 1;
                    }
                    poTable                        = new BllPurchaseOrderTable();
                    poTable.SLIP_TYPE              = CConstant.PURCHASE_NEED;
                    poTable.SLIP_DATE              = currentTime;
                    poTable.DUE_DATE               = currentTime.AddDays(CConstant.DEFAULT_LEAD_TIME);
                    poTable.SUPPLIER_CODE          = CConvert.ToString(row["BASIC_SUPPLIER"]);
                    poTable.ORDER_SLIP_NUMBER      = "";
                    poTable.SUPPLIER_ORDER_NUMBER  = "";
                    poTable.CURRENCY_CODE          = CConstant.DEFAULT_CURRENCY_CODE;
                    poTable.TAX_RATE               = CConstant.DEFAULT_RATE;
                    poTable.RECEIPT_WAREHOUSE_CODE = CConstant.DEFAULT_WAREHOUSE_CODE;
                    poTable.STATUS_FLAG            = CConstant.INIT;
                    poTable.CREATE_USER            = _userInfo.CODE;
                    poTable.LAST_UPDATE_USER       = _userInfo.CODE;
                    poTable.COMPANY_CODE           = _userInfo.COMPANY_CODE;
                }

                currentSupplier = CConvert.ToString(row["BASIC_SUPPLIER"]);

                polTable                     = new BllPurchaseOrderLineTable();
                polTable.LINE_NUMBER         = i++;
                polTable.PRODUCT_CODE        = CConvert.ToString(row["PRODUCT_CODE"]);
                polTable.QUANTITY            = CConvert.ToDecimal(row["QUANTITY"]);
                polTable.UNIT_CODE           = CConvert.ToString(row["BASIC_UNIT_CODE"]);
                polTable.PRICE               = CConvert.ToDecimal(row["PURCHASE_PRICE"]);
                polTable.AMOUNT_WITHOUT_TAX  = polTable.QUANTITY * polTable.PRICE;
                polTable.TAX_AMOUNT          = CConvert.ToDecimal(poTable.TAX_RATE) * polTable.AMOUNT_WITHOUT_TAX;
                polTable.AMOUNT_INCLUDED_TAX = polTable.AMOUNT_WITHOUT_TAX + polTable.TAX_AMOUNT;
                polTable.STATUS_FLAG         = CConstant.INIT;
                total += polTable.AMOUNT_INCLUDED_TAX;
                poTable.TOTAL_AMOUNT = total;

                poTable.AddItem(polTable);
            }

            if (poTable != null)
            {
                poList.Add(poTable);
            }
            //订单分组采购清单的取得,用于记录本次采购的原材料数量

            DataTable historyDt = bPurchaseOrder.GetAutoPurchaseList(slipNumbers).Tables[0];

            List <BllOrderLineProductPartsTable> olppList  = new List <BllOrderLineProductPartsTable>();
            BllOrderLineProductPartsTable        olppTable = null;

            foreach (DataRow dr in historyDt.Rows)
            {
                olppTable = new BllOrderLineProductPartsTable();
                olppTable.ORDER_SLIP_NUMBER = CConvert.ToString(dr["SLIP_NUMBER"]);
                olppTable.PRODUCT_CODE      = CConvert.ToString(dr["PRODUCT_CODE"]);
                olppTable.QUANTITY          = CConvert.ToDecimal(dr["QUANTITY"]);
                olppTable.STATUS_FLAG       = CConstant.INIT;
                olppTable.CREATE_USER       = _userInfo.CODE;
                olppTable.LAST_UPDATE_USER  = _userInfo.CODE;

                olppList.Add(olppTable);
            }


            //数据保存
            try
            {
                if (bPurchaseOrder.AutoPurchase(poList, olppList, slipNumbers) > 0)
                {
                    MessageBox.Show("自动采购成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    btnSearch_Click(null, EventArgs.Empty);
                }
                else
                {
                    MessageBox.Show("自动采购失败,请重试或与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("自动采购失败,请重试或与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Logger.Error("自动采购失败。", ex);
            }
        }