示例#1
0
    protected void btn_Reject_Click(object sender, EventArgs e)
    {
        try
        {
            CheckBox   chkBox          = new CheckBox();
            Label      lblID           = new Label();
            Label      lblempid        = new Label();
            RadTextBox rtxt_rej_reason = new RadTextBox();
            int        i = 0;
            Label1.Text = "";
            bool status  = false;
            bool status1 = false;
            for (i = 0; i < RG_LeaveApproval.Items.Count; i++)
            {
                chkBox          = RG_LeaveApproval.Items[i].FindControl("chk_Choose") as CheckBox;
                lblID           = RG_LeaveApproval.Items[i].FindControl("lblLeavetypeid") as Label;
                lblempid        = RG_LeaveApproval.Items[i].FindControl("lblempID") as Label;
                rtxt_rej_reason = RG_LeaveApproval.Items[i].FindControl("rtxt_rej_reason") as RadTextBox;
                if (chkBox.Checked)
                {
                    if (Label1.Text == "")
                    {
                        Label1.Text = lblID.Text;
                    }
                    else
                    {
                        Label1.Text = Label1.Text + "," + lblID.Text;
                    }
                    if (Convert.ToString(rtxt_rej_reason.Text) == string.Empty)
                    {
                        BLL.ShowMessage(this, "Please Enter Comments For rejection"); return;
                    }
                    _obj_smhr_leaveapp = new SMHR_LEAVEAPP();
                    _obj_smhr_leaveapp.LEAVEAPP_REASON        = lblID.Text;
                    _obj_smhr_leaveapp.LEAVEAPP_STATUS        = 2;
                    _obj_smhr_leaveapp.LEAVEAPP_APPROVEDBY    = Convert.ToInt32(Convert.ToString(Session["EMP_ID"]));
                    _obj_smhr_leaveapp.LEAVEAPP_APPROVEDATE   = Convert.ToDateTime(rdp_ApprovalDate.SelectedDate.Value);
                    _obj_smhr_leaveapp.LASTMDFBY              = 1;
                    _obj_smhr_leaveapp.LASTMDFDATE            = DateTime.Now;
                    _obj_smhr_leaveapp.ORGANISATION_ID        = Convert.ToInt32(Session["ORG_ID"]);
                    _obj_smhr_leaveapp.LEAVEAPP_REJECT_REASON = Convert.ToString(rtxt_rej_reason.Text.Replace("'", "''"));
                    _obj_smhr_leaveapp.OPERATION              = operation.Check;
                    status = BLL.set_LeaveApp(_obj_smhr_leaveapp);
                    if (status == true)
                    {
                        //BLL.ShowMessage(this, "Selected Leaves Rejected");
                        SMHR_LEAVEAPP _obj_Smhr_LeaveApp = new SMHR_LEAVEAPP();
                        _obj_Smhr_LeaveApp.LEAVEAPP_EMP_ID = Convert.ToInt32(lblempid.Text);
                        _obj_Smhr_LeaveApp.MODE            = 4;
                        DataTable dt_mail = BLL.get_EmpLeaveDetails(_obj_Smhr_LeaveApp);
                        if (dt_mail.Rows.Count > 0)
                        {
                            //if (!((dt_mail.Rows[0]["REPORTING_EMP_EMAIL"] != System.DBNull.Value && dt_mail.Rows[0]["REPORTING_EMP_EMAIL"] != string.Empty) || (dt_mail.Rows[0]["EMP_EMAIL"] != System.DBNull.Value && dt_mail.Rows[0]["EMP_EMAIL"] != string.Empty) || (dt_mail.Rows[0]["REPORTING_EMP"] != System.DBNull.Value && dt_mail.Rows[0]["REPORTING_EMP"] != string.Empty)))
                            if (((Convert.ToString(dt_mail.Rows[0]["REPORTING_EMP_EMAIL"]) != string.Empty) && (dt_mail.Rows[0]["REPORTING_EMP_EMAIL"]) != System.DBNull.Value) &&
                                ((Convert.ToString(dt_mail.Rows[0]["EMP_EMAIL"]) != string.Empty) && (dt_mail.Rows[0]["EMP_EMAIL"]) != System.DBNull.Value) &&
                                ((Convert.ToString(dt_mail.Rows[0]["REPORTING_EMP"]) != string.Empty) && ((dt_mail.Rows[0]["REPORTING_EMP"]) != System.DBNull.Value)))
                            {
                                _obj_Smhr_LeaveApp.MODE        = 3;
                                _obj_Smhr_LeaveApp.LEAVEAPP_ID = Convert.ToInt32(lblID.Text);
                                if (BLL.get_Leave_Mail(_obj_Smhr_LeaveApp))
                                {
                                    status1 = true;
                                }
                            }
                        }
                    }
                }
                //else
                //{
                //    i = i + 1;
                //}
            }

            if (string.IsNullOrEmpty(Label1.Text))
            {
                BLL.ShowMessage(this, "Please Select Employees");
                return;
            }
            if (status)
            {
                if (status1)
                {
                    BLL.ShowMessage(this, "Selected Leave Rejected and Notification Sent");
                }
                else
                {
                    BLL.ShowMessage(this, "Selected Leave Rejected");
                }
            }
            LoadData();
            RG_LeaveApproval.DataBind();
            return;
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_LeaveApproval", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }
示例#2
0
    protected void btn_Approve_Click(object sender, EventArgs e)
    {
        try
        {
            CheckBox   chkBox          = new CheckBox();
            Label      lblAppID        = new Label();
            Label      lblempid        = new Label();
            Label      lblNoDays       = new Label();
            Label      lblLeaveID      = new Label();
            Label      lblLeaveCode    = new Label();
            Label      lblPrdID        = new Label();
            RadTextBox rtxt_rej_reason = new RadTextBox();
            bool       status          = false;
            bool       status1         = false;
            //string str = "";
            //string str1 = "";
            for (int index = 0; index <= RG_LeaveApproval.Items.Count - 1; index++)
            {
                string str  = "";
                string str1 = "";
                chkBox          = RG_LeaveApproval.Items[index].FindControl("chk_Choose") as CheckBox;
                lblAppID        = RG_LeaveApproval.Items[index].FindControl("lblLeavetypeid") as Label;
                lblempid        = RG_LeaveApproval.Items[index].FindControl("lblempID") as Label;
                lblNoDays       = RG_LeaveApproval.Items[index].FindControl("lblempLeaveDays") as Label;
                lblLeaveID      = RG_LeaveApproval.Items[index].FindControl("lblLeaveID") as Label;
                lblLeaveCode    = RG_LeaveApproval.Items[index].FindControl("lblempLeave") as Label;
                lblPrdID        = RG_LeaveApproval.Items[index].FindControl("lblPrdID") as Label;
                rtxt_rej_reason = RG_LeaveApproval.Items[index].FindControl("rtxt_rej_reason") as RadTextBox;
                if (chkBox.Checked)
                {
                    I_ChkCount = I_ChkCount + 1;
                    if (str == "")
                    {
                        str = "" + lblAppID.Text + "";
                    }
                    else
                    {
                        str = str + "," + lblAppID.Text + "";
                    }
                    if (str1 == "")
                    {
                        str1 = "" + lblempid.Text + "";
                    }

                    _obj_smhr_leaveapp = new SMHR_LEAVEAPP();
                    _obj_smhr_leaveapp.LEAVEAPP_REASON        = str;
                    _obj_smhr_leaveapp.LEAVEAPP_STATUS        = 1;
                    _obj_smhr_leaveapp.LEAVEAPP_EMP_ID        = Convert.ToInt32(str1);
                    _obj_smhr_leaveapp.LEAVEAPP_APPROVEDBY    = Convert.ToInt32(Convert.ToString(Session["EMP_ID"]));
                    _obj_smhr_leaveapp.LEAVEAPP_APPROVEDATE   = Convert.ToDateTime(rdp_ApprovalDate.SelectedDate.Value);
                    _obj_smhr_leaveapp.LASTMDFBY              = 1;
                    _obj_smhr_leaveapp.LASTMDFDATE            = DateTime.Now;
                    _obj_smhr_leaveapp.ORGANISATION_ID        = Convert.ToInt32(Session["ORG_ID"]);
                    _obj_smhr_leaveapp.LEAVEAPP_LEAVETYPE_ID  = Convert.ToInt32(lblLeaveID.Text);
                    _obj_smhr_leaveapp.LEAVEAPP_REJECT_REASON = Convert.ToString(rtxt_rej_reason.Text.Replace("'", "''"));

                    /*if (lblLeaveCode.Text.Trim() != "LOP")
                     * {
                     *  //TO GET LEAVEBALANCES OF EMPLOYEE
                     *  _obj_smhr_leaveapp.OPERATION = operation.Select1;
                     *  DataTable dt_bal = BLL.get_LeaveApp(_obj_smhr_leaveapp);
                     *  if (dt_bal.Rows.Count > 0)
                     *  {
                     *      if (Convert.ToDouble(dt_bal.Rows[0]["LT_CURRENTBALANCE"]) <= 0.00)
                     *      {
                     *          BLL.ShowMessage(this, "Employee Does Not Have Leaves For This LeaveType.");
                     *          return;
                     *      }
                     *      if (Convert.ToDouble(dt_bal.Rows[0]["LT_CURRENTBALANCE"]) < Convert.ToDouble(lblNoDays.Text))
                     *      {
                     *          BLL.ShowMessage(this, "Employee Has Only " + Convert.ToDouble(dt_bal.Rows[0]["LT_CURRENTBALANCE"]) + " Balances.");
                     *          return;
                     *      }
                     *
                     *  }
                     *  else
                     *  {
                     *      BLL.ShowMessage(this, "Employee Does Not Have Balances For Selected Leave Type.");
                     *      return;
                     *  }
                     * }*/
                    _obj_smhr_leaveapp.OPERATION = operation.Check;
                    status = BLL.set_LeaveApp(_obj_smhr_leaveapp);
                    if (lblLeaveCode.Text.Trim() != "LOP")
                    {
                        if (status == true)
                        {
                            SMHR_LEAVEBALANCE _obj_smhr_leavebal = new SMHR_LEAVEBALANCE();

                            _obj_smhr_leavebal.LT_LEAVETYPEID  = Convert.ToInt32(lblLeaveID.Text);
                            _obj_smhr_leavebal.OPERATION       = operation.Update;
                            _obj_smhr_leavebal.EMPNAME         = str1;
                            _obj_smhr_leavebal.MODE            = 9; //5;
                            _obj_smhr_leavebal.NDays           = float.Parse(lblNoDays.Text);
                            _obj_smhr_leavebal.LEAVEAPP_ID     = Convert.ToInt32(lblAppID.Text);
                            _obj_smhr_leavebal.CREATEDDATE     = Convert.ToDateTime(rdp_ApprovalDate.SelectedDate.Value);
                            _obj_smhr_leavebal.ORGANISATION_ID = Convert.ToInt32(Session["ORG_ID"]);
                            if (lblPrdID.Text != string.Empty)
                            {
                                _obj_smhr_leavebal.LT_PRD_ID = Convert.ToInt32(lblPrdID.Text);
                            }
                            _obj_smhr_leavebal.LT_EMPID = Convert.ToInt32(lblempid.Text);
                            bool rs = BLL.set_leavebalances(_obj_smhr_leavebal);
                            //BLL.ShowMessage(this, "Selected Leave approved and Leave Balance Updated");
                            SMHR_LEAVEAPP _obj_Smhr_LeaveApp = new SMHR_LEAVEAPP();
                            _obj_Smhr_LeaveApp.LEAVEAPP_EMP_ID = Convert.ToInt32(str1);
                            _obj_Smhr_LeaveApp.LEAVEAPP_ID     = Convert.ToInt32(lblAppID.Text);
                            _obj_Smhr_LeaveApp.MODE            = 4;
                            DataTable dt_mail = BLL.get_EmpLeaveDetails(_obj_Smhr_LeaveApp);
                            if (dt_mail.Rows.Count > 0)
                            {
                                //if (!((dt_mail.Rows[0]["REPORTING_EMP_EMAIL"] != System.DBNull.Value && dt_mail.Rows[0]["REPORTING_EMP_EMAIL"] != string.Empty) || (dt_mail.Rows[0]["EMP_EMAIL"] != System.DBNull.Value && dt_mail.Rows[0]["EMP_EMAIL"] != string.Empty) || (dt_mail.Rows[0]["REPORTING_EMP"] != System.DBNull.Value && dt_mail.Rows[0]["REPORTING_EMP"] != string.Empty)))
                                if (((Convert.ToString(dt_mail.Rows[0]["REPORTING_EMP_EMAIL"]) != string.Empty) && (dt_mail.Rows[0]["REPORTING_EMP_EMAIL"]) != System.DBNull.Value) &&
                                    ((Convert.ToString(dt_mail.Rows[0]["EMP_EMAIL"]) != string.Empty) && (dt_mail.Rows[0]["EMP_EMAIL"]) != System.DBNull.Value) &&
                                    ((Convert.ToString(dt_mail.Rows[0]["REPORTING_EMP"]) != string.Empty) && ((dt_mail.Rows[0]["REPORTING_EMP"]) != System.DBNull.Value)))
                                {
                                    _obj_Smhr_LeaveApp.MODE = 2;
                                    if (BLL.get_Leave_Mail(_obj_Smhr_LeaveApp))
                                    {
                                        status1 = true;
                                        //BLL.ShowMessage(this, "Notification Sent");
                                    }
                                }
                            }
                            //LoadData();
                            //return;
                        }
                    }
                    else
                    {
                        if (status == true)
                        {
                            //BLL.ShowMessage(this, "Selected Leave Approved.");
                        }
                    }
                }
                //}


                //if (string.IsNullOrEmpty(str))
                //{
                //    BLL.ShowMessage(this, "Please Select Employees");
                //    return;
                //}
            }
            if (I_ChkCount == 0)
            {
                BLL.ShowMessage(this, "Please Select Employees");
                return;
            }
            if (status)
            {
                if (status1)
                {
                    BLL.ShowMessage(this, "Selected Leave Approved And Leave Balance Updated And Notification Sent");
                }
                else
                {
                    BLL.ShowMessage(this, "Selected Leave Approved And Leave Balance Updated");
                }
            }

            LoadData();
            RG_LeaveApproval.DataBind();
            return;
        }
        catch (Exception ex)
        {
            SMHR.BLL.Error_Log(Session["USER_ID"].ToString(), ex.TargetSite.ToString(), ex.Message.Replace("'", "''"), "frm_LeaveApproval", ex.StackTrace, DateTime.Now);
            Response.Redirect("~/Frm_ErrorPage.aspx");
        }
    }