/// <summary>
        /// 入库确认
        /// </summary>
        /// <returns>添加是否成功 false:失败,true:成功</returns>
        public static bool ConfirmAll(string OfficeThingsBuySql, string OfficeThingsInStorageInfos, string BuyRecordNo, string CompanyCD, string UserID, SqlParameter[] paramgas)
        {
            try
            {
                ArrayList listADD = new ArrayList();
                OfficeThingsBuyDetailModel OfficeThingsBuyDetailM = new OfficeThingsBuyDetailModel();
                string[] OfficeThingsInStorageArrary = OfficeThingsInStorageInfos.Split('|');
                SqlCommand[] comms = new SqlCommand[OfficeThingsInStorageArrary.Length]; //申明cmd数组(主表,明细表,每条明细生成一条库存记录)
                SqlCommand OfficeThingsBuyCom = new SqlCommand(OfficeThingsBuySql.ToString());
                OfficeThingsBuyCom.Parameters.AddRange(paramgas);
                //comms[0] = OfficeThingsBuyCom;
                listADD.Add(OfficeThingsBuyCom);
                string recorditems = "";
                string[] gasfield = null;

                for (int i = 1; i < OfficeThingsInStorageArrary.Length; i++) //循环数组
                {
                    recorditems = OfficeThingsInStorageArrary[i].ToString();
                    gasfield = recorditems.Split(',');

                    string ThingNo = gasfield[0].ToString();//用品编号
                    string BuyCount = gasfield[1].ToString();//采购数量
                    string UnitPrice = gasfield[2].ToString();//采购单价
                    string BuyMoney = gasfield[3].ToString();//采购金额
                    string Provider = gasfield[4].ToString();//供应商


                    string FromBillID = gasfield[5].ToString();//采购金额
                    string FromSortNo = gasfield[6].ToString();//供应商


                    OfficeThingsBuyDetailM.BuyCount = Convert.ToDecimal(BuyCount);
                    OfficeThingsBuyDetailM.BuyMoney = Convert.ToDecimal(BuyMoney);
                    OfficeThingsBuyDetailM.BuyRecordNo = BuyRecordNo;
                    OfficeThingsBuyDetailM.CompanyCD = CompanyCD;
                    OfficeThingsBuyDetailM.ModifiedDate = System.DateTime.Now;
                    OfficeThingsBuyDetailM.ModifiedUserID = UserID;
                    OfficeThingsBuyDetailM.Provider = Provider;
                    OfficeThingsBuyDetailM.ThingNo = ThingNo;
                    OfficeThingsBuyDetailM.UnitPrice = Convert.ToDecimal(UnitPrice);

                    int RetOfficeThingsVal = OfficeThingsStorageIsExist(ThingNo, CompanyCD);//库存是否有此用品编号的记录,有更新库存,无插入新的库存记录
                    OfficeThingsStorageModel OfficeThingsStorageM = new OfficeThingsStorageModel();
                    if (RetOfficeThingsVal == 0)//无此编号的库存,插入库存信息
                    {
                        #region 拼写添加入库库存信息sql语句
                        StringBuilder OfficeThingsStorageSql = new StringBuilder();
                        OfficeThingsStorageSql.AppendLine("INSERT INTO officedba.OfficeThingsStorage");
                        OfficeThingsStorageSql.AppendLine("(CompanyCD");
                        OfficeThingsStorageSql.AppendLine(",ThingNo     ");
                        OfficeThingsStorageSql.AppendLine(",TotalCount");
                        OfficeThingsStorageSql.AppendLine(",SurplusCount   ");
                        OfficeThingsStorageSql.AppendLine(",UsedCount  ");
                        OfficeThingsStorageSql.AppendLine(",ModifiedDate");
                        OfficeThingsStorageSql.AppendLine(",ModifiedUserID)");
                        OfficeThingsStorageSql.AppendLine(" values ");
                        OfficeThingsStorageSql.AppendLine("(@CompanyCD");
                        OfficeThingsStorageSql.AppendLine(",@ThingNo     ");
                        OfficeThingsStorageSql.AppendLine(",@TotalCount");
                        OfficeThingsStorageSql.AppendLine(",@SurplusCount   ");
                        OfficeThingsStorageSql.AppendLine(",@UsedCount  ");
                        OfficeThingsStorageSql.AppendLine(",@ModifiedDate");
                        OfficeThingsStorageSql.AppendLine(",@ModifiedUserID)");
                        #endregion
                        #region 设置参数
                        SqlParameter[] OfficeThingsStorageParams = new SqlParameter[7];
                        OfficeThingsStorageParams[0] = SqlHelper.GetParameter("@CompanyCD", OfficeThingsBuyDetailM.CompanyCD);
                        OfficeThingsStorageParams[1] = SqlHelper.GetParameter("@ThingNo", OfficeThingsBuyDetailM.ThingNo);
                        OfficeThingsStorageParams[2] = SqlHelper.GetParameter("@TotalCount", OfficeThingsBuyDetailM.BuyCount);
                        OfficeThingsStorageParams[3] = SqlHelper.GetParameter("@SurplusCount", OfficeThingsBuyDetailM.BuyCount);
                        OfficeThingsStorageParams[4] = SqlHelper.GetParameter("@UsedCount", 0);
                        OfficeThingsStorageParams[5] = SqlHelper.GetParameter("@ModifiedDate", OfficeThingsBuyDetailM.ModifiedDate);
                        OfficeThingsStorageParams[6] = SqlHelper.GetParameter("@ModifiedUserID", OfficeThingsBuyDetailM.ModifiedUserID);
                        #endregion
                        SqlCommand OfficeThingsStorageComInfo = new SqlCommand(OfficeThingsStorageSql.ToString());
                        OfficeThingsStorageComInfo.Parameters.AddRange(OfficeThingsStorageParams);
                        //comms[i] = OfficeThingsStorageComInfo;

                        listADD.Add(OfficeThingsStorageComInfo);
                    }
                    else //有此编号,更新库存信息
                    {
                        #region 拼写添加入库库存信息sql语句
                        StringBuilder OfficeThingsStorageSql = new StringBuilder();
                        OfficeThingsStorageSql.AppendLine("UPDATE officedba.OfficeThingsStorage");
                        OfficeThingsStorageSql.AppendLine("SET TotalCount=TotalCount+@TotalCount");
                        OfficeThingsStorageSql.AppendLine(",SurplusCount=SurplusCount+@TotalCount1   ");
                        OfficeThingsStorageSql.AppendLine(",ModifiedDate=@ModifiedDate");
                        OfficeThingsStorageSql.AppendLine(",ModifiedUserID=@ModifiedUserID");
                        OfficeThingsStorageSql.AppendLine(" WHERE ThingNo=@ThingNo AND CompanyCD=@CompanyCD ");
                        #endregion
                        #region 设置参数
                        SqlParameter[] OfficeThingsStorageParams = new SqlParameter[6];
                        OfficeThingsStorageParams[0] = SqlHelper.GetParameter("@TotalCount", OfficeThingsBuyDetailM.BuyCount);
                        OfficeThingsStorageParams[1] = SqlHelper.GetParameter("@TotalCount1", OfficeThingsBuyDetailM.BuyCount);
                        OfficeThingsStorageParams[2] = SqlHelper.GetParameter("@ModifiedDate", OfficeThingsBuyDetailM.ModifiedDate);
                        OfficeThingsStorageParams[3] = SqlHelper.GetParameter("@ModifiedUserID", OfficeThingsBuyDetailM.ModifiedUserID);
                        OfficeThingsStorageParams[4] = SqlHelper.GetParameter("@ThingNo", OfficeThingsBuyDetailM.ThingNo);
                        OfficeThingsStorageParams[5] = SqlHelper.GetParameter("@CompanyCD", OfficeThingsBuyDetailM.CompanyCD);


                        #endregion
                        SqlCommand OfficeThingsStorageComInfo = new SqlCommand(OfficeThingsStorageSql.ToString());
                        OfficeThingsStorageComInfo.Parameters.AddRange(OfficeThingsStorageParams);
                       // comms[i] = OfficeThingsStorageComInfo;
                        listADD.Add(OfficeThingsStorageComInfo);
                    }


                    if (Convert .ToInt32 ( FromBillID) >0)// 回写信息
                    {
                        #region 拼写添加入库库存信息sql语句
                        StringBuilder OfficeThingsStorageSql = new StringBuilder();
                        OfficeThingsStorageSql.AppendLine("UPDATE officedba.OfficeThingsPurchaseApplyDetail ");
                        OfficeThingsStorageSql.AppendLine("SET InCount=isnull(InCount,0)+@InCount ");
                        OfficeThingsStorageSql.AppendLine(" WHERE ID=@FromBillID AND CompanyCD=@CompanyCD  ");
                        #endregion
                        #region 设置参数
                        SqlParameter[] OfficeThingsStorageParams = new SqlParameter[3];
                        OfficeThingsStorageParams[0] = SqlHelper.GetParameter("@FromBillID", FromBillID);
                        OfficeThingsStorageParams[1] = SqlHelper.GetParameter("@InCount", OfficeThingsBuyDetailM.BuyCount);
                        OfficeThingsStorageParams[2] = SqlHelper.GetParameter("@CompanyCD", OfficeThingsBuyDetailM.CompanyCD);

                        #endregion
                        SqlCommand OfficeThingsStorageComInfo = new SqlCommand(OfficeThingsStorageSql.ToString());
                        OfficeThingsStorageComInfo.Parameters.AddRange(OfficeThingsStorageParams);
                       // comms[(i+1)] = OfficeThingsStorageComInfo;

                        listADD.Add(OfficeThingsStorageComInfo);
                    }

                }
                //执行
             //   SqlHelper.ExecuteTransForList(comms);
                SqlHelper.ExecuteTransWithArrayList(listADD);
                return SqlHelper.Result.OprateCount > 0 ? true : false;
            }
            catch 
            {
                return false;
            }
        }
        /// <summary>
        /// 修改入库库存和入库单明细信息
        /// </summary>
        /// <returns>更新是否成功 false:失败,true:成功</returns>
        public static bool UpdateAll(string OfficeThingsBuySql, string OfficeThingsInStorageInfos, string BuyRecordNo, string CompanyCD, string UserID, SqlParameter[] paramgas)
        {
            try
            {
                OfficeThingsBuyDetailModel OfficeThingsBuyDetailM = new OfficeThingsBuyDetailModel();
                string[] OfficeThingsInStorageArrary = OfficeThingsInStorageInfos.Split('|');
                SqlCommand[] comms = new SqlCommand[OfficeThingsInStorageArrary.Length+1]; //申明cmd数组(主表,明细表,每条明细生成一条库存记录)
                SqlCommand OfficeThingsBuyCom = new SqlCommand(OfficeThingsBuySql.ToString());
                OfficeThingsBuyCom.Parameters.AddRange(paramgas);
                comms[0] = OfficeThingsBuyCom;

                #region 首先删除此入库单的明细
                string OfficeThingsDelBuyDetailSql = "DELETE FROM officedba.OfficeThingsBuyDetail WHERE BuyRecordNo='" + BuyRecordNo + "' AND CompanyCD='"+CompanyCD+"'";
                //SqlParameter[] OfficeThingsDelBuyDetailParams = new SqlParameter[1];
               // OfficeThingsDelBuyDetailParams[0] = SqlHelper.GetParameter("@BuyRecordNo1", BuyRecordNo);
                //OfficeThingsDelBuyDetailParams[0] = SqlHelper.GetParameter("@CompanyCD1", CompanyCD);
                SqlCommand OfficeThingsDelBuyDetailCom = new SqlCommand(OfficeThingsDelBuyDetailSql.ToString());
                //OfficeThingsBuyCom.Parameters.AddRange(OfficeThingsDelBuyDetailParams);
                comms[1] = OfficeThingsDelBuyDetailCom;
                #endregion
               
                string recorditems = "";
                string[] gasfield = null;

                for (int i = 1; i < OfficeThingsInStorageArrary.Length; i++) //循环数组
                {
                    recorditems = OfficeThingsInStorageArrary[i].ToString();
                    gasfield = recorditems.Split(',');

                    string ThingNo = gasfield[0].ToString();//用品编号
                    string BuyCount = gasfield[1].ToString();//采购数量
                    string UnitPrice = gasfield[2].ToString();//采购单价
                    string BuyMoney = gasfield[3].ToString();//采购金额
                    string Provider = gasfield[4].ToString();//供应商

                    string FromBillID = gasfield[5].ToString();//采购金额
                    string FromSortNo = gasfield[6].ToString();//供应商

                    OfficeThingsBuyDetailM.BuyCount = Convert.ToDecimal(BuyCount);
                    OfficeThingsBuyDetailM.BuyMoney = Convert.ToDecimal(BuyMoney);
                    OfficeThingsBuyDetailM.BuyRecordNo = BuyRecordNo;
                    OfficeThingsBuyDetailM.CompanyCD = CompanyCD;
                    OfficeThingsBuyDetailM.ModifiedDate = System.DateTime.Now;
                    OfficeThingsBuyDetailM.ModifiedUserID = UserID;
                    OfficeThingsBuyDetailM.Provider = Provider;
                    OfficeThingsBuyDetailM.ThingNo = ThingNo;
                    OfficeThingsBuyDetailM.UnitPrice = Convert.ToDecimal(UnitPrice);

                    OfficeThingsBuyDetailM.FromBillID = FromBillID;
                    OfficeThingsBuyDetailM.FromSortNo = FromSortNo;
                    #region 拼写添加入库明细信息sql语句
                    StringBuilder OfficeThingsBuyDetailSql = new StringBuilder();
                    OfficeThingsBuyDetailSql.AppendLine("INSERT INTO officedba.OfficeThingsBuyDetail");
                    OfficeThingsBuyDetailSql.AppendLine("(CompanyCD");
                    OfficeThingsBuyDetailSql.AppendLine(",BuyRecordNo     ");
                    OfficeThingsBuyDetailSql.AppendLine(",ThingNo");
                    OfficeThingsBuyDetailSql.AppendLine(",Provider   ");
                    OfficeThingsBuyDetailSql.AppendLine(",UnitPrice  ");
                    OfficeThingsBuyDetailSql.AppendLine(",BuyCount    ");
                    OfficeThingsBuyDetailSql.AppendLine(",BuyMoney    ");

                    OfficeThingsBuyDetailSql.AppendLine(",FromBillID    ");
                    OfficeThingsBuyDetailSql.AppendLine(",FromSortNo    ");

                    OfficeThingsBuyDetailSql.AppendLine(",ModifiedDate");
                    OfficeThingsBuyDetailSql.AppendLine(",ModifiedUserID)");
                    OfficeThingsBuyDetailSql.AppendLine(" values ");
                    OfficeThingsBuyDetailSql.AppendLine("(@CompanyCD");
                    OfficeThingsBuyDetailSql.AppendLine(",@BuyRecordNo     ");
                    OfficeThingsBuyDetailSql.AppendLine(",@ThingNo");
                    OfficeThingsBuyDetailSql.AppendLine(",@Provider   ");
                    OfficeThingsBuyDetailSql.AppendLine(",@UnitPrice  ");
                    OfficeThingsBuyDetailSql.AppendLine(",@BuyCount    ");
                    OfficeThingsBuyDetailSql.AppendLine(",@BuyMoney    ");

                    OfficeThingsBuyDetailSql.AppendLine(",@FromBillID    ");
                    OfficeThingsBuyDetailSql.AppendLine(",@FromSortNo    ");
                    OfficeThingsBuyDetailSql.AppendLine(",@ModifiedDate");
                    OfficeThingsBuyDetailSql.AppendLine(",@ModifiedUserID)");
                    #endregion
                    #region 设置参数
                    SqlParameter[] OfficeThingsBuyDetailParams = new SqlParameter[11];
                    OfficeThingsBuyDetailParams[0] = SqlHelper.GetParameter("@CompanyCD", OfficeThingsBuyDetailM.CompanyCD);
                    OfficeThingsBuyDetailParams[1] = SqlHelper.GetParameter("@BuyRecordNo", OfficeThingsBuyDetailM.BuyRecordNo);
                    OfficeThingsBuyDetailParams[2] = SqlHelper.GetParameter("@ThingNo", OfficeThingsBuyDetailM.ThingNo);
                    OfficeThingsBuyDetailParams[3] = SqlHelper.GetParameter("@Provider", OfficeThingsBuyDetailM.Provider);
                    OfficeThingsBuyDetailParams[4] = SqlHelper.GetParameter("@UnitPrice", OfficeThingsBuyDetailM.UnitPrice);
                    OfficeThingsBuyDetailParams[5] = SqlHelper.GetParameter("@BuyCount", OfficeThingsBuyDetailM.BuyCount);
                    OfficeThingsBuyDetailParams[6] = SqlHelper.GetParameter("@BuyMoney", OfficeThingsBuyDetailM.BuyMoney);
                    OfficeThingsBuyDetailParams[7] = SqlHelper.GetParameter("@ModifiedDate", OfficeThingsBuyDetailM.ModifiedDate);
                    OfficeThingsBuyDetailParams[8] = SqlHelper.GetParameter("@ModifiedUserID", OfficeThingsBuyDetailM.ModifiedUserID);
                    OfficeThingsBuyDetailParams[9] = SqlHelper.GetParameter("@FromBillID", OfficeThingsBuyDetailM.FromBillID);
                    OfficeThingsBuyDetailParams[10] = SqlHelper.GetParameter("@FromSortNo", OfficeThingsBuyDetailM.FromSortNo);
                    SqlCommand OfficeThingsBuyDetailComInfo = new SqlCommand(OfficeThingsBuyDetailSql.ToString());
                    OfficeThingsBuyDetailComInfo.Parameters.AddRange(OfficeThingsBuyDetailParams);
                    comms[i+1] = OfficeThingsBuyDetailComInfo;
                    #endregion

                    //int RetOfficeThingsVal = OfficeThingsStorageIsExist(ThingNo, CompanyCD);//库存是否有此用品编号的记录,有更新库存,无插入新的库存记录
                    //OfficeThingsStorageModel OfficeThingsStorageM = new OfficeThingsStorageModel();
                    //if (RetOfficeThingsVal == 0)//无此编号的库存,插入库存信息
                    //{
                    //    #region 拼写添加入库库存信息sql语句
                    //    StringBuilder OfficeThingsStorageSql = new StringBuilder();
                    //    OfficeThingsStorageSql.AppendLine("INSERT INTO officedba.OfficeThingsStorage");
                    //    OfficeThingsStorageSql.AppendLine("(CompanyCD");
                    //    OfficeThingsStorageSql.AppendLine(",ThingNo     ");
                    //    OfficeThingsStorageSql.AppendLine(",TotalCount");
                    //    OfficeThingsStorageSql.AppendLine(",SurplusCount   ");
                    //    OfficeThingsStorageSql.AppendLine(",UsedCount  ");
                    //    OfficeThingsStorageSql.AppendLine(",ModifiedDate");
                    //    OfficeThingsStorageSql.AppendLine(",ModifiedUserID)");
                    //    OfficeThingsStorageSql.AppendLine(" values ");
                    //    OfficeThingsStorageSql.AppendLine("(@CompanyCD");
                    //    OfficeThingsStorageSql.AppendLine(",@ThingNo     ");
                    //    OfficeThingsStorageSql.AppendLine(",@TotalCount");
                    //    OfficeThingsStorageSql.AppendLine(",@SurplusCount   ");
                    //    OfficeThingsStorageSql.AppendLine(",@UsedCount  ");
                    //    OfficeThingsStorageSql.AppendLine(",@ModifiedDate");
                    //    OfficeThingsStorageSql.AppendLine(",@ModifiedUserID)");
                    //    #endregion
                    //    #region 设置参数
                    //    SqlParameter[] OfficeThingsStorageParams = new SqlParameter[7];
                    //    OfficeThingsStorageParams[0] = SqlHelper.GetParameter("@CompanyCD", OfficeThingsBuyDetailM.CompanyCD);
                    //    OfficeThingsStorageParams[1] = SqlHelper.GetParameter("@ThingNo", OfficeThingsBuyDetailM.ThingNo);
                    //    OfficeThingsStorageParams[2] = SqlHelper.GetParameter("@TotalCount", OfficeThingsBuyDetailM.BuyCount);
                    //    OfficeThingsStorageParams[3] = SqlHelper.GetParameter("@SurplusCount", OfficeThingsBuyDetailM.BuyCount);
                    //    OfficeThingsStorageParams[4] = SqlHelper.GetParameter("@UsedCount", 0);
                    //    OfficeThingsStorageParams[5] = SqlHelper.GetParameter("@ModifiedDate", OfficeThingsBuyDetailM.ModifiedDate);
                    //    OfficeThingsStorageParams[6] = SqlHelper.GetParameter("@ModifiedUserID", OfficeThingsBuyDetailM.ModifiedUserID);
                    //    #endregion
                    //    SqlCommand OfficeThingsStorageComInfo = new SqlCommand(OfficeThingsStorageSql.ToString());
                    //    OfficeThingsStorageComInfo.Parameters.AddRange(OfficeThingsStorageParams);
                    //    comms[i + 2] = OfficeThingsStorageComInfo;
                    //}
                    //else //有此编号,更新库存信息
                    //{
                    //    #region 拼写添加入库库存信息sql语句
                    //    StringBuilder OfficeThingsStorageSql = new StringBuilder();
                    //    OfficeThingsStorageSql.AppendLine("UPDATE officedba.OfficeThingsStorage");
                    //    OfficeThingsStorageSql.AppendLine("SET TotalCount=TotalCount+@TotalCount");
                    //    OfficeThingsStorageSql.AppendLine(",SurplusCount=SurplusCount+@TotalCount1   ");
                    //    OfficeThingsStorageSql.AppendLine(",ModifiedDate=@ModifiedDate");
                    //    OfficeThingsStorageSql.AppendLine(",ModifiedUserID=@ModifiedUserID");
                    //    OfficeThingsStorageSql.AppendLine(" WHERE ThingNo=@ThingNo AND CompanyCD=@CompanyCD ");
                    //    #endregion
                    //    #region 设置参数
                    //    SqlParameter[] OfficeThingsStorageParams = new SqlParameter[6];
                    //    OfficeThingsStorageParams[0] = SqlHelper.GetParameter("@TotalCount", OfficeThingsBuyDetailM.BuyCount);
                    //    OfficeThingsStorageParams[1] = SqlHelper.GetParameter("@TotalCount1", OfficeThingsBuyDetailM.BuyCount);
                    //    OfficeThingsStorageParams[2] = SqlHelper.GetParameter("@ModifiedDate", OfficeThingsBuyDetailM.ModifiedDate);
                    //    OfficeThingsStorageParams[3] = SqlHelper.GetParameter("@ModifiedUserID", OfficeThingsBuyDetailM.ModifiedUserID);
                    //    OfficeThingsStorageParams[4] = SqlHelper.GetParameter("@ThingNo", OfficeThingsBuyDetailM.ThingNo);
                    //    OfficeThingsStorageParams[5] = SqlHelper.GetParameter("@CompanyCD", OfficeThingsBuyDetailM.CompanyCD);


                    //    #endregion
                    //    SqlCommand OfficeThingsStorageComInfo = new SqlCommand(OfficeThingsStorageSql.ToString());
                    //    OfficeThingsStorageComInfo.Parameters.AddRange(OfficeThingsStorageParams);
                    //    comms[i + 2] = OfficeThingsStorageComInfo;
                    //}
                }
                //执行
                SqlHelper.ExecuteTransForList(comms);
                return SqlHelper.Result.OprateCount > 0 ? true : false;
            }
            catch 
            {
                return false;
            }
        }