コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (SessionWrapper.UserName == string.Empty || SessionWrapper.UserType != "A")
            {
                //Response.Redirect("Default.aspx");
            }
            else
            {
                lblUserName.Text = "Welcome : " + SessionWrapper.UserName;
            }
            EntityLogin entLogin = (EntityLogin)Session["user"];

            if (entLogin != null)
            {
                EntityEmployee entEmp = new EntityEmployee();
                entEmp.EmpFirstName   = new EmployeeBLL().GetEmpName(entLogin.UserName);
                lblUserName.Text      = "Welcome : " + entLogin.UserType;
                Session["UserType12"] = entLogin.UserType;
                Session["AdminName"]  = entEmp.EmpFirstName;
                if (!entLogin.UserType.Equals("admin", StringComparison.CurrentCultureIgnoreCase))
                {
                    AddForms(entEmp.EmpFirstName);
                    //Userauthenticate(entLogin);
                }
                else
                {
                    List <EntityFormMaster> entLstForms = new UserAuthenticationBLL().GetAllForms();
                    Session["AccessibleForm"] = entLstForms;
                }
            }
        }
コード例 #2
0
        private void AddForms(string UserName)
        {
            List <EntityFormMaster> entLstForms = new UserAuthenticationBLL().ListofForms(UserName);

            Session["AccessibleForm"] = entLstForms;
            EntityFormMaster EntForms             = new EntityFormMaster();
            Dictionary <string, MenuItem> DicMenu = new Dictionary <string, MenuItem>();

            foreach (MenuItem item in Menu1.Items)
            {
                int Count = 0;
                if (item.Value == "Main")
                {
                    item.Enabled = true;

                    foreach (MenuItem childItem in item.ChildItems)
                    {
                        if (entLstForms != null)
                        {
                            foreach (EntityFormMaster Lst in entLstForms)
                            {
                                if (childItem.NavigateUrl.Contains(Lst.FormName))
                                {
                                    DicMenu.Add(item.Text + Count.ToString(), childItem);
                                    Count++;
                                }
                            }
                        }
                    }
                }
            }
            foreach (MenuItem item in Menu1.Items)
            {
                if (item.Value == "Main")
                {
                    for (int i = 0; i < item.ChildItems.Count; i++)
                    {
                        item.ChildItems.Clear();
                    }
                }
            }

            foreach (MenuItem item in Menu1.Items)
            {
                if (item.Value == "Main")
                {
                    foreach (KeyValuePair <string, MenuItem> item1 in DicMenu)
                    {
                        if (item1.Key.Contains(item.Text))
                        {
                            item.ChildItems.Add(item1.Value);
                        }
                    }
                }
            }
        }
