コード例 #1
0
        protected void ddlRole_SelectedIndexChanged(object sender, EventArgs e)
        {
            TextBox txtbxDispName = (TextBox)ADU.FindControl("txtbxDispName");

            txtbxDispName.Text = "";
            BindListbox();
        }
コード例 #2
0
        protected void btnReset_Click(object sender, EventArgs e)
        {
            lblError.Text   = "";
            lblSuccess.Text = "";
            TextBox txtbxDispName = (TextBox)ADU.FindControl("txtbxDispName");

            txtbxDispName.Text    = "";
            ddlRole.SelectedIndex = 0;
        }
コード例 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            lblError.Text   = "";
            lblSuccess.Text = "";
            try
            {
                TextBox     txtbxDispName = (TextBox)ADU.FindControl("txtbxDispName");
                HiddenField hdnfldADID    = (HiddenField)ADU.FindControl("hdnfldADID");
                if (txtbxDispName.Text != "")
                {
                    if (ddlRole.SelectedIndex != 0)
                    {
                        if (hdnfldADID.Value != "")
                        {
                            clsBALCommon objclsBALCommon = new clsBALCommon();
                            clsEALUser   objclsEALUser   = new clsEALUser();
                            objclsEALUser = objclsBALCommon.FetchUserDetailsFromAD(hdnfldADID.Value);
                            if (objclsEALUser != null)
                            {
                                bool flag = CheckUserRoles(objclsEALUser);

                                if (!flag)
                                {
                                    string userRole = ddlRole.SelectedItem.Value;
                                    //bool blnRoleExists = CheckRole(userRole);
                                    //if (!blnRoleExists)
                                    //{
                                    objclsBALUsers = new clsBALUsers();

                                    bool blnSave = objclsBALUsers.SaveUserRole(objclsEALUser, userRole, objclsEALLoggedInUser.StrUserADID);
                                    lblSuccess.Text       = "User has been assigned with the role successfully.";
                                    hdnfldADID.Value      = "";
                                    txtbxDispName.Text    = "";
                                    ddlRole.SelectedIndex = 0;
                                    PopulateGrid();
                                    //}
                                    //else
                                    //{
                                    //    lblError.Text = "RoleGroup has already been assigned to other user.";
                                    //}
                                }
                            }
                        }
                    }
                    else
                    {
                        lblError.Text = "Select role to assign.";
                    }
                }
                else
                {
                    lblError.Text = "Please select a user.";
                }
                txtbxDispName.Text    = "";
                hdnfldADID.Value      = "";
                ddlRole.SelectedIndex = 0;
            }
            catch (NullReferenceException)
            {
                Response.Redirect("wfrmErrorPage.aspx", true);
            }
            catch (Exception ex)
            {
                HttpContext  context            = HttpContext.Current;
                LogException objclsLogException = new LogException();
                objclsLogException.LogErrorInDataBase(ex, context);
                Response.Redirect("wfrmErrorPage.aspx", true);
            }
        }
コード例 #4
0
        protected void btnScheduleMail_Click(object sender, EventArgs e)
        {
            try
            {
                if (Convert.ToDateTime(txtDate.Text.ToString()) <= DateTime.Today)
                {
                    DateTime Date = System.DateTime.Now.Date;
                    if (Convert.ToDateTime(txtDate.Text.ToString()).Date == Date)
                    {
                        int intTime = System.DateTime.Now.TimeOfDay.Hours;
                        if (intTime >= 9)
                        {
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "aa", "javascript:alert('Mail cannot be scheduled today after 9 AM.');", true);
                        }
                        else
                        {
                            clsBALUsers objBI_User = new clsBALUsers();
                            DataTable   dt         = (DataTable)Session["dtrolewiseuser"];
                            if (dt.Rows.Count > 0)
                            {
                                string groupID = Guid.NewGuid().ToString();
                                foreach (DataRow da in dt.Rows)
                                {
                                    string       username        = da["UserName"].ToString();
                                    string       UserADID        = da["UserADID"].ToString();
                                    string       UserEmail       = da["UserEmail"].ToString();
                                    clsBALCommon objclsBALCommon = new clsBALCommon();
                                    objBI_User.InsertDeleteScheduleMail(Int32.Parse(ddlRole.SelectedItem.Value.ToString()), groupID, username, UserADID, UserEmail, "Insert", DateTime.Parse(txtDate.Text.ToString()), txtSubject.Text.ToString(), Editor1.Content.ToString());
                                }
                                BindScheduleGrid();

                                BindListbox();
                                TextBox txtbxDispName = (TextBox)ADU.FindControl("txtbxDispName");
                                txtbxDispName.Text = "";
                                txtSubject.Text    = "";
                                txtDate.Text       = "";
                                Editor1.Content    = "";
                                panelMail.Visible  = false;
                                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "aa", "javascript:alert('New mail schedule saved.');", true);
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "aa", "javascript:alert('There is no user to schedule mail.');", true);
                            }
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "aa", "javascript:alert('Past date not allowed.');", true);
                    }
                }
                else
                {
                    clsBALUsers objBI_User = new clsBALUsers();
                    DataTable   dt         = (DataTable)Session["dtrolewiseuser"];
                    if (dt.Rows.Count > 0)
                    {
                        string groupID = Guid.NewGuid().ToString();
                        foreach (DataRow da in dt.Rows)
                        {
                            string       username        = da["UserName"].ToString();
                            string       UserADID        = da["UserADID"].ToString();
                            string       UserEmail       = da["UserEmail"].ToString();
                            clsBALCommon objclsBALCommon = new clsBALCommon();
                            objBI_User.InsertDeleteScheduleMail(Int32.Parse(ddlRole.SelectedItem.Value.ToString()), groupID, username, UserADID, UserEmail, "Insert", DateTime.Parse(txtDate.Text.ToString()), txtSubject.Text.ToString(), Editor1.Content.ToString());
                        }
                        BindScheduleGrid();

                        BindListbox();
                        TextBox txtbxDispName = (TextBox)ADU.FindControl("txtbxDispName");
                        txtbxDispName.Text = "";
                        txtSubject.Text    = "";
                        txtDate.Text       = "";
                        Editor1.Content    = "";
                        panelMail.Visible  = false;
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "aa", "javascript:alert('New mail schedule saved.');", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "aa", "javascript:alert('There is no user to schedule mail.');", true);
                    }
                }
            }
            catch (NullReferenceException)
            {
                Response.Redirect("wfrmErrorPage.aspx", true);
            }
            catch (Exception ex)
            {
                HttpContext  Context         = HttpContext.Current;
                LogException objLogException = new LogException();
                objLogException.LogErrorInDataBase(ex, Context);

                Response.Redirect("wfrmErrorPage.aspx", true);
            }
        }
