Пример #1
0
        /// <summary>
        /// 读取控件参数值
        /// </summary>
        private void ReadFieldValue()
        {
            if (mlItemID > 0)
            {
                DataTable dtBackUp = ExecuteSQL.CallView(203, "", "ItemID=" + mlItemID, "");
                if (dtBackUp.Rows.Count > 0)
                {
                    DataRow dr             = dtBackUp.Rows[0];
                    string  strItemCode    = LBConverter.ToString(dr["ItemCode"]);
                    string  strK3ItemCode  = LBConverter.ToString(dr["K3ItemCode"]);
                    string  strItemName    = LBConverter.ToString(dr["ItemName"]);
                    string  strItemMode    = LBConverter.ToString(dr["ItemMode"]);
                    decimal dItemRate      = LBConverter.ToDecimal(dr["ItemRate"]);
                    long    lUOMID         = LBConverter.ToInt32(dr["UOMID"]);
                    long    lItemTypeID    = LBConverter.ToInt32(dr["ItemTypeID"]);
                    string  strDescription = LBConverter.ToString(dr["Description"]);
                    bool    bIsForbid      = LBConverter.ToBoolean(dr["IsForbid"]);
                    decimal decprice       = LBConverter.ToDecimal(dr["ItemPrice"]);

                    this.txtK3ItemCode.Text          = strK3ItemCode;
                    this.txtItemCode.Text            = strItemCode;
                    this.txtItemName.Text            = strItemName;
                    this.txtItemMode.Text            = strItemMode;
                    this.txtItemRate.Text            = dItemRate.ToString();
                    this.txtUOMID.SelectedValue      = lUOMID;
                    this.txtItemTypeID.SelectedValue = lItemTypeID;
                    this.txtDescription.Text         = strDescription;
                    this.chkIsForbid.Checked         = bIsForbid;
                    this.txtPrice.Text = decprice.ToString("0.000");
                }
            }
        }
Пример #2
0
        private void ReadFieldValue()
        {
            if (mlReceiveBillHeaderID > 0)
            {
                DataTable dtHeader = ExecuteSQL.CallView(111, "", "ReceiveBillHeaderID=" + mlReceiveBillHeaderID, "");
                if (dtHeader.Rows.Count > 0)
                {
                    DataRow drHeader                    = dtHeader.Rows[0];
                    bool    bolIsApprove                = LBConverter.ToBoolean(drHeader["IsApprove"]);
                    bool    bolIsCancel                 = LBConverter.ToBoolean(drHeader["IsCancel"]);
                    decimal decReceiveAmount            = LBConverter.ToDecimal(drHeader["ReceiveAmount"]);
                    decimal decSalesReceiveAmountAdd    = LBConverter.ToDecimal(drHeader["SalesReceiveAmountAdd"]);
                    decimal decSalesReceiveAmountReduce = LBConverter.ToDecimal(drHeader["SalesReceiveAmountReduce"]);
                    decimal decOriginalAmount           = LBConverter.ToDecimal(drHeader["OriginalAmount"]);
                    this.txtBillDate.Text   = LBConverter.ToString(drHeader["BillDate"]);
                    this.txtBillStatus.Text = bolIsApprove?"已审核":
                                              (bolIsCancel?"已作废":("未审核"));
                    this.txtCustomerID.TextBox.SelectedItemID = drHeader["CustomerID"].ToString();
                    this.txtDescription.Text     = drHeader["Description"].ToString();
                    this.txtReceiveAmount.Text   = decReceiveAmount.ToString("N0");
                    this.txtReceiveBillCode.Text = drHeader["ReceiveBillCode"].ToString();

                    this.txtChangedBy.Text   = drHeader["ChangedBy"].ToString();
                    this.txtChangeTime.Text  = drHeader["ChangeTime"].ToString();
                    this.txtApproveBy.Text   = drHeader["ApproveBy"].ToString();
                    this.txtApproveTime.Text = drHeader["ApproveTime"].ToString();
                    this.txtCancelBy.Text    = drHeader["CancelBy"].ToString();
                    this.txtCancelTime.Text  = drHeader["CancelTime"].ToString();
                    this.txtRPReceiveType.TextBox.SelectedItemID = drHeader["ChargeTypeID"];
                    this.txtReceiveBankID.TextBox.SelectedItemID = drHeader["ReceiveBankID"];
                }
            }
        }
Пример #3
0
        private long SaveInBill()
        {
            long lCarID       = LBConverter.ToInt64(this.txtCarID.TextBox.SelectedItemID);
            long lItemID      = LBConverter.ToInt64(this.txtItemID.TextBox.SelectedItemID);
            long lCustomerID  = LBConverter.ToInt64(this.txtCustomerID.TextBox.SelectedItemID);
            int  iReceiveType = 1;

            using (DataTable dtCustomer = ExecuteSQL.CallView(112, "CustomerID,ReceiveType,TotalReceivedAmount,SalesReceivedAmount", "CustomerID=" + lCustomerID.ToString(), ""))
            {
                if (dtCustomer.Rows.Count > 0)
                {
                    lCustomerID = LBConverter.ToInt64(dtCustomer.Rows[0]["CustomerID"]);
                    //客户收款方式
                    iReceiveType = LBConverter.ToInt32(dtCustomer.Rows[0]["ReceiveType"]);
                }
            }

            Dictionary <string, double> dictTest = new Dictionary <string, double>();
            DateTime dt1 = DateTime.Now;
            DateTime dt2 = DateTime.Now;
            long     lSaleCarInBillID = 0;

            int     iCalculateType = LBConverter.ToInt32(this.txtCalculateType.SelectedValue);
            decimal decCarTare     = LBConverter.ToDecimal(this.txtCarTare.Text);
            string  strBillDateIn  = Convert.ToDateTime(this.txtBillDateIn.Text).ToString("yyyy-MM-dd") + " " +
                                     Convert.ToDateTime(this.txtBillTimeIn.Text).ToString("HH:mm:ss");

            if (decCarTare == 0)
            {
                throw new Exception("当前【皮重】值为0,无法保存!");
            }

            LBDbParameterCollection parmCol = new LBDbParameterCollection();

            parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, 0));
            parmCol.Add(new LBParameter("SaleCarInBillCode", enLBDbType.String, ""));
            parmCol.Add(new LBParameter("BillDate", enLBDbType.DateTime, Convert.ToDateTime(strBillDateIn)));
            parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, lCarID));
            parmCol.Add(new LBParameter("ItemID", enLBDbType.Int64, lItemID));
            parmCol.Add(new LBParameter("CustomerID", enLBDbType.Int64, lCustomerID));
            parmCol.Add(new LBParameter("Description", enLBDbType.String, this.txtAddReason.Text));
            parmCol.Add(new LBParameter("ReceiveType", enLBDbType.Int32, iReceiveType));
            parmCol.Add(new LBParameter("CalculateType", enLBDbType.Int32, iCalculateType));
            parmCol.Add(new LBParameter("CarTare", enLBDbType.Decimal, decCarTare));

            DataSet dsReturn;
            Dictionary <string, object> dictValue;

            ExecuteSQL.CallSP(14100, parmCol, out dsReturn, out dictValue);
            if (dictValue.ContainsKey("SaleCarInBillID"))
            {
                lSaleCarInBillID = LBConverter.ToInt64(dictValue["SaleCarInBillID"]);
            }
            if (dictValue.ContainsKey("SaleCarInBillCode"))
            {
                this.txtSaleCarInBillCode.Text = dictValue["SaleCarInBillCode"].ToString();
            }

            return(lSaleCarInBillID);
        }
Пример #4
0
        private void CalWeight()
        {
            decimal decTotalWeight = LBConverter.ToDecimal(this.txtTotalWeight.Text);
            decimal decCarTare     = LBConverter.ToDecimal(this.txtCarTare.Text);

            this.txtSuttleWeight.Text = (decTotalWeight - decCarTare).ToString("0");
        }
