コード例 #1
0
        protected void gvSchedule_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                clsBALUsers             objBI_User = new clsBALUsers();
                PPLPicker.ADUserControl adu        = (PPLPicker.ADUserControl)gvSchedule.Rows[e.RowIndex].FindControl("ADUSerControl1");
                TextBox txtbxDispName  = (TextBox)adu.FindControl("txtbxDispName");
                TextBox txtDateGrid    = (TextBox)gvSchedule.Rows[e.RowIndex].FindControl("txtDateGrid");
                TextBox txtSubjectGrid = (TextBox)gvSchedule.Rows[e.RowIndex].FindControl("txtSubjectGrid");
                Label   lblBody        = (Label)gvSchedule.Rows[e.RowIndex].FindControl("lblBody");
                Label   lblRoleID      = (Label)gvSchedule.Rows[e.RowIndex].FindControl("lblRoleID");
                Label   lblGroupID     = (Label)gvSchedule.Rows[e.RowIndex].FindControl("lblGroupID");
                Label   lblUsers1      = (Label)gvSchedule.Rows[e.RowIndex].FindControl("lblUsers1");
                string  groupID        = lblGroupID.Text.ToString();

                string[] strApprovers = null;

                if (Convert.ToDateTime(txtDateGrid.Text.ToString()) <= DateTime.Today)
                {
                    //ScriptManager.RegisterStartupScript(Page, Page.GetType(), "aa", "javascript:alert('Please select date greater than today.');", true);
                    DateTime Date = System.DateTime.Now.Date;
                    if (Convert.ToDateTime(txtDateGrid.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
                        {
                            objBI_User.UpdateScheduleMail(groupID, DateTime.Parse(txtDateGrid.Text.ToString()).Date, txtSubjectGrid.Text.ToString(), lblBody.Text.ToString(), "UpdateSchedule_Mail");

                            if (txtbxDispName.Text.ToString() != "")
                            {
                                strApprovers = (txtbxDispName.Text.ToString().ToLower()).Split(";".ToCharArray());


                                for (int i = 0; i < strApprovers.Length; i++)
                                {
                                    string strApp = strApprovers[i];
                                    if (strApp != "")
                                    {
                                        //if (!strFetchedApprovers.Contains<string>(strApp))
                                        //{
                                        clsEALUser   objclsEALApp    = new clsEALUser();
                                        clsBALCommon objclsBALCommon = new clsBALCommon();
                                        objclsEALApp = objclsBALCommon.FetchUserDetailsFromAD(strApp);
                                        string mailid = objclsEALApp.StrUserEmailID;
                                        string adID   = objclsEALApp.StrUserADID;


                                        string selectedUser = lblUsers1.Text;
                                        //string[] selectedUserarr = selectedUser.Split(";".ToCharArray());
                                        if (!selectedUser.Contains(objclsEALApp.StrUserName))
                                        {
                                            objBI_User.InsertDeleteScheduleMail(Int32.Parse(lblRoleID.Text.ToString()), groupID, objclsEALApp.StrUserName, objclsEALApp.StrUserADID, objclsEALApp.StrUserEmailID, "Insert", DateTime.Parse(txtDateGrid.Text.ToString()).Date, txtSubjectGrid.Text.ToString(), lblBody.Text.ToString());
                                        }


                                        //}
                                    }
                                }
                            }
                            gvSchedule.EditIndex = -1;
                            BindScheduleGrid();
                        }
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "aa", "javascript:alert('Past date not allowed.');", true);
                    }
                }
                else
                {
                    objBI_User.UpdateScheduleMail(groupID, DateTime.Parse(txtDateGrid.Text.ToString()).Date, txtSubjectGrid.Text.ToString(), lblBody.Text.ToString(), "UpdateSchedule_Mail");

                    if (txtbxDispName.Text.ToString() != "")
                    {
                        strApprovers = (txtbxDispName.Text.ToString().ToLower()).Split(";".ToCharArray());


                        for (int i = 0; i < strApprovers.Length; i++)
                        {
                            string strApp = strApprovers[i];
                            if (strApp != "")
                            {
                                //if (!strFetchedApprovers.Contains<string>(strApp))
                                //{
                                clsEALUser   objclsEALApp    = new clsEALUser();
                                clsBALCommon objclsBALCommon = new clsBALCommon();
                                objclsEALApp = objclsBALCommon.FetchUserDetailsFromAD(strApp);
                                string mailid = objclsEALApp.StrUserEmailID;
                                string adID   = objclsEALApp.StrUserADID;


                                string selectedUser = lblUsers1.Text;
                                //string[] selectedUserarr = selectedUser.Split(";".ToCharArray());
                                if (!selectedUser.Contains(objclsEALApp.StrUserName))
                                {
                                    objBI_User.InsertDeleteScheduleMail(Int32.Parse(lblRoleID.Text.ToString()), groupID, objclsEALApp.StrUserName, objclsEALApp.StrUserADID, objclsEALApp.StrUserEmailID, "Insert", DateTime.Parse(txtDateGrid.Text.ToString()).Date, txtSubjectGrid.Text.ToString(), lblBody.Text.ToString());
                                }


                                //}
                            }
                        }
                    }
                    gvSchedule.EditIndex = -1;
                    BindScheduleGrid();
                }
            }
            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);
            }
        }
コード例 #2
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);
            }
        }