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); } }
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); } }
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); } }