Пример #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.VerifyTextBoxIsEmpty();//校验控件是否为空

                long lSupplierID = LBConverter.ToInt64(this.txtSupplierID.SelectedValue);
                long lCardID     = LBConverter.ToInt64(this.txtCardID.SelectedValue);
                //先判断该卡片是否已绑定了其他车辆,提示用户是否取消绑定
                if (lCardID > 0)
                {
                    string strBindCarNum;
                    bool   bolExists = this.GetCardRefCarInfo(lCardID, out strBindCarNum);
                    if (bolExists)
                    {
                        if (LB.WinFunction.LBCommonHelper.ConfirmMessage("该卡号已关联车牌【" + strBindCarNum + "】,是否取消与该车牌的关联?", "提示", MessageBoxButtons.YesNo) != DialogResult.Yes)
                        {
                            return;
                        }
                    }
                }

                int iSPType = 13500;
                if (mlCarID > 0)
                {
                    iSPType = 13501;
                }

                LBDbParameterCollection parmCol = new LBDbParameterCollection();
                parmCol.Add(new LBParameter("SupplierID", enLBDbType.Int64, lSupplierID));
                parmCol.Add(new LBParameter("CardID", enLBDbType.Int64, lCardID));
                parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, mlCarID));
                parmCol.Add(new LBParameter("CarNum", enLBDbType.String, this.txtCarNum.Text));
                parmCol.Add(new LBParameter("CarCode", enLBDbType.String, this.txtCarCode.Text));
                parmCol.Add(new LBParameter("Description", enLBDbType.String, this.txtDescription.Text));
                parmCol.Add(new LBParameter("DefaultCarWeight", enLBDbType.Decimal, LBConverter.ToDecimal(this.txtDefaultCarWeight.Text)));

                DataSet dsReturn;
                Dictionary <string, object> dictValue;
                ExecuteSQL.CallSP(iSPType, parmCol, out dsReturn, out dictValue);
                if (dictValue.ContainsKey("CarID"))
                {
                    mlCarID = LBConverter.ToInt64(dictValue["CarID"]);
                }
                if (dictValue.ContainsKey("CarCode"))
                {
                    this.txtCarCode.Text = dictValue["CarCode"].ToString();
                }
                LB.WinFunction.LBCommonHelper.ShowCommonMessage("保存成功!");
                SetButtonStatus();
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #6
0
        private void btnChangeBillInfoSave_Click(object sender, EventArgs e)
        {
            try
            {
                long lCarID      = LBConverter.ToInt64(this.txtCarID.TextBox.SelectedItemID);
                long lItemID     = LBConverter.ToInt64(this.txtItemID.TextBox.SelectedItemID);
                long lCustomerID = LBConverter.ToInt64(this.txtCustomerID.TextBox.SelectedItemID);
                if (lItemID == 0)
                {
                    throw new Exception("请输入正确的货物名称!");
                }
                if (lCustomerID == 0)
                {
                    throw new Exception("请输入正确的客户名称!");
                }
                LBDbParameterCollection parmCol = new LBDbParameterCollection();
                parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, mlSaleCarInBillID));
                parmCol.Add(new LBParameter("ItemID", enLBDbType.Int64, lItemID));
                parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, lCarID));
                parmCol.Add(new LBParameter("CustomerID", enLBDbType.Int64, lCustomerID));
                parmCol.Add(new LBParameter("Price", enLBDbType.Decimal, LBConverter.ToDecimal(this.txtPrice.Text)));
                parmCol.Add(new LBParameter("Amount", enLBDbType.Decimal, LBConverter.ToDecimal(this.txtAmount.Text)));
                parmCol.Add(new LBParameter("Description", enLBDbType.String, this.txtDescription.Text));

                DataSet dsReturn;
                Dictionary <string, object> dictValue;
                ExecuteSQL.CallSP(14116, parmCol, out dsReturn, out dictValue);
                if (LB.WinFunction.LBCommonHelper.ConfirmMessage("修改成功!是否自动审核该磅单?", "提示", MessageBoxButtons.YesNo) ==
                    DialogResult.Yes)
                {
                    AppeoveBill();
                }
                else
                {
                    ReadFeildValue();
                }

                btnChangeBillInfoSave.Visible        = false;
                this.btnChangeBillInfoDirect.Visible = true;
                this.txtItemID.TextBox.ReadOnly      = true;
                this.txtCarID.TextBox.ReadOnly       = true;
                this.txtCustomerID.TextBox.ReadOnly  = true;
                this.txtDescription.ReadOnly         = true;
                txtPrice.ReadOnly = true;

                this.btnApprove.Visible   = true;
                this.btnUnApprove.Visible = true;
                this.btnCancel.Visible    = true;
                this.btnUnCancel.Visible  = true;
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #7
0
 private void TxtPrice_TextChanged(object sender, EventArgs e)
 {
     try
     {
         decimal decStuffWeight = LBConverter.ToDecimal(txtSuttleWeight.Text);
     }
     catch (Exception ex)
     {
         LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
     }
 }
Пример #8
0
 private void TxtReceiveAmount_Leave(object sender, EventArgs e)
 {
     try
     {
         decimal decReceiveAmount = LBConverter.ToDecimal(this.txtReceiveAmount.Text);
         this.txtReceiveAmount.Text = String.Format("{0:N}", decReceiveAmount);
     }
     catch (Exception ex)
     {
         LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
     }
 }
Пример #9
0
        /// <summary>
        /// 读取物料价格
        /// </summary>
        /// <param name="sender"></param>
        private void ReadPrice()
        {
            //if (sender == this.txtCustomerID.TextBox || sender == this.txtCarID.TextBox || sender == this.txtItemID.TextBox || sender == this.txtCalculateType)
            {
                this.txtPrice.Text = "0";

                string strCarNum       = this.txtCarID.TextBox.Text.ToString();
                string strItemName     = this.txtItemID.TextBox.Text.ToString();
                string strCustomerName = this.txtCustomerID.TextBox.Text.ToString();

                if (this.txtCustomerID.TextBox.SelectedRow != null)
                {
                    decimal decTotalReceivedAmount = LBConverter.ToDecimal(this.txtCustomerID.TextBox.SelectedRow["TotalReceivedAmount"]);
                    decimal decSalesReceivedAmount = LBConverter.ToDecimal(this.txtCustomerID.TextBox.SelectedRow["SalesReceivedAmount"]);
                }

                if (strCarNum == "" || strItemName == "")
                {
                    return;
                }

                long lCarID      = 0;
                long lItemID     = 0;
                long lCustomerID = 0;
                using (DataTable dtCar = ExecuteSQL.CallView(113, "CarID", "CarNum='" + strCarNum + "'", ""))
                {
                    if (dtCar.Rows.Count > 0)
                    {
                        lCarID = LBConverter.ToInt64(dtCar.Rows[0]["CarID"]);
                    }
                }
                using (DataTable dtItem = ExecuteSQL.CallView(203, "ItemID", "ItemName='" + strItemName + "'", ""))
                {
                    if (dtItem.Rows.Count > 0)
                    {
                        lItemID = LBConverter.ToInt64(dtItem.Rows[0]["ItemID"]);
                    }
                }

                using (DataTable dtCustomer = ExecuteSQL.CallView(112, "CustomerID,ReceiveType,TotalReceivedAmount,SalesReceivedAmount", "CustomerName='" + strCustomerName + "'", ""))
                {
                    if (dtCustomer.Rows.Count > 0)
                    {
                        lCustomerID = LBConverter.ToInt64(dtCustomer.Rows[0]["CustomerID"]);
                        //客户收款方式
                        this.txtReceiveType.SelectedValue = LBConverter.ToInt32(dtCustomer.Rows[0]["ReceiveType"]);
                    }
                }

                ReadPrice(lCarID, lItemID, lCustomerID);
            }
        }
Пример #10
0
        private long SaveInBill()
        {
            Dictionary <string, double> dictTest = new Dictionary <string, double>();
            DateTime dt1 = DateTime.Now;
            DateTime dt2 = DateTime.Now;
            long     lSaleCarInBillID = 0;
            long     lCarID           = LBConverter.ToInt64(this.txtCarID.TextBox.SelectedItemID);
            long     lSupplierID      = LBConverter.ToInt64(this.txtSupplierID.TextBox.SelectedItemID);
            decimal  decCarTare       = LBConverter.ToDecimal(this.txtCarTare.Text);
            decimal  decTotalWeight   = LBConverter.ToDecimal(this.txtTotalWeight.Text);
            decimal  decSuttleWeight  = LBConverter.ToDecimal(this.txtSuttleWeight.Text);
            DateTime dtDate           = Convert.ToDateTime(txtBillDateIn.Text + " " + this.txtBillTimeIn.Text);

            if (decCarTare == 0)
            {
                throw new Exception("当前【皮重】值为0,无法保存!");
            }
            if (decTotalWeight == 0)
            {
                throw new Exception("当前【毛重】值为0,无法保存!");
            }
            if (decSuttleWeight <= 0)
            {
                throw new Exception("当前【净重】值为0,无法保存!");
            }

            LBDbParameterCollection parmCol = new LBDbParameterCollection();

            parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, 0));
            parmCol.Add(new LBParameter("SaleCarInBillCode", enLBDbType.String, ""));
            parmCol.Add(new LBParameter("BillDate", enLBDbType.DateTime, dtDate));
            parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, lCarID));
            parmCol.Add(new LBParameter("SupplierID", enLBDbType.Int64, lSupplierID));
            parmCol.Add(new LBParameter("CarTare", enLBDbType.Decimal, decCarTare));
            parmCol.Add(new LBParameter("TotalWeight", enLBDbType.Decimal, decTotalWeight));
            parmCol.Add(new LBParameter("SuttleWeight", enLBDbType.Decimal, decTotalWeight - decCarTare));
            parmCol.Add(new LBParameter("CardCode", enLBDbType.String, ""));

            DataSet dsReturn;
            Dictionary <string, object> dictValue;

            ExecuteSQL.CallSP(14100, parmCol, out dsReturn, out dictValue);
            if (dictValue.ContainsKey("SaleCarInBillID"))
            {
                lSaleCarInBillID = LBConverter.ToInt64(dictValue["SaleCarInBillID"]);
            }

            return(lSaleCarInBillID);
        }
