/// <summary>
    /// 保存或保存并提交公用方法
    /// </summary>
    /// <param name="isSubmit"></param>
    protected void SubmitArrangeBill(bool isSubmit)
    {
        //要保存之前判断状态是否被改变
        CStockUpBillBB stockUpBillBB = new CStockUpBillBB();
        string stockUpState = stockUpBillBB.GetVList("stockUpBillNo = '" + stockUpBillNo.Text.Trim() + "'").Tables[0].Rows[0]["instantState"].ToString();
        stockUpBillNo.Dispose();
        if (stockUpState != StockUpinstantState)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"拣货单已经被别人生成\");", true);
            return;
        }
        using (CPickOutPlanBC planBC = new CPickOutPlanBC())
        {
            CStockUpDetailBB stockUpDetailBB = new CStockUpDetailBB();
            LMaterialRelationBB materialRelationBB = new LMaterialRelationBB();

            try
            {
                #region 判断是否完全拣货

                DataSet dsStockUpDetail_Temp = stockUpDetailBB.GetMaterielVList("stockUpBillNo='" + this.stockUpBillNo.Text.Trim() + "'");

                foreach (DataRow rowStockUpDetail in dsStockUpDetail_Temp.Tables[0].Rows)
                {
                    int planNum = 0, factNum = 0;
                    DataRow[] myDataRowArray = null;
                    string strNewMaterialNo = "";
                    DataTable dtConvertMaterial = new DataTable();

                    //计算计划备货数量
                    myDataRowArray = dsStockUpDetail_Temp.Tables[0].Select("materialNo='"
                        + rowStockUpDetail["materialNo"].ToString() + "'");
                    foreach (DataRow row in myDataRowArray)
                    {
                        planNum += Convert.ToInt32(row["num"]);
                    }

                    //计算原物料可拣货数量
                    //7月25号修改
                    //解决拣货单下发不下去的问题
                    //myDataRowArray = this.DtResult.Select("isDel=0 and materialNo='"
                    //    + rowStockUpDetail["materialNo"].ToString() + "'");
                    myDataRowArray = this.DtResult.Select("isDel=0 and materialNo=stockupmaterialNo and materialNo='"
                                        + rowStockUpDetail["materialNo"].ToString() + "'");

                    foreach (DataRow row in myDataRowArray)
                    {
                        factNum += Convert.ToInt32(row["num"]);
                    }

                    //获取转换物料的拣货数量
                    //20140807 add
                    if (planNum != factNum)
                    {
                        dtConvertMaterial = materialRelationBB.GetList("oldMaterialNo='" + rowStockUpDetail["materialNo"].ToString() + "'").Tables[0];
                        if (dtConvertMaterial.Rows.Count > 0)
                        {
                            //7月25号修改
                            //解决拣货单下发不下去的问题
                            //strNewMaterialNo = dtConvertMaterial.Rows[0]["newMaterialNo"].ToString();
                            //myDataRowArray = this.DtResult.Select("isDel=0 and materialNo='" + strNewMaterialNo + "'");
                            strNewMaterialNo = dtConvertMaterial.Rows[0]["oldMaterialNo"].ToString();
                            myDataRowArray = this.DtResult.Select("isDel=0 and stockupmaterialNo='" + strNewMaterialNo + "' and materialNo<>stockupmaterialNo");

                            foreach (DataRow row in myDataRowArray)
                            {
                                factNum += Convert.ToInt32(row["num"]);
                            }
                        }
                    }

                    if (planNum != factNum)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"当前未完成拣货,不允许保存!\");", true);
                        return;
                    }
                }

                #endregion 判断是否完全拣货

                planBC.EmpID = this.currentUser.empId;
                planBC.SavePickOutPlanBill(this.DtResult, this.stockUpBillNo.Text.Trim(), isSubmit);

                this.DtResult = null;
                this.InitDtPickOutPlan();

                if (isSubmit)//保存并提交
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"拣货单维护成功!\");window.location='"
                            + Request.Params["backurl"] + "';", true);
                }
                else//保存
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "alert12", "alert(\"拣货单维护成功!\");", true);
                }
            }
            catch (Exception ex)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
                return;
            }
            finally
            {
                stockUpDetailBB.Dispose();
                materialRelationBB.Dispose();
            }
        }
    }
Beispiel #2
0
    public bool SavePickOutInfo(int pickOutPlanId, int empId)
    {
        CPickOutPlanBC pickOutPlanBC = new CPickOutPlanBC();

        try
        {
            pickOutPlanBC.EmpID = empId;

            return pickOutPlanBC.SavePickOutInfo(pickOutPlanId);
        }
        finally
        {
            pickOutPlanBC.Dispose();
        }
    }