Ejemplo n.º 1
0
        /// <summary>
        /// 插入红冲出库和红冲出库明细
        /// </summary>
        /// <param name="model"></param>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public static bool InsertStorageOutRed(StorageOutRedModel model,Hashtable ht, List<StorageOutRedDetailModel> modelList, out int IndexIDentity)
        {
            IndexIDentity = 0;
            //获取登陆用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            //设置公司代码
            model.CompanyCD = userInfo.CompanyCD;
            //定义返回变量
            bool isSucc = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */
            //获取公司代码
            string companyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;

            //执行删除操作
            try
            {
                //执行更新
                isSucc = StorageOutRedDBHelper.InsertStorageOutRed(model,ht, modelList, out IndexIDentity);


            }
            catch (Exception ex)
            {
                //输出日志
                WriteSystemLog(userInfo, ex);
            }
            //定义变量
            string remark;
            //成功时
            if (isSucc)
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
            }
            else
            {
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
            }
            //操作日志
            LogInfoModel logModel = InitLogInfo(model.OutNo);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = ConstUtil.LOG_PROCESS_INSERT;
            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);
            return isSucc;
        }
    protected void btnImport_Click(object sender, ImageClickEventArgs e)
    {

        StorageOutRedModel model = new StorageOutRedModel();
        string OutDateStart = string.Empty;
        string OutDateEnd = string.Empty;
        model.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
        model.OutNo = txtOutNo.Value;
        model.Title = txtTitle.Value;
        model.BillStatus = sltBillStatus.Value;
        model.FromType = sltFromType.Value;
        model.Executor = txtOuterID.Value;
        OutDateStart = txtOutDateStart.Value;
        OutDateEnd = txtOutDateEnd.Value;
        model.FromBillID = hidFromBillID.Value;
        string orderBy = txtorderBy.Value;
        if (!string.IsNullOrEmpty(orderBy))
        {
            if (orderBy.Split('_')[1] == "a")
            {
                orderBy = orderBy.Split('_')[0] + " asc";
            }
            else
            {
                orderBy = orderBy.Split('_')[0] + " desc";
            }
        }
        string IndexValue = GetBillExAttrControl1.GetExtIndexValue;
        string TxtValue = GetBillExAttrControl1.GetExtTxtValue;
        string BatchNo = this.txtBatchNo.Value.ToString();

        DataTable dt = StorageOutRedBus.GetStorageOutRedTableBycondition(model, IndexValue, TxtValue, OutDateStart, OutDateEnd,BatchNo, orderBy);

        if (((UserInfoUtil)SessionUtil.Session["UserInfo"]).IsDisplayPrice)
            OutputToExecl.ExportToTableFormat(this, dt,
                new string[] { "出库单编号", "出库单主题", "源单类型", "原始出库单", "出库人", "出库时间", "红冲数量", "红冲金额", "摘要", "单据状态" },
                new string[] { "OutNo", "Title", "FromTypeName", "FromOutNo", "Transactor", "OutDate", "CountTotal", "TotalPrice", "Summary", "BillStatusName" },
                "红冲出库列表");
        else
            OutputToExecl.ExportToTableFormat(this, dt,
                new string[] { "出库单编号", "出库单主题", "源单类型", "原始出库单", "出库人", "出库时间", "红冲数量",  "摘要", "单据状态" },
                new string[] { "OutNo", "Title", "FromTypeName", "FromOutNo", "Transactor", "OutDate", "CountTotal",  "Summary", "BillStatusName" },
                "红冲出库列表");

    }
Ejemplo n.º 3
0
 /// <summary>
 /// 获取红冲出库详细信息(加载页面的时候)
 /// </summary>
 /// <returns>DataTable</returns>
 public static DataTable GetStorageOutRedDetailInfo(StorageOutRedModel model)
 {
     return StorageOutRedDBHelper.GetStorageOutRedDetailInfo(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取出库单列表
        /// </summary>
        /// <param name="companycd"></param>
        /// <returns></returns>
        public static DataTable GetStorageOutList(StorageOutRedModel model, string OutType)
        {
            try
            {
                return StorageOutRedDBHelper.GetStorageOutList(model, OutType);
            }
            catch (Exception)
            {

                throw;
            }

        }
Ejemplo n.º 5
0
        public static bool CancelCloseBill(StorageOutRedModel model)
        {

            //获取登陆用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];
            //设置公司代码
            model.CompanyCD = userInfo.CompanyCD;
            //定义返回变量
            bool isSucc = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */
            //获取公司代码
            string companyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;

            //执行删除操作
            try
            {
                //执行更新
                isSucc = StorageOutRedDBHelper.CancelCloseBill(model);
            }
            catch (Exception ex)
            {
                //输出日志
                WriteSystemLog(userInfo, ex);
            }

            //定义变量
            string remark;
            //成功时
            if (isSucc)
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
            }
            else
            {
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
            }
            //操作日志
            LogInfoModel logModel = InitLogInfo(model.ID);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = "取消结单";
            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);
            return isSucc;
        }
Ejemplo n.º 6
0
 public static DataTable GetStorageOutRedTableBycondition(StorageOutRedModel model, string IndexValue, string TxtValue, string timeStart, string timeEnd,string BatchNo, string orderby)
 {
     return StorageOutRedDBHelper.GetStorageOutRedTableBycondition(model, IndexValue, TxtValue, timeStart, timeEnd,BatchNo, orderby);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 查询红冲出库单
 /// </summary>
 /// <returns>DataTable</returns>
 public static DataTable GetStorageOutRedTableBycondition(StorageOutRedModel model, string timeStart, string timeEnd, string EFIndex, string EFDesc, int pageIndex, int pageCount, string ord, ref int TotalCount)
 {
     return StorageOutRedDBHelper.GetStorageOutRedTableBycondition(model, timeStart, timeEnd,EFIndex,EFDesc, pageIndex, pageCount, ord, ref TotalCount);
 }
 /// <summary>
 /// 获取出库单列表
 /// </summary>
 /// <param name="companycd"></param>
 /// <returns></returns>
 public static DataTable GetStorageOutList(StorageOutRedModel model, string OutType)
 {
     string sql = string.Empty;
     switch (OutType)
     {
         case "1":
             {
                 sql = "select ID,'销售出库单' as FromType,OutNo,Title,CountTotal,ISNULL(CONVERT(VARCHAR(10),CreateDate,21),'') AS CreateDate from officedba.StorageOutSell where CompanyCD='" + model.CompanyCD + "' and BillStatus=2";
             }
             break;
         case "2":
             {
                 sql = "select ID,'其他出库单' as FromType,OutNo,Title,CountTotal,ISNULL(CONVERT(VARCHAR(10),CreateDate,21),'') AS CreateDate from officedba.StorageOutOther where CompanyCD='" + model.CompanyCD + "' and BillStatus=2";
             }
             break;
         default:
             break;
     }
     SqlCommand comm = new SqlCommand();
     //添加公司代码参数
     if (!string.IsNullOrEmpty(model.OutNo))
     {
         sql += " and OutNo like '%'+ @OutNo +'%'";
         comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutNo", model.OutNo));
     }
     if (!string.IsNullOrEmpty(model.Title))
     {
         sql += " and Title like '%'+ @Title +'%'";
         comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title", model.Title));
     }
     comm.CommandText = sql;
     return SqlHelper.ExecuteSearch(comm);
 }
        /// <summary>
        /// 获取红冲出库详细信息(加载页面的时候)
        /// </summary>
        /// <returns>DataTable</returns>
        public static DataTable GetStorageOutRedDetailInfo(StorageOutRedModel model)
        {
            //a->officedba.StorageOutRed
            //b->officedba.StorageOutRedDetail
            //k->officedba.SellSend
            //l->officedba.SellSendDetail

            StringBuilder sql = new StringBuilder();
            sql.AppendLine("select DISTINCT a.ID,a.CanViewUser,a.CanViewUserName,a.ExtField1,a.ExtField2,a.ExtField3,a.ExtField4,a.ExtField5,a.ExtField6,a.ExtField6,a.ExtField7,a.ExtField8,a.ExtField9,a.ExtField10   ");
            sql.AppendLine(",x.StorageName,y.CodeName as ReasonTypeName,a.CompanyCD                                                                                                                                                                                      ");
            sql.AppendLine(",a.OutNo,c.IsBatchNo,b.UnitID as HiddenUnitID,b.BatchNo,b.UsedUnitID,b.UsedUnitCount,b.UsedPrice,b.ExRate,ii.CodeName as UsedUnitName                                                                                                                                                                                          ");
            sql.AppendLine(",case a.FromType when  '1' then '销售出库单' when '2' then '其他出库单' else '' end as FromTypeName  ");
            sql.AppendLine(",case a.billStatus when  '1' then '制单' when '2' then '执行' when '3' then '变更'");
            sql.AppendLine("when '4' then '手工结单' when '5' then '自动结单' else '' end as BillStatusName   ");
            sql.AppendLine(",a.FromType                                                                                                                                                                                       ");
            sql.AppendLine(",a.FromBillID                                                                                                                                                                                     ");
            sql.AppendLine(",a.ReasonType");
            sql.AppendLine(",case a.FromType                                                                                                                                                                                  ");
            sql.AppendLine("when '1' then (select  bb.OutNo from officedba.StorageOutSell bb where bb.id=a.FrombillID)                                                                                                        ");
            sql.AppendLine("when '2' then (select  cc.OutNo from officedba.StorageOutOther cc where cc.id=a.FrombillID)                                                                                                       ");
            sql.AppendLine("end FromOutNo                                                                                                                                                                                     ");
            sql.AppendLine("                                                                                                                                                                                                  ");
            sql.AppendLine(",case a.FromType                                                                                                                                                                                  ");
            sql.AppendLine("when '1' then (select  CONVERT(VARCHAR(10),bb.OutDate, 21) from officedba.StorageOutSell bb where bb.id=a.FrombillID)                                                                             ");
            sql.AppendLine("when '2' then (select  CONVERT(VARCHAR(10),cc.OutDate, 21) from officedba.StorageOutOther cc where cc.id=a.FrombillID)                                                                            ");
            sql.AppendLine("end FromOutDate                                                                                                                                                                                   ");
            sql.AppendLine(",case a.FromType                                                                                                                                                                                  ");
            sql.AppendLine("when '1' then (select ISNULL(ee.DeptName,'') from officedba.StorageOutSell bb left join officedba.DeptInfo ee on bb.DeptID=ee.ID where bb.id=a.FrombillID)                                                                             ");
            sql.AppendLine("when '2' then (select ISNULL(ee.DeptName,'') from officedba.StorageOutOther cc left join officedba.DeptInfo ee on cc.DeptID=ee.ID where cc.id=a.FrombillID)                                                                            ");
            sql.AppendLine("end FromDeptName                                                                                                                                                                                   ");
            sql.AppendLine(",case a.FromType                                                                                                                                                                                  ");
            sql.AppendLine("when '1' then (select  ee.EmployeeName from officedba.StorageOutSell bb left join officedba.EmployeeInfo ee on bb.Transactor=ee.ID where bb.id=a.FrombillID)                                      ");
            sql.AppendLine("when '2' then (select  ee.EmployeeName from officedba.StorageOutOther cc left join officedba.EmployeeInfo ee on cc.Transactor=ee.ID where cc.id=a.FrombillID)                                     ");
            sql.AppendLine("end FromExecutor                                                                                                                                                                                  ");
            sql.AppendLine("                                                                                                                                                                                                  ");
            sql.AppendLine(",case a.FromType                                                                                                                                                                                  ");
            sql.AppendLine("when '1' then (select  bb.ProductCount from officedba.StorageOutSellDetail bb left join officedba.StorageOutSell ee on bb.OutNo=ee.OutNo and bb.Companycd=ee.Companycd  and bb.SortNo=b.FromLineNo where ee.id=a.FrombillID)     ");
            sql.AppendLine("when '2' then (select  bb.ProductCount from officedba.StorageOutOtherDetail  bb left join officedba.StorageOutOther  ee on bb.OutNo=ee.OutNo and bb.Companycd=ee.Companycd  and bb.SortNo=b.FromLineNo where ee.ID=a.FrombillID) ");
            sql.AppendLine("end FromBillCount                                                                                                                                                                                 ");
            sql.AppendLine(",case a.FromType                                                                                                                                                                                  ");
            sql.AppendLine("when '1' then (select  bb.Summary from officedba.StorageOutSell bb where bb.id=a.FrombillID)");
            sql.AppendLine("when '2' then (select  bb.Summary from officedba.StorageOutOther  bb where bb.id=a.FrombillID) ");
            sql.AppendLine("end FromSummary                                                                                                                                                                                 ");
            sql.AppendLine("                                                                                                                                                                                                  ");
            sql.AppendLine(",a.Title                                                                                                                                                                                          ");
            sql.AppendLine(",a.DeptID                                                                                                                                                                                         ");
            sql.AppendLine(",j.DeptName                                                                                                                                                                                       ");
            sql.AppendLine(",a.Executor                                                                                                                                                                                       ");
            sql.AppendLine(",ISNULL(f.EmployeeName,'') as TransactorName                                                                                                                                                      ");
            sql.AppendLine(",case when a.OutDate Is NULL then '' else CONVERT(VARCHAR(10),a.OutDate, 21) end AS OutDate                                                                                                       ");
            sql.AppendLine(",a.BillStatus                                                                                                                                                                                     ");
            sql.AppendLine(",ISNULL(a.Summary,'') as Summary                                                                                                                                                                  ");
            sql.AppendLine(",ISNULL(a.TotalPrice,'0') as A_TotalPrice                                                                                                                                                         ");
            sql.AppendLine(",ISNULL(a.CountTotal,'0') as CountTotal                                                                                                                                                           ");
            sql.AppendLine(",a.Creator                                                                                                                                                                                        ");
            sql.AppendLine(",ISNULL(g.EmployeeName,'') as CreatorName                                                                                                                                                         ");
            sql.AppendLine(",case when a.CreateDate Is NULL then '' else CONVERT(VARCHAR(10),a.CreateDate, 21) end AS CreateDate                                                                                              ");
            sql.AppendLine(",a.Confirmor                                                                                                                                                                                      ");
            sql.AppendLine(",ISNULL(h.EmployeeName,'') as ConfirmorName                                                                                                                                                       ");
            sql.AppendLine(",case when a.ConfirmDate Is NULL then '' else CONVERT(VARCHAR(10),a.ConfirmDate, 21) end AS ConfirmDate                                                                                           ");
            sql.AppendLine(",a.Closer                                                                                                                                                                                         ");
            sql.AppendLine(",ISNULL(i.EmployeeName,'') as CloserName                                                                                                                                                          ");
            sql.AppendLine(",case when a.CloseDate Is NULL then '' else CONVERT(VARCHAR(10),a.CloseDate, 21) end AS CloseDate                                                                                                 ");
            sql.AppendLine(",case when a.ModifiedDate Is NULL then '' else CONVERT(VARCHAR(10),a.ModifiedDate, 21) end AS ModifiedDate                                                                                        ");
            sql.AppendLine(",a.ModifiedUserID                                                                                                                                                                                 ");
            sql.AppendLine(",a.ModifiedUserID as ModifiedUserName                                                                                                                                                               ");
            sql.AppendLine(",ISNULL(a.Remark,'') as Remark                                                                                                                                                                    ");
            sql.AppendLine(",b.ID as DetailID                                                                                                                                                                                 ");
            sql.AppendLine(",b.ProductID                                                                                                                                                                                      ");
            sql.AppendLine(",c.ProdNo as ProductNo                                                                                                                                                                            ");
            sql.AppendLine(",c.ProductName                                                                                                                                                                                    ");
            sql.AppendLine(",c.Specification                                                                                                                                                                                  ");
            sql.AppendLine(",q.CodeName as UnitID                                                                                                                                                                             ");
            sql.AppendLine(",b.UnitPrice as UnitPrice                                                                                                                                                                         ");
            sql.AppendLine(",b.StorageID                                                                                                                                                                                      ");
            sql.AppendLine(",b.TotalPrice as B_TotalPrice                                                                                                                                                                     ");
            sql.AppendLine(",b.FromType                                                                                                                                                                                       ");
            sql.AppendLine(",b.FromBillID                                                                                                                                                                                     ");
            sql.AppendLine(",b.FromLineNo                                                                                                                                                                                     ");
            sql.AppendLine(",b.SortNo                                                                                                                                                                                         ");
            sql.AppendLine(",b.Remark as DetaiRemark                                                                                                                                                                          ");
            sql.AppendLine(",b.ProductCount                                                                                                                                                                                   ");
            sql.AppendLine("FROM officedba.StorageOutRed a                                                                                                                                                              ");
            sql.AppendLine("left join officedba.StorageOutRedDetail b                                                                                                                                                         ");
            sql.AppendLine("on a.OutNo=b.OutNo  and a.CompanyCD=b.CompanyCD                                                                                                                                                                              ");
            sql.AppendLine("left join officedba.ProductInfo c on c.ID=b.ProductID                                                                                                                                             ");
            sql.AppendLine("left join officedba.EmployeeInfo f on a.Executor=f.ID                                                                                                                                             ");
            sql.AppendLine("left join officedba.EmployeeInfo g on a.Creator=g.ID                                                                                                                                              ");
            sql.AppendLine("left join officedba.EmployeeInfo h on a.Confirmor=h.ID                                                                                                                                            ");
            sql.AppendLine("left join officedba.EmployeeInfo i on a.Closer=i.ID                                                                                                                                               ");
            sql.AppendLine("left join officedba.DeptInfo j on a.DeptID=j.ID                                                                                                                                                   ");
            sql.AppendLine("left join officedba.CodeUnitType q on q.ID=b.UnitID                                                                                                                                               ");
            sql.AppendLine("left join officedba.StorageInfo x on x.ID=b.StorageID ");
            sql.AppendLine("left join officedba.CodeUnitType ii on ii.ID=b.UsedUnitID                                                                                                                                               ");
            sql.AppendLine("left join officedba.CodeReasonType y on a.ReasonType=y.ID ");
            sql.AppendLine("left join (select w.UserID,x.EmployeeName from officedba.UserInfo w ,officedba.EmployeeInfo x where w.EmployeeID =x.ID) m                                                                         ");
            sql.AppendLine("on a.ModifiedUserID=m.UserID 																							                                                                                                                        ");
            sql.AppendLine("   where b.CompanyCD='" + model.CompanyCD + "' and a.id=" + model.ID);
            return SqlHelper.ExecuteSql(sql.ToString());
        }
        public static bool ConfirmBill(StorageOutRedModel model)
        {
            ArrayList lstConfirm = new ArrayList();
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" UPDATE officedba.StorageOutRed 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<StorageOutRedDetailModel> modelList = new List<StorageOutRedDetailModel>();
            string sqlSele = "select ProductID,CompanyCD,StorageID,UnitPrice,OutNo,BatchNo,UsedUnitCount,ProductCount from officedba.StorageOutRedDetail where CompanyCD='" + model.CompanyCD + "'"
                            + "and OutNo=(select OutNo from officedba.StorageOutRed 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++)
                {
                    StorageOutRedDetailModel modelDetail = new StorageOutRedDetailModel();
                    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();
                    }
                    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 = 9;
                    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/StorageOutRedAdd.aspx";
                    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_,"0");
                    lstConfirm.Add(AccountCom_);
                    #endregion
                }
            }
            if (modelList != null && modelList.Count > 0)//明细不为空的时候
            {
                for (int i = 0; i < modelList.Count; i++)
                {
                    SqlCommand commPD = updateStorageProduct(modelList[i].BatchNo, modelList[i].ProductID, modelList[i].StorageID, modelList[i].ProductCount, model, true);
                    lstConfirm.Add(commPD);
                }
            }
            foreach (SqlCommand cmd in GetOutFromBillInfo(model.CompanyCD, model.ID))
            {
                lstConfirm.Add(cmd);
            }

            return SqlHelper.ExecuteTransWithArrayList(lstConfirm);
        }
        /// <summary>
        /// 保存时基本信息参数设置
        /// </summary>
        /// <param name="comm"></param>
        /// <param name="model"></param>
        private static void SetSaveParameter(SqlCommand comm, StorageOutRedModel model)
        {
            if (!string.IsNullOrEmpty(model.ID))
            {
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID ", model.ID));//自动生成
            }
            //@CompanyCD,@OutNo,@Title,@FromType,@FromBillID,@ReasonType,@DeptID,@Executor,@OutDate,@TotalPrice,
            //@CountTotal,@Summary,@Remark,@Creator,getdate(),@BillStatus,getdate(),@ModifiedUserID)
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD ", model.CompanyCD));//公司编码
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title ", model.Title));//主题
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutNo ", model.OutNo));//出库单编号
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromType ", model.FromType));//源单类型
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromBillID ", model.FromBillID));//源单ID
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ReasonType ", model.ReasonType));//原因ID
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@DeptID ", model.DeptID));//出库部门
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@TotalPrice ", model.TotalPrice));//出库金额合计
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CountTotal ", model.CountTotal));//出库数量合计
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Summary ", model.Summary));//摘要
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Remark ", model.Remark));//备注
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Executor ", model.Executor));//出库人
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@Creator ", model.Creator));//制单人
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutDate ", model.OutDate));//出库时间
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus ", model.BillStatus));//单据状态
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID ", model.ModifiedUserID));//最后更新用户ID(对应操作用户表中的UserID)

            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CanViewUser ", model.CanViewUser));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CanViewUserName ", model.CanViewUserName));
        }
        public static SqlCommand updateStorageProduct(string BatchNo, string ProductID, string StorageID, string ProductNum, StorageOutRedModel model, bool flag)
        {
            //true 表示出库增加分仓存量数据
            StringBuilder strSql = new StringBuilder();
            if (flag == true)
            {

                strSql.AppendLine("update officedba.StorageProduct set ");
                strSql.AppendLine("ProductCount=ISNULL(ProductCount,0)+@ProductNum");
                strSql.AppendLine(" where StorageID=@StorageID and ProductID=@ProductID and CompanyCD=@CompanyCD");
                if (BatchNo != "")
                    strSql.AppendLine(" and BatchNo='" + BatchNo.Trim() + "' ");
                else
                    strSql.AppendLine(" and BatchNo is null ");
            }
            //否则 表示(出库减少)分仓存量数据(修改的时候)
            else
            {
                strSql.AppendLine("update officedba.StorageProduct set ");
                strSql.AppendLine("ProductCount=ISNULL(ProductCount,0)-@ProductNum");
                strSql.AppendLine(" where StorageID=@StorageID and ProductID=@ProductID and CompanyCD=@CompanyCD");
                if (BatchNo != "")
                    strSql.AppendLine(" and BatchNo='" + BatchNo.Trim() + "' ");
                else
                    strSql.AppendLine(" and BatchNo is null ");
            }
            SqlCommand commRePD = new SqlCommand();
            commRePD.CommandText = strSql.ToString();

            commRePD.Parameters.AddWithValue("@ProductNum", decimal.Parse(ProductNum));
            commRePD.Parameters.AddWithValue("@StorageID", StorageID);
            commRePD.Parameters.AddWithValue("@ProductID", ProductID);
            commRePD.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));

            return commRePD;

        }
        /// <summary>
        /// 扩展属性保存操作
        /// </summary>
        /// <returns></returns>
        private static void GetExtAttrCmd(StorageOutRedModel model, Hashtable htExtAttr, SqlCommand cmd)
        {
            try
            {
                string strSql = string.Empty;

                strSql = "UPDATE officedba.StorageOutRed set ";
                foreach (DictionaryEntry de in htExtAttr)// fileht为一个Hashtable实例
                {
                    strSql += de.Key.ToString().Trim() + "=@" + de.Key.ToString().Trim() + ",";
                    cmd.Parameters.AddWithValue("@" + de.Key.ToString().Trim(), de.Value.ToString().Trim());
                }
                int iLength = strSql.Length - 1;
                strSql = strSql.Substring(0, iLength);
                strSql += " where CompanyCD = @CompanyCD  AND OutNo = @OutNo";
                cmd.Parameters.AddWithValue("@CompanyCD", model.CompanyCD);
                cmd.Parameters.AddWithValue("@OutNo", model.OutNo);
                cmd.CommandText = strSql;
            }
            catch (Exception)
            { }


        }
        /// <summary>
        /// 更新红冲出库及红冲出库明细
        /// </summary>
        /// <param name="model"></param>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public static bool UpdateStorageOutRed(StorageOutRedModel model,Hashtable htExtAttr,List<StorageOutRedDetailModel> modelList)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update officedba.StorageOutRed set ");
            strSql.Append("CompanyCD=@CompanyCD,");
            strSql.Append("Title=@Title,");
            strSql.Append("FromType=@FromType,");
            strSql.Append("FromBillID=@FromBillID,");
            strSql.Append("ReasonType=@ReasonType,");
            strSql.Append("DeptID=@DeptID,");
            strSql.Append("Executor=@Executor,");
            strSql.Append("OutDate=@OutDate,");
            strSql.Append("TotalPrice=@TotalPrice,");
            strSql.Append("CountTotal=@CountTotal,");
            strSql.Append("Summary=@Summary,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("CanViewUser=@CanViewUser,");
            strSql.Append("CanViewUserName=@CanViewUserName,");
            strSql.Append("Creator=@Creator,");
            strSql.Append("BillStatus=@BillStatus,");
            strSql.Append("ModifiedDate=getdate(),");
            strSql.Append("ModifiedUserID=@ModifiedUserID");
            strSql.Append(" where ID=@ID ");
            SqlCommand comm = new SqlCommand(strSql.ToString());
            SetSaveParameter(comm, model);
            ArrayList lstUpdate = new ArrayList();
            lstUpdate.Add(comm);//数组加入插入基表的command
            #region 拓展属性
            SqlCommand cmd = new SqlCommand();
            GetExtAttrCmd(model, htExtAttr, cmd);
            if (htExtAttr.Count > 0)
                lstUpdate.Add(cmd);
            #endregion
            //先删掉明细表中对应单据的所有数据
            string delDetail = "delete from officedba.StorageOutRedDetail where CompanyCD='" + model.CompanyCD + "' and OutNo='" + model.OutNo + "'";
            SqlCommand commdel = new SqlCommand(delDetail);
            lstUpdate.Add(commdel);

            if (modelList != null && modelList.Count > 0)//明细不为空的时候
            {
                StringBuilder strSqlDetail = new StringBuilder();
                strSqlDetail.Append("insert into officedba.StorageOutRedDetail(");
                strSqlDetail.Append("CompanyCD,OutNo,SortNo,ProductID,StorageID,UnitID,UnitPrice,ProductCount,TotalPrice,Remark,FromType,FromLineNo,ModifiedDate,ModifiedUserID,UsedUnitID,UsedUnitCount,UsedPrice,ExRate,BatchNo)");
                strSqlDetail.Append(" values (");
                strSqlDetail.Append("@CompanyCD,@OutNo,@SortNo,@ProductID,@StorageID,@UnitID,@UnitPrice,@ProductCount,@TotalPrice,@Remark,@FromType,@FromLineNo,getdate(),@ModifiedUserID,@UsedUnitID,@UsedUnitCount,@UsedPrice,@ExRate,@BatchNo)");
                strSqlDetail.Append(";select @@IDENTITY");

                for (int i = 0; i < modelList.Count; i++)
                {
                    SqlCommand commDetail = new SqlCommand();
                    commDetail.CommandText = strSqlDetail.ToString();
                    EditOutRedDetailInfo(commDetail, modelList[i]);//赋参数
                    lstUpdate.Add(commDetail);//循环加入数组(重新获取页面上明细数据)
                }

            }
            return SqlHelper.ExecuteTransWithArrayList(lstUpdate);
        }
        /// <summary>
        /// 插入红冲出库和红冲出库明细
        /// </summary>
        /// <param name="model"></param>
        /// <param name="modelList"></param>
        /// <returns></returns>
        public static bool InsertStorageOutRed(StorageOutRedModel model,Hashtable htExtAttr, List<StorageOutRedDetailModel> modelList, out int IndexIDentity)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into officedba.StorageOutRed(");
            strSql.Append("CompanyCD,OutNo,Title,FromType,FromBillID,ReasonType,DeptID,Executor,OutDate,TotalPrice,CountTotal,Summary,Remark,Creator,CreateDate,BillStatus,ModifiedDate,ModifiedUserID,CanViewUser,CanViewUserName)");
            strSql.Append(" values (");
            strSql.Append("@CompanyCD,@OutNo,@Title,@FromType,@FromBillID,@ReasonType,@DeptID,@Executor,@OutDate,@TotalPrice,@CountTotal,@Summary,@Remark,@Creator,getdate(),@BillStatus,getdate(),@ModifiedUserID,@CanViewUser,@CanViewUserName)");
            strSql.Append(";set @IndexID = @@IDENTITY");
            SqlCommand comm = new SqlCommand();
            comm.CommandText = strSql.ToString();
            SqlParameter IndexID = new SqlParameter("@IndexID", SqlDbType.Int);
            IndexID.Direction = ParameterDirection.Output;
            comm.Parameters.Add(IndexID);
            SetSaveParameter(comm, model);
            ArrayList lstInsert = new ArrayList();
            lstInsert.Add(comm);//数组加入插入基表的command

            #region 拓展属性
            SqlCommand cmd = new SqlCommand();
            GetExtAttrCmd(model, htExtAttr, cmd);
            if (htExtAttr.Count > 0)
                lstInsert.Add(cmd);
            #endregion
            if (modelList != null && modelList.Count > 0)//明细为空的时候
            {
                //插入红冲出库明细
                StringBuilder strSqlDetail = new StringBuilder();
                strSqlDetail.Append("insert into officedba.StorageOutRedDetail(");
                strSqlDetail.Append("CompanyCD,OutNo,SortNo,ProductID,StorageID,UnitID,UnitPrice,ProductCount,TotalPrice,Remark,FromType,FromLineNo,ModifiedDate,ModifiedUserID,UsedUnitID,UsedUnitCount,UsedPrice,ExRate,BatchNo)");
                strSqlDetail.Append(" values (");
                strSqlDetail.Append("@CompanyCD,@OutNo,@SortNo,@ProductID,@StorageID,@UnitID,@UnitPrice,@ProductCount,@TotalPrice,@Remark,@FromType,@FromLineNo,getdate(),@ModifiedUserID,@UsedUnitID,@UsedUnitCount,@UsedPrice,@ExRate,@BatchNo)");
                strSqlDetail.Append(";select @@IDENTITY");
                for (int i = 0; i < modelList.Count; i++)
                {
                    SqlCommand commDetail = new SqlCommand();
                    commDetail.CommandText = strSqlDetail.ToString();
                    EditOutRedDetailInfo(commDetail, modelList[i]);
                    lstInsert.Add(commDetail);//循环加入数组(重新获取页面上明细数据)
                }
            }

            bool result = SqlHelper.ExecuteTransWithArrayList(lstInsert);
            if (result)
            {
                IndexIDentity = int.Parse(((SqlCommand)lstInsert[0]).Parameters["@IndexID"].Value.ToString());
            }
            else
            {
                IndexIDentity = 0;
            }
            return result;


        }
        /// <summary>
        /// 查询红冲出库单
        /// </summary>
        /// <returns>DataTable</returns>
        public static DataTable GetStorageOutRedTableBycondition(StorageOutRedModel model, string timeStart, string timeEnd, string EFIndex, string EFDesc, int pageIndex, int pageCount, string ord, ref int TotalCount)
        {
            string CanUserID = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).EmployeeID.ToString();//当前用户ID

            //出库单编号、出库单主题、源单类型、原始出库单、出库人、出库时间、出库原因、红冲数量、红冲金额、摘要、单据状态
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("SELECT DISTINCT a.ID                                                                           ");
            sql.AppendLine(",a.OutNo                                                                               ");
            sql.AppendLine(",a.Title                                                                               ");
            sql.AppendLine(",a.FromType                                                                            ");
            sql.AppendLine(",case a.FromType when '1' then '销售出库单' when '2' then '其他出库单' end as FromTypeName ");
            sql.AppendLine(",case a.FromType                                                                           ");
            sql.AppendLine("when '1' then (select distinct b.OutNo from  officedba.StorageOutSell b where b.id=a.frombillID) ");
            sql.AppendLine("when '2' then (select distinct c.OutNo from officedba.StorageOutOther c where c.id=a.frombillID) ");
            sql.AppendLine("end FromOutNo                                                                         ");
            sql.AppendLine(",ISNULL(a.TotalPrice,0) as TotalPrice                                                  ");
            sql.AppendLine(",ISNULL(a.CountTotal,0) CountTotal                                                     ");
            sql.AppendLine(",ISNULL(a.Summary,'') as Summary                                                        ");
            sql.AppendLine(",ISNULL(CONVERT(VARCHAR(10),a.OutDate,21),'') AS OutDate	                           ");
            sql.AppendLine(",ISNULL(e.EmployeeName,'') as Transactor	                                                       ");
            sql.AppendLine(",case a.billStatus when  '1' then '制单' when '2' then '执行' when '3' then '变更'     ");
            sql.AppendLine("when '4' then '手工结单' when '5' then '自动结单' else '' end as BillStatusName        ");
            sql.AppendLine("FROM officedba.StorageOutRed a                                                   ");
            sql.AppendLine("left join officedba.EmployeeInfo e on e.ID=a.Executor							       ");
            sql.AppendLine(" left join officedba.StorageOutRedDetail x on x.OutNo=a.OutNo and x.CompanyCD=a.CompanyCD ");
            sql.AppendLine("where a.CompanyCD=@CompanyCD");
            sql.AppendLine("  AND (a.CanViewUser like '%" + "," + CanUserID + "," + "%' or '" + CanUserID + "' = a.Creator or a.CanViewUser = '******' or a.CanViewUser is null )                                                     ");


            //:出库单编号、出库单主题、源单类型(选择)、原始出库单(选择)
            //、出库人(选择)、出库时间(日期段,日期控件)、出库原因(选择)、单据状态(下拉列表)
            SqlCommand comm = new SqlCommand();
            //添加公司代码参数
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));

            if (!string.IsNullOrEmpty(model.OutNo))
            {
                sql.AppendLine("	and a.OutNo like  '%'+ @OutNo + '%' ");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@OutNo", model.OutNo));
            }
            if (!string.IsNullOrEmpty(model.BatchNo))
            {
                sql.AppendLine(" and x.BatchNo = @BatchNo");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BatchNo", model.BatchNo));
            }
            if (!string.IsNullOrEmpty(model.Title))
            {
                sql.AppendLine(" and a.Title like  '%'+ @Title + '%'");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title", model.Title));
            }
            if (!string.IsNullOrEmpty(model.FromBillID))
            {
                sql.AppendLine(" and a.FromBillID = @FromBillID");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromBillID", model.FromBillID));
            }
            if (!string.IsNullOrEmpty(model.FromType))
            {
                sql.AppendLine(" and a.FromType = @FromType");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@FromType", model.FromType));
            }
            if (!string.IsNullOrEmpty(model.Executor))
            {
                sql.AppendLine(" and a.Executor = @Executor");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@Executor", model.Executor));
            }
            if (!string.IsNullOrEmpty(timeStart))
            {
                sql.AppendLine(" and a.OutDate>=@timeStart");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@timeStart", timeStart));
            }

            if (!string.IsNullOrEmpty(timeEnd))
            {
                sql.AppendLine(" and a.OutDate<=@timeEnd");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@timeEnd", timeEnd));
            }
            if (!string.IsNullOrEmpty(model.BillStatus))
            {
                sql.AppendLine(" and a.BillStatus=@BillStatus");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@BillStatus", model.BillStatus));
            }
            if (!string.IsNullOrEmpty(EFIndex) && !string.IsNullOrEmpty(EFDesc))
            {
                sql.AppendLine(" and a.ExtField" + EFIndex + " LIKE @EFDesc");
                comm.Parameters.Add(SqlHelper.GetParameterFromString("@EFDesc", "%" + EFDesc + "%"));
            }
            comm.CommandText = sql.ToString();
            return SqlHelper.PagerWithCommand(comm, pageIndex, pageCount, ord, ref TotalCount);
        }
        public static bool CancelCloseBill(StorageOutRedModel model)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(" UPDATE officedba.StorageOutRed SET");
            sql.AppendLine(" Closer          = NULL,");
            sql.AppendLine(" CloseDate      = NULL,");
            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("@ModifiedUserID", model.ModifiedUserID));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));
            comm.Parameters.Add(SqlHelper.GetParameterFromString("@ID", model.ID));
            return SqlHelper.ExecuteTransWithCommand(comm);
        }
    protected void LoadPrintInfo()
    {
        PrintParameterSettingModel model = new PrintParameterSettingModel();
        model.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
        model.BillTypeFlag = int.Parse(ConstUtil.BILL_TYPEFLAG_STORAGE);
        model.PrintTypeFlag = ConstUtil.PRINTBILL_TYPEFLAG_OUTRED;

        StorageOutRedModel OutRedM_ = new StorageOutRedModel();
        OutRedM_.CompanyCD = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD;
        OutRedM_.ID = this.intMrpID.ToString();

        /*此处需注意在模板设置表里的字段和取基本信息的字段是否一致*/
        string[,] aBase;
        string[,] aDetail;
        if (HiddenPrice.Value == "True")
        {
            aBase = new string[,] { 
                                { "{ExtField1}", "ExtField1"},
                                { "{ExtField2}", "ExtField2"},
                                { "{ExtField3}", "ExtField3"},
                                { "{ExtField4}", "ExtField4"},
                                { "{ExtField5}", "ExtField5"},
                                { "{ExtField6}", "ExtField6"},
                                { "{ExtField7}", "ExtField7"},
                                { "{ExtField8}", "ExtField8"},
                                { "{ExtField9}", "ExtField9"},
                                { "{ExtField10}", "ExtField10"},
                                { "出库单编号", "OutNo"}, 
                                { "出库单主题", "Title"}, 
                                { "源单类型", "FromTypeName" },
                                { "原始出库单", "FromOutNo" },
                                { "原始出库部门", "FromDeptName"},
                                { "原始出库人", "FromExecutor"},
                                { "原始出库时间", "FromOutDate"},
                                { "原始摘要", "FromSummary"},
                                { "出库部门", "DeptName"},
                                { "出库人", "TransactorName"},
                                { "出库时间", "OutDate"},
                                { "出库原因", "ReasonTypeName"},
                                { "数量合计", "CountTotal"},
                                { "金额合计", "A_TotalPrice"},
                                { "制单人", "CreatorName"},
                                { "制单日期", "CreateDate"},
                                { "确认人", "ConfirmorName"},
                                { "确认日期", "ConfirmDate"},
                                { "结单人", "CloserName"},
                                { "结单日期", "CloseDate"},
                                { "最后更新人", "ModifiedUserName"},
                                { "最后更新日期", "ModifiedDate"},
                                { "单据状态", "BillStatusName"},
                                { "备注", "Remark"},
                                { "摘要", "Summary"},
                          };
            if (HiddenMoreUnit.Value == "True")
            {
                aDetail = new string[,]{ 
                                { "序号", "SortNo"}, 
                                { "物品编号", "ProductNo"}, 
                                { "物品名称", "ProductName" },
                                { "批次", "BatchNo" },
                                { "基本单位", "UnitID" },
                                { "基本数量", "ProductCount" },
                                { "规格", "Specification" },
                                { "单位", "UsedUnitName"},
                                { "仓库", "StorageName"},
                                { "原始出库量", "FromBillCount"},
                                { "红冲数量", "UsedUnitCount"},
                                { "单价", "UsedPrice"},
                                { "金额", "B_TotalPrice"},
                                { "备注", "DetaiRemark"},
                           };
            }
            else
            {
                aDetail = new string[,]{ 
                                { "序号", "SortNo"}, 
                                { "物品编号", "ProductNo"}, 
                                { "物品名称", "ProductName" },
                                { "批次", "BatchNo" },
                                { "规格", "Specification" },
                                { "单位", "UnitID"},
                                { "仓库", "StorageName"},
                                { "原始出库量", "FromBillCount"},
                                { "红冲数量", "ProductCount"},
                                { "单价", "UnitPrice"},
                                { "金额", "B_TotalPrice"},
                                { "备注", "DetaiRemark"},
                           };
            }
        }
        else 
        {
            aBase = new string[,] { 
                                { "{ExtField1}", "ExtField1"},
                                { "{ExtField2}", "ExtField2"},
                                { "{ExtField3}", "ExtField3"},
                                { "{ExtField4}", "ExtField4"},
                                { "{ExtField5}", "ExtField5"},
                                { "{ExtField6}", "ExtField6"},
                                { "{ExtField7}", "ExtField7"},
                                { "{ExtField8}", "ExtField8"},
                                { "{ExtField9}", "ExtField9"},
                                { "{ExtField10}", "ExtField10"},
                                { "出库单编号", "OutNo"}, 
                                { "出库单主题", "Title"}, 
                                { "源单类型", "FromTypeName" },
                                { "原始出库单", "FromOutNo" },
                                { "原始出库部门", "FromDeptName"},
                                { "原始出库人", "FromExecutor"},
                                { "原始出库时间", "FromOutDate"},
                                { "原始摘要", "FromSummary"},
                                { "出库部门", "DeptName"},
                                { "出库人", "TransactorName"},
                                { "出库时间", "OutDate"},
                                { "出库原因", "ReasonTypeName"},
                                { "数量合计", "CountTotal"},
                               // { "金额合计", "A_TotalPrice"},
                                { "制单人", "CreatorName"},
                                { "制单日期", "CreateDate"},
                                { "确认人", "ConfirmorName"},
                                { "确认日期", "ConfirmDate"},
                                { "结单人", "CloserName"},
                                { "结单日期", "CloseDate"},
                                { "最后更新人", "ModifiedUserName"},
                                { "最后更新日期", "ModifiedDate"},
                                { "单据状态", "BillStatusName"},
                                { "备注", "Remark"},
                                { "摘要", "Summary"},
                          };

            if (HiddenMoreUnit.Value == "True")
            {
                aDetail = new string[,]{ 
                                { "序号", "SortNo"}, 
                                { "物品编号", "ProductNo"}, 
                                { "物品名称", "ProductName" },
                                { "基本单位", "UnitID" },
                                { "基本数量", "ProductCount" },
                                { "规格", "Specification" },
                                { "单位", "UsedUnitName"},
                                { "仓库", "StorageName"},
                                { "原始出库量", "FromBillCount"},
                                { "红冲数量", "UsedUnitCount"},
                                { "单价", "UsedPrice"},
                                { "金额", "B_TotalPrice"},
                                { "备注", "DetaiRemark"},
                           };
            }
            else
            {
                aDetail = new string[,]{ 
                                { "序号", "SortNo"}, 
                                { "物品编号", "ProductNo"}, 
                                { "物品名称", "ProductName" },
                                { "批次", "BatchNo" },
                                { "规格", "Specification" },
                                { "单位", "UnitID"},
                                { "仓库", "StorageName"},
                                { "原始出库量", "FromBillCount"},
                                { "红冲数量", "ProductCount"},
                                { "单价", "UnitPrice"},
                                { "金额", "B_TotalPrice"},
                                { "备注", "DetaiRemark"},
                           };
            }
        }


        #region 1.扩展属性
        int countExt = 0;
        DataTable dtExtTable = XBase.Business.Office.SupplyChain.TableExtFieldsBus.GetAllList(((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyCD, "", "officedba.StorageOutRed");
        if (dtExtTable.Rows.Count > 0)
        {
            for (int i = 0; i < dtExtTable.Rows.Count; i++)
            {
                for (int x = 0; x < (aBase.Length / 2) - 15; x++)
                {
                    if (x == i)
                    {
                        aBase[x, 0] = dtExtTable.Rows[i]["EFDesc"].ToString();
                        countExt++;
                    }
                }
            }
        }
        #endregion
        DataTable dbPrint = XBase.Business.Common.PrintParameterSettingBus.GetPrintParameterSettingInfo(model);
        DataTable dtMain = StorageOutRedBus.GetStorageOutRedDetailInfo(OutRedM_);
        // DataTable dtDetail = MRPBus.GetMRPDetailInfo(modelMRP);
        string strBaseFields = "";
        string strDetailFields = "";

        if (dbPrint.Rows.Count > 0)
        {
            isSeted.Value = "1";
            strBaseFields = dbPrint.Rows[0]["BaseFields"].ToString();
            strDetailFields = dbPrint.Rows[0]["DetailFields"].ToString();
        }
        else
        {
            #region 未设置过打印模板设置 默认显示所有的
            isSeted.Value = "0";

            /*未设置过打印模板设置时,默认显示的字段  基本信息字段*/
            for (int m = 10; m < aBase.Length / 2; m++)
            {
                strBaseFields = strBaseFields + aBase[m, 1] + "|";
            }
            /*未设置过打印模板设置时,默认显示的字段 基本信息字段+扩展信息字段*/
            if (countExt > 0)
            {
                for (int i = 0; i < countExt; i++)
                {
                    strBaseFields = strBaseFields + "ExtField" + (i + 1) + "|";
                }
            }
            /*未设置过打印模板设置时,默认显示的字段 明细信息字段*/
            for (int n = 0; n < aDetail.Length / 2; n++)
            {
                strDetailFields = strDetailFields + aDetail[n, 1] + "|";
            }
            #endregion
        }

        #region 主表信息
        if (!string.IsNullOrEmpty(strBaseFields))
        {
            tableBase.InnerHtml = WritePrintPageTable("红冲出库单", strBaseFields.TrimEnd('|'), strDetailFields.TrimEnd('|'), aBase, aDetail, dtMain, dtMain, true);
        }
        #endregion

        #region 明细信息
        if (!string.IsNullOrEmpty(strDetailFields))
        {
            tableDetail.InnerHtml = WritePrintPageTable("红冲出库单", strBaseFields.TrimEnd('|'), strDetailFields.TrimEnd('|'), aBase, aDetail, dtMain, dtMain, false);
        }
        #endregion

    }