コード例 #3
0
 protected void ddlEmployee_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (ddlEmployee.SelectedIndex > 0)
         {
             dgvAllocEmp.DataSource = null;
             List <EntityFormMaster> lstForms = new UserAuthenticationBLL().GetAllocatedForms(Convert.ToInt32(ddlEmployee.SelectedValue));
             if (lstForms != null)
             {
                 dgvAllocEmp.AutoGenerateColumns = false;
                 dgvAllocEmp.DataSource          = lstForms;
                 dgvAllocEmp.DataBind();
                 int lintRowcount1 = lstForms.Count;
                 lblRowCount1.Text = "<b>Total Records:</b> " + lintRowcount1.ToString();
                 pnlShow.Style.Add(HtmlTextWriterStyle.Display, "");
                 hdnPanel.Value = "";
             }
             else
             {
                 dgvAllocEmp.AutoGenerateColumns = false;
                 dgvAllocEmp.DataSource          = new List <EntityFormMaster>();
                 dgvAllocEmp.DataBind();
                 int lintRowcount1 = lstForms.Count;
                 lblRowCount1.Text = "<b>Total Records:</b> " + lintRowcount1.ToString();
                 pnlShow.Style.Add(HtmlTextWriterStyle.Display, "");
                 hdnPanel.Value = "";
             }
         }
         else
         {
             if (ddlEmployee.SelectedIndex == 0)
             {
                 ddlEmployee.Focus();
                 dgvAllocEmp.DataSource = new List <EntityFormMaster>();
                 dgvAllocEmp.DataBind();
             }
         }
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }
コード例 #4
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ddlDesignation.SelectedIndex == 0)
                {
                    lblMessage.Text = "Please Select Designation";
                    ddlDesignation.Focus();
                    return;
                }
                else
                {
                    if (ddlEmployee.SelectedIndex == 0)
                    {
                        lblMessage.Text = "Please select Shift.";
                        ddlEmployee.Focus();
                        return;
                    }
                    else
                    {
                        List <tblUserAuthorization> lstUser = new List <tblUserAuthorization>();
                        List <tblShiftAllocEmp>     lst     = new List <tblShiftAllocEmp>();//
                        foreach (GridViewRow item in dgvAllocEmp.Rows)
                        {
                            int FormAllocId = Convert.ToInt32(item.Cells[0].Text);
                            if (FormAllocId > 0)
                            {
                                bool lstAlloc = new UserAuthenticationBLL().GetAllocFormOnEmp(Convert.ToInt32(ddlEmployee.SelectedValue), Convert.ToInt32(item.Cells[0].Text));
                                bool lst1     = new EmployeeBLL().GetAEmpIdOnShiftId(Convert.ToInt32(ddlEmployee.SelectedValue), Convert.ToInt32(item.Cells[0].Text));//
                                if (!lstAlloc)
                                {
                                    lstUser.Add(new tblUserAuthorization {
                                        EmpId = Convert.ToInt32(ddlEmployee.SelectedValue), FormId = Convert.ToInt32(item.Cells[0].Text), IsDelete = false
                                    });
                                }
                                else
                                {
                                }
                            }
                        }
                        if (lstUser.Count > 0)
                        {
                            bool b = new UserAuthenticationBLL().Save(lstUser);
                            dgvAllocEmp.DataSource = new List <tblUserAuthorization>();
                            dgvAllocEmp.DataBind();

                            ddlEmployee.SelectedIndex    = 0;
                            ddlDesignation.SelectedIndex = 0;

                            lblMessage.Text   = "Record Saved SuccessFully";
                            lblRowCount1.Text = string.Empty;
                        }
                        else
                        {
                            lblMessage.Text = "Record Not Saved";
                        }
                    }
                }
                GetForms();
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
コード例 #5
0
 protected void BtnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         bool        flag = false;
         bool        b;
         EmployeeBLL obj1 = new EmployeeBLL();
         if (ddlDesignation.SelectedIndex == 0)
         {
             lblMessage.Text = "Please Select Designation";
             ddlDesignation.Focus();
             return;
         }
         else
         {
             if (ddlEmployee.SelectedIndex == 0)
             {
                 lblMessage.Text = "Please Select Employee";
                 ddlEmployee.Focus();
                 return;
             }
             else
             {
                 List <EntityFormMaster> lstForm = new UserAuthenticationBLL().GetAllocatedForms(Convert.ToInt32(ddlEmployee.SelectedValue));
                 int RowCount = 0;
                 int TotalRow = dgvAllForms.Rows.Count;
                 int Freq     = 0;
                 foreach (GridViewRow item in dgvAllForms.Rows)
                 {
                     Freq++;
                     CheckBox CheckBox = item.FindControl("chkSelect") as CheckBox;
                     if (CheckBox.Checked)
                     {
                         RowCount++;
                         lstForm.Add(new EntityFormMaster {
                             FormId = Convert.ToInt32(item.Cells[1].Text), FormTitle = Convert.ToString(item.Cells[2].Text)
                         });
                         lblMessage.Text   = string.Empty;
                         lblRowCount1.Text = "<b>Total Records:</b> " + RowCount.ToString();
                     }
                     if (Freq == TotalRow && RowCount == 0)
                     {
                         lblMessage.Text = "Please Select Form";
                     }
                 }
                 if (flag)
                 {
                     lblMessage.Text = "Invalid Form Allocation..";
                     foreach (GridView item in dgvAllForms.Rows)
                     {
                         item.Columns[0].Visible = true;//
                     }
                 }
                 else
                 {
                     dgvAllocEmp.AutoGenerateColumns = false;
                     dgvAllocEmp.DataSource          = lstForm;
                     dgvAllocEmp.DataBind();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }