예제 #1
0
    //保存
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        TB_System_Adver model = new TB_System_Adver();

        if (ViewState["id"] != null)
        {
            model.ID = ViewState["id"].ToInt();
        }
        model.ProCategoryId = Request["categoryId"].ToInt();
        model.AdverType     = DDLAdverType.SelectedValue.ToInt();
        model.PicWidth      = TbWidth.Text;
        model.PicHeight     = TbHeight.Text;
        model.Creater       = AdminUserName;
        model.AddDate       = DateTime.Now;

        ISystem_Adver Adver = SystemService.AdverService;

        if (ViewState["id"] == null)
        {
            if (Adver.Insert(model) == 1)
            {
                MessageDiv.InnerHtml = CommonClass.Reload("数据添加成功");
            }
            else
            {
                MessageDiv.InnerHtml = CommonClass.Alert("数据添加失败");
            }
        }
        else
        {
            if (Adver.Update(model) == 1)
            {
                MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功");
            }
            else
            {
                MessageDiv.InnerHtml = CommonClass.Alert("数据修改失败");
            }
        }
    }
예제 #2
0
    //保存
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        List <Expression> express = new List <Expression>();

        express.Add(new Expression("Code", "=", TbCode.Text.TrimEnd()));

        TB_System_Adver model = new TB_System_Adver();

        if (ViewState["id"] != null)
        {
            model = SystemService.AdverService.Get(ViewState["id"]);
            if (model.Code.ToLower() != TbCode.Text.TrimEnd().ToLower())
            {
                if (SystemService.AdverService.Search(express).Count > 0)
                {
                    MessageDiv.InnerHtml = CommonClass.Alert("当前标识已经存在,请重新输入");
                    return;
                }
            }
        }
        else
        {
            if (SystemService.AdverService.Search(express).Count > 0)
            {
                MessageDiv.InnerHtml = CommonClass.Alert("当前标识已经存在,请重新输入");
                return;
            }
        }

        model.CategoryId = DDLModel.SelectedValue.ToInt();
        model.Name       = TbName.Text.Trim();
        model.Code       = TbCode.Text;
        model.AdverType  = DDLAdverType.SelectedValue.ToInt();
        model.PicWidth   = TbWidth.Text;
        model.PicHeight  = TbHeight.Text;
        model.Remark     = TbRemark.Text;
        model.OrderBy    = TbOrderBy.Text.ToInt();
        model.Creater    = AdminUserName;
        model.AddDate    = DateTime.Now;
        ISystem_Adver Adver = SystemService.AdverService;

        if (ViewState["id"] == null)
        {
            if (Adver.Insert(model) == 1)
            {
                MessageDiv.InnerHtml = CommonClass.Reload("数据添加成功");
            }
            else
            {
                MessageDiv.InnerHtml = CommonClass.Alert("数据添加失败");
            }
        }
        else
        {
            if (Adver.Update(model) == 1)
            {
                MessageDiv.InnerHtml = CommonClass.Reload("数据修改成功");
            }
            else
            {
                MessageDiv.InnerHtml = CommonClass.Alert("数据修改失败");
            }
        }
    }