Example #1
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        Template_Rules RuleManager = new Template_Rules();

        RuleManager.DeleteRule(this.iRuleID);

        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_DeleteSuccess", string.Format("deleteSuccessfully('{0}');", this.iRuleID), true);
    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string sSelectedRuleIDs = this.hdnSelectedRuleIDs.Value;

        // update
        Template_Rules RuleManager = new Template_Rules();

        RuleManager.AddGlobalRules(sSelectedRuleIDs);

        PageCommon.WriteJsEnd(this, "Added global rule successfully.", "window.parent.location.href=window.parent.location.href;");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 初始化Rule列表

        Template_Rules RuleManager = new Template_Rules();
        DataTable      RuleList    = RuleManager.GetNonGlobalRuleList();
        this.gridRuleList.DataSource = RuleList;
        this.gridRuleList.DataBind();

        #endregion
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验必要参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "RuleID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "$('#divContainer').hide();alert('Missing required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        this.iRuleID = Convert.ToInt32(this.Request.QueryString["RuleID"]);

        #endregion

        #region 加载Rule信息
        Template_Rules RuleManager = new Template_Rules();
        DataTable      RuleInfo    = RuleManager.GetRuleInfo(this.iRuleID);
        if (RuleInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Invalid", "$('#divContainer').hide();alert('Invalid required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        #endregion

        if (this.IsPostBack == false)
        {
            #region 加载email template
            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an email template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

            this.ddlRecomActionTemplate.DataSource = EmailTemplates;
            this.ddlRecomActionTemplate.DataBind();

            this.ddlAlertEmailTemplate.DataSource = EmailTemplates;
            this.ddlAlertEmailTemplate.DataBind();

            #endregion

            #region 加载Conditions

            DataTable ConditionListData = RuleManager.GetConditionList(this.iRuleID);

            this.hdnTolerances.Text = "";
            string Tol = "";
            foreach (DataRow dr in ConditionListData.Rows)
            {
                if ((dr["Tolerance"] != DBNull.Value) &&
                    (dr["Tolerance"] != string.Empty))
                {
                    Tol = (string)dr["Tolerance"];
                }
                else
                {
                    Tol = "";
                }

                if (this.hdnTolerances.Text == "")
                {
                    this.hdnTolerances.Text = "[$" + Tol + "$]";
                }
                else
                {
                    this.hdnTolerances.Text += ",[$" + Tol + "$]";
                }
            }

            this.gridConditionList.DataSource = ConditionListData;
            this.gridConditionList.DataBind();

            #endregion

            #region 绑定数据

            this.txtRuleName.Text   = "Copy of " + RuleInfo.Rows[0]["Name"].ToString();
            this.txtDesc.Text       = RuleInfo.Rows[0]["Desc"].ToString();
            this.chkEnabled.Checked = Convert.ToBoolean(RuleInfo.Rows[0]["Enabled"]);
            this.ddlRecomActionTemplate.SelectedValue = RuleInfo.Rows[0]["RecomEmailTemplid"].ToString();
            this.ddlAlertEmailTemplate.SelectedValue  = RuleInfo.Rows[0]["AlertEmailTemplId"].ToString();
            this.chkReqAck.Checked      = Convert.ToBoolean(RuleInfo.Rows[0]["AckReq"]);
            this.txtFormula.Text        = RuleInfo.Rows[0]["AdvFormula"].ToString();
            this.ddlScope.SelectedValue = RuleInfo.Rows[0]["RuleScope"].ToString();

            #region get loan target

            //this.ddlTarget.SelectedValue = RuleInfo.Rows[0]["LoanTarget"].ToString();

            LPWeb.Model.Template_Rules_LoanTarget modelLoanTarget;
            if (!RuleInfo.Rows[0].IsNull("LoanTarget"))
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget(Convert.ToInt16(RuleInfo.Rows[0]["LoanTarget"]));
            }
            else
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget();
            }

            this.chkTargetActiveLoans.Checked   = modelLoanTarget.ActiveLoans;
            this.chkTargetActiveLeads.Checked   = modelLoanTarget.ActiveLeads;
            this.chkTargetArchivedLoans.Checked = modelLoanTarget.ArchivedLoans;
            this.chkTargetArchivedLeads.Checked = modelLoanTarget.ArchivedLeads;

            #endregion

            #endregion

            // set counter
            this.hdnCounter.Value = ConditionListData.Rows.Count.ToString();
        }
    }
Example #5
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region get rule data

        string sRuleName = this.txtRuleName.Text.Trim();
        bool   bEnabled  = this.chkEnabled.Checked;
        string sDesc     = this.txtDesc.Text.Trim();
        if (string.IsNullOrEmpty(sDesc))
        {
            sDesc             = txtRuleName.Text.Trim();
            this.txtDesc.Text = sDesc;
        }

        string sRecomEmailTemplateID  = this.ddlRecomActionTemplate.SelectedValue;
        int    isRecomEmailTemplateID = Convert.ToInt32(sRecomEmailTemplateID);

        string sAlertEmailTemplateID = this.ddlAlertEmailTemplate.SelectedValue;
        int    iAlertEmailTemplateID = Convert.ToInt32(sAlertEmailTemplateID);

        bool   bReqAck     = this.chkReqAck.Checked;
        string sAdvFormula = this.txtFormula.Text.Trim();

        string sScope = this.ddlScope.SelectedValue;
        Int16  iScope = Convert.ToInt16(sScope);

        #region get loan target

        //string sTarget = this.ddlTarget.SelectedValue;
        //Int16 iTarget = Convert.ToInt16(sTarget);

        LPWeb.Model.Template_Rules_LoanTarget modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget();

        modelLoanTarget.ActiveLoans   = this.chkTargetActiveLoans.Checked;
        modelLoanTarget.ActiveLeads   = this.chkTargetActiveLeads.Checked;
        modelLoanTarget.ArchivedLoans = this.chkTargetArchivedLoans.Checked;
        modelLoanTarget.ArchivedLeads = this.chkTargetArchivedLeads.Checked;

        Int16 iTarget = modelLoanTarget.LoanTargetValue;

        if (iTarget == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_NoLoanTarget", "$('#divContainer').hide();alert('No target for rule selected. Please select a rule target.');$('#divContainer').show();", true);
            return;
        }

        #endregion

        #endregion

        Template_Rules RuleManager = new Template_Rules();

        #region 检查Rule Name是否重复

        bool bIsExist = RuleManager.IsExist_Create(sRuleName);
        if (bIsExist == true)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Duplicate", "$('#divContainer').hide();alert('The rule name has been taken. Please use a different name.');$('#divContainer').show();", true);
            return;
        }

        #endregion

        #region get condition data

        string sSequences      = this.hdnSequences.Text;
        string sPointFieldIDs  = this.hdnPointFieldIDs.Text;
        string sConditions     = this.hdnConditions.Text;
        string sTolerances     = this.hdnTolerances.Text;     // [$xxx$],[$yyy$],[$zzz$]
        string sToleranceTypes = this.hdnToleranceTypes.Text; // $,%,#null#

        #endregion

        #region build conditiion list

        DataTable ConditionList = RuleManager.GetConditionList(" and 1=0");

        string[] SequenceArray      = sSequences.Split(',');
        string[] PointFieldIDArray  = sPointFieldIDs.Split(',');
        string[] ConditionArray     = sConditions.Split(',');
        string[] ToleranceArray     = sTolerances.Split(',');
        string[] ToleranceTypeArray = sToleranceTypes.Split(',');

        for (int i = 0; i < PointFieldIDArray.Length; i++)
        {
            string sSequence       = SequenceArray[i];
            string sPointFieldID   = PointFieldIDArray[i];
            string sConditionID    = ConditionArray[i];
            string sToleranceBlock = ToleranceArray[i];
            string sToleranceType  = ToleranceTypeArray[i];

            #region format Tolerance

            string sTelerance = sToleranceBlock.Replace("[$", string.Empty);
            sTelerance = sTelerance.Replace("$]", string.Empty);

            #endregion

            #region add rows

            DataRow ConditionRow = ConditionList.NewRow();
            ConditionRow["RuleCondId"]   = 0;
            ConditionRow["RuleId"]       = 0;
            ConditionRow["PointFieldId"] = Convert.ToInt32(sPointFieldID);
            ConditionRow["Condition"]    = Convert.ToInt32(sConditionID);
            ConditionRow["Tolerance"]    = sTelerance;
            if (sToleranceType == "#null#")
            {
                ConditionRow["ToleranceType"] = DBNull.Value;
            }
            else if (sToleranceType == "#empty#")
            {
                ConditionRow["ToleranceType"] = string.Empty;
            }
            else
            {
                ConditionRow["ToleranceType"] = sToleranceType;
            }
            ConditionRow["Sequence"] = Convert.ToInt32(sSequence);
            ConditionList.Rows.Add(ConditionRow);

            #endregion
        }

        #endregion

        // insert
        if (sAdvFormula.Trim() == string.Empty)
        {
            sAdvFormula = sSequences.Replace(",", " AND ");
        }
        RuleManager.InsertRule(sRuleName, sDesc, iAlertEmailTemplateID, bReqAck, isRecomEmailTemplateID, sAdvFormula, iScope, iTarget, ConditionList);

        // success
        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Clone rule successfully.');window.parent.location.href=window.parent.location.href;", true);
    }
