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

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

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

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

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

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


        }
        public static bool SubDeliveryBackIn(SubDeliveryBack model, List<SubDeliveryBackDetail> modelList)
        {
            ArrayList SqlList = new ArrayList();

            #region 更新配送单信息
            StringBuilder sbMainSql = new StringBuilder();
            sbMainSql.Append("UPDATE officedba.SubDeliveryBack 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

            StringBuilder sbSubDelSql = new StringBuilder();
            sbSubDelSql.Append("DELETE officedba.SubDeliveryBackDetail WHERE   ");
            sbSubDelSql.Append(" BackNo=@BackNo AND CompanyCD=@CompanyCD ");
            SqlParameter[] delParas = { 
                                          new SqlParameter("@BackNo",SqlDbType.VarChar),
                                          new SqlParameter("@CompanyCD",SqlDbType.VarChar)};
            delParas[0].Value = model.BackNo;
            delParas[1].Value = model.CompanyCD;
            SqlCommand sqlDelCmd = new SqlCommand() { CommandText = sbSubDelSql.ToString() };
            sqlDelCmd.Parameters.AddRange(delParas);
            SqlList.Add(sqlDelCmd);


            /*如果单据有源单 则回写源单退货数量*/
            if (model.SendID > 0)
            {
                StringBuilder sbSetSendSql = new StringBuilder();
                sbSetSendSql.Append("UPDATE officedba.SubDeliverySend SET BackCount=(isnull(BackCount,0)+@BackCount)  ");
                sbSetSendSql.Append(" where ID=@ID");
                SqlParameter[] setSendParas = { 
                                                  new SqlParameter("@BackCount",SqlDbType.Decimal),
                                                  new SqlParameter("@ID",SqlDbType.Int)};
                setSendParas[0].Value = model.BackCount;
                setSendParas[1].Value = model.SendID;

                SqlCommand sqlSetSendCmd = new SqlCommand() { CommandText = sbSetSendSql.ToString() };
                sqlSetSendCmd.Parameters.AddRange(setSendParas);
                SqlList.Add(sqlSetSendCmd);
            }

            foreach (SubDeliveryBackDetail m in modelList)
            {
                SqlList.Add(GetSaveDetail(m));

                #region 添加门店库存流水帐
                XBase.Model.Office.StorageManager.StorageAccountModel sModel = new XBase.Model.Office.StorageManager.StorageAccountModel();
                sModel.BatchNo = m.BackBatchNo;
                sModel.BillNo = m.BackNo;
                sModel.BillType = 20;
                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.BackPrice.Value;
                sModel.HappenCount = m.BackCount.Value;
                sModel.PageUrl = model.Remark;
                SqlList.Add(XBase.Data.Office.StorageManager.StorageAccountDBHelper.InsertStorageAccountCommand(sModel, "0"));
                #endregion

                #region 入库操作
                SqlList.Add(XBase.Data.Office.StorageManager.StorageSearchDBHelper.UpdateProductCount(m.CompanyCD, m.ProductID.ToString(), m.StorageID.ToString(), m.BackBatchNo, m.BackCount.Value));
                #endregion

            }
            return SqlHelper.ExecuteTransWithArrayList(SqlList);
        }
        public static bool SubDeliveryBackOut(SubDeliveryBack model)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append("SELECT * FROM officedba.SubDeliveryBackDetail  ");
            sbSql.Append(" WHERE CompanyCD=@CompanyCD and BackNo=@BackNo");

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

            DataTable dtBack = SqlHelper.ExecuteSql(sbSql.ToString(), paras);
            ArrayList SqlList = new ArrayList();

            if (dtBack != null && dtBack.Rows.Count > 0)
            {

                #region 更新单据
                StringBuilder sbMainSql = new StringBuilder();
                sbMainSql.Append("UPDATE  officedba.SubDeliveryBack SET OutUserID=@OutUserID,OutDate=@OutDate,BusiStatus=@BusiStatus ");
                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)
                                       };
                MainParas[0].Value = model.OutUserID;
                MainParas[1].Value = model.OutDate;
                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

                int id = 0;
                decimal count = 0m;
                foreach (DataRow row in dtBack.Rows)
                {
                    #region 添加门店库存流水帐
                    SubStorageAccountModel aModel = new SubStorageAccountModel();
                    aModel.BatchNo = row["SendBatchNo"].ToString();
                    aModel.BillNo = model.BackNo;
                    aModel.BillType = 7;
                    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["BackPrice"].ToString(), out count))
                    {
                        aModel.Price = count;
                    }
                    if (decimal.TryParse(row["BackCount"].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(), row["SendBatchNo"].ToString(), -count));

                }

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

            }
            else
                return false;

        }
        /*打印使用*/
        public static DataTable GetSubDeliveryBackInfoPrint(SubDeliveryBack model)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.AppendLine("  SELECT     ID, CompanyCD, BackNo, SendID, Title, ApplyUserID, ApplyDeptID, OutDeptID,BackReason, BusiStatus, ");
            sbSql.AppendLine("   OutUserID, convert(varchar(10),OutDate,120)OutDate, InUserID, convert(varchar(10),InDate,120)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, ExtField1,");
            sbSql.AppendLine("ExtField2,ExtField3,ExtField4,ExtField5,ExtField6,ExtField7,ExtField8,ExtField9,ExtField10");
            sbSql.AppendLine("  ,CONVERT(NUMERIC(12,2),ISNULL(BackPrice,0)) BackPrice");
            sbSql.AppendLine("  ,CONVERT(NUMERIC(12,2),ISNULL(BackFeeSum,0)) BackFeeSum");
            sbSql.AppendLine("  ,CONVERT(NUMERIC(12,2),ISNULL(BackCount,0)) BackCount");
            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     SendNo  ");
            sbSql.AppendLine("  FROM          officedba.SubDeliverySend AS s  ");
            sbSql.AppendLine("  WHERE      (ID = sds.SendID)) AS SendNo,  ");
            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 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.SubDeliveryBack 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 GetSubDeliveryBackInfo(SubDeliveryBack model)
        {
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append("SELECT sds.* ,");
            sbSql.Append("(SELECT s.SendNo from officedba.SubDeliverySend  as s where s.ID=sds.SendID) AS SendNo ,");
            sbSql.Append(" (select ei1.EmployeeName from officedba.EmployeeInfo  as ei1  where ei1.ID=sds.ApplyUserID) as ApplyUserIDName,");
            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.SubDeliveryBack 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 UpdateSubDeliverySend(SubDeliveryBack model, List<SubDeliveryBackDetail> modelList, Hashtable htExtAttr)
        {

            ArrayList SqlList = new ArrayList();
            #region 配送单
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update officedba.SubDeliveryBack set ");
            strSql.Append("SendID=@SendID,");
            strSql.Append("Title=@Title,");
            strSql.Append("ApplyUserID=@ApplyUserID,");
            strSql.Append("ApplyDeptID=@ApplyDeptID,");
            strSql.Append("BackPrice=@BackPrice,");
            strSql.Append("BackFeeSum=@BackFeeSum,");
            strSql.Append("BackCount=@BackCount,");
            strSql.Append("BackReason=@BackReason,");
            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("@SendID", SqlDbType.Int,4),
					new SqlParameter("@Title", SqlDbType.VarChar,100),
					new SqlParameter("@ApplyUserID", SqlDbType.Int,4),
					new SqlParameter("@ApplyDeptID", SqlDbType.Int,4),
					new SqlParameter("@BackPrice", SqlDbType.Decimal,9),
					new SqlParameter("@BackFeeSum", SqlDbType.Decimal,9),
					new SqlParameter("@BackCount", SqlDbType.Decimal,9),
					new SqlParameter("@BackReason", 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.SendID;
            parameters[2].Value = model.Title;
            parameters[3].Value = model.ApplyUserID;
            parameters[4].Value = model.ApplyDeptID;
            parameters[5].Value = model.BackPrice;
            parameters[6].Value = model.BackFeeSum;
            parameters[7].Value = model.BackCount;
            parameters[8].Value = model.BackReason;
            parameters[9].Value = model.Remark;
            parameters[10].Value = model.ModifiedDate;
            parameters[11].Value = model.ModifiedUserID;

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

            #endregion

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

            foreach (SubDeliveryBackDetail m in modelList)
            {
                SqlList.Add(GetSaveDetail(m));
            }
            #endregion

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

        }
        public static bool UpdateStatus(SubDeliveryBack model, int stype)
        {
            if (stype == 1)
            {
                #region 确认单据
                StringBuilder strSql = new StringBuilder();
                strSql.Append("update officedba.SubDeliveryBack 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.SubDeliveryBack 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_SubDeliveryBack_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.SubDeliveryBack 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 string AddSubDeliveryBack(SubDeliveryBack model, List<SubDeliveryBackDetail> modelList, Hashtable htExtAttr)
        {
            ArrayList SqlList = new ArrayList();

            #region 构造退货单主表
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into officedba.SubDeliveryBack(");
            strSql.Append("CompanyCD,BackNo,SendID,Title,ApplyUserID,ApplyDeptID,OutDeptID,BackPrice,BackFeeSum,BackCount,BackReason,BusiStatus,Remark,Creator,CreateDate,BillStatus,ModifiedDate,ModifiedUserID)");
            strSql.Append(" values (");
            strSql.Append("@CompanyCD,@BackNo,@SendID,@Title,@ApplyUserID,@ApplyDeptID,@OutDeptID,@BackPrice,@BackFeeSum,@BackCount,@BackReason,@BusiStatus,@Remark,@Creator,@CreateDate,@BillStatus,@ModifiedDate,@ModifiedUserID)");
            strSql.Append(";select @ID=@@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@CompanyCD", SqlDbType.VarChar,8),
					new SqlParameter("@BackNo", SqlDbType.VarChar,50), 
					new SqlParameter("@SendID", 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("@BackPrice", SqlDbType.Decimal,9),
					new SqlParameter("@BackFeeSum", SqlDbType.Decimal,9),
					new SqlParameter("@BackCount", SqlDbType.Decimal,9),
					new SqlParameter("@BackReason", 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.BackNo;
            parameters[2].Value = model.SendID;
            parameters[3].Value = model.Title;
            parameters[4].Value = model.ApplyUserID;
            parameters[5].Value = model.ApplyDeptID;
            if (model.OutDeptID.HasValue)
            {
                parameters[6].Value = model.OutDeptID;
            }
            else
            {
                parameters[6].Value = DBNull.Value;
            }
            parameters[7].Value = model.BackPrice;
            parameters[8].Value = model.BackFeeSum;
            parameters[9].Value = model.BackCount;
            parameters[10].Value = model.BackReason;
            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;

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


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

            #region 构造明细表
            foreach (SubDeliveryBackDetail m in modelList)
            {
                SqlList.Add(GetSaveDetail(m));
            }
            #endregion

            bool result = SqlHelper.ExecuteTransWithArrayList(SqlList);
            if (result)
            {
                return ((SqlCommand)SqlList[0]).Parameters["@ID"].Value.ToString();
            }
            else
                return string.Empty;
        }
Пример #10
0
        public static bool UpdateStatus(SubDeliveryBack model, int stype)
        {
            //定义返回变量
            bool res = false;
            /* 
             * 定义日志内容变量 
             * 增删改相关的日志,需要输出操作日志,该类型日志插入到数据库
             * 其他的 如出现异常时,需要输出系统日志,该类型日志保存到日志文件
             */
            //获取当前用户信息
            UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"];

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

            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;
        }
Пример #11
0
 /*打印使用*/
 public static DataTable GetSubDeliveryBackInfoPrint(SubDeliveryBack model)
 {
     return XBase.Data.Office.LogisticsDistributionManager.SubDeliveryBackDBHelper.GetSubDeliveryBackInfoPrint(model);
 }