protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "add"))
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("You are not authorised to Perform any operation on this page. Please contact system administrator.", false);
                return;
            }
            if (ValidData())
            {
            }
            else
            {
                LoggedIn  master       = (LoggedIn)this.Master;
                CommonBAL combal       = new CommonBAL();
                UserBE    addUserBE    = new UserBE();
                UserDAL   addUserdAL   = new UserDAL();
                UserBAL   addUserBal   = new UserBAL();
                int       ReturnOutput = 0;
                addUserBE.LastModifiedBy = ((UserBE)Session["LoggedInUser"]).UserId;

                addUserBE.UserName         = txtUserName.Text;
                addUserBE.FirstName        = txtFName.Text;
                addUserBE.MiddleName       = txtMName.Text;
                addUserBE.LastName         = txtLName.Text;
                addUserBE.PrimaryEmailId   = txtPREmailId.Text;
                addUserBE.SecondaryEmailId = txtSCEmailId.Text;
                addUserBE.MobileNo         = txtMobileNo.Text;
                addUserBE.Address1         = txtAddress1.Text;
                addUserBE.Address2         = txtAddress2.Text;
                addUserBE.Street           = txtStreet.Text;
                addUserBE.City             = txtCity.Text;
                addUserBE.State1           = txtState.Text;
                addUserBE.Country          = txtCountry.Text;
                addUserBE.SecretQuest      = ddSecretQuest.SelectedValue;
                addUserBE.SecretAns        = txtSecretAns.Text;
                addUserBE.EncPass          = combal.Encrypt(txtPass.Text, false);

                if (addUserBal.AddUser(addUserBE, ref ReturnOutput))
                {
                    if (ReturnOutput == 1)
                    {
                        master.ShowMessage("User of this User Name Already exist. ", false);
                    }
                    else if (ReturnOutput == 2)
                    {
                        clearFields();
                        master.ShowMessage("Record Inserted Successfully.", true);
                    }
                }
                else
                {
                    master.ShowMessage("Unsuccessful", false);
                }
            }
        }
        protected void CurrentRowTextBox_OnTextChanged(object sender, EventArgs e)
        {
            TextBox t = (TextBox)sender;

            try
            {
                DataPagertxtValue = Convert.ToInt32(t.Text);
            }
            catch
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Value Out of Range", false);
                return;
            }

            if (t.Text == "")
            {
                return;
            }


            if (DataPagertxtValue <= RoleDataPager.TotalRowCount)
            {
                RoleDataPager.SetPageProperties(Convert.ToInt32(t.Text) - 1,
                                                RoleDataPager.PageSize, true);
                bind();
                recalcNoOfPages();
            }
            else
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Incorrect Input", false);
            }
        }
        //protected void btnUpdate_Click(object sender, EventArgs e)
        //{
        //    RoleBE role = new RoleBE();
        //    RoleBAL roleBAL = new RoleBAL();


        //    role.RoleId = Convert.ToInt32(hdnRoleUpdateId.Value);
        //    //role.RoleShortDesc = txtRoleShortDesc.Text;
        //    //role.RoleLongDesc = txtRolelongDesc.Text;
        //    role.LastModifiedBy = ((UserBE)Session["LoggedInUser"]).UserId;
        //    if (roleBAL.ModifyRole(role))
        //    {
        //        LvRoleItems.EditIndex = -1;
        //        bind();
        //        recalcNoOfPages();
        //        LoggedIn master = (LoggedIn)this.Master;
        //        master.ShowMessage("Role successfully Updated.", true);
        //    }
        //    else
        //    {
        //        LoggedIn master = (LoggedIn)this.Master;
        //        master.ShowMessage("Unsuccessful", true);
        //    }

        //}

        //protected void btnCancel_Click(object sender, EventArgs e)
        //{
        //    LvRoleItems.EditIndex = -1;
        //    bind();
        //    recalcNoOfPages();
        //}

        protected void btnDeleteYes_Click(object sender, EventArgs e)
        {
            RoleBE  role    = new RoleBE();
            RoleBAL roleBAL = new RoleBAL();
            int     RoleId  = Convert.ToInt32(hdnRoleId.Value);

            role.RoleId = Convert.ToInt32(RoleId);
            if (roleBAL.DeleteRole(role))
            {
                if (LvRoleItems.Items.Count == 1)
                {
                    RoleDataPager.SetPageProperties(RoleDataPager.TotalRowCount - RoleDataPager.PageSize - 1,
                                                    RoleDataPager.PageSize, true);
                    bind();
                    recalcNoOfPages();
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("Role successfully deleted.", true);
                }
                else
                {
                    LvRoleItems.EditIndex = -1;
                    bind();
                    recalcNoOfPages();
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("Role successfully deleted.", true);
                }
            }
            else
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Sorry You cannot delete Role because it is already in use", false);
                recalcNoOfPages();
            }
        }
        void UCRoleAddList_btnUpdateClick(object sender, EventArgs e)
        {
            RoleBE  role    = new RoleBE();
            RoleBAL roleBAL = new RoleBAL();


            role.RoleId        = Convert.ToInt32(hdnRoleUpdateId.Value);
            role.RoleShortDesc = UCRoleAddList.ShortDesc;
            role.RoleLongDesc  = UCRoleAddList.LongDesc;

            role.LastModifiedBy = ((UserBE)Session["LoggedInUser"]).UserId;
            if (roleBAL.ModifyRole(role))
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Role successfully Updated.", true);
                LvRoleItems.EditIndex = -1;
                bind();
                recalcNoOfPages();
            }
            else
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Unsuccessful", true);
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string   msg    = Request.QueryString["Message"];
            LoggedIn master = (LoggedIn)this.Master;

            master.ShowMessage(msg, false);

            LoggedInUser = (UserBE)Session["LoggedInUser"];

            if (LoggedInUser == null)
            {
                // return to login page because user has not loggedin or session has timedout...
                Response.Redirect("~/Login.aspx");
            }

            if (Session["QuestId"] != null)
            {
                Response.Redirect("~/QuestAns/QA_QuestWithAns.aspx");
            }

            if (!IsPostBack)
            {
                setBreadCrumb();
                hdnbtnQueryId.Value = "1";
                hdnbtnKOId.Value    = "4";
                ChangeKOButtonBackColor(Convert.ToInt32(hdnbtnKOId.Value));
                ChangeQueryButtonBackColor(Convert.ToInt32(hdnbtnQueryId.Value));
                ddlPageSize.Text      = KODataPager.PageSize.ToString();
                ddlPageSizeQuery.Text = QueryDataPager.PageSize.ToString();
                bindLVKO();
                bindLVQuery();
            }

            //CultureInfo ci = new CultureInfo("en-US");

            //if (!IsPostBack) //???
            //{
            //    HomePageSetUpBAL setupBAL = new HomePageSetUpBAL();
            //    DataTable dt = new DataTable();
            //    if (setupBAL.DisplayHomePage(ref dt))
            //    {

            //        string s = dt.Rows[0]["Pagehtml"].ToString();
            //        pnl.InnerHtml = HttpUtility.HtmlDecode(s);

            //        //???divOutput.InnerText = s;

            //        DateTime time = DateTime.Now;
            //        string format = "dd (ddd) MM (MMM) yyyy - HH:mm ";
            //        divOutput.InnerHtml = "<b>" + (time.ToString(format, ci)) + "</b><br/><br/>";

            //    }
            //}
        }
 private bool ValidData()
 {
     if (txtRoleShortDesc.Text == "" || txtRoleLongDesc.Text == "")
     {
         LoggedIn master = (LoggedIn)this.Master;
         master.ShowMessage("Every Field must be filled.", false);
         return(true);
     }
     else
     {
         return(false);
     }
 }
 private bool ValidData()
 {
     if (txtUserName.Text == "" || txtFName.Text == "" || txtLName.Text == "" || txtPREmailId.Text == "" || txtSecretAns.Text == "" || txtPass.Text == "")
     {
         LoggedIn master = (LoggedIn)this.Master;
         master.ShowMessage("Fields which are marked as (*) are mandatory.", false);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        protected void lvRoleMember_OnItemCommand(object sender, ListViewCommandEventArgs e)
        {
            RoleMemberBAL roleMemberBAL = new RoleMemberBAL();
            RoleMemberBE  roleMember    = new RoleMemberBE();

            roleMember.LastModifiedBy = ((UserBE)Session["LoggedInUser"]).UserId;
            LoggedIn master = (LoggedIn)this.Master;

            if (String.Equals(e.CommandName, "Add"))
            {
                if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "add"))
                {
                    master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false);
                    return;
                }
                string[] arg = new string[2];
                arg = e.CommandArgument.ToString().Split(',');
                roleMember.UserId = Convert.ToInt32(arg[0]);
                roleMember.RoleId = Convert.ToInt32(arg[1]);
                if (roleMemberBAL.AddRoleMember(roleMember))
                {
                    bindlvRoleMember();
                    recalcNoOfPages();
                    master.ShowMessage("Successfully Added.", true);
                }
                else
                {
                    master.ShowMessage("Unsuccessful.", false);
                }
                lvRoleMember.EditIndex = -1;
            }
            else if (String.Equals(e.CommandName, "Remove"))
            {
                if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "add"))
                {
                    master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false);
                    return;
                }
                string[] arg = new string[2];
                arg = e.CommandArgument.ToString().Split(',');
                roleMember.UserId = Convert.ToInt32(arg[0]);
                roleMember.RoleId = Convert.ToInt32(arg[1]);
                if (roleMemberBAL.DeleteRoleMember(roleMember))
                {
                    bindlvRoleMember();
                    recalcNoOfPages();

                    master.ShowMessage("Successfully Removed.", true);
                }
                else
                {
                    master.ShowMessage("Unsuccessful.", false);
                }
                lvRoleMember.EditIndex = -1;
            }
        }
        //protected void LvRoleItems_Canceling(object sender, ListViewCancelEventArgs e)
        //{

        //    LvRoleItems.EditIndex = -1;
        //    bind();
        //    recalcNoOfPages();
        //}

        protected void LvRoleItems_ItemEditing(object sender, ListViewEditEventArgs e)
        {
            // Check if user has access right to perform the update/modify function
            if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "edit"))
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false);
                e.Cancel = true;
                return;
            }

            //LvRoleItems.EditIndex = e.NewEditIndex;
            //bind();
            //recalcNoOfPages();
        }
        private void bind()
        {
            RoleBAL   roleBAL = new RoleBAL();
            DataTable dt      = new DataTable();

            if (roleBAL.GetAllRoleDetails(ref dt))
            {
                this.LvRoleItems.DataSource = dt;
                LvRoleItems.DataBind();
            }
            else
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Unsuccessful", false);
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "add"))
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false);
                return;
            }
            RoleAccessRightsBAL roleAccessBAL = new RoleAccessRightsBAL();
            RoleAccessRightsBE  roleAccessBE  = new RoleAccessRightsBE();

            // roleAccessBE = loadRoleAccessRightsBE(roleAccessBE);
            roleAccessBE.RoleID         = Convert.ToInt32(ddlRoleId.SelectedValue);
            roleAccessBE.LastModifiedBy = ((UserBE)Session["LoggedInUser"]).UserId;
            loadRoleAccessRightsBE(roleAccessBE);
        }
        private void loadRoleAccessRightsBE(RoleAccessRightsBE roleAccessBE)
        {
            int a     = 0;
            int count = 0;
            RoleAccessRightsBAL RACBAL = new RoleAccessRightsBAL();

            for (int iRow = 0; iRow < lvRoleAccessRight.Items.Count; iRow++)
            {
                for (int iCell = 5; iCell < lvRoleAccessRight.Items[0].Controls.Count - 1; iCell += 2)
                {
                    roleAccessBE.PRAId = Convert.ToInt32(lvRoleAccessRight.DataKeys[iRow].Value.ToString());
                    if (((CheckBox)lvRoleAccessRight.Items[iRow].Controls[iCell]).Checked)
                    {
                        a = 1;
                    }
                    else
                    {
                        a = 0;
                    }
                    AssignValueRoleAccessRightsBE(iCell, ref roleAccessBE, a);
                }

                if (RACBAL.SaveRoleAccessRightDetails(roleAccessBE))
                {
                    count = count + 1;
                    if (count == lvRoleAccessRight.Items.Count)
                    {
                        LoggedIn master = (LoggedIn)this.Master;
                        master.ShowMessage("Role Successfully Updated.", true);
                    }
                }
                else
                {
                    count = count + 1;
                    if (count == lvRoleAccessRight.Items.Count)
                    {
                        LoggedIn master = (LoggedIn)this.Master;
                        master.ShowMessage("Unsuccessful", false);
                    }
                }
            }
        }
        private void bindlvRoleMember()
        {
            RoleMemberBE  roleMember    = new RoleMemberBE();
            RoleMemberBAL roleMemberBAL = new RoleMemberBAL();
            DataTable     dt            = new DataTable();

            roleMember.RoleId = Convert.ToInt32(hdnRoleId.Value.ToString());
            if (roleMemberBAL.GetAllRoleMembers(ref dt, ref roleMember))
            {
                this.lvRoleMember.DataSource = dt;
                lvRoleMember.Visible         = true;
                RoleMemberDataPager.Visible  = true;
                lvRoleMember.DataBind();
                recalcNoOfPages();
            }
            else
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Unsuccessful", false);
            }
        }
        protected void btnAddRole_Click(object sender, EventArgs e)
        {
            if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "add"))
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("You are not authorised to Perform any operation on this page. Please contact system administrator.", false);
                //   Server.Transfer("UM_BlankPage.aspx"); //?? send Message through Query String to the BlankPage
                //  string cat = Request.QueryString["Message"];
                //  Response.Redirect("UM_BlankPage.aspx?Message=You are not authorised to Perform any operation on this page. Please contact system administrator.");
                return;
            }
            if (ValidData())
            {
            }
            else
            {
                UserBE  user       = (UserBE)Session["LoggedInUser"];
                RoleBE  addRoleBE  = new RoleBE();
                RoleDAL addRoleDal = new RoleDAL();
                RoleBAL addRoleBal = new RoleBAL();

                addRoleBE.RoleShortDesc  = txtRoleShortDesc.Text;
                addRoleBE.RoleLongDesc   = txtRoleLongDesc.Text;
                addRoleBE.LastModifiedBy = user.UserId;

                if (addRoleBal.AddRole(addRoleBE))
                {
                    txtRoleShortDesc.Text = "";
                    txtRoleLongDesc.Text  = "";
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("Record Inserted Successfully.", true);
                }
                else
                {
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("Unsuccessful.", false);
                }
            }
        }
        private void bindListView()
        {
            RoleMemberBE        roleMember    = new RoleMemberBE();
            RoleAccessRightsBAL roleAccessBAL = new RoleAccessRightsBAL();
            DataTable           dt            = new DataTable();

            roleMember.RoleId = Convert.ToInt32(hdnRoleId.Value.ToString());
            if (roleAccessBAL.GetAllRoleAccessRightDetails(ref dt, ref roleMember))
            {
                this.lvRoleAccessRight.DataSource = dt;
                lvRoleAccessRight.Visible         = true;
                RoleAccessRightDataPager.Visible  = true;
                btnSave.Visible     = true;
                ddlPageSize.Visible = true;
                lblSelect.Visible   = true;
                lvRoleAccessRight.DataBind();
                recalcNoOfPages();
            }
            else
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("Unsuccessful", false);
            }
        }
        protected void LvRoleItems_ItemDeleting(object sender, ListViewDeleteEventArgs e)
        {
            if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "delete"))
            {
                LoggedIn master = (LoggedIn)this.Master;
                master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false);
                e.Cancel = true;
                return;
            }

            //string confirmValue = Request.Form["confirm_value"];
            //if (confirmValue == "Yes")
            //{
            //    RoleBE role = new RoleBE();
            //    RoleBAL roleBAL = new RoleBAL();
            //    string RoleId = LvRoleItems.DataKeys[e.ItemIndex].Value.ToString();
            //    role.RoleId = Convert.ToInt32(RoleId);
            //    if (roleBAL.DeleteRole(role))
            //    {
            //        LvRoleItems.EditIndex = -1;
            //        bind();
            //        LoggedIn master = (LoggedIn)this.Master;
            //        master.ShowMessage("Record Successfully deleted.", true);
            //    }
            //    else
            //    {
            //        LoggedIn master = (LoggedIn)this.Master;
            //        master.ShowMessage("Unsuccessful", false);
            //    }
            //}
            //else
            //{

            //}
            //recalcNoOfPages();
        }
        protected void LvRoleItems_OnItemCommand(object sender, ListViewCommandEventArgs e)
        {
            UM_UC_RoleAdd roleAdd = new UM_UC_RoleAdd();
            HtmlTableRow  SelectedRow;

            if (e.Item.DisplayIndex % 2 == 0) //even
            {
                SelectedRow = e.Item.FindControl("trItemTemplate") as HtmlTableRow;
            }
            else //odd
            {
                SelectedRow = e.Item.FindControl("trAltItemTemplate") as HtmlTableRow;
            }

            SelectedRow.BgColor = "Red";


            if (String.Equals(e.CommandName, "Delete"))
            {
                if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "delete"))
                {
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false);

                    return;
                }
                RoleBE   role = new RoleBE();
                string[] arg  = new string[3];
                arg                    = e.CommandArgument.ToString().Split(',');
                hdnRoleId.Value        = arg[0].ToString();
                role.RoleShortDesc     = arg[1].ToString();
                role.RoleLongDesc      = arg[2].ToString();
                RoleShortDescText.Text = role.RoleShortDesc;
                RoleLongDescText.Text  = role.RoleLongDesc;

                mpe_DeleteRole.Show();
            }

            if (String.Equals(e.CommandName, "Edit"))
            {
                if (!commonBAL.isUserAuthorisedForPageFunc(LoggedInUser.UserId, thisPageName, "edit"))
                {
                    LoggedIn master = (LoggedIn)this.Master;
                    master.ShowMessage("You are not authorised to perform this function. Please contact system administrator.", false);
                    return;
                }
                RoleBE   role = new RoleBE();
                string[] arg  = new string[5];
                arg = e.CommandArgument.ToString().Split(',');
                hdnRoleUpdateId.Value = arg[0].ToString();
                role.RoleShortDesc    = arg[1].ToString();
                role.RoleLongDesc     = arg[2].ToString();
                string lastModifiedBy = arg[3].ToString();
                string lastModifiedAt = arg[4].ToString();

                UCRoleAddList.RoleId         = Convert.ToInt32(hdnRoleUpdateId.Value);
                UCRoleAddList.ShortDesc      = role.RoleShortDesc;
                UCRoleAddList.LongDesc       = role.RoleLongDesc;
                UCRoleAddList.LastModifiedBy = lastModifiedBy;
                UCRoleAddList.LastModifiedAt = lastModifiedAt;

                mpe_EditRole.Show();
            }
        }