Example #6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        #region get rule data

        string sRuleName = this.txtRuleName.Text.Trim();
        string sDesc     = this.txtDesc.Text.Trim();
        if (string.IsNullOrEmpty(sDesc))
        {
            sDesc             = txtRuleName.Text.Trim();
            this.txtDesc.Text = sDesc;
        }

        string sRecomEmailTemplateID  = this.ddlRecomActionTemplate.SelectedValue;
        int    isRecomEmailTemplateID = Convert.ToInt32(sRecomEmailTemplateID);

        string sAlertEmailTemplateID = this.ddlAlertEmailTemplate.SelectedValue;
        int    iAlertEmailTemplateID = Convert.ToInt32(sAlertEmailTemplateID);

        bool   bReqAck     = this.chkReqAck.Checked;
        string sAdvFormula = this.txtFormula.Text.Trim();

        string sScope = this.ddlScope.SelectedValue;
        Int16  iScope = Convert.ToInt16(sScope);

        #region get loan target

        //string sTarget = this.ddlTarget.SelectedValue;
        //Int16 iTarget = Convert.ToInt16(sTarget);

        LPWeb.Model.Template_Rules_LoanTarget modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget();

        modelLoanTarget.ActiveLoans   = this.chkTargetActiveLoans.Checked;
        modelLoanTarget.ActiveLeads   = this.chkTargetActiveLeads.Checked;
        modelLoanTarget.ArchivedLoans = this.chkTargetArchivedLoans.Checked;
        modelLoanTarget.ArchivedLeads = this.chkTargetArchivedLeads.Checked;

        Int16 iTarget = modelLoanTarget.LoanTargetValue;

        if (iTarget == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_NoLoanTarget", "$('#divContainer').hide();alert('No target for rule selected. Please select a rule target.');$('#divContainer').show();", true);
            return;
        }

        #endregion

        #endregion

        Template_Rules RuleManager = new Template_Rules();

        #region 检查Rule Name是否重复

        bool bIsExist = RuleManager.IsExist_Create(sRuleName);
        if (bIsExist == true)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Duplicate", "$('#divContainer').hide();alert('The rule name has been taken. Please use a different name.');$('#divContainer').show();", true);
            return;
        }

        #endregion

        #region get condition data

        string sSequences      = this.hdnSequences.Text;
        string sPointFieldIDs  = this.hdnPointFieldIDs.Text;
        string sConditions     = this.hdnConditions.Text;
        string sTolerances     = this.hdnTolerances.Text;     // [$xxx$],[$yyy$],[$zzz$]
        string sToleranceTypes = this.hdnToleranceTypes.Text; // $,%,#null#

        #endregion

        #region build conditiion list


        DataTable ConditionList = RuleManager.GetConditionList(" and 1=0");

        string[] SequenceArray      = sSequences.Split(',');
        string[] PointFieldIDArray  = sPointFieldIDs.Split(',');
        string[] ConditionArray     = sConditions.Split(',');
        string[] ToleranceArray     = sTolerances.Split(',');
        string[] ToleranceTypeArray = sToleranceTypes.Split(',');

        for (int i = 0; i < PointFieldIDArray.Length; i++)
        {
            string sSequence       = SequenceArray[i];
            string sPointFieldID   = PointFieldIDArray[i];
            string sConditionID    = ConditionArray[i];
            string sToleranceBlock = ToleranceArray[i];
            string sToleranceType  = ToleranceTypeArray[i];

            #region format Tolerance

            string sTelerance = sToleranceBlock.Replace("[$", string.Empty);
            sTelerance = sTelerance.Replace("$]", string.Empty);

            #endregion

            #region add rows

            DataRow ConditionRow = ConditionList.NewRow();
            ConditionRow["RuleCondId"]   = 0;
            ConditionRow["RuleId"]       = 0;
            ConditionRow["PointFieldId"] = Convert.ToInt32(sPointFieldID);
            ConditionRow["Condition"]    = Convert.ToInt32(sConditionID);
            ConditionRow["Tolerance"]    = sTelerance;
            if (sToleranceType == "#null#")
            {
                ConditionRow["ToleranceType"] = DBNull.Value;
            }
            else if (sToleranceType == "#empty#")
            {
                ConditionRow["ToleranceType"] = string.Empty;
            }
            else
            {
                ConditionRow["ToleranceType"] = sToleranceType;
            }
            ConditionRow["Sequence"] = Convert.ToInt32(sSequence);
            ConditionList.Rows.Add(ConditionRow);

            #endregion
        }



        #endregion

        // insert
        if (sAdvFormula.Trim() == string.Empty)
        {
            sAdvFormula = sSequences.Replace(",", " AND ");
        }

        int iSelCampaignID = 0;
        if (hfSelCampaigns.Value != "")
        {
            iSelCampaignID = Convert.ToInt32(hfSelCampaigns.Value);
            AutoCampaigns _bAutoCampaigns = new AutoCampaigns();
            int           iCount          = _bAutoCampaigns.GetMarketingCount(" AND CampaignId=" + iSelCampaignID);
            if (iCount == 0)
            {
                LPWeb.Model.AutoCampaigns _mAutoCampaigns = new LPWeb.Model.AutoCampaigns();
                _mAutoCampaigns.CampaignId = iSelCampaignID;
                _mAutoCampaigns.PaidBy     = 0;
                _mAutoCampaigns.Enabled    = true;
                _mAutoCampaigns.SelectedBy = CurrUser.iUserID;
                _bAutoCampaigns.Add(_mAutoCampaigns);
            }
        }

        int nNewId = RuleManager.InsertRule(sRuleName, sDesc, iAlertEmailTemplateID, bReqAck, isRecomEmailTemplateID, sAdvFormula, iScope, iTarget, ConditionList, iSelCampaignID);

        DataTable dtNewRuleWithEmailTpltInfo = RuleManager.GetRuleWithAlertEmailTpltInfo(nNewId);
        string    strReturn = "<table></table>";
        if (dtNewRuleWithEmailTpltInfo.Rows.Count > 0)
        {
            strReturn = "<table><Rule RuleId=\"{0}\" Name=\"{1}\" AlertEmailTemplId=\"{2}\" AlertEmailTpltName=\"{3}\"></Rule></table>";
            strReturn = string.Format(strReturn, dtNewRuleWithEmailTpltInfo.Rows[0]["RuleId"],
                                      string.Format("{0}", dtNewRuleWithEmailTpltInfo.Rows[0]["Name"]).Replace("<", "&amp;lt;"), dtNewRuleWithEmailTpltInfo.Rows[0]["AlertEmailTemplId"],
                                      string.Format("{0}", dtNewRuleWithEmailTpltInfo.Rows[0]["AlertEmailTpltName"]).Replace("<", "&amp;lt;"));
        }
        strReturn = strReturn.Replace('<', '\u0001').Replace("'", "&#39;");
        // success
        //this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Create rule successfully.');window.parent.location.href=window.parent.location.href;", true);
        this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", string.Format("addSuccessfully('{0}');", strReturn), true); // changed by peter 20110116
    }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Request.QueryString["needret"]))
        {
            strNeedReturn = "0";
        }
        else
        {
            strNeedReturn = "1";
        }

        #region 校验必要参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "RuleID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "$('#divContainer').hide();alert('Missing required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        this.iRuleID = Convert.ToInt32(this.Request.QueryString["RuleID"]);

        #endregion

        #region 加载Rule信息
        Template_Rules RuleManager = new Template_Rules();
        DataTable      RuleInfo    = RuleManager.GetRuleInfo(this.iRuleID);
        if (RuleInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Invalid", "$('#divContainer').hide();alert('Invalid required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        #endregion

        // is referenced by rule group
        this.hdnIsRef.Text = RuleManager.bIsRef(this.iRuleID).ToString();

        if (this.IsPostBack == false)
        {
            #region 加载email template
            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an email template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

            this.ddlRecomActionTemplate.DataSource = EmailTemplates;
            this.ddlRecomActionTemplate.DataBind();

            this.ddlAlertEmailTemplate.DataSource = EmailTemplates;
            this.ddlAlertEmailTemplate.DataBind();

            #endregion

            #region 加载Conditions

            DataTable ConditionListData = RuleManager.GetConditionList(this.iRuleID);
            this.gridConditionList.DataSource = ConditionListData;
            this.gridConditionList.DataBind();

            #endregion

            #region 绑定数据

            this.txtRuleName.Text   = RuleInfo.Rows[0]["Name"].ToString();
            this.txtDesc.Text       = RuleInfo.Rows[0]["Desc"].ToString();
            this.chkEnabled.Checked = Convert.ToBoolean(RuleInfo.Rows[0]["Enabled"]);
            this.ddlRecomActionTemplate.SelectedValue = RuleInfo.Rows[0]["RecomEmailTemplid"].ToString();
            this.ddlAlertEmailTemplate.SelectedValue  = RuleInfo.Rows[0]["AlertEmailTemplId"].ToString();
            this.chkReqAck.Checked      = Convert.ToBoolean(RuleInfo.Rows[0]["AckReq"]);
            this.txtFormula.Text        = RuleInfo.Rows[0]["AdvFormula"].ToString();
            this.ddlScope.SelectedValue = RuleInfo.Rows[0]["RuleScope"].ToString();

            #region get loan target

            //this.ddlTarget.SelectedValue = RuleInfo.Rows[0]["LoanTarget"].ToString();

            LPWeb.Model.Template_Rules_LoanTarget modelLoanTarget;
            if (!RuleInfo.Rows[0].IsNull("LoanTarget"))
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget(Convert.ToInt16(RuleInfo.Rows[0]["LoanTarget"]));
            }
            else
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget();
            }

            this.chkTargetActiveLoans.Checked   = modelLoanTarget.ActiveLoans;
            this.chkTargetActiveLeads.Checked   = modelLoanTarget.ActiveLeads;
            this.chkTargetArchivedLoans.Checked = modelLoanTarget.ArchivedLoans;
            this.chkTargetArchivedLeads.Checked = modelLoanTarget.ArchivedLeads;

            #endregion

            #endregion
            if (RuleInfo.Rows[0]["AutoCampaignId"].ToString() != "")
            {
                this.hfSelCampaigns.Value = RuleInfo.Rows[0]["AutoCampaignId"].ToString();
                MarketingCampaigns             _bMarketingCampaigns = new MarketingCampaigns();
                LPWeb.Model.MarketingCampaigns _mMarketingCampaigns = _bMarketingCampaigns.GetModel(Convert.ToInt32(RuleInfo.Rows[0]["AutoCampaignId"]));
                //txtMarketingCampaign.Text = _mMarketingCampaigns.CampaignName;
            }
            // set counter
            this.hdnCounter.Value = ConditionListData.Rows.Count.ToString();
        }
    }