예제 #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(lblID.Text))
        {
            try
            {
                WR_Rule model = GetModel();
                model.Rule_GUID       = Guid.NewGuid();
                model.Created_By      = CurrentEmployee.EmployeeCode;
                model.Created_By_Name = CurrentEmployee.EmployeeName;
                model.Created_On      = DateTime.Now;
                model.Record_Status   = 0;
                bll.Insert(model);

                List <WR_Attachment> attachements = GetAttachementModel(model.ID);
                new Attachement().Insert(attachements);

                JsHelper.AlertOperationSuccessAndRedirect(Page, "RuleList.aspx");
            }
            catch (Exception ex)
            {
                JsHelper.AlertOperationFailure(Page, ex);
            }
        }
        else
        {
            try
            {
                WR_Rule model = GetModel();
                model.ID = Convert.ToInt16(lblID.Text);
                bll.Update(model);

                new Attachement().DeleteByRuleId(model.ID);

                List <WR_Attachment> attachements = GetAttachementModel(model.ID);
                new Attachement().Insert(attachements);

                JsHelper.AlertOperationSuccessAndRedirect(Page, "RuleList.aspx");
            }
            catch (Exception ex)
            {
                JsHelper.AlertOperationFailure(Page, ex);
            }
        }
    }