Пример #11
0
        private void ReadFieldValue()
        {
            if (mlCustomerID > 0)
            {
                DataTable dtHeader = ExecuteSQL.CallView(112, "", "CustomerID=" + mlCustomerID, "");
                if (dtHeader.Rows.Count > 0)
                {
                    DataRow drHeader = dtHeader.Rows[0];

                    this.txtK3CustomerCode.Text          = drHeader["K3CustomerCode"].ToString();
                    this.txtCustomerCode.Text            = drHeader["CustomerCode"].ToString();
                    this.txtCustomerName.Text            = drHeader["CustomerName"].ToString();
                    this.txtDescription.Text             = drHeader["Description"].ToString();
                    this.txtContact.Text                 = drHeader["Contact"].ToString();
                    this.txtPhone.Text                   = drHeader["Phone"].ToString();
                    this.txtAddress.Text                 = drHeader["Address"].ToString();
                    this.txtCreditAmount.Text            = drHeader["CreditAmount"].ToString();
                    this.txtAmountType.SelectedValue     = LBConverter.ToInt32(drHeader["AmountType"]);
                    this.txtReceiveType.SelectedValue    = LBConverter.ToInt32(drHeader["ReceiveType"]);
                    this.txtCustomerTypeID.SelectedValue = LBConverter.ToInt32(drHeader["CustomerTypeID"]);
                    this.txtAmountNotEnough.Text         = drHeader["AmountNotEnough"].ToString();

                    this.chkCarIsLimit.Checked      = LBConverter.ToBoolean(drHeader["CarIsLimit"]);
                    this.chkIsDisplayPrice.Checked  = LBConverter.ToBoolean(drHeader["IsDisplayPrice"]);
                    this.chkIsDisplayAmount.Checked = LBConverter.ToBoolean(drHeader["IsDisplayAmount"]);
                    this.chkIsPrintAmount.Checked   = LBConverter.ToBoolean(drHeader["IsPrintAmount"]);
                    this.chkIsAllowOverFul.Checked  = LBConverter.ToBoolean(drHeader["IsAllowOverFul"]);
                    this.chkIsAllowEmptyIn.Checked  = LBConverter.ToBoolean(drHeader["IsAllowEmptyIn"]);

                    this.txtCreateBy.Text   = drHeader["CreateBy"].ToString();
                    this.txtCreateTime.Text = drHeader["CreateTime"].ToString();
                    this.txtChangeBy.Text   = drHeader["ChangeBy"].ToString();
                    this.txtChangeTime.Text = drHeader["ChangeTime"].ToString();

                    decimal decSalesReceivedAmount = LBConverter.ToDecimal(drHeader["SalesReceivedAmount"]);
                    decimal decTotalReceivedAmount = LBConverter.ToDecimal(drHeader["TotalReceivedAmount"]);
                    decimal decOverRangeAmount     = decSalesReceivedAmount - decTotalReceivedAmount;
                    this.lblOverRangeAmount.Text = decOverRangeAmount > 0 ? decOverRangeAmount.ToString("0.00") : "0";
                    this.lblRemainAmount.Text    = decTotalReceivedAmount > decSalesReceivedAmount ? (decTotalReceivedAmount - decSalesReceivedAmount).ToString("0.00") : "0";

                    //是否禁用
                    bool bolIsForbid = LBConverter.ToBoolean(drHeader["IsForbid"]);
                    this.btnForbid.Visible   = !bolIsForbid;
                    this.btnUnForbid.Visible = bolIsForbid;
                    this.lblForbid.Visible   = bolIsForbid;
                }
            }
        }
Пример #12
0
        private bool ReadTareWeight()
        {
            VerifyDeviceIsSteady();                                    //校验地磅数值是否稳定以及红外线对射是否正常

            decimal decWeight = LBConverter.ToDecimal(lblWeight.Text); //读皮重

            if (decWeight == 0)
            {
                throw new Exception("当前【皮重】读数值为0!");
            }
            else
            {
                this.txtDefaultCarWeight.Text = decWeight.ToString("0");
                return(true);
            }
        }
Пример #13
0
        private void btnOutWeight_Click(object sender, EventArgs e)
        {
            try
            {
                //先读取重量
                VerifyDeviceIsSteady();                                    //校验地磅数值是否稳定以及红外线对射是否正常
                VerifyTextBoxIsEmpty();                                    //判断相关控件值是否为空

                decimal decWeight = LBConverter.ToDecimal(lblWeight.Text); //读皮重

                this.txtOutWeight.Text = decWeight.ToString("0");
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #14
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.VerifyTextBoxIsEmpty();//校验控件是否为空

                //判断车牌号码是否大于等于6位
                if (this.txtCarNum.Text.TrimEnd().Length < 6)
                {
                    throw new Exception("车牌号码必须大于等于6位数!");
                }

                int iSPType = 13500;
                if (mlCarID > 0)
                {
                    iSPType = 13501;
                }
                mlCustomerID = LBConverter.ToInt64(this.txtCustomerID.SelectedValue);
                LBDbParameterCollection parmCol = new LBDbParameterCollection();
                parmCol.Add(new LBParameter("CustomerID", enLBDbType.Int64, mlCustomerID));
                parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, mlCarID));
                parmCol.Add(new LBParameter("CarNum", enLBDbType.String, this.txtCarNum.Text));
                parmCol.Add(new LBParameter("CarCode", enLBDbType.String, this.txtCarCode.Text));
                parmCol.Add(new LBParameter("Description", enLBDbType.String, this.txtDescription.Text));
                parmCol.Add(new LBParameter("DefaultCarWeight", enLBDbType.Decimal, LBConverter.ToDecimal(this.txtDefaultCarWeight.Text)));

                DataSet dsReturn;
                Dictionary <string, object> dictValue;
                ExecuteSQL.CallSP(iSPType, parmCol, out dsReturn, out dictValue);
                if (dictValue.ContainsKey("CarID"))
                {
                    mlCarID = LBConverter.ToInt64(dictValue["CarID"]);
                }
                if (dictValue.ContainsKey("CarCode"))
                {
                    this.txtCarCode.Text = dictValue["CarCode"].ToString();
                }
                LB.WinFunction.LBCommonHelper.ShowCommonMessage("保存成功!");
                SetButtonStatus();
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #15
0
        private void CalAmount()
        {
            decimal decTotalWeight = LBConverter.ToDecimal(this.txtTotalWeight.Text);
            decimal decCarTare     = LBConverter.ToDecimal(this.txtCarTare.Text);
            int     iCalculateType = LBConverter.ToInt32(this.txtCalculateType.SelectedValue);//0按重量计算 1按车计算

            this.txtSuttleWeight.Text = (decTotalWeight - decCarTare).ToString("0");
            decimal decPrice = LBConverter.ToDecimal(this.txtPrice.Text);

            if (iCalculateType == 0)
            {
                this.txtAmount.Text = (decPrice * (decTotalWeight - decCarTare)).ToString("0.00");
            }
            else
            {
                this.txtAmount.Text = decPrice.ToString("0.00");
            }
        }
Пример #16
0
 private void TxtPrice_TextChanged(object sender, EventArgs e)
 {
     try
     {
         decimal decStuffWeight = LBConverter.ToDecimal(txtSuttleWeight.Text);
         decimal decPrice       = LBConverter.ToDecimal(this.txtPrice.Text);
         int     iCalculateType = LBConverter.ToInt32(txtCalculateType.SelectedValue);
         if (iCalculateType == 0)//按重量
         {
             this.txtAmount.Text = (decPrice * decStuffWeight).ToString("0.00");
         }
         else if (iCalculateType == 0)//按车
         {
             this.txtAmount.Text = (decPrice * 1).ToString("0.00");
         }
     }
     catch (Exception ex)
     {
         LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
     }
 }
Пример #17
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                this.VerifyTextBoxIsEmpty();//校验控件值是否为空

                int iSPType = mlItemID > 0 ? 20301 : 20300;

                LBDbParameterCollection parmCol = new LBDbParameterCollection();
                parmCol.Add(new LBParameter("ItemID", enLBDbType.Int64, mlItemID));
                parmCol.Add(new LBParameter("ItemTypeID", enLBDbType.Int64, this.txtItemTypeID.SelectedValue));
                parmCol.Add(new LBParameter("ItemCode", enLBDbType.String, this.txtItemCode.Text));
                parmCol.Add(new LBParameter("K3ItemCode", enLBDbType.String, this.txtK3ItemCode.Text));
                parmCol.Add(new LBParameter("ItemName", enLBDbType.String, this.txtItemName.Text));
                parmCol.Add(new LBParameter("ItemMode", enLBDbType.String, this.txtItemMode.Text));
                parmCol.Add(new LBParameter("ItemRate", enLBDbType.Decimal, LBConverter.ToDecimal(this.txtItemRate.Text)));
                parmCol.Add(new LBParameter("ItemPrice", enLBDbType.Decimal, LBConverter.ToDecimal(this.txtPrice.Text)));
                parmCol.Add(new LBParameter("UOMID", enLBDbType.Int64, this.txtUOMID.SelectedValue));
                parmCol.Add(new LBParameter("Description", enLBDbType.String, this.txtDescription.Text));
                parmCol.Add(new LBParameter("IsForbid", enLBDbType.Boolean, this.chkIsForbid.Checked));

                DataSet dsReturn;
                Dictionary <string, object> dictValue;
                ExecuteSQL.CallSP(iSPType, parmCol, out dsReturn, out dictValue);
                if (dictValue.ContainsKey("ItemID"))
                {
                    long.TryParse(dictValue["ItemID"].ToString(), out mlItemID);
                }
                if (dictValue.ContainsKey("ItemCode"))
                {
                    this.txtItemCode.Text = dictValue["ItemCode"].ToString();
                }
                LB.WinFunction.LBCommonHelper.ShowCommonMessage("保存成功!");
                btnDelete.Visible = mlItemID > 0;
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #18
0
        private void ReadPrice(long lCarID, long lItemID, long lCustomerID)
        {
            this.txtPrice.Text = "0";
            int iCalculateType = LBConverter.ToInt32(this.txtCalculateType.SelectedValue);

            if (lCarID > 0 && lItemID > 0)
            {
                LBDbParameterCollection parmCol = new LBDbParameterCollection();
                parmCol.Add(new LBParameter("ItemID", enLBDbType.Int64, lItemID));
                parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, lCarID));
                parmCol.Add(new LBParameter("CustomerID", enLBDbType.Int64, lCustomerID));
                parmCol.Add(new LBParameter("CalculateType", enLBDbType.Int32, iCalculateType));

                DataSet dsReturn;
                Dictionary <string, object> dictValue;
                ExecuteSQL.CallSP(13608, parmCol, out dsReturn, out dictValue);
                if (dictValue.ContainsKey("Price"))
                {
                    this.txtPrice.Text = LBConverter.ToDecimal(dictValue["Price"]).ToString("0.000");
                }
            }
        }
