Beispiel #1
0
        private void initOperate(int currentPage)
        {
            BllShipmentTable    shipment    = bShipment.GetModel(slipnumber);
            BllOrderHeaderTable orderheader = bOrderHeader.GetModel(shipment.ORDER_SLIP_NUMBER);

            txtSlipNumber.Text      = slipnumber;
            txtOrderSlipNumber.Text = shipment.ORDER_SLIP_NUMBER;
            //txtCustomerCode.Text = orderheader.CUSTOMER_CODE;
            //txtCustomerName.Text = orderheader.CUSTOMER_NAME;
            txtEndCustomerCode.Text = orderheader.ENDER_CUSTOMER_CODE;
            txtEndCustomerName.Text = orderheader.ENDER_CUSTOMER_NAME;
            //txtDeliveryPointCode.Text = orderheader.ENDER_CUSTOMER_CODE;
            //txtDeliveryPointName.Text = orderheader.ENDER_CUSTOMER_NAME;
            //txtSerialNumber.Text = shipment.SERIAL_NUMBER;
            txtCustomerPoNumber.Text   = orderheader.CUSTOMER_PO_NUMBER;
            txtOrderSlipDateFrom.Value = CConvert.ToDateTime(orderheader.SLIP_DATE.ToString());
            txtOrderSlipDateTo.Value   = CConvert.ToDateTime(orderheader.SLIP_DATE.ToString());
            txtSlipDateFrom.Value      = CConvert.ToDateTime(shipment.SLIP_DATE.ToString("yyyy-MM-dd"));
            txtSlipDateTo.Value        = CConvert.ToDateTime(shipment.SLIP_DATE.ToString("yyyy-MM-dd"));
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat(" STATUS_FLAG <> {0}", CConstant.DELETE);
            sb.AppendFormat(" AND SLIP_NUMBER = '{0}'", slipnumber);
            DataSet ds          = bShipment.GetList(sb.ToString(), "", (currentPage - 1) * PageSize + 1, currentPage * PageSize);
            int     recordCount = bShipment.GetRecordCount(sb.ToString());

            _currentDt = ds.Tables[0];
            reSetCurrentDt();
            this.dgvData.DataSource = _currentDt;
            this.pgControl.init(GetTotalPage(recordCount), currentPage);
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BllShipmentTable shipmentTable)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BLL_SHIPMENT set ");
            strSql.Append("ORDER_SLIP_NUMBER=@ORDER_SLIP_NUMBER,");
            strSql.Append("SERIAL_NUMBER=@SERIAL_NUMBER,");
            strSql.Append("SLIP_DATE=@SLIP_DATE,");
            strSql.Append("ARRIVAL_DATE=@ARRIVAL_DATE,");
            strSql.Append("AMOUNT=@AMOUNT,");
            strSql.Append("CURRENCY_CODE=@CURRENCY_CODE,");
            strSql.Append("STATUS_FLAG=@STATUS_FLAG,");
            strSql.Append("LAST_UPDATE_TIME=GETDATE(),");
            strSql.Append("LAST_UPDATE_USER=@LAST_UPDATE_USER,");
            strSql.Append("AMOUNT_INCLUDED_TAX=@AMOUNT_INCLUDED_TAX,");
            strSql.Append("AMOUNT_WITHOUT_TAX=@AMOUNT_WITHOUT_TAX,");
            strSql.Append("TAX_RATE=@TAX_RATE,");
            strSql.Append("TAX_AMOUNT=@TAX_AMOUNT");
            strSql.Append(" where SLIP_NUMBER=@SLIP_NUMBER ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SLIP_NUMBER",         SqlDbType.VarChar,   20),
                new SqlParameter("@ORDER_SLIP_NUMBER",   SqlDbType.VarChar,   20),
                new SqlParameter("@SERIAL_NUMBER",       SqlDbType.VarChar,   50),
                new SqlParameter("@SLIP_DATE",           SqlDbType.DateTime),
                new SqlParameter("@ARRIVAL_DATE",        SqlDbType.DateTime),
                new SqlParameter("@AMOUNT",              SqlDbType.Decimal,    9),
                new SqlParameter("@CURRENCY_CODE",       SqlDbType.VarChar,   20),
                new SqlParameter("@STATUS_FLAG",         SqlDbType.Int,        4),
                new SqlParameter("@LAST_UPDATE_USER",    SqlDbType.VarChar,   20),
                new SqlParameter("@AMOUNT_INCLUDED_TAX", SqlDbType.Decimal,    9),
                new SqlParameter("@AMOUNT_WITHOUT_TAX",  SqlDbType.Decimal,    9),
                new SqlParameter("@TAX_RATE",            SqlDbType.Decimal,    5),
                new SqlParameter("@TAX_AMOUNT",          SqlDbType.Decimal, 9)
            };
            parameters[0].Value  = shipmentTable.SLIP_NUMBER;
            parameters[1].Value  = shipmentTable.ORDER_SLIP_NUMBER;
            parameters[2].Value  = shipmentTable.SERIAL_NUMBER;
            parameters[3].Value  = shipmentTable.SLIP_DATE;
            parameters[4].Value  = shipmentTable.ARRIVAL_DATE;
            parameters[5].Value  = shipmentTable.AMOUNT;
            parameters[6].Value  = shipmentTable.CURRENCY_CODE;
            parameters[7].Value  = shipmentTable.STATUS_FLAG;
            parameters[8].Value  = shipmentTable.LAST_UPDATE_USER;
            parameters[9].Value  = shipmentTable.AMOUNT_INCLUDED_TAX;
            parameters[10].Value = shipmentTable.AMOUNT_WITHOUT_TAX;
            parameters[11].Value = shipmentTable.TAX_RATE;
            parameters[12].Value = shipmentTable.TAX_AMOUNT;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BllShipmentTable GetModel(string slipNumber)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 SLIP_NUMBER,ORDER_SLIP_NUMBER,SERIAL_NUMBER,SLIP_DATE,ARRIVAL_DATE,AMOUNT,CURRENCY_CODE,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_TIME,LAST_UPDATE_USER,AMOUNT_INCLUDED_TAX,AMOUNT_WITHOUT_TAX,TAX_RATE,TAX_AMOUNT,COMPANY_CODE ");
            strSql.Append(" from BLL_SHIPMENT ");
            strSql.Append(" where SLIP_NUMBER=@SLIP_NUMBER ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SLIP_NUMBER", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = slipNumber;

            BllShipmentTable shipModel = new BllShipmentTable();
            DataSet          ds        = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                shipModel.SLIP_NUMBER       = ds.Tables[0].Rows[0]["SLIP_NUMBER"].ToString();
                shipModel.ORDER_SLIP_NUMBER = ds.Tables[0].Rows[0]["ORDER_SLIP_NUMBER"].ToString();
                shipModel.SERIAL_NUMBER     = ds.Tables[0].Rows[0]["SERIAL_NUMBER"].ToString();
                if (ds.Tables[0].Rows[0]["SLIP_DATE"].ToString() != "")
                {
                    shipModel.SLIP_DATE = DateTime.Parse(ds.Tables[0].Rows[0]["SLIP_DATE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ARRIVAL_DATE"].ToString() != "")
                {
                    shipModel.ARRIVAL_DATE = DateTime.Parse(ds.Tables[0].Rows[0]["ARRIVAL_DATE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AMOUNT"].ToString() != "")
                {
                    shipModel.AMOUNT = decimal.Parse(ds.Tables[0].Rows[0]["AMOUNT"].ToString());
                }
                shipModel.CURRENCY_CODE = ds.Tables[0].Rows[0]["CURRENCY_CODE"].ToString();
                if (ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString() != "")
                {
                    shipModel.STATUS_FLAG = int.Parse(ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString());
                }
                shipModel.CREATE_USER = ds.Tables[0].Rows[0]["CREATE_USER"].ToString();
                if (ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString() != "")
                {
                    shipModel.CREATE_DATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString());
                }
                if (ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString() != "")
                {
                    shipModel.LAST_UPDATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString());
                }
                shipModel.LAST_UPDATE_USER = ds.Tables[0].Rows[0]["LAST_UPDATE_USER"].ToString();
                if (ds.Tables[0].Rows[0]["AMOUNT_INCLUDED_TAX"].ToString() != "")
                {
                    shipModel.AMOUNT_INCLUDED_TAX = decimal.Parse(ds.Tables[0].Rows[0]["AMOUNT_INCLUDED_TAX"].ToString());
                }
                if (ds.Tables[0].Rows[0]["AMOUNT_WITHOUT_TAX"].ToString() != "")
                {
                    shipModel.AMOUNT_WITHOUT_TAX = decimal.Parse(ds.Tables[0].Rows[0]["AMOUNT_WITHOUT_TAX"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TAX_RATE"].ToString() != "")
                {
                    shipModel.TAX_RATE = decimal.Parse(ds.Tables[0].Rows[0]["TAX_RATE"].ToString());
                }
                if (ds.Tables[0].Rows[0]["TAX_AMOUNT"].ToString() != "")
                {
                    shipModel.TAX_AMOUNT = decimal.Parse(ds.Tables[0].Rows[0]["TAX_AMOUNT"].ToString());
                }
                shipModel.COMPANY_CODE = ds.Tables[0].Rows[0]["COMPANY_CODE"].ToString();

                strSql = new StringBuilder();
                strSql.Append("select  * from BLL_SHIPMENT_LINE ");
                strSql.Append(" where SLIP_NUMBER=@SLIP_NUMBER ");
                SqlParameter[] lineParam =
                {
                    new SqlParameter("@SLIP_NUMBER", SqlDbType.VarChar, 50)
                };
                lineParam[0].Value = slipNumber;
                ds = DbHelperSQL.Query(strSql.ToString(), lineParam);
                BllShipmentLineTable lineModel = null;
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    lineModel             = new BllShipmentLineTable();
                    lineModel.SLIP_NUMBER = CConvert.ToString(row["SLIP_NUMBER"]);
                    lineModel.LINE_NUMBER = CConvert.ToInt32(row["LINE_NUMBER"]);
                    lineModel.DEPARTUAL_WAREHOUSE_CODE = CConvert.ToString(row["DEPARTUAL_WAREHOUSE_CODE"]);
                    lineModel.PRODUCT_CODE             = CConvert.ToString(row["PRODUCT_CODE"]);
                    lineModel.QUANTITY    = CConvert.ToDecimal(row["QUANTITY"]);
                    lineModel.UNIT_CODE   = CConvert.ToString(row["UNIT_CODE"]);
                    lineModel.PRICE       = CConvert.ToDecimal(row["PRICE"]);
                    lineModel.AMOUNT      = CConvert.ToDecimal(row["AMOUNT"]);
                    lineModel.MEMO        = CConvert.ToString(row["MEMO"]);
                    lineModel.STATUS_FLAG = CConvert.ToInt32(row["STATUS_FLAG"]);
                    if (!string.IsNullOrEmpty(lineModel.SLIP_NUMBER))
                    {
                        shipModel.AddItems(lineModel);
                    }
                }
                return(shipModel);
            }
            else
            {
                return(null);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 出库确定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool isExsit = false;

            ht = new Hashtable();
            foreach (DataGridViewRow dgvr in dgvData.Rows)
            {
                if (Convert.ToBoolean(dgvr.Cells["SHIPMENT_CHK"].Value))
                {
                    if (!Convert.ToBoolean(dgvr.Cells["SHIPMENT_FLAG"].Value))
                    {
                        MessageBox.Show("出库条件未满足,请检查订单信息(合同编号,预付款)。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    if (CConvert.ToDecimal(dgvr.Cells["QUANTITY"].Value) > 0)
                    {
                        string slipNumber = CConvert.ToString(dgvr.Cells["TRUE_SLIP_NUMBER"].Value);

                        //预付金额
                        decimal DepositAmount = (new BDepositArr()).GetArrAmount(slipNumber);
                        try
                        {
                            if (CConvert.ToDecimal(dgvr.Cells["SHIPMENT_DEPOSIT"].Value) / 100 > DepositAmount / CConvert.ToDecimal(dgvr.Cells["AMOUNT_INCLUDED_TAX"].Value))
                            {
                                MessageBox.Show("出库时预付款金额未支付或支付不足。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                return;
                            }
                        }
                        catch (Exception ex) { }
                    }

                    if (CConvert.ToDecimal(dgvr.Cells["QUANTITY"].Value) + CConvert.ToDecimal(dgvr.Cells["SHIPMENT_QUANTITY"].Value) > CConvert.ToDecimal(dgvr.Cells["ORDER_QUANTITY"].Value))
                    {
                        MessageBox.Show("本次出库数量与已出库数量之和不能大于销售数量。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    string key = CConvert.ToString(dgvr.Cells["WAREHOUSE_CODE"].Value) + "_" + CConvert.ToString(dgvr.Cells["PRODUCT_CODE"].Value);
                    foreach (DictionaryEntry de in ht)
                    {
                        if (key.Equals(de.Key))
                        {
                            ht[key] = CConvert.ToDecimal(de.Value) + CConvert.ToDecimal(dgvr.Cells["QUANTITY"].Value);
                            isExsit = true;
                            break;
                        }
                    }
                    if (!isExsit)
                    {
                        ht.Add(key, CConvert.ToDecimal(dgvr.Cells["QUANTITY"].Value));
                    }
                }
            }

            foreach (DictionaryEntry de in ht)
            {
                string [] arry      = CConvert.ToString(de.Key).Split('_');
                string    warehouse = arry[0];
                string    product   = arry[1];
                decimal   quantity  = CConvert.ToDecimal(de.Value);
                if (bShipment.GetStock(warehouse, product) < quantity)
                {
                    MessageBox.Show("在库数不足。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
            }

            if (MessageBox.Show("确定要出库吗?", this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                List <BllShipmentTable> datas         = new List <BllShipmentTable>();
                BllShipmentTable        shipmentTable = null;
                DateTime currentDate       = DateTime.Now;
                string   currentSlipNumber = "";
                int      i           = 1;
                decimal  totalAmount = 0;
                foreach (DataGridViewRow dgvr in dgvData.Rows)
                {
                    if (Convert.ToBoolean(dgvr.Cells["SHIPMENT_CHK"].Value) && CConvert.ToDecimal(dgvr.Cells["QUANTITY"].Value) > 0)
                    {
                        string slipNumber = CConvert.ToString(dgvr.Cells["TRUE_SLIP_NUMBER"].Value);

                        if (currentSlipNumber != slipNumber)
                        {
                            if (currentSlipNumber != "")
                            {
                                shipmentTable.AMOUNT = totalAmount;
                                shipmentTable.AMOUNT_INCLUDED_TAX = totalAmount;

                                shipmentTable.AMOUNT_WITHOUT_TAX = WithoutAmount(totalAmount, shipmentTable.TAX_RATE);
                                shipmentTable.TAX_AMOUNT         = totalAmount - shipmentTable.AMOUNT_WITHOUT_TAX;
                                datas.Add(shipmentTable);
                                totalAmount = 0;
                            }
                            currentSlipNumber = slipNumber;
                            shipmentTable     = new BllShipmentTable();
                            i = 1;
                            shipmentTable.ORDER_SLIP_NUMBER = slipNumber;

                            shipmentTable.SERIAL_NUMBER = CConvert.ToString(dgvr.Cells["SERIAL_NUMBER"].Value);
                            shipmentTable.SLIP_DATE     = currentDate;
                            shipmentTable.ARRIVAL_DATE  = CConvert.ToDateTime(dgvr.Cells["DEPARTUAL_DATE"].Value);
                            shipmentTable.TAX_RATE      = CConvert.ToDecimal(dgvr.Cells["TAX_RATE"].Value);

                            shipmentTable.CURRENCY_CODE      = CConvert.ToString(dgvr.Cells["CURRENCY_CODE"].Value);
                            shipmentTable.STATUS_FLAG        = CConstant.INIT;
                            shipmentTable.CREATE_USER        = UserTable.CODE;
                            shipmentTable.LAST_UPDATE_USER   = UserTable.CODE;
                            shipmentTable.COMPANY_CODE       = UserTable.COMPANY_CODE;
                            shipmentTable.CHECK_NUMBER       = CConvert.ToString(dgvr.Cells["CHECK_NUMBER"].Value);
                            shipmentTable.CUSTOMER_PO_NUMBER = CConvert.ToString(dgvr.Cells["CUSTOMER_PO_NUMBER"].Value);
                        }
                        BllShipmentLineTable shipmentLineTable = new BllShipmentLineTable();
                        shipmentLineTable.LINE_NUMBER              = i++;
                        shipmentLineTable.ORDER_LINE_NUMBER        = CConvert.ToInt32(dgvr.Cells["LINE_NUMBER"].Value);
                        shipmentLineTable.DEPARTUAL_WAREHOUSE_CODE = CConvert.ToString(dgvr.Cells["WAREHOUSE_CODE"].Value);
                        shipmentLineTable.PRODUCT_CODE             = CConvert.ToString(dgvr.Cells["PRODUCT_CODE"].Value);
                        shipmentLineTable.QUANTITY    = CConvert.ToDecimal(dgvr.Cells["QUANTITY"].Value);
                        shipmentLineTable.UNIT_CODE   = CConvert.ToString(dgvr.Cells["UNIT_CODE"].Value);
                        shipmentLineTable.PRICE       = CConvert.ToDecimal(dgvr.Cells["PRICE"].Value);
                        shipmentLineTable.AMOUNT      = shipmentLineTable.QUANTITY * shipmentLineTable.PRICE;
                        shipmentLineTable.MEMO        = CConvert.ToString(dgvr.Cells["LINE_MEMO"].Value);
                        shipmentLineTable.STATUS_FLAG = CConstant.INIT;
                        totalAmount += CConvert.ToDecimal(shipmentLineTable.PRICE * shipmentLineTable.QUANTITY);
                        shipmentTable.AddItems(shipmentLineTable);
                    }
                }

                if (shipmentTable != null)
                {
                    shipmentTable.AMOUNT = totalAmount;
                    shipmentTable.AMOUNT_INCLUDED_TAX = totalAmount;
                    shipmentTable.AMOUNT_WITHOUT_TAX  = WithoutAmount(totalAmount, shipmentTable.TAX_RATE);
                    shipmentTable.TAX_AMOUNT          = totalAmount - shipmentTable.AMOUNT_WITHOUT_TAX;
                    datas.Add(shipmentTable);
                }

                //数据表的更新
                if (datas.Count > 0)
                {
                    try
                    {
                        int ret = bShipment.Add(datas);
                        if (ret > 0)
                        {
                            MessageBox.Show("出库确认成功。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            BindData(false);
                        }
                        else
                        {
                            MessageBox.Show("出库确认失败,请重试或与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        MessageBox.Show("出库确认失败,请重试或与管理员联系。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Logger.Error("出库确认失败。", ex);
                    }
                }
                else
                {
                    MessageBox.Show("请先择需要出库的数据,或出库数量小于等于零。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }