public static string AddSubDeliverySend(SubDeliverySend model, List<SubDeliverySendDetail> modellist, Hashtable htExtAttr)
        {
            //定义返回变量
            string res = string.Empty;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */
            //获取当前用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];

            //执行操作
            try
            {
                //执行操作
                res = XBase.Data.Office.LogisticsDistributionManager.SubDeliverySendSaveDBHelper.AddSubDeliverySend(model, modellist, htExtAttr);
            }
            catch (Exception ex)
            {
                //输出日志
                WriteSystemLog(userInfo, ex);
            }
            //定义变量
            string remark;
            //成功时
            if (res != string.Empty)
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
            }
            else
            {
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
            }
            //操作日志
            LogInfoModel logModel = InitLogInfo(model.SendNo);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = ConstUtil.LOG_PROCESS_INSERT; ;

            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);

            return res;

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

                strSql = "UPDATE officedba.SubDeliverySend 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 SendNo = @SendNo";
                cmd.Parameters.AddWithValue("@CompanyCD", model.CompanyCD);
                cmd.Parameters.AddWithValue("@SendNo", model.SendNo);
                cmd.CommandText = strSql;
            }
            catch (Exception)
            { }


        }
        public static bool RunSubDeliverySendIn(SubDeliverySend model)
        {
            #region 读取配送单明细
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append("SELECT sdsd.SendNo,sdsd.ProductID,sdsd.SendPrice,sdsd.SendCount,pi1.IsBatchNo FROM officedba.SubDeliverySendDetail sdsd ");
            sbSql.Append(" LEFT JOIN officedba.ProductInfo pi1 ON pi1.ID=sdsd.ProductID ");
            sbSql.Append(" where sdsd.CompanyCD=@CompanyCD AND sdsd.SendNo=@SendNo");

            SqlParameter[] Paras = { 
                                   new SqlParameter("@CompanyCD",SqlDbType.VarChar),
                                   new SqlParameter("@SendNo",SqlDbType.VarChar)};
            Paras[0].Value = model.CompanyCD;
            Paras[1].Value = model.SendNo;
            DataTable dtDetail = SqlHelper.ExecuteSql(sbSql.ToString(), Paras);


            ArrayList SqlList = new ArrayList();
            int id = 0;
            decimal count = 0m;
            /*实时判断明细是否存在*/
            if (dtDetail != null && dtDetail.Rows.Count > 0)
            {
                #region 更新配送单信息
                StringBuilder sbMainSql = new StringBuilder();
                sbMainSql.Append("UPDATE officedba.SubDeliverySend SET InUserID=@InUserID , InDate=@InDate ,BusiStatus=@BusiStatus ");
                sbMainSql.Append(" where ID=@ID");
                SqlParameter[] MainParas = { 
                                           new SqlParameter("@InUserID",SqlDbType.Int),
                                           new SqlParameter("@InDate",SqlDbType.DateTime),
                                           new SqlParameter("@BusiStatus",SqlDbType.VarChar),
                                           new SqlParameter("@ID",SqlDbType.Int)};
                MainParas[0].Value = model.InUserID;
                MainParas[1].Value = model.InDate;
                MainParas[2].Value = model.BusiStatus;
                MainParas[3].Value = model.ID;
                SqlCommand SqlMainCmd = new SqlCommand() { CommandText = sbMainSql.ToString() };
                SqlMainCmd.Parameters.AddRange(MainParas);
                SqlList.Add(SqlMainCmd);
                #endregion
                foreach (DataRow row in dtDetail.Rows)
                {
                    string BatchNo = "";
                    #region 添加门店库存流水帐
                    if (row["IsBatchNo"].ToString() == "1")
                    {
                        BatchNo = model.BatchNo;
                    }
                    SubStorageAccountModel aModel = new SubStorageAccountModel();
                    aModel.BatchNo = BatchNo;
                    aModel.BillNo = row["SendNo"].ToString();
                    aModel.BillType = 2;
                    aModel.CompanyCD = model.CompanyCD;
                    aModel.Creator = model.Creator;
                    aModel.DeptID = model.ApplyDeptID;
                    aModel.HappenDate = DateTime.Now;
                    if (int.TryParse(row["ProductID"].ToString(), out id))
                    {
                        aModel.ProductID = id;
                    }
                    if (decimal.TryParse(row["SendPrice"].ToString(), out count))
                    {
                        aModel.Price = count;
                    }
                    if (decimal.TryParse(row["SendCount"].ToString(), out count))
                    {
                        aModel.HappenCount = count;
                    }
                    aModel.PageUrl = model.Remark;
                    SqlList.Add(XBase.Data.Office.SubStoreManager.SubStorageAccountDBHelper.GetCountAndInsertCommand(aModel));
                    #endregion

                    SqlList.Add(XBase.Data.Office.LogisticsDistributionManager.StorageProductQueryDBHelper.UpdateProductCount(model.CompanyCD
                            , row["ProductID"].ToString(), model.ApplyDeptID.ToString(), BatchNo, count));

                }
                return SqlHelper.ExecuteTransWithArrayList(SqlList);
            }
            else
                return false;
            #endregion
        }
        public static bool RunSubDeliverySendOut(SubDeliverySend model, List<SubDeliverySendDetail> modelList)
        {
            ArrayList SqlList = new ArrayList();

            #region 配送明细单
            StringBuilder sbDel = new StringBuilder();
            sbDel.Append("DELETE officedba.SubDeliverySendDetail WHERE CompanyCD=@CompanyCD AND SendNo=@SendNo");
            SqlParameter[] delParas = { 
                                          new SqlParameter("@CompanyCD",SqlDbType.VarChar),
                                          new SqlParameter("@SendNo",SqlDbType.VarChar)
                                      };
            delParas[0].Value = model.CompanyCD;
            delParas[1].Value = model.SendNo;
            SqlCommand sqlDelCmd = new SqlCommand { CommandText = sbDel.ToString() };
            sqlDelCmd.Parameters.AddRange(delParas);
            SqlList.Add(sqlDelCmd);
            foreach (Model.Office.LogisticsDistributionManager.SubDeliverySendDetail m in modelList)
            {

                SqlList.Add(SaveDetail(m));

                #region 添加门店库存流水帐

                XBase.Model.Office.StorageManager.StorageAccountModel sModel = new XBase.Model.Office.StorageManager.StorageAccountModel();
                sModel.BatchNo = m.BatchNo;
                sModel.BillNo = m.SendNo;
                sModel.BillType = 19;
                sModel.CompanyCD = m.CompanyCD;
                sModel.StorageID = m.StorageID.Value;
                sModel.ProductID = m.ProductID.Value;
                sModel.Creator = model.Creator.Value;
                sModel.HappenDate = DateTime.Now;
                sModel.Price = m.SendPrice.Value;
                sModel.HappenCount = m.SendCount.Value;
                sModel.PageUrl = model.Remark;
                SqlList.Add(XBase.Data.Office.StorageManager.StorageAccountDBHelper.InsertStorageAccountCommand(sModel, "1"));

                #endregion

                // 更新库存
                SqlList.Add(XBase.Data.Office.StorageManager.StorageSearchDBHelper.UpdateProductCount(m.CompanyCD, m.ProductID.ToString(), m.StorageID.ToString()
                    , m.BatchNo, -m.SendCount.Value));
            }
            #endregion

            #region 更新配送单
            StringBuilder sbMainSql = new StringBuilder();
            sbMainSql.Append("UPDATE  officedba.SubDeliverySend SET OutUserID=@OutUserID,OutDate=@OutDate,BusiStatus=@BusiStatus ,");
            sbMainSql.Append("SendPrice=@SendPrice,SendCount=@SendCount ");
            sbMainSql.Append(" WHERE ID=@ID ");
            SqlParameter[] MainParas = { 
                                           new SqlParameter("@OutUserID",SqlDbType.Int),
                                           new SqlParameter("@OutDate",SqlDbType.DateTime),
                                           new SqlParameter("@BusiStatus",SqlDbType.VarChar),
                                           new SqlParameter("@ID",SqlDbType.Int),
                                           new SqlParameter("@SendPrice",SqlDbType.Decimal),
                                           new SqlParameter("@SendCount",SqlDbType.Decimal)
                                       };
            MainParas[0].Value = model.OutUserID;
            MainParas[1].Value = model.OutDate;
            MainParas[2].Value = model.BusiStatus;
            MainParas[3].Value = model.ID;
            MainParas[4].Value = model.SendPrice;
            MainParas[5].Value = model.SendCount;
            SqlCommand SqlMainCmd = new SqlCommand() { CommandText = sbMainSql.ToString() };
            SqlMainCmd.Parameters.AddRange(MainParas);
            SqlList.Add(SqlMainCmd);
            #endregion

            return SqlHelper.ExecuteTransWithArrayList(SqlList);

        }
        /*打印使用*/
        public static DataTable GetSubDeliverySendInfoPrint(SubDeliverySend model)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.AppendLine("  SELECT     ID, CompanyCD, SendNo, Title, ApplyUserID, ApplyDeptID, OutDeptID, convert(varchar(10),RequireInDate,120)RequireInDate ,BusiStatus, OutUserID,BatchNo,   ");
            sbSql.AppendLine("  OutDate, InUserID, InDate, BackCount, Remark, Creator,convert(varchar(10),CreateDate,120) CreateDate, BillStatus, Confirmor,convert(varchar(10),ConfirmDate,120) ConfirmDate, Closer, convert(varchar(10),CloseDate,120) CloseDate,convert(varchar(10),ModifiedDate,120) ModifiedDate");
            sbSql.AppendLine("  ,CONVERT(NUMERIC(12,2),ISNULL(sds.SendPrice,0)) SendPrice");
            sbSql.AppendLine("  ,CONVERT(NUMERIC(12,2),ISNULL(sds.SendCount,0)) SendCount");
            sbSql.AppendLine("  ,CONVERT(NUMERIC(12,2),ISNULL(sds.SendFeeSum,0)) SendFeeSum");
            sbSql.AppendLine("  ,ModifiedUserID,   ExtField1,ExtField2,ExtField3,ExtField4,ExtField5,ExtField6,ExtField7,ExtField8,ExtField9,ExtField10,");
            sbSql.AppendLine("  (CASE sds.BusiStatus WHEN '1' THEN '配送申请' WHEN '2' THEN '配送出库' WHEN '3' THEN '配送入库' WHEN '4' THEN '配送完成' END)   ");
            sbSql.AppendLine("   AS BusiStatusText, (CASE sds.BillStatus WHEN '1' THEN '制单' WHEN '2' THEN '执行' WHEN '4' THEN '手工结单' WHEN '5' THEN '自动结单' END)   ");
            sbSql.AppendLine("   AS BillStatusText,  ");
            sbSql.AppendLine("  (SELECT     EmployeeName  ");
            sbSql.AppendLine("  FROM          officedba.EmployeeInfo AS ei1  ");
            sbSql.AppendLine("  WHERE      (ID = sds.ApplyUserID)) AS ApplyUserIDName,  ");
            sbSql.AppendLine("  (SELECT     DeptName  ");
            sbSql.AppendLine("  FROM          officedba.DeptInfo AS di1  ");
            sbSql.AppendLine("   WHERE      (ID = sds.OutDeptID)) AS OutDeptIDName,  ");
            sbSql.AppendLine("   (SELECT     DeptName  ");
            sbSql.AppendLine("   FROM          officedba.DeptInfo AS di2  ");
            sbSql.AppendLine("  WHERE      (ID = sds.ApplyDeptID)) AS ApplyDeptIDName,  ");
            sbSql.AppendLine("   (SELECT     EmployeeName  ");
            sbSql.AppendLine("  FROM          officedba.EmployeeInfo AS ei2  ");
            sbSql.AppendLine("  WHERE      (ID = sds.OutUserID)) AS OutUserIDName,  ");
            sbSql.AppendLine("   (SELECT     EmployeeName  ");
            sbSql.AppendLine("  FROM          officedba.EmployeeInfo AS ei3  ");
            sbSql.AppendLine("  WHERE      (ID = sds.InUserID)) AS InUserIDName,  ");
            sbSql.AppendLine("  (SELECT     EmployeeName  ");
            sbSql.AppendLine("  FROM          officedba.EmployeeInfo AS ei4  ");
            sbSql.AppendLine("  WHERE      (ID = sds.Creator)) AS CreatorName,  ");
            sbSql.AppendLine("  (SELECT     EmployeeName  ");
            sbSql.AppendLine("  FROM          officedba.EmployeeInfo AS ei5  ");
            sbSql.AppendLine("   WHERE      (ID = sds.Confirmor)) AS ConfirmorName,  ");
            sbSql.AppendLine("  (SELECT     EmployeeName  ");
            sbSql.AppendLine("  FROM          officedba.EmployeeInfo AS ei6  ");
            sbSql.AppendLine("   WHERE      (ID = sds.Closer)) AS CloserName  ");
            sbSql.AppendLine("   FROM         officedba.SubDeliverySend AS sds  ");
            sbSql.AppendLine("  where sds.CompanyCD=@CompanyCD AND sds.ID=@ID");

            SqlParameter[] Paras = { 
                                   new SqlParameter("@CompanyCD",SqlDbType.VarChar),
                                   new SqlParameter("@ID",SqlDbType.Int)};
            Paras[0].Value = model.CompanyCD;
            Paras[1].Value = model.ID;

            return SqlHelper.ExecuteSql(sbSql.ToString(), Paras);
        }
        public static DataTable GetSubDeliverySendInfo(SubDeliverySend model)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append("SELECT sds.* ,");
            sbSql.Append(" (select ei1.EmployeeName from officedba.EmployeeInfo  as ei1  where ei1.ID=sds.ApplyUserID) as ApplyUserIDName,");
            sbSql.Append("(select  di1.DeptName from officedba.DeptInfo as di1 where di1.ID=sds.OutDeptID ) as OutDeptIDName,");
            sbSql.Append("(select di2.DeptName from officedba.DeptInfo as di2 where di2.ID=sds.ApplyDeptID) as ApplyDeptIDName,");
            sbSql.Append("(select ei2.EmployeeName from officedba.EmployeeInfo  as ei2 where ei2.ID=sds.OutUserID) as OutUserIDName,");
            sbSql.Append("(select ei3.EmployeeName from officedba.EmployeeInfo  as ei3 where ei3.ID=sds.InUserID) as InUserIDName,");
            sbSql.Append("(select ei4.EmployeeName from officedba.EmployeeInfo  as ei4 where ei4.ID=sds.Creator) as CreatorName,");
            sbSql.Append("(select ei5.EmployeeName from officedba.EmployeeInfo  as ei5 where ei5.ID=sds.Confirmor) as ConfirmorName,");
            sbSql.Append("(select ei6.EmployeeName from officedba.EmployeeInfo  as ei6 where ei6.ID=sds.Closer) as CloserName ");
            sbSql.Append(" from officedba.SubDeliverySend as sds where sds.CompanyCD=@CompanyCD AND sds.ID=@ID");

            SqlParameter[] Paras = { 
                                   new SqlParameter("@CompanyCD",SqlDbType.VarChar),
                                   new SqlParameter("@ID",SqlDbType.Int)};
            Paras[0].Value = model.CompanyCD;
            Paras[1].Value = model.ID;

            return SqlHelper.ExecuteSql(sbSql.ToString(), Paras);
        }
        public static bool UpdateStatus(SubDeliverySend model, int stype)
        {
            if (stype == 1)
            {
                #region 确认单据
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update officedba.SubDeliverySend set ");
                strSql.Append("BusiStatus=@BusiStatus,");
                strSql.Append("BillStatus=@BillStatus,");
                strSql.Append("Confirmor=@Confirmor,");
                strSql.Append("ConfirmDate=@ConfirmDate,");
                strSql.Append("ModifiedDate=@ModifiedDate,");
                strSql.Append("ModifiedUserID=@ModifiedUserID");
                strSql.Append(" where ID=@ID ");
                SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4),
					new SqlParameter("@BusiStatus", SqlDbType.Char,1),
					new SqlParameter("@BillStatus", SqlDbType.Char,1),
					new SqlParameter("@Confirmor", SqlDbType.Int,4),
					new SqlParameter("@ConfirmDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,50)};
                parameters[0].Value = model.ID;
                parameters[1].Value = model.BusiStatus;
                parameters[2].Value = model.BillStatus;
                parameters[3].Value = model.Confirmor;
                parameters[4].Value = model.ConfirmDate;
                parameters[5].Value = model.ModifiedDate;
                parameters[6].Value = model.ModifiedUserID;

                if (SqlHelper.ExecuteTransSql(strSql.ToString(), parameters) > 0)
                    return true;
                else
                    return false;
                #endregion
            }
            else if (stype == 3 || stype == 4)
            {
                #region 取消结单
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update officedba.SubDeliverySend set ");
                strSql.Append("BillStatus=@BillStatus,");
                if (stype == 4)
                    strSql.Append("BusiStatus=@BusiStatus, ");
                strSql.Append("ModifiedDate=@ModifiedDate,");
                strSql.Append("ModifiedUserID=@ModifiedUserID");
                strSql.Append(" where ID=@ID ");


                int length = 4;
                int index = 0;
                if (stype == 4)
                    length++;
                SqlParameter[] parameters = new SqlParameter[length];
                parameters[index] = new SqlParameter("@ID", SqlDbType.Int);
                parameters[index++].Value = model.ID;
                parameters[index] = new SqlParameter("@BillStatus", SqlDbType.VarChar);
                parameters[index++].Value = model.BillStatus;
                parameters[index] = new SqlParameter("@ModifiedDate", SqlDbType.DateTime);
                parameters[index++].Value = model.ModifiedDate;
                parameters[index] = new SqlParameter("@ModifiedUserID", SqlDbType.VarChar);
                parameters[index++].Value = model.ModifiedUserID;
                if (stype == 4)
                {
                    parameters[index] = new SqlParameter("@BusiStatus", SqlDbType.VarChar);
                    parameters[index++].Value = model.BusiStatus;
                }

                SqlCommand SqlMainCmd = new SqlCommand();
                SqlMainCmd.CommandText = strSql.ToString();
                SqlMainCmd.Parameters.AddRange(parameters);

                List<SqlCommand> SqlCmdList = new List<SqlCommand>();
                SqlCmdList.Add(SqlMainCmd);


                /*追加取消确认的SqlCommond*/
                if (stype == 4)
                {
                    IList<SqlCommand> tempList = Data.Common.FlowDBHelper.GetCancelConfirmSqlCommond(model.CompanyCD, Convert.ToInt32(ConstUtil.TYPEFLAG_LogisticsDistribution_NO), Convert.ToInt32(ConstUtil.TYPECODE_SubDeliverySend_NO), model.ID, model.ModifiedUserID);
                    foreach (SqlCommand scmd in tempList)
                    {
                        SqlCmdList.Add(scmd);
                    }
                }

                if (SqlHelper.ExecuteTransWithCollections(SqlCmdList))
                    return true;
                else
                    return false;
                #endregion
            }
            else if (stype == 2)
            {
                #region 结单
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update officedba.SubDeliverySend set ");
                strSql.Append("BillStatus=@BillStatus,");
                strSql.Append("Closer=@Closer,");
                strSql.Append("CloseDate=@CloseDate,");
                strSql.Append("ModifiedDate=@ModifiedDate,");
                strSql.Append("ModifiedUserID=@ModifiedUserID");
                strSql.Append(" where ID=@ID ");
                SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4),
					new SqlParameter("@BillStatus", SqlDbType.Char,1),
					new SqlParameter("@Closer", SqlDbType.Int,4),
					new SqlParameter("@CloseDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,50)};
                parameters[0].Value = model.ID;
                parameters[1].Value = model.BillStatus;
                parameters[2].Value = model.Closer;
                parameters[3].Value = model.CloseDate;
                parameters[4].Value = model.ModifiedDate;
                parameters[5].Value = model.ModifiedUserID;
                if (SqlHelper.ExecuteTransSql(strSql.ToString(), parameters) > 0)
                    return true;
                else
                    return false;
                #endregion

            }
            else
            {
                return false;
            }
        }
        public static bool UpdateSubDeliverySend(SubDeliverySend model, List<SubDeliverySendDetail> modelList, Hashtable htExtAttr)
        {
            #region 配送单
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update officedba.SubDeliverySend set ");
            strSql.Append("Title=@Title,");
            strSql.Append("ApplyUserID=@ApplyUserID,");
            strSql.Append("ApplyDeptID=@ApplyDeptID,");
            strSql.Append("OutDeptID=@OutDeptID,");
            strSql.Append("RequireInDate=@RequireInDate,");
            strSql.Append("SendPrice=@SendPrice,");
            strSql.Append("SendCount=@SendCount,");
            strSql.Append("SendFeeSum=@SendFeeSum,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("ModifiedDate=@ModifiedDate,");
            strSql.Append("ModifiedUserID=@ModifiedUserID,");
            strSql.Append("BatchNo=@BatchNo");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4),
					new SqlParameter("@Title", SqlDbType.VarChar,100),
					new SqlParameter("@ApplyUserID", SqlDbType.Int,4),
					new SqlParameter("@ApplyDeptID", SqlDbType.Int,4),
					new SqlParameter("@OutDeptID", SqlDbType.Int,4),
					new SqlParameter("@RequireInDate", SqlDbType.DateTime),
					new SqlParameter("@SendPrice", SqlDbType.Decimal,9),
					new SqlParameter("@SendCount", SqlDbType.Decimal,9),
					new SqlParameter("@SendFeeSum", SqlDbType.Decimal,9),
					new SqlParameter("@Remark", SqlDbType.VarChar,800),
					new SqlParameter("@ModifiedDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,50),
					new SqlParameter("@BatchNo", SqlDbType.VarChar,50)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Title;
            parameters[2].Value = model.ApplyUserID;
            parameters[3].Value = model.ApplyDeptID;
            parameters[4].Value = model.OutDeptID;
            parameters[5].Value = model.RequireInDate;
            parameters[6].Value = model.SendPrice;
            parameters[7].Value = model.SendCount;
            parameters[8].Value = model.SendFeeSum;
            parameters[9].Value = model.Remark;
            parameters[10].Value = model.ModifiedDate;
            parameters[11].Value = model.ModifiedUserID;
            parameters[12].Value = model.BatchNo;

            #endregion

            ArrayList SqlList = new ArrayList();
            SqlCommand SqlCmd = new SqlCommand { CommandText = strSql.ToString() };
            SqlCmd.Parameters.AddRange(parameters);
            SqlList.Add(SqlCmd);


            #region 拓展属性
            SqlCommand cmd = new SqlCommand();
            GetExtAttrCmd(model, htExtAttr, cmd);
            if (htExtAttr.Count > 0)
                SqlList.Add(cmd);
            #endregion


            #region 配送明细单
            StringBuilder sbDel = new StringBuilder();
            sbDel.Append("DELETE officedba.SubDeliverySendDetail WHERE CompanyCD=@CompanyCD AND SendNo=@SendNo");
            SqlParameter[] delParas = { 
                                          new SqlParameter("@CompanyCD",SqlDbType.VarChar),
                                          new SqlParameter("@SendNo",SqlDbType.VarChar)
                                      };
            delParas[0].Value = model.CompanyCD;
            delParas[1].Value = model.SendNo;
            SqlCommand sqlDelCmd = new SqlCommand { CommandText = sbDel.ToString() };
            sqlDelCmd.Parameters.AddRange(delParas);
            SqlList.Add(sqlDelCmd);

            foreach (Model.Office.LogisticsDistributionManager.SubDeliverySendDetail m in modelList)
            {
                SqlList.Add(SaveDetail(m));
            }
            #endregion

            bool result = SqlHelper.ExecuteTransWithArrayList(SqlList);
            return result;

        }
        public static bool RunSubDeliverySendIn(SubDeliverySend model)
        {
            //定义返回变量
            bool res = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */
            //获取当前用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];

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

            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);

            return res;
        }
 /*打印使用*/
 public static DataTable GetSubDeliverySendInfoPrint(SubDeliverySend model)
 {
     return XBase.Data.Office.LogisticsDistributionManager.SubDeliverySendSaveDBHelper.GetSubDeliverySendInfoPrint(model);
 }
        public static bool UpdateStatus(SubDeliverySend model, int stype)
        {
            //定义返回变量
            bool res = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */
            //获取当前用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];

            //执行操作
            try
            {
                //执行操作
                res = XBase.Data.Office.LogisticsDistributionManager.SubDeliverySendSaveDBHelper.UpdateStatus(model, stype);
            }
            catch (Exception ex)
            {
                //输出日志
                WriteSystemLog(userInfo, ex);
            }
            //定义变量
            string remark;
            //成功时
            if (res)
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
            }
            else
            {
                //设置操作成功标识 
                remark = ConstUtil.LOG_PROCESS_FAILED;
            }
            //操作日志
            LogInfoModel logModel = InitLogInfo(model.SendNo);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            string msg = string.Empty;
            switch (stype)
            {
                case 1:
                    /*确认*/
                    msg = ConstUtil.LOG_PROCESS_CONFIRM; 
                    break;
                case 2:
                    /*结单*/
                    msg = ConstUtil.LOG_PROCESS_COMPLETE; 
                    break;
                case 3:
                    /*取消结单*/
                    msg = ConstUtil.LOG_PROCESS_CONCELCOMPLETE;
                    break;
                case 4:
                    /*取消确认*/
                    msg = ConstUtil.LOG_PROCESS_UNCONFIRM;
                    break;
            }
            logModel.Element = msg; ;

            //设置操作成功标识
            logModel.Remark = remark;

            //登陆日志
            LogDBHelper.InsertLog(logModel);

            return res;
        }