protected void btnSave_Click(object sender, EventArgs e) { BusinessRule rule = null; int businessRuleID = 0; Page.Validate("rule"); if (!Page.IsValid) return; businessRuleID = Convert.ToInt32(ViewState["businessRuleID"]); lblMessage.Text = ""; lblMessage.Visible = false; try { using (BusinessRuleManager repository = new BusinessRuleManager()) { if (businessRuleID == 0) { rule = new BusinessRule(); rule.RuleID = (int)Globals.RuleType.AdjusterClaimReview; rule.ClientID = SessionHelper.getClientId(); } else { rule = repository.GetBusinessRule(businessRuleID); } if (rule != null) { rule.UpdateDate = DateTime.Now; rule.IsActive = cbxActive.Checked; rule.EmailAdjuster = cbxEmailAdjuster.Checked; rule.EmailSupervisor = cbxEmailSupervisor.Checked; rule.Description = txtDescription.Text; rule.RuleXML = buildRule().ToString(); rule = repository.Save(rule); ViewState["businessRuleID"] = rule.BusinessRuleID.ToString(); lblMessage.Text = "Rule saved successfully."; lblMessage.CssClass = "ok"; lblMessage.Visible = true; } } } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblMessage.Text = "Rule not saved."; lblMessage.CssClass = "error"; lblMessage.Visible = true; } }
protected void gvBsuinessRules_RowCommand(object sender, GridViewCommandEventArgs e) { BusinessRule businessRule = null; int businessRuleID = 0; lblMessage.Text = string.Empty; lblMessage.Visible = false; if (e.CommandName == "DoEdit") { businessRuleID = Convert.ToInt32(e.CommandArgument); using (BusinessRuleManager repository = new BusinessRuleManager()) { businessRule = repository.GetBusinessRule(businessRuleID); if (businessRule != null) { editBusinessRule((int)businessRule.RuleID, businessRule.Rule.RuleName, businessRule); } } } else if (e.CommandName == "DoDelete") { try { businessRuleID = Convert.ToInt32(e.CommandArgument); using (BusinessRuleManager repository = new BusinessRuleManager()) { businessRule = repository.GetBusinessRule(businessRuleID); businessRule.IsActive = false; repository.Save(businessRule); refreshBusinessRuleGrid(); lblMessage.Text = "Rule was deactivate successfully."; lblMessage.CssClass = "ok"; lblMessage.Visible = true; Login login = new Login(); login.formatException(); login.setRulexception(); } } catch (Exception ex) { lblMessage.Text = "Rule was not deactivate."; lblMessage.CssClass = "ok"; lblMessage.Visible = true; } } }
protected void btnSave_Click(object sender, EventArgs e) { BusinessRule rule = null; int businessRuleID = 0; Page.Validate("rule"); if (!Page.IsValid) return; businessRuleID = Convert.ToInt32(ViewState["businessRuleID"]); lblMessage.Text = ""; lblMessage.Visible = false; try { using (BusinessRuleManager repository = new BusinessRuleManager()) { if (businessRuleID == 0) { rule = new BusinessRule(); BusinessRules businessRulesObj = new BusinessRules(); rule.RuleID = Convert.ToInt32(Session["ruleId"]); rule.ClientID = SessionHelper.getClientId(); rule.CarrierId = Convert.ToInt32(this.ddlCarrier.SelectedValue); } else { rule = repository.GetBusinessRule(businessRuleID); } if (rule != null) { rule.IsActive = cbxActive.Checked; rule.EmailAdjuster = cbxEmailAdjuster.Checked; rule.EmailSupervisor = cbxEmailSupervisor.Checked; rule.CarrierId = Convert.ToInt32(this.ddlCarrier.SelectedValue); rule.Description = txtDescription.Text; ViewState["businessRuleID"] = rule.BusinessRuleID.ToString(); rule.RuleXML = buildRule().ToString(); rule = repository.Save(rule); string str_query = @"update BusinessRule set CarrierId = @CarrierId where BusinessRuleID=@BusinessRuleID "; using (SqlConnection conn = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand(str_query, conn)) { cmd.Parameters.AddWithValue("@BusinessRuleID ", rule.BusinessRuleID); cmd.Parameters.AddWithValue("@CarrierId", rule.CarrierId); conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); conn.Dispose(); conn.Close(); } lblMessage.Text = "Rule saved successfully."; // notifyUser(txtDescription.Text, SessionHelper.getClientId()); lblMessage.CssClass = "ok"; lblMessage.Visible = true; } } Login login = new Login(); login.setGlobalSession(); login.formatException(); login.setRulexception(); } catch (Exception ex) { Core.EmailHelper.emailError(ex); lblMessage.Text = "Rule not saved."; lblMessage.CssClass = "error"; lblMessage.Visible = true; } }