Пример #19
0
        //选择车辆触发事件
        private void CarTextBox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string  strCarNum           = this.txtCarID.TextBox.Text.ToString();
                long    lCarID              = 0;
                long    lSupplierID         = 0;
                decimal decDefaultCarWeight = 0;
                #region -- 读取车辆ID号 --
                using (DataTable dtCar = ExecuteSQL.CallView(117, "CarID,SupplierID,DefaultCarWeight", "CarNum='" + strCarNum + "'", ""))
                {
                    if (dtCar.Rows.Count > 0)
                    {
                        lCarID              = LBConverter.ToInt64(dtCar.Rows[0]["CarID"]);
                        lSupplierID         = LBConverter.ToInt64(dtCar.Rows[0]["SupplierID"]);
                        decDefaultCarWeight = LBConverter.ToInt64(dtCar.Rows[0]["DefaultCarWeight"]);
                    }
                }
                #endregion -- 读取车辆ID号 --

                if (lCarID > 0)//如果存在该车辆
                {
                    this.txtSupplierID.TextBox.SelectedItemID = lSupplierID;
                    this.txtCarTare.Text = LBConverter.ToString(decDefaultCarWeight);
                }
                else
                {
                    this.txtSupplierID.TextBox.Text = "";
                    this.txtCarTare.Text            = "";
                }

                this.txtSuttleWeight.Text = (LBConverter.ToDecimal(this.txtTotalWeight.Text) - decDefaultCarWeight).ToString();
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #20
0
 public frmChooseReceiveType(int iReceiveType,
                             string strCustomerName,
                             string strCarNum,
                             string strItem,
                             string strAmount,
                             string strCustomerLeftAmount,
                             bool bolIsDisplayAmount)
 {
     InitializeComponent();
     ReceiveType = iReceiveType;
     decimal.TryParse(strAmount, out decAmount);
     if (bolIsDisplayAmount)
     {
         this.lblAmount.Text = strAmount;
     }
     this.lblCarNum.Text       = strCarNum;
     this.lblCustomerName.Text = strCustomerName;
     this.lblItem.Text         = strItem;
     this.lblRemainAmount.Text = strCustomerLeftAmount;
     this.bolIsDisplayAmount   = bolIsDisplayAmount;
     //this.txtReceiveType.SelectedValue = ReceiveType;
     decCustomerLeftAmount = LBConverter.ToDecimal(strCustomerLeftAmount);
 }
Пример #21
0
        private void SaveHeader()
        {
            this.VerifyTextBoxIsEmpty();
            int iSPType = 13600;

            if (mModifyBillHeaderID > 0)
            {
                iSPType = 13601;
            }

            LBDbParameterCollection parmCol = new LBDbParameterCollection();

            parmCol.Add(new LBParameter("ModifyBillHeaderID", enLBDbType.Int64, mModifyBillHeaderID));
            parmCol.Add(new LBParameter("CustomerID", enLBDbType.Int64, this.txtCustomerID.TextBox.SelectedItemID));
            parmCol.Add(new LBParameter("ModifyBillCode", enLBDbType.String, this.txtModifyBillCode.Text));
            parmCol.Add(new LBParameter("BillDate", enLBDbType.DateTime, this.txtBillDate.Text));
            parmCol.Add(new LBParameter("EffectDate", enLBDbType.DateTime, this.txtEffectDate.Text));
            parmCol.Add(new LBParameter("Description", enLBDbType.String, this.txtDescription.Text));

            DataSet dsReturn;
            Dictionary <string, object> dictValue;

            ExecuteSQL.CallSP(iSPType, parmCol, out dsReturn, out dictValue);
            if (dictValue.ContainsKey("ModifyBillHeaderID"))
            {
                mModifyBillHeaderID = LBConverter.ToInt64(dictValue["ModifyBillHeaderID"]);
            }
            if (dictValue.ContainsKey("ModifyBillCode"))
            {
                this.txtModifyBillCode.Text = dictValue["ModifyBillCode"].ToString();
            }

            #region -- 保存明细 --

            string strMsg;
            bool   bolExistsSave = ExistsSameDetail(out strMsg);
            if (bolExistsSave)
            {
                throw new Exception(strMsg);
            }

            this.grdMain.EndEdit();
            this.grdMain.CurrentCell = null;
            DataView dvResult = this.grdMain.DataSource as DataView;
            //int iRowIndex = 0;
            StringBuilder strError = new StringBuilder();
            int           iIndex   = 0;
            foreach (DataRow dr in dvResult.Table.Rows)
            {
                iIndex++;
                if (dr.RowState != DataRowState.Added &&
                    dr.RowState != DataRowState.Modified &&
                    dr.RowState != DataRowState.Deleted)
                {
                    continue;
                }

                parmCol = new LBDbParameterCollection();

                if (dr.RowState == DataRowState.Deleted)
                {
                    long lModifyBillDetailID = dr["ModifyBillDetailID", DataRowVersion.Original] == DBNull.Value ?
                                               0 : Convert.ToInt64(dr["ModifyBillDetailID", DataRowVersion.Original]);
                    if (lModifyBillDetailID > 0)
                    {
                        parmCol.Add(new LBParameter("ModifyBillDetailID", enLBDbType.Int64, lModifyBillDetailID));
                        ExecuteSQL.CallSP(13702, parmCol, out dsReturn, out dictValue);
                    }
                }
                else
                {
                    long lModifyBillDetailID = dr["ModifyBillDetailID"] == DBNull.Value ?
                                               0 : Convert.ToInt64(dr["ModifyBillDetailID"]);
                    long    ItemID        = LBConverter.ToInt64(dr["ItemID"]);
                    long    CarID         = LBConverter.ToInt64(dr["CarID"]);
                    int     CalculateType = LBConverter.ToInt32(dr["CalculateType"]);
                    decimal Price         = LBConverter.ToDecimal(dr["Price"]);
                    long    UOMID         = LBConverter.ToInt64(dr["UOMID"]);
                    string  Description   = dr["Description"].ToString().TrimEnd();
                    decimal MaterialPrice = LBConverter.ToDecimal(dr["MaterialPrice"]);
                    decimal FarePrice     = LBConverter.ToDecimal(dr["FarePrice"]);
                    decimal TaxPrice      = LBConverter.ToDecimal(dr["TaxPrice"]);
                    decimal BrokerPrice   = LBConverter.ToDecimal(dr["BrokerPrice"]);

                    iSPType = 13700;//Insert

                    if (lModifyBillDetailID > 0)
                    {
                        parmCol.Add(new LBParameter("ModifyBillDetailID", enLBDbType.Int64, lModifyBillDetailID));
                        iSPType = 13701;//Update
                    }
                    else
                    {
                        parmCol.Add(new LBParameter("ModifyBillDetailID", enLBDbType.Int64, lModifyBillDetailID, true));
                    }

                    parmCol.Add(new LBParameter("ModifyBillHeaderID", enLBDbType.Int64, mModifyBillHeaderID));
                    parmCol.Add(new LBParameter("ItemID", enLBDbType.Int64, ItemID));
                    if (CarID > 0)
                    {
                        parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, CarID));
                    }
                    parmCol.Add(new LBParameter("CalculateType", enLBDbType.Int16, CalculateType));
                    parmCol.Add(new LBParameter("Price", enLBDbType.Decimal, Price));
                    parmCol.Add(new LBParameter("MaterialPrice", enLBDbType.Decimal, MaterialPrice));
                    parmCol.Add(new LBParameter("FarePrice", enLBDbType.Decimal, FarePrice));
                    parmCol.Add(new LBParameter("TaxPrice", enLBDbType.Decimal, TaxPrice));
                    parmCol.Add(new LBParameter("BrokerPrice", enLBDbType.Decimal, BrokerPrice));
                    parmCol.Add(new LBParameter("UOMID", enLBDbType.Int64, UOMID));
                    parmCol.Add(new LBParameter("Description", enLBDbType.String, Description));

                    try
                    {
                        ExecuteSQL.CallSP(iSPType, parmCol, out dsReturn, out dictValue);
                        //dgvr.ErrorText = "";
                        if (dictValue.ContainsKey("ModifyBillDetailID"))
                        {
                            dr["ModifyBillDetailID"] = dictValue["ModifyBillDetailID"];
                        }
                    }
                    catch (Exception ex)
                    {
                        //dgvr.ErrorText = ex.Message;
                        strError.AppendLine("第" + (iIndex + 1).ToString() + "行保存失败:" + ex.Message);
                    }
                }
            }
            dvResult.Table.AcceptChanges();
            if (strError.ToString() != "")
            {
                throw new Exception(strError.ToString());
            }
            LB.WinFunction.LBCommonHelper.ShowCommonMessage("保存成功!");

            #endregion -- 保存明细 --

            //刷新单头信息
            ReadFieldValue(mModifyBillHeaderID);

            ReadDetailData(mModifyBillHeaderID);
        }
