示例#1
0
        protected void LeaveSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Business obj = new Business();
                string timezone = "";

                if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                {
                    timezone = "Eastern Standard Time";
                }
                else
                {
                    timezone = "India Standard Time";

                }
                DateTime CurrentDt = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));
                int UserID = Convert.ToInt32(hdnLeaveUserID.Value);
                DateTime FromDt = Convert.ToDateTime(txtFromDt.Text);
                DateTime ToDt = Convert.ToDateTime(txtToDt.Text);
                string Passcode = txtLeavePassCode.Text.ToString();
                string Reason = txtReason.Text == "" ? "" : GeneralFunction.ToProperNotes(txtReason.Text);
                string EmpID = txtLeaveEmpID.Text;
                DataSet ds = obj.SaveLeaveRequestDetails(UserID, EmpID, FromDt, ToDt, CurrentDt, Reason, Passcode);

                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["LeaveID"].ToString() == "Applied")
                        {
                            lblLeaveError.Text = "You have already applied leave for these days";
                            lblLeaveError.Visible = true;
                            txtReason.Text = "";
                            txtFromDt.Text = "";
                            txtToDt.Text = "";
                        }
                        else
                        {
                            System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "showLeaveSuccess();", true);
                        }
                    }
                    else
                    {
                        lblLeaveError.Text = "Invalid employee id and passcode";
                        lblLeaveError.Visible = true;
                    }
                }
                else
                {
                    lblLeaveError.Text = "Invalid employee id and passcode";
                    lblLeaveError.Visible = true;
                }
            }
            catch (Exception ex)
            {
            }
        }
        protected void btnLeaveReqSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Business obj = new Business();
                int userid = Convert.ToInt32(Session["UserID"]);
                DateTime FromDate = Convert.ToDateTime(txtLeaveFrom.Text);
                DateTime ToDate = Convert.ToDateTime(txtLeaveTo.Text);
                string Reason = txtReason.Text == "" ? "" : GeneralFunction.ToProperNotes(txtReason.Text);

                string timezone = "";
                if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                {
                    timezone = "Eastern Standard Time";
                }
                else
                {
                    timezone = "India Standard Time";

                }
                DateTime ISTTime = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));
                DataSet ds = obj.SaveLeaveRequestDetails(userid, "", FromDate, ToDate, ISTTime, Reason, "");
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["LeaveID"].ToString() == "Applied")
                        {
                            lblLeaveError.Text = "You have already applied leave for these days";
                            lblLeaveError.Visible = true;
                            txtReason.Text = "";
                            txtLeaveFrom.Text = "";
                            txtLeaveTo.Text = "";
                        }
                        else
                        {
                            System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "alert('Leave request updated successfully');", true);
                            mdlNewLeaveRequest.Hide();

                            DateTime startDate = Convert.ToDateTime(Session["TodayDate"]);
                            DateTime endDate = startDate.AddDays(7);

                            EmployeeBL objLeave = new EmployeeBL();
                            DataTable datas = objLeave.GetLeaveRequestDetByUserID(Convert.ToInt32(Session["UserID"]), startDate, endDate);
                            grdSingleLeaveReq.DataSource = datas;
                            grdSingleLeaveReq.DataBind();
                            objLeave = null;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
            }
        }