Esempio n. 1
0
        protected void btnRegret_Click(object sender, EventArgs e)
        {
            personTable = ViewState["dt"] as DataTable;
            DataTable dtLeaveApp = new DataTable();

            dtLeaveApp = objLeaveMgr.SelectRequestLeaveAppMst(Convert.ToInt32(personTable.Rows[0]["LvAppID"].ToString().Trim()), personTable.Rows[0]["EmpId"].ToString().Trim(), "", Common.ReturnDateTimeInString(Common.DisplayDateTime(personTable.Rows[0]["LeaveStart"].ToString().Trim(), false, Constant.strDateFormat), false, Constant.strDateFormat), Common.ReturnDateTimeInString(Common.DisplayDateTime(personTable.Rows[0]["LeaveEnd"].ToString().Trim(), false, Constant.strDateFormat), false, Constant.strDateFormat), "");
            if (dtLeaveApp.Rows.Count > 0)
            {
                this.AvailableLeave("A", dtLeaveApp.Rows[0]["EmpId"].ToString().Trim(), dtLeaveApp.Rows[0]["LTypeId"].ToString().Trim(), dtLeaveApp.Rows[0]["LDurInDays"].ToString().Trim());
                this.GetLeaveDates(dtLeaveApp.Rows[0]["LvAppID"].ToString().Trim(), "A", dtLeaveApp.Rows[0]["LeaveStart"].ToString().Trim(), dtLeaveApp.Rows[0]["LeaveEnd"].ToString().Trim());

                objLeaveMgr.UpdateLeaveAppMstForDeny(dtLeaveApp.Rows[0]["LvAppID"].ToString().Trim(),
                                                     dtLeaveApp.Rows[0]["EmpId"].ToString().Trim(), "Y", "N", "D",
                                                     Session["USERID"].ToString(), Common.ReturnDateTimeInString(Common.DisplayDateTime(DateTime.Now.ToString(), false, Constant.strDateFormat), false, Constant.strDateFormat));

                ScriptManager.RegisterClientScriptBlock(Page, typeof(string), Guid.NewGuid().ToString(), "ReLoadPreviousPage();", true);
                SiteMaster.ShowClientMessage(Page, "Leave has been Regreted Successfully.", "success");
                ScriptManager.RegisterClientScriptBlock(Page, typeof(string), Guid.NewGuid().ToString(), "CloseWindow(3200);", true);
            }
            else
            {
                SiteMaster.ShowClientMessage(Page, "No Leave Information to Regret.", "warn");
            }
        }
        protected void grLeaveApp_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            MailManagerSmtpClient objMail = new MailManagerSmtpClient();
            string   mailMessage          = "";
            GridView _gridView            = (GridView)sender;
            // Get the selected index and the command name
            int    _selectedIndex = int.Parse(e.CommandArgument.ToString());
            string _commandName   = e.CommandName;

            _gridView.SelectedIndex = _selectedIndex;
            string strPreYrLv = "";

            char[]   splitter   = { ',' };
            string[] arinfo2    = new string[10];
            string   leaveStart = "";
            string   leaveEnd   = "";

            switch (_commandName)
            {
            case ("ViewClick"):
                StringBuilder sb     = new StringBuilder();
                string        strURL = "LeaveApplicationView.aspx?params=" + grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString() + "," + grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString().Trim() + ", R" + ", L";
                // string strURL = "LeaveApplicationView.aspx";
                sb.Append("<script>");

                sb.Append("window.open('" + strURL + "', '', '');");
                sb.Append("</script>");
                ScriptManager.RegisterStartupScript(this, this.GetType(), "ConfirmSubmit",
                                                    sb.ToString(), false);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "ConfirmSubmit", sb.ToString());
                break;

            case ("ApproveClick"):
                this.AvailableLeave("A", grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString().Trim(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[2].ToString(), _gridView.SelectedIndex);
                this.GetLeaveDates(grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString(), "A", grLeaveList.DataKeys[_gridView.SelectedIndex].Values[4].ToString(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[5].ToString());
                objLeaveMgr.UpdateLeaveAppMstForApprove(grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString(),
                                                        grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString().Trim(), "Y", "N", "A", hfLEnjoyed.Value.ToString(), hfLDates.Value.ToString(),
                                                        grLeaveList.DataKeys[_gridView.SelectedIndex].Values[10].ToString(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[2].ToString(),
                                                        grLeaveList.DataKeys[_gridView.SelectedIndex].Values[9].ToString(),
                                                        Session["USERID"].ToString(), Common.ReturnDateTimeInString(Common.DisplayDateTime(DateTime.Now.ToString(), false, Constant.strDateFormat), false, Constant.strDateFormat), strPreYrLv, grLeaveList.DataKeys[_gridView.SelectedIndex].Values[7].ToString());

                arinfo2 = Common.str_split(hfLDates.Value.ToString(), splitter);
                if (arinfo2.Length > 1)
                {
                    leaveStart = arinfo2[0];
                    leaveEnd   = arinfo2[1];
                }
                else if (arinfo2.Length == 1)
                {
                    leaveStart = arinfo2[0];
                    leaveEnd   = arinfo2[0];
                }
                else
                {
                    leaveStart = "";
                    leaveEnd   = "";
                }

                //Email Notification
                mailMessage = objMail.LeaveMail(grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString(),
                                                Session["EMPID"].ToString(), leaveStart, leaveEnd, "A");
                if (mailMessage == "")
                {
                    mailMessage = "Leave has been approved successfully";
                }
                //lblMsg.Text = "Leave has been approved and mailed successfully";
                SiteMaster.ShowClientMessage(Page, "Leave has been approved successfully", "success");
                break;

            case ("DenyClick"):
                AvailableLeave("A", grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString().Trim(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[2].ToString(), _gridView.SelectedIndex);
                this.GetLeaveDates(grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString(), "A", grLeaveList.DataKeys[_gridView.SelectedIndex].Values[4].ToString(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[5].ToString());
                //CalculateLeaveDates("A");
                //this.GetWeekend(grLeaveApp.SelectedRow.Cells[1].Text.Trim(), grLeaveApp.SelectedRow.Cells[4].Text.Trim(), grLeaveApp.SelectedRow.Cells[5].Text.Trim(),"A");
                objLeaveMgr.UpdateLeaveAppMstForDeny(grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString(),
                                                     grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString().Trim(), "Y", "N", "D",
                                                     Session["USERID"].ToString(), Common.ReturnDateTimeInString(Common.DisplayDateTime(DateTime.Now.ToString(), false, Constant.strDateFormat), false, Constant.strDateFormat));

                arinfo2 = Common.str_split(hfLDates.Value.ToString(), splitter);
                if (arinfo2.Length > 1)
                {
                    leaveStart = arinfo2[0];
                    leaveEnd   = arinfo2[1];
                }
                else if (arinfo2.Length == 1)
                {
                    leaveStart = arinfo2[0];
                    leaveEnd   = arinfo2[0];
                }
                else
                {
                    leaveStart = "";
                    leaveEnd   = "";
                }
                mailMessage = objMail.LeaveMail(grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString(),
                                                Session["EMPID"].ToString(), leaveStart, leaveEnd, "D");
                SiteMaster.ShowClientMessage(Page, "Leave has been Regreted Successfully.", "success");
                break;

            case ("CancelClick"):
                AvailableLeave("A", grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString().Trim(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[2].ToString(), _gridView.SelectedIndex);
                this.GetLeaveDates(grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString(), "A", grLeaveList.DataKeys[_gridView.SelectedIndex].Values[4].ToString(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[5].ToString());
                //CalculateLeaveDates("A");
                //this.GetWeekend(grLeaveApp.SelectedRow.Cells[1].Text.Trim(), grLeaveApp.SelectedRow.Cells[4].Text.Trim(), grLeaveApp.SelectedRow.Cells[5].Text.Trim(),"A");
                objLeaveMgr.CancelLeaveApp(grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString(),
                                           grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString().Trim(), "Y", "N", "C",
                                           Session["USERID"].ToString(), Common.ReturnDateTimeInString(Common.DisplayDateTime(DateTime.Now.ToString(), false, Constant.strDateFormat), false, Constant.strDateFormat));

                arinfo2 = Common.str_split(hfLDates.Value.ToString(), splitter);
                if (arinfo2.Length > 1)
                {
                    leaveStart = arinfo2[0];
                    leaveEnd   = arinfo2[1];
                }
                else if (arinfo2.Length == 1)
                {
                    leaveStart = arinfo2[0];
                    leaveEnd   = arinfo2[0];
                }
                else
                {
                    leaveStart = "";
                    leaveEnd   = "";
                }
                mailMessage = objMail.LeaveMail(grLeaveList.DataKeys[_gridView.SelectedIndex].Values[11].ToString(), grLeaveList.DataKeys[_gridView.SelectedIndex].Values[0].ToString(),
                                                Session["EMPID"].ToString(), leaveStart, leaveEnd, "C");

                SiteMaster.ShowClientMessage(Page, "Leave has been Cancelled Successfully.", "success");
                break;
            }

            this.OpenRecord();
            strPreYrLv = "";
        }