Пример #22
0
        private void LoadAllSalesBill()
        {
            string strFilter = "";

            if (this.txtCustomerID.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CustomerName like '%" + this.txtCustomerID.Text + "%'";
            }

            if (this.txtCustomerTypeID.SelectedValue != null)
            {
                long lCustomerTypeID;
                long.TryParse(this.txtCustomerTypeID.SelectedValue.ToString(), out lCustomerTypeID);
                if (lCustomerTypeID > 0)
                {
                    if (strFilter != "")
                    {
                        strFilter += " and ";
                    }
                    strFilter += "CustomerTypeID =" + lCustomerTypeID;
                }
            }

            if (this.txtCarID.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CarNum like '%" + this.txtCarID.Text + "%'";
            }

            if (this.txtItemID.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "ItemName like '%" + this.txtItemID.Text + "%'";
            }

            if (this.txtBillCode.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "SaleCarInBillCode like '%" + this.txtBillCode.Text + "%'";
            }


            if (this.txtBillCodeOut.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "SaleCarOutBillCode like '%" + this.txtBillCodeOut.Text + "%'";
            }

            if (this.txtOutBillCraeteBy.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CreateByOut like '%" + this.txtOutBillCraeteBy.Text + "%'";
            }

            if (cbUseInDate.Checked)
            {
                if (this.txtInBillDateFrom.Text != "")
                {
                    if (strFilter != "")
                    {
                        strFilter += " and ";
                    }
                    strFilter += "CreateTimeIn >= '" + this.txtInBillDateFrom.Text + " " + this.txtInBillTimeFrom.Text + "'";
                }

                if (this.txtInBillDateTo.Text != "")
                {
                    if (strFilter != "")
                    {
                        strFilter += " and ";
                    }
                    strFilter += "CreateTimeIn <= '" + this.txtInBillDateTo.Text + " " + this.txtInBillTimeTo.Text + "'";
                }
            }

            if (cbUseOutDate.Checked)
            {
                if (this.txtOutBillDateFrom.Text != "")
                {
                    if (strFilter != "")
                    {
                        strFilter += " and ";
                    }
                    strFilter += "CreateTimeOut >= '" + this.txtOutBillDateFrom.Text + " " + this.txtOutBillTimeFrom.Text + "'";
                }

                if (this.txtOutBillDateTo.Text != "")
                {
                    if (strFilter != "")
                    {
                        strFilter += " and ";
                    }
                    strFilter += "CreateTimeOut <= '" + this.txtOutBillDateTo.Text + " " + this.txtOutBillTimeTo.Text + "'";
                }
            }

            if (rbFinished.Checked)//已完成
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "SaleCarOutBillID is not null";
            }

            if (rbUnFinish.Checked)//未完成
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "SaleCarOutBillID is null";
            }

            if (rbCanceled.Checked)//已作废
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "IsCancel =1";
            }
            if (rbUnCancel.Checked)//未作废
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "isnull(IsCancel,0) =0";
            }
            if (rbApproved.Checked)//已审核
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "isnull(BillStatus,0) =2";
            }
            if (rbUnApprove.Checked)//未审核
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "isnull(BillStatus,0) <>2";
            }

            // strFilter += "(BillDateIn>='" + dtBillDateFrom.ToString("yyyy-MM-dd") + "' and BillDateIn<='" + dtBillDateTo.AddDays(1).ToString("yyyy-MM-dd") + "')";
            DataTable dtBill = ExecuteSQL.CallView(125, "", strFilter, "SaleCarOutBillID desc,SaleCarInBillID desc");

            decimal decTotalWeight  = 0;
            decimal decCarTare      = 0;
            decimal decSuttleWeight = 0;
            decimal decAmount       = 0;

            foreach (DataRow dr in dtBill.Rows)
            {
                decTotalWeight  += LBConverter.ToDecimal(dr["TotalWeight"]);
                decCarTare      += LBConverter.ToDecimal(dr["CarTare"]);
                decSuttleWeight += LBConverter.ToDecimal(dr["SuttleWeight"]);
                decAmount       += LBConverter.ToDecimal(dr["Amount"]);
            }

            this.txtTotalWeight.Text = (decTotalWeight / 1000).ToString("0.000");
            this.txtTareWeight.Text  = (decCarTare / 1000).ToString("0.000");
            this.txtStuffWeight.Text = (decSuttleWeight / 1000).ToString("0.000");
            this.txtTotalAmount.Text = decAmount.ToString("0.00");
            this.txtTotalCar.Text    = dtBill.Rows.Count.ToString();

            //如果当前登录用户为地磅文员,则将非现金客户的单价和金额隐藏
            if (LoginInfo.UserType == 0)
            {
                foreach (DataRow dr in dtBill.Rows)
                {
                    int iReceiveType = LBConverter.ToInt32(dr["ReceiveType"]);
                    if (iReceiveType != 0)
                    {
                        dr["PriceT"]        = DBNull.Value;
                        dr["Price"]         = DBNull.Value;
                        dr["Amount"]        = DBNull.Value;
                        dr["MaterialPrice"] = DBNull.Value;
                        dr["FarePrice"]     = DBNull.Value;
                        dr["TaxPrice"]      = DBNull.Value;
                        dr["BrokerPrice"]   = DBNull.Value;
                    }
                }
            }

            this.grdMain.DataSource = dtBill.DefaultView;

            string strSelectField = "sum(Amount) as Amount,sum(TotalWeight) as TotalWeight,sum(CarTare) as CarTare,sum(SuttleWeight) as SuttleWeight,count(1) as CarCount";
            string strGroupBy     = "";

            if (this.cbSumCar.Checked)
            {
                if (strGroupBy != "")
                {
                    strGroupBy += ",";
                }
                strGroupBy     += "CarNum";
                strSelectField += ",CarNum";
                //strSelectField += ",count(CarNum) as CarCount";
            }
            if (this.cbSumCustomer.Checked)
            {
                if (strGroupBy != "")
                {
                    strGroupBy += ",";
                }
                strGroupBy     += "CustomerName";
                strSelectField += ",CustomerName";
            }
            if (this.cbSumItem.Checked)
            {
                if (strGroupBy != "")
                {
                    strGroupBy += ",";
                }
                strGroupBy     += "ItemName";
                strSelectField += ",ItemName";
            }

            this.grdSumMain.Columns["CarNumSum"].Visible = this.cbSumCar.Checked;
            //this.grdSumMain.Columns["CarCount"].Visible = this.cbSumCar.Checked;
            this.grdSumMain.Columns["CustomerNameSum"].Visible = this.cbSumCustomer.Checked;
            this.grdSumMain.Columns["ItemNameSum"].Visible     = this.cbSumItem.Checked;

            DataTable dtSumBill = ExecuteSQL.CallDirectSQL("select " + strSelectField + " from View_SaleCarInOutBill " +
                                                           (strFilter == ""?"":"where " + strFilter) +
                                                           (strGroupBy == ""?"":" group by " + strGroupBy));

            //如果当前登录用户为地磅文员,则将非现金客户的单价和金额隐藏
            if (LoginInfo.UserType == 0)
            {
                foreach (DataRow dr in dtSumBill.Rows)
                {
                    dr["Amount"] = DBNull.Value;
                }
            }

            this.grdSumMain.DataSource = dtSumBill;
        }
Пример #23
0
        private long SaveOutBill(long lSaleCarInBillID)
        {
            string strCarNum = this.txtCarID.TextBox.Text.ToString();
            long   lCarID    = 0;

            using (DataTable dtCar = ExecuteSQL.CallView(113, "CarID", "CarNum='" + strCarNum + "'", ""))
            {
                if (dtCar.Rows.Count > 0)
                {
                    lCarID = LBConverter.ToInt64(dtCar.Rows[0]["CarID"]);
                }
            }

            long lItemID     = LBConverter.ToInt64(this.txtItemID.TextBox.SelectedItemID);
            long lCustomerID = LBConverter.ToInt64(this.txtCustomerID.TextBox.SelectedItemID);

            decimal decCarTare = LBConverter.ToDecimal(this.txtCarTare.Text);

            int     iReceiveType         = LBConverter.ToInt32(this.txtReceiveType.SelectedValue);
            int     iCalculateType       = LBConverter.ToInt32(this.txtCalculateType.SelectedValue);
            decimal decTotalWeight       = LBConverter.ToDecimal(this.txtTotalWeight.Text);
            decimal decSuttleWeight      = LBConverter.ToDecimal(this.txtSuttleWeight.Text);
            decimal decPrice             = LBConverter.ToDecimal(this.txtPrice.Text);
            decimal decAmount            = LBConverter.ToDecimal(this.txtAmount.Text);
            decimal decCustomerPayAmount = iReceiveType == 0 ? decAmount : 0;

            string strBillDateOut = Convert.ToDateTime(this.txtBillDateIn.Text).ToString("yyyy-MM-dd") + " " +
                                    Convert.ToDateTime(this.txtBillTimeIn.Text).ToString("HH:mm:ss");

            if (decTotalWeight == 0)
            {
                throw new Exception("当前【毛重】值为0,无法保存!");
            }
            if (decSuttleWeight == 0)
            {
                throw new Exception("当前【净重】值为0,无法保存!");
            }
            if (decCarTare == 0)
            {
                throw new Exception("当前【皮重】值为0,无法保存!");
            }

            if (lSaleCarInBillID == 0)
            {
                throw new Exception("该车辆没有入场纪录,无法保存!");
            }

            LBDbParameterCollection parmCol = new LBDbParameterCollection();

            parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, lSaleCarInBillID));
            parmCol.Add(new LBParameter("SaleCarOutBillCode", enLBDbType.String, ""));
            parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, lCarID));
            parmCol.Add(new LBParameter("Price", enLBDbType.Decimal, decPrice));
            parmCol.Add(new LBParameter("Amount", enLBDbType.Decimal, decAmount));
            parmCol.Add(new LBParameter("Description", enLBDbType.String, this.txtAddReason.Text));
            parmCol.Add(new LBParameter("ReceiveType", enLBDbType.Int32, iReceiveType));
            parmCol.Add(new LBParameter("CalculateType", enLBDbType.Int32, iCalculateType));
            parmCol.Add(new LBParameter("TotalWeight", enLBDbType.Decimal, decTotalWeight));
            parmCol.Add(new LBParameter("SuttleWeight", enLBDbType.Decimal, decSuttleWeight));
            //入库单信息
            parmCol.Add(new LBParameter("ItemID", enLBDbType.Int64, lItemID));
            parmCol.Add(new LBParameter("CustomerID", enLBDbType.Int64, lCustomerID));
            parmCol.Add(new LBParameter("CarTare", enLBDbType.Decimal, decCarTare));
            parmCol.Add(new LBParameter("CustomerPayAmount", enLBDbType.Decimal, decCustomerPayAmount));
            parmCol.Add(new LBParameter("BillDate", enLBDbType.DateTime, Convert.ToDateTime(strBillDateOut)));

            int     iSPType = 14102;
            DataSet dsReturn;
            Dictionary <string, object> dictValue;

            ExecuteSQL.CallSP(iSPType, parmCol, out dsReturn, out dictValue);
            long lSaleCarOutBillID = 0;

            if (dictValue.ContainsKey("SaleCarOutBillID"))
            {
                lSaleCarOutBillID = LBConverter.ToInt64(dictValue["SaleCarOutBillID"].ToString());
            }
            return(lSaleCarOutBillID);
        }
