コード例 #1
0
        protected void frmRule_ItemCommand(object sender, FormViewCommandEventArgs e)
        {
            DropDownList ddlRuleName   = (DropDownList)frmRule.FindControl("ddlRuleName");
            TextBox      txtRuleText   = (TextBox)frmRule.FindControl("txtRuleText");
            CheckBox     chkIsInternal = (CheckBox)frmRule.FindControl("chkIsInternal");

            if (e.CommandName.ToString() == "Add")
            {
                TLGX_Consumer.MDMSVC.DC_Accommodation_RuleInfo newObj = new MDMSVC.DC_Accommodation_RuleInfo
                {
                    Accommodation_RuleInfo_Id = Guid.NewGuid(),
                    Accommodation_Id          = Guid.Parse(Request.QueryString["Hotel_Id"]),
                    Create_Date = DateTime.Now,
                    Create_User = System.Web.HttpContext.Current.User.Identity.Name,
                    Description = txtRuleText.Text.Trim(),
                    RuleType    = ddlRuleName.SelectedItem.Text.Trim(),
                    IsActive    = true
                };
                if (chkIsInternal.Checked)
                {
                    newObj.IsInternal = true;
                }
                else
                {
                    newObj.IsInternal = false;
                }
                if (AccSvc.AddHotelRule(newObj))
                {
                    BindHotelRules();

                    frmRule.DataBind();
                    frmRule.ChangeMode(FormViewMode.Insert);

                    GetLookUpValues();
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, "Rule has been added successfully", BootstrapAlertType.Success);
                }
                else
                {
                    BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning);
                }
            }


            if (e.CommandName.ToString() == "Modify")
            {
                Accomodation_ID = new Guid(Request.QueryString["Hotel_Id"]);
                Guid myRow_Id = Guid.Parse(grdHOtelRUles.SelectedDataKey.Value.ToString());

                var result = AccSvc.GetHotelRuleDetails(Accomodation_ID, myRow_Id);

                if (result.Count > 0)
                {
                    TLGX_Consumer.MDMSVC.DC_Accommodation_RuleInfo newObj = new MDMSVC.DC_Accommodation_RuleInfo
                    {
                        Accommodation_RuleInfo_Id = myRow_Id,
                        Accommodation_Id          = Guid.Parse(Request.QueryString["Hotel_Id"]),
                        Edit_Date   = DateTime.Now,
                        Edit_User   = System.Web.HttpContext.Current.User.Identity.Name,
                        Description = txtRuleText.Text.Trim(),
                        RuleType    = ddlRuleName.SelectedItem.Text.Trim(),
                        IsActive    = true
                    };
                    if (chkIsInternal.Checked)
                    {
                        newObj.IsInternal = true;
                    }
                    else
                    {
                        newObj.IsInternal = false;
                    }

                    if (AccSvc.UpdateHotelRule(newObj))
                    {
                        BindHotelRules();

                        frmRule.ChangeMode(FormViewMode.Insert);
                        frmRule.DataBind();

                        GetLookUpValues();
                        BootstrapAlert.BootstrapAlertMessage(dvMsg, "Rule has been updated successfully", BootstrapAlertType.Success);
                    }
                    else
                    {
                        BootstrapAlert.BootstrapAlertMessage(dvMsg, "Error Occurred", BootstrapAlertType.Warning);
                    }
                }
            }
            ;
        }