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

            //执行操作
            try
            {
                //执行操作
                res = XBase.Data.Office.LogisticsDistributionManager.SubDeliveryTransDBHelper.AddSubDeliveryTrans(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.TransNo);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = ConstUtil.LOG_PROCESS_INSERT; ;

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

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

            return res;

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

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


        }
        public static bool RunSubDeliveryTransIn(SubDeliveryTrans model)
        {
            ArrayList SqlList = new ArrayList();

            #region 更新调拨单
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update officedba.SubDeliveryTrans set ");
            strSql.Append("BusiStatus=@BusiStatus,");
            strSql.Append("InUserID=@InUserID,");
            strSql.Append("InDate=@InDate");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4),
					new SqlParameter("@BusiStatus", SqlDbType.Char,1),
					new SqlParameter("@InUserID", SqlDbType.Int,4),
					new SqlParameter("@InDate", SqlDbType.DateTime)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.BusiStatus;
            parameters[2].Value = model.InUserID;
            parameters[3].Value = model.InDate;
            #endregion

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

            #region 实时读取明细信息
            StringBuilder sbDetailSql = new StringBuilder();
            sbDetailSql.Append(" SELECT ProductID,TransCount,BatchNo,TransPrice FROM officedba.SubDeliveryTransDetail  ");
            sbDetailSql.Append(" WHERE CompanyCD=@CompanyCD AND TransNo=@TransNo");
            SqlParameter[] DetailParas = { 
                                        new SqlParameter("@CompanyCD",SqlDbType.VarChar),
                                        new SqlParameter("@TransNo",SqlDbType.VarChar)};
            DetailParas[0].Value = model.CompanyCD;
            DetailParas[1].Value = model.TransNo;
            DataTable dtDetails = SqlHelper.ExecuteSql(sbDetailSql.ToString(), DetailParas);
            #endregion

            int id = 0;
            decimal count = 0m;
            if (dtDetails != null && dtDetails.Rows.Count > 0)
            {
                foreach (DataRow row in dtDetails.Rows)
                {
                    #region 添加门店库存流水帐
                    SubStorageAccountModel aModel = new SubStorageAccountModel();
                    aModel.BatchNo = row["BatchNo"].ToString().Trim();
                    aModel.BillNo = model.TransNo;
                    aModel.BillType = 6;
                    aModel.CompanyCD = model.CompanyCD;
                    aModel.Creator = model.Creator;
                    aModel.DeptID = model.InDeptID;
                    aModel.HappenDate = DateTime.Now;
                    if (int.TryParse(row["ProductID"].ToString(), out id))
                    {
                        aModel.ProductID = id;
                    }
                    if (decimal.TryParse(row["TransPrice"].ToString(), out count))
                    {
                        aModel.Price = count;
                    }
                    if (decimal.TryParse(row["TransCount"].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.InDeptID.ToString(), row["BatchNo"].ToString(), count));

                }
                return SqlHelper.ExecuteTransWithArrayList(SqlList);
            }
            else
                return false;

        }
        /*打印使用*/
        public static DataTable GetSubDeliveryTransInfoPrint(SubDeliveryTrans model)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.AppendLine("      ");
            sbSql.AppendLine("    SELECT     ID, CompanyCD, TransNo, Title, ApplyUserID, OutDeptID, InDeptID, TransDeptID, Reason, BusiStatus,    ");
            sbSql.AppendLine("    OutUserID, OutDate, InUserID, InDate, 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("ExtField1,ExtField2,ExtField3,ExtField4,ExtField5,ExtField6,ExtField7,ExtField8,ExtField9,ExtField10");
            sbSql.AppendLine("  ,CONVERT(NUMERIC(12,2),ISNULL(sds.TransPrice,0)) TransPrice");
            sbSql.AppendLine("  ,CONVERT(NUMERIC(12,2),ISNULL(sds.TransFeeSum,0)) TransFeeSum");
            sbSql.AppendLine("  ,CONVERT(NUMERIC(12,2),ISNULL(sds.TransCount,0)) TransCount");
            sbSql.AppendLine("  ,ModifiedUserID    ");
            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.InDeptID)) AS InDeptIDName,  ");
            sbSql.AppendLine("     (SELECT     DeptName  ");
            sbSql.AppendLine("      FROM          officedba.DeptInfo AS di3  ");
            sbSql.AppendLine("      WHERE      (ID = sds.TransDeptID)) AS TransDeptIDName,  ");
            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.SubDeliveryTrans 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 GetSubDeliveryTransInfo(SubDeliveryTrans 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.InDeptID) as InDeptIDName,");
            sbSql.Append("(select di3.DeptName from officedba.DeptInfo as di3 where di3.ID=sds.TransDeptID ) AS TransDeptIDName ,");
            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.SubDeliveryTrans 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 string AddSubDeliveryTrans(SubDeliveryTrans model, List<SubDeliveryTransDetail> modellist, Hashtable htExtAttr)
        {

            #region 构造调拨单
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into officedba.SubDeliveryTrans(");
            strSql.Append("CompanyCD,TransNo,Title,ApplyUserID,OutDeptID,InDeptID,TransDeptID,TransPrice,TransFeeSum,TransCount,Reason,BusiStatus,Remark,Creator,CreateDate,BillStatus,ModifiedDate,ModifiedUserID)");
            strSql.Append(" values (");
            strSql.Append("@CompanyCD,@TransNo,@Title,@ApplyUserID,@OutDeptID,@InDeptID,@TransDeptID,@TransPrice,@TransFeeSum,@TransCount,@Reason,@BusiStatus,@Remark,@Creator,@CreateDate,@BillStatus,@ModifiedDate,@ModifiedUserID)");
            strSql.Append(";select @ID=@@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@CompanyCD", SqlDbType.VarChar,8),
					new SqlParameter("@TransNo", SqlDbType.VarChar,50),
					new SqlParameter("@Title", SqlDbType.VarChar,100),
					new SqlParameter("@ApplyUserID", SqlDbType.Int,4),
					new SqlParameter("@OutDeptID", SqlDbType.Int,4),
					new SqlParameter("@InDeptID", SqlDbType.Int,4),
					new SqlParameter("@TransDeptID", SqlDbType.Int,4),
					new SqlParameter("@TransPrice", SqlDbType.Decimal,9),
					new SqlParameter("@TransFeeSum", SqlDbType.Decimal,9),
					new SqlParameter("@TransCount", SqlDbType.Decimal,9),
					new SqlParameter("@Reason", SqlDbType.VarChar,1024),
					new SqlParameter("@BusiStatus", SqlDbType.Char,1),
					new SqlParameter("@Remark", SqlDbType.VarChar,800),
					new SqlParameter("@Creator", SqlDbType.Int,4),
					new SqlParameter("@CreateDate", SqlDbType.DateTime),
					new SqlParameter("@BillStatus", SqlDbType.Char,1),
					new SqlParameter("@ModifiedDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,50),
                    new SqlParameter("@ID",SqlDbType.Int)};
            parameters[0].Value = model.CompanyCD;
            parameters[1].Value = model.TransNo;
            parameters[2].Value = model.Title;
            parameters[3].Value = model.ApplyUserID;
            parameters[4].Value = model.OutDeptID;
            parameters[5].Value = model.InDeptID;
            if (model.TransDeptID.HasValue)
            {
                parameters[6].Value = model.TransDeptID;
            }
            else
            {
                parameters[6].Value = DBNull.Value;
            }
            parameters[7].Value = model.TransPrice;
            parameters[8].Value = model.TransFeeSum;
            parameters[9].Value = model.TransCount;
            parameters[10].Value = model.Reason;
            parameters[11].Value = model.BusiStatus;
            parameters[12].Value = model.Remark;
            parameters[13].Value = model.Creator;
            parameters[14].Value = model.CreateDate;
            parameters[15].Value = model.BillStatus;
            parameters[16].Value = model.ModifiedDate;
            parameters[17].Value = model.ModifiedUserID;
            parameters[18].Direction = ParameterDirection.Output;
            #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 构造调拨单明细
            foreach (SubDeliveryTransDetail m in modellist)
            {
                SqlList.Add(SaveDetail(m));
            }
            #endregion


            bool result = SqlHelper.ExecuteTransWithArrayList(SqlList);
            if (result)
            {
                return ((SqlCommand)SqlList[0]).Parameters["@ID"].Value.ToString();
            }
            else
                return string.Empty;
        }
        public static bool UpdateStatus(SubDeliveryTrans model, int stype)
        {
            if (stype == 1)
            {
                #region 确认单据
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update officedba.SubDeliveryTrans 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.SubDeliveryTrans set ");
                strSql.Append("BillStatus=@BillStatus,");
                strSql.Append("ModifiedDate=@ModifiedDate,");
                strSql.Append("ModifiedUserID=@ModifiedUserID,");
                strSql.Append("BusiStatus=@BusiStatus ");
                strSql.Append(" where ID=@ID ");
                SqlParameter[] parameters = {
					new SqlParameter("@ID", SqlDbType.Int,4),
					new SqlParameter("@BillStatus", SqlDbType.Char,1),
					new SqlParameter("@ModifiedDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,50),
                    new SqlParameter("@BusiStatus",SqlDbType.VarChar)};
                parameters[0].Value = model.ID;
                parameters[1].Value = model.BillStatus;
                parameters[2].Value = model.ModifiedDate;
                parameters[3].Value = model.ModifiedUserID;
                parameters[4].Value = model.BusiStatus;


                SqlCommand SqlMainCmd = new SqlCommand() { 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_SubDeliveryTrans_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.SubDeliveryTrans 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 UpdateSubDeliveryTrans(SubDeliveryTrans model, List<SubDeliveryTransDetail> modelList, Hashtable htExtAttr)
        {

            #region 更新调拨单主表
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update officedba.SubDeliveryTrans set ");
            strSql.Append("Title=@Title,");
            strSql.Append("ApplyUserID=@ApplyUserID,");
            strSql.Append("OutDeptID=@OutDeptID,");
            strSql.Append("InDeptID=@InDeptID,");
            strSql.Append("TransDeptID=@TransDeptID,");
            strSql.Append("TransPrice=@TransPrice,");
            strSql.Append("TransFeeSum=@TransFeeSum,");
            strSql.Append("TransCount=@TransCount,");
            strSql.Append("Reason=@Reason,");
            strSql.Append("Remark=@Remark,");
            strSql.Append("ModifiedDate=@ModifiedDate,");
            strSql.Append("ModifiedUserID=@ModifiedUserID");
            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("@OutDeptID", SqlDbType.Int,4),
					new SqlParameter("@InDeptID", SqlDbType.Int,4),
					new SqlParameter("@TransDeptID", SqlDbType.Int,4),
					new SqlParameter("@TransPrice", SqlDbType.Decimal,9),
					new SqlParameter("@TransFeeSum", SqlDbType.Decimal,9),
					new SqlParameter("@TransCount", SqlDbType.Decimal,9),
					new SqlParameter("@Reason", SqlDbType.VarChar,1024),
					new SqlParameter("@Remark", SqlDbType.VarChar,800),
					new SqlParameter("@ModifiedDate", SqlDbType.DateTime),
					new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,50)};
            parameters[0].Value = model.ID;
            parameters[1].Value = model.Title;
            parameters[2].Value = model.ApplyUserID;
            parameters[3].Value = model.OutDeptID;
            parameters[4].Value = model.InDeptID;
            if (model.TransDeptID.HasValue)
            {
                parameters[5].Value = model.TransDeptID;
            }
            else
            {
                parameters[5].Value = DBNull.Value;
            }
            parameters[6].Value = model.TransPrice;
            parameters[7].Value = model.TransFeeSum;
            parameters[8].Value = model.TransCount;
            parameters[9].Value = model.Reason;
            parameters[10].Value = model.Remark;
            parameters[11].Value = model.ModifiedDate;
            parameters[12].Value = model.ModifiedUserID;

            #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.SubDeliveryTransDetail WHERE CompanyCD=@CompanyCD AND TransNo=@TransNo");
            SqlParameter[] delParas = { 
                                          new SqlParameter("@CompanyCD",SqlDbType.VarChar),
                                          new SqlParameter("@TransNo",SqlDbType.VarChar)
                                      };
            delParas[0].Value = model.CompanyCD;
            delParas[1].Value = model.TransNo;
            SqlCommand sqlDelCmd = new SqlCommand { CommandText = sbDel.ToString() };
            sqlDelCmd.Parameters.AddRange(delParas);
            SqlList.Add(sqlDelCmd);

            foreach (SubDeliveryTransDetail m in modelList)
            {
                SqlList.Add(SaveDetail(m));
            }
            #endregion

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

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

            //执行操作
            try
            {
                //执行操作
                res = XBase.Data.Office.LogisticsDistributionManager.SubDeliveryTransDBHelper.RunSubDeliveryTransIn(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.TransNo);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;

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

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

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

            //执行操作
            try
            {
                //执行操作
                res = XBase.Data.Office.LogisticsDistributionManager.SubDeliveryTransDBHelper.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.TransNo);
            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            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;
        }