Пример #24
0
        private void btnInWeight_Click(object sender, EventArgs e)
        {
            try
            {
                LBPermission.VerifyUserPermission("称重并保存", "WeightSalesReturnIn_Save");
                //先读取重量
                VerifyDeviceIsSteady(); //校验地磅数值是否稳定以及红外线对射是否正常
                VerifyTextBoxIsEmpty(); //判断相关控件值是否为空
                long   lCarID               = LBConverter.ToInt64(this.txtCarID.TextBox.SelectedItemID);
                long   lItemID              = LBConverter.ToInt64(this.txtItemID.TextBox.SelectedItemID);
                long   lCustomerID          = LBConverter.ToInt64(this.txtCustomerID.TextBox.SelectedItemID);
                string strSaleCarInBillCode = this.txtSaleCarInBillCode.Text.TrimEnd();

                if (strSaleCarInBillCode != "")
                {
                    long lSaleCarInBillID = 0;

                    #region -- 判断是否存在未出场记录 --

                    DataTable dtInBill = ExecuteSQL.CallView(125, "SaleCarInBillID,SaleCarOutBillID", "SaleCarInBillCode='" + strSaleCarInBillCode + "'", "");
                    if (dtInBill.Rows.Count > 0)
                    {
                        lSaleCarInBillID = LBConverter.ToInt64(dtInBill.Rows[0]["SaleCarInBillID"]);
                        long lSaleCarOutBillID = LBConverter.ToInt64(dtInBill.Rows[0]["SaleCarOutBillID"]);
                        if (lSaleCarOutBillID == 0)
                        {
                            throw new Exception("该车辆存在入场而未出场记录,无法退货!");
                        }
                    }

                    #endregion

                    #region -- 判断该车辆是否正在走退货流程(即退货入场但未出场)

                    DataTable dtInReturnBill = ExecuteSQL.CallView(137, "*", "ReturnStatus=0 and SaleCarInBillID=" + lSaleCarInBillID.ToString(), "");
                    if (dtInReturnBill.Rows.Count > 0)
                    {
                        throw new Exception("该车辆正在场内退货,无法进行入场称重!");
                    }

                    #endregion

                    decimal decWeight = LBConverter.ToDecimal(lblWeight.Text);//读皮重
                    this.txtInWeight.Text = decWeight.ToString("0");

                    if (LB.WinFunction.LBCommonHelper.ConfirmMessage("是否确认退货?", "提示", MessageBoxButtons.YesNo) ==
                        DialogResult.Yes)
                    {
                        decimal decInWeight = LBConverter.ToDecimal(this.txtInWeight.Text);

                        if (decInWeight <= 0)
                        {
                            throw new Exception("入场称重值不能为0");
                        }

                        LBDbParameterCollection parmCol = new LBDbParameterCollection();
                        parmCol.Add(new LBParameter("SaleCarReturnBillID", enLBDbType.Int64, 0));
                        parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, lSaleCarInBillID));
                        parmCol.Add(new LBParameter("TotalWeight", enLBDbType.Decimal, decInWeight));

                        DataSet dsReturn;
                        Dictionary <string, object> dictValue;
                        ExecuteSQL.CallSP(30000, parmCol, out dsReturn, out dictValue);
                        if (dictValue.ContainsKey("SaleCarReturnBillID"))
                        {
                            long SaleCarReturnBillID = LBConverter.ToInt64(dictValue["SaleCarReturnBillID"]);

                            if (SaleCarReturnBillID > 0)
                            {
                                Thread threadSavePic = new Thread(SaveInSalesPicture);
                                threadSavePic.Start(SaleCarReturnBillID);

                                LB.WinFunction.LBCommonHelper.ShowCommonMessage("生成入场退货单成功!");
                                ClearAllBillInfo();
                                LoadReturnBill();
                            }
                        }
                    }
                }
                else
                {
                    throw new Exception("入场单号不能为空!");
                }
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #25
0
        private void btnChangeBillInfoSave_Click(object sender, EventArgs e)
        {
            try
            {
                long    lCarID          = LBConverter.ToInt64(this.txtCarID.TextBox.SelectedItemID);
                long    lSupplierID     = LBConverter.ToInt64(this.txtSupplierID.TextBox.SelectedItemID);
                decimal decCarTare      = LBConverter.ToDecimal(this.txtCarTare.Text);
                decimal decSuttleWeight = LBConverter.ToDecimal(this.txtSuttleWeight.Text);

                LBDbParameterCollection parmCol = new LBDbParameterCollection();
                parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, mlSaleCarInBillID));
                parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, lCarID));
                parmCol.Add(new LBParameter("SuttleWeight", enLBDbType.Decimal, decSuttleWeight));
                parmCol.Add(new LBParameter("CarTare", enLBDbType.Decimal, decCarTare));
                parmCol.Add(new LBParameter("SupplierID", enLBDbType.Int64, lSupplierID));

                DataSet dsReturn;
                Dictionary <string, object> dictValue;
                ExecuteSQL.CallSP(14101, parmCol, out dsReturn, out dictValue);
                LB.WinFunction.LBCommonHelper.ShowCommonMessage("修改成功!");

                //long lItemID = LBConverter.ToInt64(this.txtItemID.TextBox.SelectedItemID);
                //long lCustomerID = LBConverter.ToInt64(this.txtCustomerID.TextBox.SelectedItemID);
                //if (lItemID == 0)
                //{
                //    throw new Exception("请输入正确的货物名称!");
                //}
                //if (lCustomerID == 0)
                //{
                //    throw new Exception("请输入正确的客户名称!");
                //}
                //LBDbParameterCollection parmCol = new LBDbParameterCollection();
                //parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, mlSaleCarInBillID));
                //parmCol.Add(new LBParameter("ItemID", enLBDbType.Int64, lItemID));
                //parmCol.Add(new LBParameter("CustomerID", enLBDbType.Int64, lCustomerID));
                //parmCol.Add(new LBParameter("Price", enLBDbType.Decimal, LBConverter.ToDecimal(this.txtPrice.Text)));
                //parmCol.Add(new LBParameter("Amount", enLBDbType.Decimal, LBConverter.ToDecimal(this.txtAmount.Text)));

                //DataSet dsReturn;
                //Dictionary<string, object> dictValue;
                //ExecuteSQL.CallSP(14116, parmCol, out dsReturn, out dictValue);
                //if( LB.WinFunction.LBCommonHelper.ConfirmMessage("修改成功!是否自动审核该磅单?", "提示", MessageBoxButtons.YesNo)==
                //     DialogResult.Yes)
                //{
                //    this.btnApprove.PerformClick();
                //}

                //btnChangeBillInfoSave.Visible = false;
                //this.btnChangeBillInfoDirect.Visible = true;
                //this.txtItemID.TextBox.ReadOnly = true;
                //this.txtCustomerID.TextBox.ReadOnly = true;
                //txtPrice.ReadOnly = true;

                //this.btnApprove.Visible = true;
                //this.btnUnApprove.Visible = true;
                //this.btnCancel.Visible = true;
                //this.btnUnCancel.Visible = true;
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #26
0
        private void btnSubmitReturn_Click(object sender, EventArgs e)
        {
            try
            {
                LBPermission.VerifyUserPermission("确认退货", "WeightSalesReturnOut_Save");

                decimal decTareCar = LBConverter.ToDecimal(this.txtCarTare.Text);//原皮重值

                decimal decInWeight   = LBConverter.ToDecimal(this.txtInWeight.Text);
                decimal decOutWeight  = LBConverter.ToDecimal(this.txtOutWeight.Text);
                int     iReturnType   = LBConverter.ToInt32(this.txtReturnType.SelectedValue);
                int     iReturnReason = LBConverter.ToInt32(this.txtReturnReason.SelectedValue);
                if (decInWeight <= 0)
                {
                    throw new Exception("入场称重值不能为0");
                }

                if (decOutWeight <= 0)
                {
                    throw new Exception("出场场称重值不能为0");
                }

                if (this.txtReturnType.SelectedValue == null ||
                    this.txtReturnType.SelectedValue.ToString() == "")
                {
                    throw new Exception("请选择退货方式");
                }
                if (this.txtReturnReason.SelectedValue == null ||
                    this.txtReturnReason.SelectedValue.ToString() == "")
                {
                    throw new Exception("请选择退货原因");
                }

                if (iReturnType == 0)//完全退货状态下必须校验原来车辆入场皮重与现在出场皮重是否存在较大磅差
                {
                    if (Math.Abs(decTareCar - decOutWeight) > 1000)
                    {
                        throw new Exception("该车辆记录的入场皮重与空车出场重量的磅差太大,无法出场,请检查该车辆是否已卸载完毕!");
                    }
                }

                string strSaleCarInBillCode = this.txtSaleCarInBillCode.Text.TrimEnd();
                if (strSaleCarInBillCode != "")
                {
                    long lSaleCarInBillID = 0;

                    #region -- 查询入场单信息 --

                    DataTable dtInBill = ExecuteSQL.CallView(125, "SaleCarInBillID,SaleCarOutBillID", "SaleCarInBillCode='" + strSaleCarInBillCode + "'", "");
                    if (dtInBill.Rows.Count > 0)
                    {
                        lSaleCarInBillID = LBConverter.ToInt64(dtInBill.Rows[0]["SaleCarInBillID"]);
                    }

                    #endregion

                    #region -- 判断该车辆是否正在走退货流程(即退货入场但未出场)
                    long      lSaleCarReturnBillID = 0;
                    DataTable dtInReturnBill       = ExecuteSQL.CallView(137, "", "ReturnStatus=0 and SaleCarInBillID=" + lSaleCarInBillID.ToString(), "");
                    if (dtInReturnBill.Rows.Count == 0)
                    {
                        throw new Exception("该车辆没有退货入场记录!");
                    }
                    else
                    {
                        lSaleCarReturnBillID = LBConverter.ToInt64(dtInReturnBill.Rows[0]["SaleCarReturnBillID"]);
                    }
                    #endregion

                    if (LB.WinFunction.LBCommonHelper.ConfirmMessage("是否确认退货?", "提示", MessageBoxButtons.YesNo) ==
                        DialogResult.Yes)
                    {
                        LBDbParameterCollection parmCol = new LBDbParameterCollection();
                        parmCol.Add(new LBParameter("SaleCarReturnBillID", enLBDbType.Int64, lSaleCarReturnBillID));
                        parmCol.Add(new LBParameter("CarTare", enLBDbType.Decimal, decOutWeight));
                        parmCol.Add(new LBParameter("SuttleWeight", enLBDbType.Decimal, decInWeight - decOutWeight));
                        parmCol.Add(new LBParameter("ReturnType", enLBDbType.Int16, iReturnType));
                        parmCol.Add(new LBParameter("ReturnReason", enLBDbType.Int16, iReturnReason));
                        parmCol.Add(new LBParameter("Description", enLBDbType.String, ""));
                        parmCol.Add(new LBParameter("NewSaleCarInBillCode", enLBDbType.String, ""));
                        parmCol.Add(new LBParameter("NewSaleCarOutBillCode", enLBDbType.String, ""));

                        DataSet dsReturn;
                        Dictionary <string, object> dictValue;
                        ExecuteSQL.CallSP(30001, parmCol, out dsReturn, out dictValue);
                        if (dictValue.ContainsKey("NewSaleCarOutBillCode"))
                        {
                            string strNewSaleCarOutBillCode = dictValue["NewSaleCarOutBillCode"].ToString();

                            if (strNewSaleCarOutBillCode != "")
                            {
                                Thread threadSavePic = new Thread(SaveOutSalesPicture);
                                threadSavePic.Start(lSaleCarReturnBillID);

                                LB.WinFunction.LBCommonHelper.ShowCommonMessage("退货完成!原磅单已作废,生成新的磅单为:" + strNewSaleCarOutBillCode);
                                ClearAllBillInfo();
                                if (dictValue.ContainsKey("NewSaleCarOutBillID"))
                                {
                                    long lNewSaleCarOutBillID = LBConverter.ToInt64(dictValue["NewSaleCarOutBillID"]);
                                    if (lNewSaleCarOutBillID > 0)
                                    {
                                        if (PrintOutBillEvent != null)
                                        {
                                            Billinfo billInfo = new Billinfo(lNewSaleCarOutBillID);
                                            PrintOutBillEvent(this, billInfo);
                                        }
                                    }
                                }
                            }
                        }

                        if (iReturnType == 0)//完全退货
                        {
                            LB.WinFunction.LBCommonHelper.ShowCommonMessage("完全退货完成,原磅单已作废!");
                            ClearAllBillInfo();
                        }
                        LoadReturnBill();
                    }
                }
                else
                {
                    throw new Exception("入场单号不能为空!");
                }
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #27
0
        private void btnSubmitReturn_Click(object sender, EventArgs e)
        {
            try
            {
                //LBPermission.VerifyUserPermission("确认退货", "WeightSalesReturnOut_Save");

                decimal decInWeight  = LBConverter.ToDecimal(this.txtTotalWeight.Text);
                decimal decOutWeight = LBConverter.ToDecimal(this.txtOutWeight.Text);
                if (decInWeight <= 0)
                {
                    throw new Exception("入场称重值不能为0");
                }

                if (decOutWeight <= 0)
                {
                    throw new Exception("出场场称重值不能为0");
                }

                string strSaleCarInBillCode = this.txtSaleCarInBillCode.Text.TrimEnd();
                if (strSaleCarInBillCode != "")
                {
                    long lSaleCarInBillID = 0;

                    #region -- 查询入场单信息 --

                    DataTable dtInBill = ExecuteSQL.CallView(125, "SaleCarInBillID,SaleCarOutBillID", "SaleCarInBillCode='" + strSaleCarInBillCode + "'", "");
                    if (dtInBill.Rows.Count > 0)
                    {
                        lSaleCarInBillID = LBConverter.ToInt64(dtInBill.Rows[0]["SaleCarInBillID"]);
                    }

                    #endregion

                    LBDbParameterCollection parmCol = new LBDbParameterCollection();
                    parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, lSaleCarInBillID));
                    parmCol.Add(new LBParameter("CarTare", enLBDbType.Decimal, decOutWeight));
                    parmCol.Add(new LBParameter("SuttleWeight", enLBDbType.Decimal, decInWeight - decOutWeight));
                    parmCol.Add(new LBParameter("Description", enLBDbType.String, ""));

                    DataSet dsReturn;
                    Dictionary <string, object> dictValue;
                    ExecuteSQL.CallSP(14120, parmCol, out dsReturn, out dictValue);
                    if (dictValue.ContainsKey("SaleCarOutBillCode") && dictValue.ContainsKey("SaleCarOutBillID"))
                    {
                        string strSaleCarOutBillCode = dictValue["SaleCarOutBillCode"].ToString();
                        long   lSaleCarOutBillID     = LBConverter.ToInt64(dictValue["SaleCarOutBillID"]);

                        if (strSaleCarOutBillCode != "")
                        {
                            Thread threadSavePic = new Thread(SaveOutSalesPicture);
                            threadSavePic.Start(lSaleCarOutBillID);

                            ClearAllBillInfo();
                            if (PrintOutBillEvent != null)
                            {
                                Billinfo billInfo = new Billinfo(lSaleCarOutBillID);
                                PrintOutBillEvent(this, billInfo);
                            }
                        }
                    }
                    LoadReturnBill();
                }
                else
                {
                    throw new Exception("入场单号不能为空!");
                }
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #28
0
        private void btnInWeight_Click(object sender, EventArgs e)
        {
            try
            {
                //LBPermission.VerifyUserPermission("称重并保存", "WeightSalesReturnIn_Save");
                //先读取重量
                VerifyDeviceIsSteady(); //校验地磅数值是否稳定以及红外线对射是否正常
                VerifyTextBoxIsEmpty(); //判断相关控件值是否为空
                long   lCarID               = LBConverter.ToInt64(this.txtCarID.TextBox.SelectedItemID);
                long   lItemID              = LBConverter.ToInt64(this.txtItemID.TextBox.SelectedItemID);
                long   lCustomerID          = LBConverter.ToInt64(this.txtCustomerID.TextBox.SelectedItemID);
                string strSaleCarInBillCode = this.txtSaleCarInBillCode.Text.TrimEnd();

                if (lCarID == 0)
                {
                    throw new Exception("车辆不能为空");
                }
                if (lItemID == 0)
                {
                    throw new Exception("货物不能为空");
                }
                if (lCustomerID == 0)
                {
                    throw new Exception("客户不能为空");
                }

                long lSaleCarInBillID = 0;

                decimal decWeight = LBConverter.ToDecimal(lblWeight.Text);//读总重
                this.txtInWeight.Text = decWeight.ToString("0");

                decimal decInWeight = LBConverter.ToDecimal(this.txtInWeight.Text);

                if (decInWeight <= 0)
                {
                    throw new Exception("入场称重值不能为0");
                }

                LBDbParameterCollection parmCol = new LBDbParameterCollection();
                parmCol.Add(new LBParameter("SaleCarInBillID", enLBDbType.Int64, 0));
                parmCol.Add(new LBParameter("CarID", enLBDbType.Int64, lCarID));
                parmCol.Add(new LBParameter("ItemID", enLBDbType.Int64, lItemID));
                parmCol.Add(new LBParameter("CalculateType", enLBDbType.Int64, 0));
                parmCol.Add(new LBParameter("CustomerID", enLBDbType.Int64, lCustomerID));
                parmCol.Add(new LBParameter("TotalWeight", enLBDbType.Decimal, decInWeight));

                DataSet dsReturn;
                Dictionary <string, object> dictValue;
                ExecuteSQL.CallSP(14119, parmCol, out dsReturn, out dictValue);
                if (dictValue.ContainsKey("SaleCarInBillID"))
                {
                    lSaleCarInBillID = LBConverter.ToInt64(dictValue["SaleCarInBillID"]);

                    if (lSaleCarInBillID > 0)
                    {
                        Thread threadSavePic = new Thread(SaveInSalesPicture);
                        threadSavePic.Start(lSaleCarInBillID);

                        if (PrintInBillEvent != null)
                        {
                            Billinfo billInfo = new Billinfo(lSaleCarInBillID);
                            PrintInBillEvent(this, billInfo);
                        }

                        LB.WinFunction.LBCommonHelper.ShowCommonMessage("生成入场单成功!");
                        ClearAllBillInfo();
                        LoadReturnBill();
                    }
                }
            }
            catch (Exception ex)
            {
                LB.WinFunction.LBCommonHelper.DealWithErrorMessage(ex);
            }
        }
Пример #29
0
        private void LoadAllSalesBill()
        {
            string strFilter = "";

            if (this.txtSupplierID.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "SupplierName like '%" + this.txtSupplierID.Text + "%'";
            }

            if (this.txtCarID.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CarNum like '%" + this.txtCarID.Text + "%'";
            }

            if (this.txtBillCode.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "SaleCarInBillCode like '%" + this.txtBillCode.Text + "%'";
            }

            if (this.txtOutBillCraeteBy.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CreateByIn like '%" + this.txtOutBillCraeteBy.Text + "%'";
            }

            if (this.txtBillDateFrom.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CreateTimeIn >= '" + Convert.ToDateTime(this.txtBillDateFrom.Text).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(this.txtBillTimeFrom.Text).ToString("HH:mm:ss") + "'";
            }

            if (this.txtBillDateTo.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CreateTimeIn <= '" + Convert.ToDateTime(this.txtBillDateTo.Text).ToString("yyyy-MM-dd") + " " + Convert.ToDateTime(this.txtBillTimeTo.Text).ToString("HH:mm:ss") + "'";
            }

            if (rbCanceled.Checked)//已作废
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "IsCancel =1";
            }
            if (rbUnCancel.Checked)//未作废
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "isnull(IsCancel,0) =0";
            }

            // strFilter += "(BillDateIn>='" + dtBillDateFrom.ToString("yyyy-MM-dd") + "' and BillDateIn<='" + dtBillDateTo.AddDays(1).ToString("yyyy-MM-dd") + "')";
            DataTable dtBill = ExecuteSQL.CallView(128, "", strFilter, "SaleCarInBillID desc");

            decimal decTotalWeight  = 0;
            decimal decCarTare      = 0;
            decimal decSuttleWeight = 0;
            decimal decAmount       = 0;

            foreach (DataRow dr in dtBill.Rows)
            {
                decTotalWeight  += LBConverter.ToDecimal(dr["TotalWeight"]);
                decCarTare      += LBConverter.ToDecimal(dr["CarTare"]);
                decSuttleWeight += LBConverter.ToDecimal(dr["SuttleWeight"]);
            }

            this.txtTotalWeight.Text = (decTotalWeight / 1000).ToString("0.000");
            this.txtTareWeight.Text  = (decCarTare / 1000).ToString("0.000");
            this.txtStuffWeight.Text = (decSuttleWeight / 1000).ToString("0.000");
            this.txtTotalAmount.Text = decAmount.ToString("0.00");
            this.txtTotalCar.Text    = dtBill.Rows.Count.ToString();

            this.grdMain.DataSource = dtBill.DefaultView;

            string strSelectField = "sum(TotalWeight) as TotalWeight,sum(CarTare) as CarTare,sum(SuttleWeight) as SuttleWeight,count(1) as CarCount";
            string strGroupBy     = "";

            if (this.cbSumCar.Checked)
            {
                if (strGroupBy != "")
                {
                    strGroupBy += ",";
                }
                strGroupBy     += "CarNum";
                strSelectField += ",CarNum";
                //strSelectField += ",count(CarNum) as CarCount";
            }
            if (this.cbSumSupplier.Checked)
            {
                if (strGroupBy != "")
                {
                    strGroupBy += ",";
                }
                strGroupBy     += "SupplierName";
                strSelectField += ",SupplierName";
            }

            this.grdSumMain.Columns["CarNumSum"].Visible       = this.cbSumCar.Checked;
            this.grdSumMain.Columns["SupplierNameSum"].Visible = this.cbSumSupplier.Checked;

            DataTable dtSumBill = ExecuteSQL.CallDirectSQL("select " + strSelectField + " from View_SaleCarInBill " +
                                                           (strFilter == ""?"":"where " + strFilter) +
                                                           (strGroupBy == ""?"":" group by " + strGroupBy));

            this.grdSumMain.DataSource = dtSumBill;
        }
        private void LoadAllSalesBill()
        {
            string strFilter = "";

            if (this.txtCustomerID.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CustomerName like '%" + this.txtCustomerID.Text + "%'";
            }

            if (this.txtCarID.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CarNum like '%" + this.txtCarID.Text + "%'";
            }

            if (this.txtItemID.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "ItemName like '%" + this.txtItemID.Text + "%'";
            }

            if (this.txtBillCode.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "SaleCarInBillCode like '%" + this.txtBillCode.Text + "%'";
            }


            if (this.txtBillCodeOut.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "SaleCarOutBillCode like '%" + this.txtBillCodeOut.Text + "%'";
            }

            if (this.txtOutBillCraeteBy.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CreateByOut like '%" + this.txtOutBillCraeteBy.Text + "%'";
            }

            if (cbDisplaySynK3Bill.Checked)
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                if (_SynType == 0)
                {
                    strFilter += "IsSynchronousToK3Receive=1";
                }
                else if (_SynType == 1)
                {
                    strFilter += "IsSynchronousToK3OutBill=1";
                }
                //else if (_SynType == 2)
                //{
                //    strFilter += "IsSynchronousToK3OutBill=2";
                //}
            }
            else
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                if (_SynType == 0)
                {
                    strFilter += "isnull(IsSynchronousToK3Receive,0)=0";
                }
                else if (_SynType == 1)
                {
                    strFilter += "isnull(IsSynchronousToK3OutBill,0) = 0";
                }
                //else if (_SynType == 2)
                //{
                //    strFilter += "isnull(IsSynchronousToK3OutBill,0) = 0";
                //}
                //strFilter += "(isnull(IsSynchronousToK3OutBill,0) = 0 or isnull(IsSynchronousToK3Receive,0)=0)";
            }

            if (this.txtOutBillDateFrom.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CreateTimeOut >= '" + this.txtOutBillDateFrom.Text + " " + this.txtOutBillTimeFrom.Text + "'";
            }

            if (this.txtOutBillDateTo.Text != "")
            {
                if (strFilter != "")
                {
                    strFilter += " and ";
                }
                strFilter += "CreateTimeOut <= '" + this.txtOutBillDateTo.Text + " " + this.txtOutBillTimeTo.Text + "'";
            }

            if (strFilter != "")
            {
                strFilter += " and ";
            }
            strFilter += "SaleCarOutBillID is not null";

            if (strFilter != "")
            {
                strFilter += " and ";
            }
            strFilter += "isnull(K3ItemCode,'')<>'' and isnull(K3CustomerCode,'')<>'' and isnull(BillStatus,0) =2";

            // strFilter += "(BillDateIn>='" + dtBillDateFrom.ToString("yyyy-MM-dd") + "' and BillDateIn<='" + dtBillDateTo.AddDays(1).ToString("yyyy-MM-dd") + "')";
            DataTable dtBill = ExecuteSQL.CallView(125, "", strFilter, "SaleCarOutBillID asc,SaleCarInBillID asc");

            decimal decTotalWeight  = 0;
            decimal decCarTare      = 0;
            decimal decSuttleWeight = 0;
            decimal decAmount       = 0;

            foreach (DataRow dr in dtBill.Rows)
            {
                decTotalWeight  += LBConverter.ToDecimal(dr["TotalWeight"]);
                decCarTare      += LBConverter.ToDecimal(dr["CarTare"]);
                decSuttleWeight += LBConverter.ToDecimal(dr["SuttleWeight"]);
                decAmount       += LBConverter.ToDecimal(dr["Amount"]);
            }

            this.txtTotalWeight.Text = (decTotalWeight / 1000).ToString("0.000");
            this.txtTareWeight.Text  = (decCarTare / 1000).ToString("0.000");
            this.txtStuffWeight.Text = (decSuttleWeight / 1000).ToString("0.000");
            this.txtTotalAmount.Text = decAmount.ToString("0.00");
            this.txtTotalCar.Text    = dtBill.Rows.Count.ToString();

            //如果当前登录用户为地磅文员,则将非现金客户的单价和金额隐藏
            if (LoginInfo.UserType == 0)
            {
                foreach (DataRow dr in dtBill.Rows)
                {
                    int iReceiveType = LBConverter.ToInt32(dr["ReceiveType"]);
                    if (iReceiveType != 0)
                    {
                        dr["PriceT"]        = DBNull.Value;
                        dr["Price"]         = DBNull.Value;
                        dr["Amount"]        = DBNull.Value;
                        dr["MaterialPrice"] = DBNull.Value;
                        dr["FarePrice"]     = DBNull.Value;
                        dr["TaxPrice"]      = DBNull.Value;
                        dr["BrokerPrice"]   = DBNull.Value;
                    }
                }
            }

            this.grdMain.DataSource = dtBill.DefaultView;
        }