示例#1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SealsEntity sealsEntity = GetEntity();

            if (app.CheckSealName(sealsEntity.ID, sealsEntity.SealName))
            {
                List <BrokenRuleMessage> list    = new List <BrokenRuleMessage>();
                BrokenRuleMessage        message = new BrokenRuleMessage("nameExist", "Seal Name already exists.");
                list.Add(message);
                this.ShowFailMessageToClient(list);
            }
            else
            {
                if (sealsEntity.ID > 0) //edit
                {
                    if (app.Update(sealsEntity))
                    {
                        Redirect(Request.RawUrl, false, true);
                    }
                    else
                    {
                        this.ShowFailMessageToClient(app.BrokenRuleMessages);
                    }
                }
                else
                {
                    List <BrokenRuleMessage> list    = new List <BrokenRuleMessage>();
                    BrokenRuleMessage        message = new BrokenRuleMessage("SealNotExist", "Seal not exists.");
                    list.Add(message);
                    this.ShowFailMessageToClient(list);
                }
            }
        }
示例#2
0
        protected string Save(string hdID, string sealName, string owner, string approver, string description, string status)
        {
            SealsEntity sealsEntity = new SealsEntity();
            int         id;

            if (int.TryParse(hdID, out id))
            {
                sealsEntity.ID = id;
            }
            else
            {
                sealsEntity.CreatedOn = DateTime.Now;
            }

            sealsEntity.SealName    = sealName.Trim().NoHTML();
            sealsEntity.Owner       = int.Parse(owner);
            sealsEntity.Approver    = int.Parse(approver);
            sealsEntity.Description = description.Trim().NoHTML();
            sealsEntity.Status      = (Status)Enum.Parse(typeof(Status), status);
            if (app.CheckSealName(sealsEntity.ID, sealsEntity.SealName))
            {
                //ShowFailMessageToClient("Seal Name already exists.");

                return("0");
            }
            if (sealsEntity.ID > 0) //edit
            {
                if (app.Update(sealsEntity))
                {
                    //ShowSuccessMessageToClient(true, true);
                    return("1");
                }
                else
                {
                    //ShowFailMessageToClient(app.BrokenRuleMessages);
                    return("2");
                }
            }
            else  //insert
            {
                if (app.Insert(sealsEntity) > 0)
                {
                    //ShowSuccessMessageToClient();
                    return("1");
                }
                else
                {
                    //ShowFailMessageToClient(app.BrokenRuleMessages);
                    return("2");
                }
            }
        }