Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text = string.Empty;

            CRM.Data.Entities.SecModule module = SecModuleManager.GetByModuleId(Convert.ToInt32(hdId.Value));
            module.ModuleName = txtModuleName.Text;
            module.ModuleDesc = txtModuleDescription.Text;
            module.Url        = txtURL.Text;
            int?_parentId = null;

            module.ParentId = Convert.ToInt32(ddlParentID.SelectedValue) == 0 ? _parentId : Convert.ToInt32(ddlParentID.SelectedValue);
            module.Status   = ddlStatus.SelectedValue == "1" ? true : false;
            if (txtURL.Text.Trim() != string.Empty)
            {
                module.ModuleType = 1;
            }
            else
            {
                module.ModuleType = 0;
            }
            if (Convert.ToInt32(ddlParentID.SelectedValue) > 0 && txtURL.Text.Trim() == string.Empty)
            {
                lblError.Text = "Please Enter Url";
                return;
            }
            SecModuleManager.Save(module);
            btnCancel_Click(null, null);
        }
Esempio n. 2
0
        protected void gvData_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            lblError.Text      = string.Empty;
            lblError.Visible   = false;
            lblSave.Text       = string.Empty;
            lblSave.Visible    = false;
            lblMessage.Text    = string.Empty;
            lblMessage.Visible = false;
            if (e.CommandName.Equals("DoEdit"))
            {
                pnlEdit.Enabled = true;
                pnlList.Enabled = false;
                pnlEdit.Visible = true;
                lbnNew.Visible  = false;
                CRM.Data.Entities.SecModule module = SecModuleManager.GetByModuleId(Convert.ToInt32(e.CommandArgument));
                hdId.Value                = module.ModuleId.ToString();
                txtModuleName.Text        = module.ModuleName;
                txtModuleDescription.Text = module.ModuleDesc;
                txtURL.Text               = module.Url;
                ddlParentID.SelectedValue = module.ParentId == null ? "0" : module.ParentId.ToString();
                ddlStatus.SelectedValue   = module.Status == true ? "1" : "0";
                ddlStatus.Focus();
            }
            else if (e.CommandName.Equals("DoDelete"))
            {
                try
                {
                    using (TransactionScope scope = new TransactionScope())
                    {
                        pnlList.Enabled = true;
                        pnlEdit.Enabled = false;

                        CRM.Data.Entities.SecModule module = SecModuleManager.GetByModuleId(Convert.ToInt32(e.CommandArgument));
                        module.Status = false;
                        SecModuleManager.Save(module);
                        DoBind();
                        scope.Complete();
                        lblSave.Text    = "Record Deleted Sucessfully.";
                        lblSave.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    lblError.Text    = "Record Not Deleted !!!";
                    lblError.Visible = true;
                }
            }
        }