コード例 #5
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                clsBALUsers objBI_User = new clsBALUsers();

                TextBox txtbxDispName = (TextBox)ADU.FindControl("txtbxDispName");
                //HiddenField hdn = (HiddenField)adu.FindControl("hdnfldADID");

                string[] strApprovers = null;


                if (txtbxDispName.Text.ToString() != "")
                {
                    DataTable dtrolewiseusertemp = (DataTable)Session["dtrolewiseuser"];
                    strApprovers = (txtbxDispName.Text.ToString().ToLower()).Split(";".ToCharArray());


                    for (int i = 0; i < strApprovers.Length; i++)
                    {
                        string strApp = strApprovers[i];
                        if (strApp != "")
                        {
                            clsEALUser   objclsEALApp    = new clsEALUser();
                            clsBALCommon objclsBALCommon = new clsBALCommon();
                            objclsEALApp = objclsBALCommon.FetchUserDetailsFromAD(strApp);
                            if (lstBoxApproverDelete.Items.Count > 0)
                            {
                                foreach (ListItem thisItem in lstBoxApproverDelete.Items)
                                {
                                    string strtemp = thisItem.Text.Trim();


                                    if (thisItem.Text.Trim() == objclsEALApp.StrUserName)
                                    {
                                        lblError.Text = "User " + objclsEALApp.StrUserName + " already exists";
                                        // strtest = strtest + strtemp;
                                        goto Outer;
                                    }
                                }
                            }
                            string mailid = objclsEALApp.StrUserEmailID;
                            string adID   = objclsEALApp.StrUserADID;


                            DataRow dr;
                            dr                  = dtrolewiseusertemp.NewRow();
                            dr["UserName"]      = objclsEALApp.StrUserName;
                            dr["RoleMappingId"] = objclsEALApp.StrUserSID;
                            dr["UserADID"]      = objclsEALApp.StrUserADID;
                            dr["UserEmail"]     = objclsEALApp.StrUserEmailID;
                            dtrolewiseusertemp.Rows.Add(dr);
                            // objBI_User.InsertDelete_RoleWiseUser(Int32.Parse(ddlRole.SelectedItem.Value.ToString()), objclsEALApp.StrUserName, objclsEALApp.StrUserADID, objclsEALApp.StrUserEmailID, "Insert");


                            lblSuccess.Text = "User added successfully";


Outer:
                            continue;
                        }
                    }
                    txtbxDispName.Text = "";
                    //BindListbox();
                    Session["dtrolewiseuser"]       = dtrolewiseusertemp;
                    lstBoxApproverDelete.DataSource = (DataTable)Session["dtrolewiseuser"];
                    lstBoxApproverDelete.DataBind();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "aa", "javascript:alert('Please select user to Add');", true);
                }
            }
            catch (NullReferenceException)
            {
                Response.Redirect("wfrmErrorPage.aspx", true);
            }
            catch (Exception ex)
            {
                HttpContext  Context         = HttpContext.Current;
                LogException objLogException = new LogException();
                objLogException.LogErrorInDataBase(ex, Context);

                Response.Redirect("wfrmErrorPage.aspx", true);
            }
        }