Ejemplo n.º 1
0
        /// <summary>
        /// 检验表单数据
        /// </summary>
        /// <returns></returns>
        public bool CheckPageInfo(string type, string PKCode, string BusCode, string StoCode, string CCname, string UCname, string TStatus, string Sort, string InsideCode, string DiscountRate, string MenuCode, string LevelCode, string SchName, string CCode, string UCode)
        {
            bool rel = false;

            try
            {
                Entity         = new TB_DiscountSchemeEntity();
                Entity.Id      = 0;
                Entity.BusCode = BusCode;
                Entity.StoCode = StoCode;
                Entity.CCode   = CCode;
                Entity.CCname  = CCname;

                Entity.UCode  = UCode;
                Entity.UCname = UCname;

                Entity.TStatus      = TStatus;
                Entity.Sort         = StringHelper.StringToInt(Sort);
                Entity.PKCode       = PKCode;
                Entity.InsideCode   = InsideCode;
                Entity.DiscountRate = StringHelper.StringToDecimal(DiscountRate);
                Entity.MenuCode     = MenuCode;
                Entity.LevelCode    = LevelCode;
                Entity.SchName      = SchName;
                rel = true;
            }
            catch (System.Exception)
            {
            }
            return(rel);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(string GUID, string UID, TB_DiscountSchemeEntity UEntity)
        {
            //更新数据
            int result = dal.Update(UEntity);

            //检测执行结果
            CheckResult(result, "");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(TB_DiscountSchemeEntity Entity)
        {
            DataSet       dtStructure = DBHelper.ExecuteDataSet("select top 0 * from TB_DiscountScheme");
            StringBuilder sql         = new StringBuilder();

            sql.Append(" declare @returnval int;");
            sql.Append(" set @returnval=0;");
            sql.Append("declare @PKCode varchar(32)");
            sql.Append(" set @PKCode='" + Entity.PKCode + "';");
            sql.Append(" if not exists(select 1 from TB_DiscountScheme where BusCode='" + Entity.BusCode + "' and StoCode='" + Entity.StoCode + "' and PKCode=@PKCode) begin set @returnval=2; end ");
            sql.Append(" else if exists(select 1 from TB_DiscountScheme where BusCode='" + Entity.BusCode + "' and StoCode='" + Entity.StoCode + "' and PKCode<>@PKCode and SchName='" + Entity.SchName + "') begin set @returnval=1; end ");
            if (!string.IsNullOrEmpty(Entity.InsideCode))
            {
                sql.Append(" else if exists(select 1 from TB_DiscountScheme where BusCode='" + Entity.BusCode + "' and StoCode='" + Entity.StoCode + "' and InsideCode='" + Entity.InsideCode + "' and PKCode<>@PKCode) begin set @returnval=1; end ");
            }
            sql.Append(" else begin BEGIN TRAN tan1");

            Entity.CTime = System.DateTime.Now;
            Entity.UTime = System.DateTime.Now;
            List <string> lstExcludeFilds = new List <string>();
            Dictionary <string, string> dicAttachFilds = new Dictionary <string, string>();

            lstExcludeFilds.Clear();
            lstExcludeFilds.Add("Id");
            lstExcludeFilds.Add("PKCode");
            lstExcludeFilds.Add("CTime");
            lstExcludeFilds.Add("UTime");
            dicAttachFilds.Clear();
            dicAttachFilds.Add("CTime", "getdate()");
            dicAttachFilds.Add("UTime", "getdate()");

            string InsertSql = EntityHelper.GenerateSqlByDE <TB_DiscountSchemeEntity>(dtStructure.Tables[0], Entity, lstExcludeFilds, dicAttachFilds, EntityHelper.eSqlType.update);

            sql.AppendFormat(" update TB_DiscountScheme set " + InsertSql + " where BusCode='" + Entity.BusCode + "' and PKCode=@PKCode;");
            sql.AppendLine(" exec dbo.p_uploaddata_isSync '" + Entity.BusCode + "','" + Entity.StoCode + "','TB_DiscountScheme','PKCode',@PKCode,'update'");
            #region 特殊折扣、
            sql.Append("delete [dbo].[TR_DiscountSchemeRate] where buscode='" + Entity.BusCode + "' and SchCode=@PKCode");
            foreach (TR_DiscountSchemeRateEntity rate in Entity.DSRateList)
            {
                sql.Append(" insert into [dbo].[TR_DiscountSchemeRate]([BusCode],[StoCode],[CCode],[CCname],[CTime],[TStatus],[Sort],[SchCode],[DiscountType],[DisTypeCode],[DisCode],[DisMetCode],[DiscountRate]) values('" + Entity.BusCode + "','" + Entity.StoCode + "','" + Entity.CCode
                           + "','" + Entity.CCname + "',getdate(),'" + Entity.TStatus + "','" + Entity.Sort + "',@PKCode,'" + rate.DiscountType + "','" + rate.DisTypeCode + "','" + rate.DisCode + "','" + rate.DiscountRate + "');");
            }
            sql.AppendLine(" if(@@error=0) begin set @returnval=0; commit tran tan1; end else begin rollback tran tran1;set @returnval=1; end");
            sql.AppendLine(" end");
            sql.AppendLine(" select @returnval;");
            DataTable dt = DBHelper.ExecuteDataTable(sql.ToString());
            if (dt != null && dt.Rows.Count > 0)
            {
                return(StringHelper.StringToInt(dt.Rows[0][0].ToString()));
            }
            else
            {
                return(2);
            }
            #endregion
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 单行数据转实体对象
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        private TB_DiscountSchemeEntity SetEntityInfo(DataRow dr)
        {
            TB_DiscountSchemeEntity Entity = new TB_DiscountSchemeEntity();

            Entity.Id      = StringHelper.StringToLong(dr["Id"].ToString());
            Entity.BusCode = dr["BusCode"].ToString();
            Entity.StoCode = dr["StoCode"].ToString();
            Entity.CCode   = dr["CCode"].ToString();
            Entity.CCname  = dr["CCname"].ToString();

            Entity.UCode  = dr["UCode"].ToString();
            Entity.UCname = dr["UCname"].ToString();

            Entity.TStatus      = dr["TStatus"].ToString();
            Entity.Sort         = StringHelper.StringToInt(dr["Sort"].ToString());
            Entity.PKCode       = dr["PKCode"].ToString();
            Entity.InsideCode   = dr["InsideCode"].ToString();
            Entity.DiscountRate = StringHelper.StringToDecimal(dr["DiscountRate"].ToString());
            Entity.MenuCode     = dr["MenuCode"].ToString();
            Entity.LevelCode    = dr["LevelCode"].ToString();
            Entity.SchName      = dr["SchName"].ToString();
            return(Entity);
        }