/// <summary>
        /// 明细参数设置
        /// </summary>
        /// <param name="comm"></param>
        /// <param name="model"></param>
        private static void EditOutOtherDetailInfo(SqlCommand comm, StorageOutOtherDetailModel model)
        {
            //@CompanyCD,@OutNo,@SortNo,@StorageID,@ProductID,@UnitPrice,@ProductCount,
            //@TotalPrice,@Remark,@FromType,@FromLineNo,getdate(),@ModifiedUserID

            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD ", model.CompanyCD));//公司代码
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutNo ", model.OutNo));//出库单编号
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@SortNo ", model.SortNo));//
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ProductID ", model.ProductID));//物品ID
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@StorageID ", model.StorageID));//仓库ID
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@UnitPrice ", model.UnitPrice));//入库单价(基本单价)
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ProductCount ", model.ProductCount));//入库数量(基本数量)
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@TotalPrice ", model.TotalPrice));//入库金额
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Remark ", model.Remark));//备注

            comm.Parameters.Add(SqlHelper.GetParameterFromString("@UnitID ", model.UnitID));//基本单位
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@UsedUnitID ", model.UsedUnitID));//实际单位
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@UsedUnitCount ", model.UsedUnitCount));//实际数量
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@UsedPrice ", model.UsedPrice));//实际单价
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ExRate ", model.ExRate));//比率
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@BatchNo ", model.BatchNo));//批次


            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID ", model.ModifiedUserID));//最后更新用户ID(对应操作用户表中的UserID)
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromType ", model.FromType));//
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromLineNo ", model.FromLineNo));//


        }
        public static bool ConfirmBill(StorageOutOtherModel model,out string retstrval)
        {
            ArrayList lstConfirm = new ArrayList();
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" UPDATE officedba.StorageOutOther SET");
            sql.AppendLine(" Confirmor          = @Confirmor,");
            sql.AppendLine(" confirmDate      = getdate(),");
            sql.AppendLine(" BillStatus              = 2,");
            sql.AppendLine(" ModifiedUserID      = @ModifiedUserID,");
            sql.AppendLine(" ModifiedDate                = getdate()");
            sql.AppendLine(" Where  CompanyCD=@CompanyCD and ID=@ID");

            SqlCommand comm = new SqlCommand();
            comm.CommandText = sql.ToString();
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Confirmor", model.Confirmor));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", model.ModifiedUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", model.ID));

            lstConfirm.Add(comm);


            List<StorageOutOtherDetailModel> modelList = new List<StorageOutOtherDetailModel>();
            string sqlSele = "select ProductID,StorageID,CompanyCD,OutNo,UnitPrice,BatchNo,UsedUnitCount,ProductCount,FromType,FromLineNo from officedba.StorageOutOtherDetail where CompanyCD='" + model.CompanyCD + "'"
                            + "and OutNo=(select OutNo from officedba.StorageOutOther where ID=" + model.ID + ")";
            DataTable dt = SqlHelper.ExecuteSql(sqlSele);
            if (dt != null && dt.Rows.Count > 0)
            {

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    StorageOutOtherDetailModel modelDetail = new StorageOutOtherDetailModel();
                    if (dt.Rows[i]["ProductID"].ToString() != "")
                    {
                        modelDetail.ProductID = dt.Rows[i]["ProductID"].ToString();
                    }
                    if (dt.Rows[i]["StorageID"].ToString() != "")
                    {
                        modelDetail.StorageID = dt.Rows[i]["StorageID"].ToString();
                    }
                    if (dt.Rows[i]["ProductCount"].ToString() != "")
                    {
                        modelDetail.ProductCount = dt.Rows[i]["ProductCount"].ToString();
                    }
                    if (dt.Rows[i]["FromType"].ToString() != "")
                    {
                        modelDetail.FromType = dt.Rows[i]["FromType"].ToString();
                    }
                    if (dt.Rows[i]["FromLineNo"].ToString() != "")
                    {
                        modelDetail.FromLineNo = dt.Rows[i]["FromLineNo"].ToString();
                    }
                    modelDetail.BatchNo = dt.Rows[i]["BatchNo"].ToString();
                    if (dt.Rows[i]["UsedUnitCount"].ToString() == "")
                        modelDetail.UsedUnitCount = dt.Rows[i]["ProductCount"].ToString();
                    else
                        modelDetail.UsedUnitCount = dt.Rows[i]["UsedUnitCount"].ToString();
                    modelList.Add(modelDetail);
                    #region 操作库存流水账
                    StorageAccountModel AccountM_ = new StorageAccountModel();
                    AccountM_.BatchNo = dt.Rows[i]["BatchNo"].ToString();
                    AccountM_.BillNo = dt.Rows[i]["OutNo"].ToString();
                    AccountM_.BillType = 8;
                    AccountM_.CompanyCD = dt.Rows[i]["CompanyCD"].ToString();
                    AccountM_.Creator = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).EmployeeID;
                    AccountM_.HappenCount = Convert.ToDecimal(dt.Rows[i]["ProductCount"].ToString());
                    AccountM_.HappenDate = System.DateTime.Now;
                    AccountM_.PageUrl = "../Office/StorageManager/StorageOutOtherAdd.aspx";
                    if (dt.Rows[i]["UnitPrice"].ToString().Trim() == "")
                        AccountM_.Price = 0;
                    else
                        AccountM_.Price = Convert.ToDecimal(dt.Rows[i]["UnitPrice"].ToString());
                    AccountM_.ProductCount = Convert.ToDecimal(dt.Rows[i]["ProductCount"].ToString());
                    AccountM_.ProductID = Convert.ToInt32(dt.Rows[i]["ProductID"].ToString());
                    AccountM_.StorageID = Convert.ToInt32(dt.Rows[i]["StorageID"].ToString());
                    SqlCommand AccountCom_ = StorageAccountDBHelper.InsertStorageAccountCommand(AccountM_,"1");
                    lstConfirm.Add(AccountCom_);
                    #endregion
                }
            }
            if (modelList != null && modelList.Count > 0)//明细不为空的时候
            {
                if (modelList[0].FromType == "1")
                {
                    StringBuilder strAddPRetail = new StringBuilder();//增加采购退货货单明细中的已出库数量
                    strAddPRetail.AppendLine("update officedba.PurchaseRejectDetail set ");
                    strAddPRetail.AppendLine(" OutedTotal =ISNULL(OutedTotal,0)+@ReBackNum where ");
                    strAddPRetail.AppendLine(" RejectNo=(select RejectNo from officedba.PurchaseReject where ID=(select FromBillID from officedba.StorageOutOther where ID=" + model.ID + "))");
                    strAddPRetail.AppendLine(" and SortNo=@SortNo");

                    for (int i = 0; i < modelList.Count; i++)
                    {
                        SqlCommand commRePR = new SqlCommand();
                        commRePR.CommandText = strAddPRetail.ToString();

                        commRePR.Parameters.Add(SqlHelper.GetParameterFromString("@ReBackNum", modelList[i].UsedUnitCount));//回写增加的数量
                        commRePR.Parameters.Add(SqlHelper.GetParameterFromString("@SortNo", modelList[i].FromLineNo));
                        lstConfirm.Add(commRePR);//循环加入数组(把PurchaseRejectDetail已经入库数量增加)

                        SqlCommand commPD = updateStorageProduct(modelList[i].BatchNo, modelList[i].ProductID, modelList[i].StorageID, modelList[i].ProductCount, model, false);
                        lstConfirm.Add(commPD);
                    }
                }
                else//FromType=0的时候,也是无来源的时候,只要更新StorageProduct中数据
                {
                    for (int i = 0; i < modelList.Count; i++)
                    {
                        SqlCommand commPD = updateStorageProduct(modelList[i].BatchNo, modelList[i].ProductID, modelList[i].StorageID, modelList[i].ProductCount, model, false);
                        lstConfirm.Add(commPD);
                    }
                }
            }
            bool retval = SqlHelper.ExecuteTransWithArrayList(lstConfirm);
            if (retval)
            {
                string sqlFrom = "select TotalPrice,OtherCorpID from officedba.StorageOutOther "
                                +" where ID=" + model.ID + " ";
                DataTable dtFrom = SqlHelper.ExecuteSql(sqlFrom);
                int custid=0;
                DataTable dtCurrtype = XBase.Data.Office.FinanceManager.CurrTypeSettingDBHelper.GetMasterCurrency(model.CompanyCD);
                string IsVoucher = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).IsVoucher ? "1" : "0";
                string IsApply = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).IsApply ? "1" : "0";
                if(dtFrom.Rows[0]["OtherCorpID"].ToString().Trim()!="")custid=Convert.ToInt32(dtFrom.Rows[0]["OtherCorpID"].ToString().Trim());
                bool VocherFlag = XBase.Data.Office.FinanceManager.AutoVoucherDBHelper.AutoVoucherInsert(6, model.CompanyCD, IsVoucher, IsApply, Convert.ToDecimal(dtFrom.Rows[0]["TotalPrice"].ToString()), "officedba.StorageOutOther," + model.ID, dtCurrtype.Rows[0]["ID"].ToString() +","+dtCurrtype.Rows[0]["ExchangeRate"].ToString(), custid, out retstrval);
                if (VocherFlag) retstrval = "确认成功!";
                else retstrval = "确认成功!" + retstrval;
            }
            else retstrval = "";
            return retval;
        }
        //判断分仓存量表中是否有不存在的记录。
        //当在无来源的时候,选择物品没有通过当前仓库选择,而是从所有的仓库中选择物品
        //就会有这样的情况,当确认的时候,而物品又允许负库存的时候就会出现,在分仓存量表中
        //不存在也时候也能确认。

        public static string ifExist(StorageOutOtherModel model)
        {
            //返回的行号,就是在分仓存量表中不存在的记录。(1,2,5)
            string ReNumList = string.Empty;
            List<StorageOutOtherDetailModel> modelList = new List<StorageOutOtherDetailModel>();
            string sqlSele = "select CompanyCD,ProductID,StorageID,FromType from officedba.StorageOutOtherDetail where CompanyCD='" + model.CompanyCD + "'"
                            + "and OutNo=(select OutNo from officedba.StorageOutOther where ID=" + model.ID + ")";
            DataTable dt = SqlHelper.ExecuteSql(sqlSele);
            if (dt != null && dt.Rows.Count > 0)
            {

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    StorageOutOtherDetailModel modelDetail = new StorageOutOtherDetailModel();
                    if (dt.Rows[i]["ProductID"].ToString() != "")
                    {
                        modelDetail.ProductID = dt.Rows[i]["ProductID"].ToString();
                    }
                    if (dt.Rows[i]["StorageID"].ToString() != "")
                    {
                        modelDetail.StorageID = dt.Rows[i]["StorageID"].ToString();
                    }

                    if (dt.Rows[i]["FromType"].ToString() != "")
                    {
                        modelDetail.FromType = dt.Rows[i]["FromType"].ToString();
                    }
                    if (dt.Rows[i]["CompanyCD"].ToString() != "")
                    {
                        modelDetail.CompanyCD = dt.Rows[i]["CompanyCD"].ToString();
                    }
                    modelList.Add(modelDetail);
                }
            }

            if (modelList != null && modelList.Count > 0)//明细不为空的时候
            {
                //当当前单据是无来源的时候
                if (modelList[0].FromType == "0")
                {
                    //循环
                    for (int i = 0; i < modelList.Count; i++)
                    {
                        //如果判断当前行是返回false那么则记录当前行
                        if (!Exists(modelList[i].StorageID, modelList[i].ProductID, modelList[i].CompanyCD))
                        {
                            if (ReNumList == "" || ReNumList == string.Empty)
                            {
                                ReNumList = (i + 1).ToString();
                            }
                            else
                            {
                                ReNumList += "," + (i + 1).ToString();
                            }
                        }
                    }
                }
            }
            return ReNumList;
        }