//button events
    protected void btnAddApplication_Click(object sender, EventArgs e)
    {
        if (this.grdEmployee.SelectedIndex == -1)
        {
            this.lblStatusMessage.Text = "**कर्मचारी छान्नुहोस्";
            this.programmaticModalPopup.Show();
        }
        ddlAppType.Enabled = true;

        string msg = EmptyMessage("appl");

        if (msg != "")
        {
            this.lblStatusMessage.Text = msg;
            this.programmaticModalPopup.Show();
            return;
        }
        else
        {
            try
            {
                List <ATTEmployeeLeave> LSTEmpLeave = (List <ATTEmployeeLeave>)Session["EmployeeLeave"];
                if (LSTEmpLeave == null)
                {
                    LSTEmpLeave = new List <ATTEmployeeLeave>();
                }
                ATTEmployeeLeave objEmpLST = new ATTEmployeeLeave();
                if (this.grdLeaveApplications.SelectedIndex > -1)
                {
                    objEmpLST             = LSTEmpLeave[grdLeaveApplications.SelectedIndex];
                    objEmpLST.EmpID       = int.Parse(txtEmpName.Attributes["ID"].ToString());
                    objEmpLST.EmpFullName = this.txtEmpName.Text;
                    objEmpLST.ApplDate    = this.txtEmpDate.Text;
                    objEmpLST.LeaveTypeID = int.Parse(this.ddlAppType.SelectedValue.ToString());
                    objEmpLST.LeaveType   = this.ddlAppType.SelectedItem.ToString();
                    objEmpLST.ReqdFrom    = this.txtEmpLvFrom.Text;
                    objEmpLST.ReqdTo      = this.txtEmpLvTo.Text;
                    objEmpLST.EmpDays     = int.Parse(this.txtEmpLvDays.Text.ToString());
                    objEmpLST.EmpReason   = this.txtEmpLvResn.Text;
                    objEmpLST.EntryBy     = Session["UserName"].ToString();
                    objEmpLST.EntryDate   = "";
                    objEmpLST.Action      = "E";
                }
                else
                {
                    objEmpLST.EmpID = int.Parse(grdEmployee.SelectedRow.Cells[0].Text);

                    int searchEmp = objEmpLST.EmpID;
                    List <ATTEmployeeLeave> LST = LSTEmpLeave.FindAll(
                        delegate(ATTEmployeeLeave obj)
                    {
                        return(searchEmp == obj.EmpID);
                    }
                        );

                    if (LST.Count > 0)
                    {
                        this.lblStatusMessage.Text = "This employee have already applied for leave and is not yet recommended";
                        this.programmaticModalPopup.Show();
                        this.btnApplSubmit.Enabled = false;
                        return;
                    }

                    objEmpLST.EmpFullName = this.txtEmpName.Text;
                    objEmpLST.ApplDate    = this.txtEmpDate.Text;
                    objEmpLST.LeaveTypeID = int.Parse(this.ddlAppType.SelectedValue.ToString());
                    objEmpLST.LeaveType   = this.ddlAppType.SelectedItem.ToString();
                    objEmpLST.ReqdFrom    = this.txtEmpLvFrom.Text;
                    objEmpLST.ReqdTo      = this.txtEmpLvTo.Text;
                    objEmpLST.EmpDays     = int.Parse(this.txtEmpLvDays.Text.ToString());
                    objEmpLST.EmpReason   = this.txtEmpLvResn.Text;

                    objEmpLST.EntryBy   = Session["UserName"].ToString();
                    objEmpLST.EntryDate = "";
                    objEmpLST.Action    = "A";
                    LSTEmpLeave.Add(objEmpLST);
                }

                Session["EmployeeLeave"]        = LSTEmpLeave;
                grdLeaveApplications.DataSource = LSTEmpLeave;
                grdLeaveApplications.DataBind();

                if (LSTEmpLeave.Count > 0)
                {
                    this.grdLeaveApplications.Visible = true;
                    btnApplSubmit.Enabled             = true;
                }
                else
                {
                    this.grdLeaveApplications.Visible = false;
                    btnApplSubmit.Enabled             = false;
                }

                ClearControls(1, 2, 0, 0);
            }
            catch (Exception ex)
            {
                this.lblStatusMessage.Text = ex.Message.ToString();
                this.programmaticModalPopup.Show();
                return;
            }
        }
    }
Beispiel #2
0
    //button events
    protected void btnAddApplication_Click(object sender, EventArgs e)
    {
        ddlAppType.Enabled = true;

        string msg = EmptyMessage("appl");

        if (msg != "")
        {
            this.lblStatusMessage.Text = msg;
            this.programmaticModalPopup.Show();
            return;
        }
        else
        {
            try
            {
                List <ATTEmployeeLeave> LSTEmpLeave = (List <ATTEmployeeLeave>)Session["EmployeeLeave"];

                if (LSTEmpLeave == null)
                {
                    LSTEmpLeave = new List <ATTEmployeeLeave>();
                }
                else if (LSTEmpLeave.Count > 0)
                {
                    btnApplSubmit.Enabled = true;
                }

                ATTEmployeeLeave objEmpLST = new ATTEmployeeLeave();
                objEmpLST.EmpID       = int.Parse(txtEmpName.Attributes["ID"].ToString());
                objEmpLST.EmpFullName = this.txtEmpName.Text;
                objEmpLST.ApplDate    = this.txtEmpDate.Text;
                objEmpLST.LeaveTypeID = int.Parse(this.ddlAppType.SelectedValue.ToString());
                objEmpLST.LeaveType   = this.ddlAppType.SelectedItem.ToString();
                objEmpLST.ReqdFrom    = this.txtEmpLvFrom.Text;
                objEmpLST.ReqdTo      = this.txtEmpLvTo.Text;
                objEmpLST.EmpDays     = int.Parse(this.txtEmpLvDays.Text.ToString());
                objEmpLST.EmpReason   = this.txtEmpLvResn.Text;

                objEmpLST.EntryBy   = Session["UserName"].ToString();
                objEmpLST.EntryDate = "";
                objEmpLST.Action    = "A";


                if (grdLeaveApplications.SelectedIndex == -1)
                {
                    //if (lstLeaveTypeEmployee.Count > 0)
                    //{
                    foreach (ATTEmployeeLeave leave in LSTEmpLeave)
                    {
                        if (leave.LeaveTypeID == int.Parse(ddlAppType.SelectedValue))
                        {
                            grdLeaveApplications.SelectedIndex = -1;

                            this.lblStatusMessage.Text = " This Leave Type Already Exists. ";
                            this.programmaticModalPopup.Show();

                            return;
                        }
                    }
                    //}
                    LSTEmpLeave.Add(objEmpLST);
                }
                else
                {
                    objEmpLST.Action = (LSTEmpLeave[grdLeaveApplications.SelectedIndex].Action == "A" ? "A" : "E");
                    LSTEmpLeave[grdLeaveApplications.SelectedIndex] = objEmpLST;
                }


                Session["EmployeeLeave"] = LSTEmpLeave;

                grdLeaveApplications.DataSource = LSTEmpLeave;
                grdLeaveApplications.DataBind();
                if (LSTEmpLeave.Count > 0)
                {
                    this.grdLeaveApplications.Visible = true;
                }
                ClearControls(1, 2, 0);
            }
            catch (Exception ex)
            {
                this.lblStatusMessage.Text = ex.Message.ToString();
                this.programmaticModalPopup.Show();
                return;
            }
        }
    }