Exemple #1
0
        public static string UpdateSubProductSellPrice(Model.Office.LogisticsDistributionManager.SubProductSellPrice model)
        {
            //return XBase.Data.Office.LogisticsDistributionManager.SubProductSendPriceDBHelper.UpdateSubProductSendPrice(model);
            //定义返回变量
            string res = string.Empty;

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

            //执行操作
            try
            {
                //执行操作
                res = XBase.Data.Office.LogisticsDistributionManager.SubProductSellPriceDBHelper.UpdateSubProductSellPrice(model);
            }
            catch (Exception ex)
            {
                //输出日志
                WriteSystemLog(userInfo, ex);
            }
            //定义变量
            string remark;

            //成功时
            if (res == "1")
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_SUCCESS;
            }
            else
            {
                //设置操作成功标识
                remark = ConstUtil.LOG_PROCESS_FAILED;
            }
            //操作日志
            LogInfoModel logModel = InitLogInfo(model.ID.ToString());

            //涉及关键元素 这个需要根据每个页面具体设置,本页面暂时设置为空
            logModel.Element = ConstUtil.LOG_PROCESS_UPDATE;;

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

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

            return(res);
        }
        public static string AddSubProductSellPrice(Model.Office.LogisticsDistributionManager.SubProductSellPrice model)
        {
            #region 验证是否添加过该产品的配送价格
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append("SELECT @IsHas=COUNT(*) FROM officedba.SubProductSellPrice WHERE ProductID=@ProductID AND CompanyCD=@CompanyCD AND DeptID=@DeptID");
            SqlParameter[] paras =
            {
                new SqlParameter("@ProductID", SqlDbType.Int),
                new SqlParameter("@CompanyCD", SqlDbType.VarChar),
                new SqlParameter("@DeptID",    SqlDbType.Int),
                new SqlParameter("@IsHas",     SqlDbType.VarChar, 50)
            };
            paras[0].Value     = model.ProductID;
            paras[1].Value     = model.CompanyCD;
            paras[2].Value     = model.DeptID;
            paras[3].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteSql(sbSql.ToString(), paras);
            string Flag = paras[3].Value.ToString();
            if (Flag != "0")
            {
                return("-1");
            }
            #endregion



            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into officedba.SubProductSellPrice(");
            strSql.Append("CompanyCD,ProductID,DeptID,SubPriceTax,SubPrice,SubTax,Discount,Creator,CreateDate,ModifiedDate,ModifiedUserID)");
            strSql.Append(" values (");
            strSql.Append("@CompanyCD,@ProductID,@DeptID,@SubPriceTax,@SubPrice,@SubTax,@Discount,@Creator,@CreateDate,@ModifiedDate,@ModifiedUserID)");
            strSql.Append(";select @ID=@@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CompanyCD",      SqlDbType.VarChar,    8),
                new SqlParameter("@ProductID",      SqlDbType.Int,        4),
                new SqlParameter("@DeptID",         SqlDbType.Int,        4),
                new SqlParameter("@SubPriceTax",    SqlDbType.Decimal,    9),
                new SqlParameter("@SubPrice",       SqlDbType.Decimal,    9),
                new SqlParameter("@SubTax",         SqlDbType.Decimal,    9),
                new SqlParameter("@Discount",       SqlDbType.Decimal,    5),
                new SqlParameter("@Creator",        SqlDbType.Int,        4),
                new SqlParameter("@CreateDate",     SqlDbType.DateTime),
                new SqlParameter("@ModifiedDate",   SqlDbType.DateTime),
                new SqlParameter("@ModifiedUserID", SqlDbType.VarChar,   10),
                new SqlParameter("@ID",             SqlDbType.Int)
            };
            parameters[0].Value      = model.CompanyCD;
            parameters[1].Value      = model.ProductID;
            parameters[2].Value      = model.DeptID;
            parameters[3].Value      = model.SubPriceTax;
            parameters[4].Value      = model.SubPrice;
            parameters[5].Value      = model.SubTax;
            parameters[6].Value      = model.Discount;
            parameters[7].Value      = model.Creator;
            parameters[8].Value      = model.CreateDate;
            parameters[9].Value      = model.ModifiedDate;
            parameters[10].Value     = model.ModifiedUserID;
            parameters[11].Direction = ParameterDirection.Output;

            ArrayList  SqlList = new ArrayList();
            SqlCommand SqlCmd  = new SqlCommand();
            SqlCmd.CommandText = strSql.ToString();
            SqlCmd.Parameters.AddRange(parameters);
            SqlList.Add(SqlCmd);
            bool result = SqlHelper.ExecuteTransWithArrayList(SqlList);
            if (result)
            {
                return(((SqlCommand)SqlList[0]).Parameters["@ID"].Value.ToString());
            }
            else
            {
                return(string.Empty);
            }
        }
        public static string UpdateSubProductSellPrice(Model.Office.LogisticsDistributionManager.SubProductSellPrice model)
        {
            #region 验证是否添加过该产品的配送价格
            StringBuilder sbSql = new StringBuilder();
            sbSql.Append("SELECT top 1 @IsHas=ID FROM officedba.SubProductSellPrice WHERE ProductID=@ProductID AND CompanyCD=@CompanyCD AND DeptID=@DeptID");
            SqlParameter[] paras =
            {
                new SqlParameter("@ProductID", SqlDbType.Int),
                new SqlParameter("@CompanyCD", SqlDbType.VarChar),
                new SqlParameter("@DeptID",    SqlDbType.Int),
                new SqlParameter("@IsHas",     SqlDbType.VarChar, 50)
            };
            paras[0].Value     = model.ProductID;
            paras[1].Value     = model.CompanyCD;
            paras[2].Value     = model.DeptID;
            paras[3].Direction = ParameterDirection.Output;

            SqlHelper.ExecuteSql(sbSql.ToString(), paras);
            string Flag = paras[3].Value.ToString();
            if (Flag != model.ID.ToString() && !string.IsNullOrEmpty(Flag))
            {
                return("-1");
            }
            #endregion



            StringBuilder strSql = new StringBuilder();
            strSql.Append("update officedba.SubProductSellPrice set ");
            strSql.Append("CompanyCD=@CompanyCD,");
            strSql.Append("ProductID=@ProductID,");
            strSql.Append("DeptID=@DeptID,");
            strSql.Append("SubPriceTax=@SubPriceTax,");
            strSql.Append("SubPrice=@SubPrice,");
            strSql.Append("SubTax=@SubTax,");
            strSql.Append("Discount=@Discount,");
            strSql.Append("ModifiedDate=@ModifiedDate,");
            strSql.Append("ModifiedUserID=@ModifiedUserID");
            strSql.Append(" where ID=@ID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID",             SqlDbType.Int,       4),
                new SqlParameter("@CompanyCD",      SqlDbType.VarChar,   8),
                new SqlParameter("@ProductID",      SqlDbType.Int,       4),
                new SqlParameter("@DeptID",         SqlDbType.Int,       4),
                new SqlParameter("@SubPriceTax",    SqlDbType.Decimal,   9),
                new SqlParameter("@SubPrice",       SqlDbType.Decimal,   9),
                new SqlParameter("@SubTax",         SqlDbType.Decimal,   9),
                new SqlParameter("@Discount",       SqlDbType.Decimal,   5),
                new SqlParameter("@ModifiedDate",   SqlDbType.DateTime),
                new SqlParameter("@ModifiedUserID", SqlDbType.VarChar, 10)
            };
            parameters[0].Value = model.ID;
            parameters[1].Value = model.CompanyCD;
            parameters[2].Value = model.ProductID;
            parameters[3].Value = model.DeptID;
            parameters[4].Value = model.SubPriceTax;
            parameters[5].Value = model.SubPrice;
            parameters[6].Value = model.SubTax;
            parameters[7].Value = model.Discount;
            parameters[8].Value = model.ModifiedDate;
            parameters[9].Value = model.ModifiedUserID;

            ArrayList  SqlList = new ArrayList();
            SqlCommand SqlCmd  = new SqlCommand();
            SqlCmd.CommandText = strSql.ToString();
            SqlCmd.Parameters.AddRange(parameters);
            SqlList.Add(SqlCmd);
            bool result = SqlHelper.ExecuteTransWithArrayList(SqlList);
            if (result)
            {
                return("1");
            }
            else
            {
                return("0");
            }
        }