Ejemplo n.º 1
0
    public void GetReport()
    {
        DateTime FromDate = new DateTime();
        DateTime ToDate   = new DateTime();
        string   Emplist  = string.Empty;

        if (Session["EmpList"] == null)
        {
            Response.Redirect("../Attendance_Report/AttendanceReport.aspx");
        }
        else
        {
            FromDate = objsys.getDateForInput(Session["FromDate"].ToString());
            ToDate   = objsys.getDateForInput(Session["ToDate"].ToString());

            Emplist = Session["EmpList"].ToString();

            DataTable dtFilter = new DataTable();

            AttendanceDataSet rptdata = new AttendanceDataSet();

            rptdata.EnforceConstraints = false;
            AttendanceDataSetTableAdapters.sp_Set_Employee_Holiday_ReportTableAdapter adp = new AttendanceDataSetTableAdapters.sp_Set_Employee_Holiday_ReportTableAdapter();

            adp.Fill(rptdata.sp_Set_Employee_Holiday_Report, int.Parse(Session["CompId"].ToString()), Convert.ToDateTime(FromDate), Convert.ToDateTime(ToDate));



            if (Emplist != "")
            {
                dtFilter = new DataView(rptdata.sp_Set_Employee_Holiday_Report, "Emp_Id in (" + Emplist.Substring(0, Emplist.Length - 1) + ") ", "", DataViewRowState.CurrentRows).ToTable();
            }
            string CompanyName    = "";
            string CompanyAddress = "";
            string Imageurl       = "";

            DataTable DtCompany = objComp.GetCompanyMasterById(Session["CompId"].ToString());
            DataTable DtAddress = ObjAddress.GetAddressChildDataByAddTypeAndAddRefId("Company", Session["CompId"].ToString());
            if (DtCompany.Rows.Count > 0)
            {
                CompanyName = DtCompany.Rows[0]["Company_Name"].ToString();
                Imageurl    = "~/CompanyResource/" + Session["CompId"].ToString() + "/" + DtCompany.Rows[0]["Logo_Path"].ToString();
            }
            if (DtAddress.Rows.Count > 0)
            {
                CompanyAddress = DtAddress.Rows[0]["Address"].ToString();
            }
            RptShift.SetImage(Imageurl);
            RptShift.setTitleName("Holiday Report" + " From " + FromDate.ToString(objsys.SetDateFormat()) + " To " + ToDate.ToString(objsys.SetDateFormat()));
            RptShift.setcompanyname(CompanyName);
            RptShift.setaddress(CompanyAddress);


            RptShift.DataSource     = dtFilter;
            RptShift.DataMember     = "sp_Set_Employee_Holiday_Report";
            rptViewer.Report        = RptShift;
            rptToolBar.ReportViewer = rptViewer;
        }
    }
Ejemplo n.º 2
0
    private void xrTableCell20_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
    {
        int      sum      = 0;
        DateTime fromdate = objSys.getDateForInput(System.Web.HttpContext.Current.Session["FromDate"].ToString());
        DateTime ToDate   = objSys.getDateForInput(System.Web.HttpContext.Current.Session["ToDate"].ToString());


        DataTable dt = objAttReg.GetAttendanceRegDataByEmpId(xrTableCell20.Text, fromdate.ToString(), ToDate.ToString());

        dt = new DataView(dt, "Is_Absent='True'", "", DataViewRowState.CurrentRows).ToTable();
        if (dt.Rows.Count > 0)
        {
            sum = dt.Rows.Count;
        }
        xrTableCell20.Text = sum.ToString();
    }
Ejemplo n.º 3
0
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        if (txtFromDate.Text == "" || txtFromDate.Text == "")
        {
            DisplayMessage("Fill From Date And To Date");

            return;
        }
        try
        {
            objSys.getDateForInput(txtFromDate.Text);
        }
        catch (Exception)
        {
            DisplayMessage("From Date Not In Proper Format");

            return;
        }

        try
        {
            objSys.getDateForInput(txtToDate.Text);
        }
        catch (Exception)
        {
            DisplayMessage("To Date Not In Proper Format");

            return;
        }

        if (objSys.getDateForInput(txtToDate.Text) < objSys.getDateForInput(txtFromDate.Text))
        {
            DisplayMessage("From Date Cannot Be Greater Than To Date");
            return;
        }

        DataTable dt = new DataTable();

        dt = objAttLog.GetAttendanceLogByDate(Session["CompId"].ToString(), objSys.getDateForInput(txtFromDate.Text).ToString(), objSys.getDateForInput(txtToDate.Text).ToString());
        dt = new DataView(dt, "Verified_Type='By Manual'", "", DataViewRowState.CurrentRows).ToTable();

        if (dt.Rows.Count > 0)
        {
            gvEmpLog.DataSource = dt;
            gvEmpLog.DataBind();

            Session["dtEmpLog"]  = dt;
            lblTotalRecord1.Text = Resources.Attendance.Total_Records + " : " + dt.Rows.Count.ToString() + "";
        }
        else
        {
            gvEmpLog.DataSource = null;
            gvEmpLog.DataBind();

            Session["dtEmpLog"] = null;
        }
    }
Ejemplo n.º 4
0
    private void xrTableCell19_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
    {
        int      sum      = 0;
        DateTime fromdate = objSys.getDateForInput(System.Web.HttpContext.Current.Session["FromDate"].ToString());
        DateTime ToDate   = objSys.getDateForInput(System.Web.HttpContext.Current.Session["ToDate"].ToString());


        DataTable dt = objAttReg.GetAttendanceRegDataByEmpId(xrTableCell19.Text, fromdate.ToString(), ToDate.ToString());

        dt = new DataView(dt, "EarlyMin<>0", "", DataViewRowState.CurrentRows).ToTable();
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sum += int.Parse(dt.Rows[i]["EarlyMin"].ToString());
            }
        }
        xrTableCell19.Text = GetHours(sum.ToString());
    }
Ejemplo n.º 5
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        if (txtFromDate.Text == "")
        {
            DisplayMessage("Enter From Date");
            txtFromDate.Focus();
            rbtnMonthly.Checked = false;
            rbtnYearly.Checked  = false;
            return;
        }
        else
        {
            try
            {
                objSys.getDateForInput(txtFromDate.Text);
            }
            catch
            {
                DisplayMessage("Enter Correct From Date Format " + objSys.SetDateFormat() + "");
                txtFromDate.Focus();
                rbtnMonthly.Checked = false;
                rbtnYearly.Checked  = false;
                return;
            }
        }
        if (objSys.getDateForInput(txtFromDate.Text) > objSys.getDateForInput(txtToDate.Text))
        {
            DisplayMessage("From Date cannot be greater than To Date");
            txtFromDate.Text = "";
            txtToDate.Text   = "";
            txtFromDate.Focus();
            rbtnMonthly.Checked = false;
            rbtnYearly.Checked  = false;
            return;
        }

        if (txtToDate.Text == "")
        {
            DisplayMessage("Enter To Date");
            txtToDate.Focus();
            rbtnMonthly.Checked = false;
            rbtnYearly.Checked  = false;
            return;
        }
        else
        {
            try
            {
                objSys.getDateForInput(txtToDate.Text);
            }
            catch
            {
                DisplayMessage("Enter Correct From Date Format " + objSys.SetDateFormat() + "");
                txtToDate.Focus();
                rbtnMonthly.Checked = false;
                rbtnYearly.Checked  = false;
                return;
            }
        }


        if (rbtnMonthly.Checked == false && rbtnYearly.Checked == false)
        {
            DisplayMessage("Please select Monthly or Yearly");
            return;
        }


        DataTable dtHoliday2 = objEmpHoliday.GetEmployeeHolidayMaster(Session["CompId"].ToString());

        DateTime fromdate2 = objSys.getDateForInput(txtFromDate.Text);
        DateTime todate2   = objSys.getDateForInput(txtToDate.Text);

        while (fromdate2 <= todate2)
        {
            DataTable dtHoliday1 = new DataView(dtHoliday2, "Holiday_Date='" + fromdate2.ToString() + "' and Emp_Id='" + hdnEmpId.Value + "'", "", DataViewRowState.CurrentRows).ToTable();

            if (dtHoliday1.Rows.Count > 0)
            {
                DisplayMessage("Employee has holiday on date " + fromdate2.ToString("dd-MMM-yyyy") + " so cannot apply");
                rbtnMonthly.Checked = false;
                rbtnYearly.Checked  = false;
                ddlLeaveType.Items.Clear();
                ddlLeaveType.DataSource = null;
                ddlLeaveType.DataBind();
                ddlLeaveType.Visible = false;
                txtFromDate.Text     = "";
                txtToDate.Text       = "";
                lblDays.Text         = "";
                txtEmpName.Text      = "";
                return;
            }

            fromdate2 = fromdate2.AddDays(1);
        }



        DateTime FromDate = objSys.getDateForInput(txtFromDate.Text);
        DateTime ToDate   = objSys.getDateForInput(txtToDate.Text);


        int dayscount = int.Parse(lblDays.Text);

        string month = FromDate.Month.ToString();


        DataTable dtLeaveSummary = objEmpleave.GetEmployeeLeaveTransactionDataByEmpId(hdnEmpId.Value);


        DataTable dtLeaveR = objleaveReq.GetLeaveRequestById(Session["CompId"].ToString(), hdnEmpId.Value);

        DateTime fromdate1 = objSys.getDateForInput(txtFromDate.Text);
        DateTime todate1   = objSys.getDateForInput(txtToDate.Text);

        while (fromdate1 <= todate1)
        {
            DataTable dtLeaveReq2 = new DataView(dtLeaveR, "From_Date <='" + fromdate1.ToString() + "' and To_Date>='" + fromdate1.ToString() + "' and Is_Canceled<>'True'", "", DataViewRowState.CurrentRows).ToTable();

            if (dtLeaveReq2.Rows.Count > 0)
            {
                DisplayMessage("You have already apply leave between from date and to date");
                rbtnMonthly.Checked = false;
                rbtnYearly.Checked  = false;
                ddlLeaveType.Items.Clear();
                ddlLeaveType.DataSource = null;
                ddlLeaveType.DataBind();
                ddlLeaveType.Visible = false;
                txtFromDate.Text     = "";
                txtToDate.Text       = "";
                lblDays.Text         = "";
                txtEmpName.Text      = "";
                return;
            }


            fromdate1 = fromdate1.AddDays(1);
        }


        if (rbtnMonthly.Checked)
        {
            string   months    = string.Empty;
            string   year      = string.Empty;
            DateTime FromDate2 = DateTime.Now;
            DateTime ToDate2   = DateTime.Now.AddMonths(2);
            while (FromDate2 <= ToDate2)
            {
                months   += FromDate2.Month.ToString() + ",";
                FromDate2 = FromDate2.AddMonths(1);
                string year1 = FromDate2.Year.ToString();
                if (!year.Split(',').Contains(year1))
                {
                    year += year1 + ",";
                }
            }


            DataTable dt = objAppParam.GetApplicationParameterByParamName("FinancialYearStartMonth", Session["CompId"].ToString());
            int       FinancialYearMonth = 0;

            if (dt.Rows.Count > 0)
            {
                FinancialYearMonth = int.Parse(dt.Rows[0]["Param_Value"].ToString());
            }

            DateTime FinancialYearStartDate = new DateTime();
            DateTime FinancialYearEndDate   = new DateTime();
            if (DateTime.Now.Month < FinancialYearMonth)
            {
                FinancialYearStartDate = new DateTime(DateTime.Now.Year - 1, FinancialYearMonth, 1);

                FinancialYearEndDate = FinancialYearStartDate.AddYears(1).AddDays(-1);
            }
            else
            {
                FinancialYearStartDate = new DateTime(DateTime.Now.Year, FinancialYearMonth, 1);
                FinancialYearEndDate   = FinancialYearStartDate.AddYears(1).AddDays(-1);
            }

            string year4   = string.Empty;
            string months4 = string.Empty;

            months4 = months;
            if (FinancialYearStartDate.Year == FinancialYearEndDate.Year)
            {
                year4 = FinancialYearStartDate.Year.ToString();
            }
            else
            {
                year4 += FinancialYearStartDate.Year.ToString() + ",";

                year4 += FinancialYearEndDate.Year.ToString() + ",";
            }

            DateTime DateFrm = Convert.ToDateTime(txtFromDate.Text);

            if (!months4.Split(',').Contains(DateFrm.Month.ToString()) && !year4.Split(',').Contains(DateFrm.Year.ToString()))
            {
                DisplayMessage("You cannot request leave for this month");
                return;
            }


            dtLeaveSummary = new DataView(dtLeaveSummary, "month in(" + month + ") and year in (" + year4 + ") ", "", DataViewRowState.CurrentRows).ToTable();

            int remainingdays = 0;
            if (dtLeaveSummary.Rows.Count > 0)
            {
                remainingdays = int.Parse(dtLeaveSummary.Rows[0]["Remaining_Days"].ToString());
            }
            if (dayscount > remainingdays)
            {
                DisplayMessage("Employee does not have sufficient leave");
                return;
            }
            else
            {
                int b = 0;
                b = objleaveReq.InsertLeaveRequest(Session["CompId"].ToString(), ddlLeaveType.SelectedValue, hdnEmpId.Value, DateTime.Now.ToString(), txtFromDate.Text, txtToDate.Text, true.ToString(), false.ToString(), false.ToString(), "", "", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());

                DataTable dtLeave = objEmpleave.GetEmployeeLeaveTransactionData(hdnEmpId.Value, ddlLeaveType.SelectedValue, FromDate.Month.ToString(), FromDate.Year.ToString());

                string TransNo   = string.Empty;
                int    remain    = 0;
                int    useddays  = 0;
                int    totaldays = 0;
                if (dtLeave.Rows.Count > 0)
                {
                    TransNo   = dtLeave.Rows[0]["Trans_Id"].ToString();
                    remain    = int.Parse(dtLeave.Rows[0]["Remaining_Days"].ToString());
                    totaldays = int.Parse(dtLeave.Rows[0]["Total_Days"].ToString());
                }

                remain   = remain - dayscount;
                useddays = totaldays - remain;
                try
                {
                    objEmpleave.UpdateEmployeeLeaveTransactionByTransNo(TransNo, Session["CompId"].ToString(), hdnEmpId.Value, ddlLeaveType.SelectedValue, FromDate.Year.ToString(), FromDate.Month.ToString(), "0", "0", "0", useddays.ToString(), remain.ToString(), dayscount.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());
                }
                catch
                {
                    DisplayMessage("Leave type not assigned to employee");
                    return;
                }
                while (FromDate <= ToDate)
                {
                    objleaveReq.InsertLeaveRequestChild(b.ToString(), ddlLeaveType.SelectedValue, FromDate.ToString(), true.ToString(), "1", "", "", "", "", "", false.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());



                    FromDate = FromDate.AddDays(1);
                }
                DisplayMessage("Leave submitted");



                rbtnMonthly.Checked = false;
                rbtnYearly.Checked  = false;
                ddlLeaveType.Items.Clear();
                ddlLeaveType.DataSource = null;
                ddlLeaveType.DataBind();
                ddlLeaveType.Visible      = false;
                txtFromDate.Text          = "";
                txtToDate.Text            = "";
                lblDays.Text              = "";
                txtEmpName.Text           = "";
                gvLeaveSummary.DataSource = null;
                gvLeaveSummary.DataBind();
            }
        }
        else if (rbtnYearly.Checked)
        {
            string year4 = string.Empty;

            DataTable dt = objAppParam.GetApplicationParameterByParamName("FinancialYearStartMonth", Session["CompId"].ToString());
            int       FinancialYearMonth = 0;

            if (dt.Rows.Count > 0)
            {
                FinancialYearMonth = int.Parse(dt.Rows[0]["Param_Value"].ToString());
            }

            DateTime FinancialYearStartDate = new DateTime();
            DateTime FinancialYearEndDate   = new DateTime();
            if (DateTime.Now.Month < FinancialYearMonth)
            {
                FinancialYearStartDate = new DateTime(DateTime.Now.Year - 1, FinancialYearMonth, 1);

                FinancialYearEndDate = FinancialYearStartDate.AddYears(1).AddDays(-1);
            }
            else
            {
                FinancialYearStartDate = new DateTime(DateTime.Now.Year, FinancialYearMonth, 1);
                FinancialYearEndDate   = FinancialYearStartDate.AddYears(1).AddDays(-1);
            }


            if (FinancialYearStartDate.Year == FinancialYearEndDate.Year)
            {
                year4 = FinancialYearStartDate.Year.ToString();
            }
            else
            {
                year4 = FinancialYearStartDate.Year.ToString();
            }


            dtLeaveSummary = new DataView(dtLeaveSummary, "month='0' and Year='" + year4 + "'", "", DataViewRowState.CurrentRows).ToTable();


            int remainingdays = 0;
            if (dtLeaveSummary.Rows.Count > 0)
            {
                remainingdays = int.Parse(dtLeaveSummary.Rows[0]["Remaining_Days"].ToString());
            }
            if (dayscount > remainingdays)
            {
                DisplayMessage("Employee does not have sufficient leave");
                return;
            }
            else
            {
                int b = 0;
                b = objleaveReq.InsertLeaveRequest(Session["CompId"].ToString(), ddlLeaveType.SelectedValue, hdnEmpId.Value, DateTime.Now.ToString(), txtFromDate.Text, txtToDate.Text, true.ToString(), false.ToString(), false.ToString(), "", "", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());

                DataTable dtLeave = objEmpleave.GetEmployeeLeaveTransactionData(hdnEmpId.Value, ddlLeaveType.SelectedValue, "0", year4);

                string TransNo   = string.Empty;
                int    remain    = 0;
                int    useddays  = 0;
                int    totaldays = 0;
                if (dtLeave.Rows.Count > 0)
                {
                    TransNo   = dtLeave.Rows[0]["Trans_Id"].ToString();
                    remain    = int.Parse(dtLeave.Rows[0]["Remaining_Days"].ToString());
                    totaldays = int.Parse(dtLeave.Rows[0]["Total_Days"].ToString());
                }

                remain   = remain - dayscount;
                useddays = totaldays - remain;

                try
                {
                    objEmpleave.UpdateEmployeeLeaveTransactionByTransNo(TransNo, Session["CompId"].ToString(), hdnEmpId.Value, ddlLeaveType.SelectedValue, year4, "0", "0", "0", "0", useddays.ToString(), remain.ToString(), dayscount.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());
                }
                catch
                {
                    DisplayMessage("Leave not Assigned to employee");
                }


                while (FromDate <= ToDate)
                {
                    objleaveReq.InsertLeaveRequestChild(b.ToString(), ddlLeaveType.SelectedValue, FromDate.ToString(), true.ToString(), "1", "", "", "", "", "", false.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());



                    FromDate = FromDate.AddDays(1);
                }
                DisplayMessage("Leave submitted");

                rbtnMonthly.Checked = false;
                rbtnYearly.Checked  = false;
                ddlLeaveType.Items.Clear();
                ddlLeaveType.DataSource = null;
                ddlLeaveType.DataBind();
                ddlLeaveType.Visible      = false;
                txtFromDate.Text          = "";
                txtToDate.Text            = "";
                lblDays.Text              = "";
                txtEmpName.Text           = "";
                gvLeaveSummary.DataSource = null;
                gvLeaveSummary.DataBind();
            }
        }
        FillLeaveStatus();
    }
    public void GetReport()
    {
        DateTime FromDate = new DateTime();
        DateTime ToDate   = new DateTime();
        string   Emplist  = string.Empty;

        if (Session["EmpList"] == null)
        {
            Response.Redirect("../Attendance_Report/AttendanceReport.aspx");
        }
        else
        {
            FromDate = objSys.getDateForInput(Session["FromDate"].ToString());
            ToDate   = objSys.getDateForInput(Session["ToDate"].ToString());

            Emplist = Session["EmpList"].ToString();

            DataTable dtFilter = new DataTable();

            AttendanceDataSet rptdata = new AttendanceDataSet();

            rptdata.EnforceConstraints = false;
            AttendanceDataSetTableAdapters.sp_Att_AttendanceRegister_ReportTableAdapter adp = new AttendanceDataSetTableAdapters.sp_Att_AttendanceRegister_ReportTableAdapter();

            adp.Fill(rptdata.sp_Att_AttendanceRegister_Report, Convert.ToDateTime(FromDate), Convert.ToDateTime(ToDate));



            if (Emplist != "")
            {
                dtFilter = new DataView(rptdata.sp_Att_AttendanceRegister_Report, "Emp_Id in (" + Emplist.Substring(0, Emplist.Length - 1) + ") ", "", DataViewRowState.CurrentRows).ToTable();
            }

            DataTable dtReport = dtFilter.Clone();


            for (int i = 0; i < dtFilter.Rows.Count; i++)
            {
                if (dtFilter.Rows[i]["In_Time"].ToString().Contains("00:00") && dtFilter.Rows[i]["Out_Time"].ToString().Contains("00:00"))
                {
                    //  dtFilter.Rows[i]["Field1"] = "NA";
                    //  dtReport.ImportRow(dtFilter.Rows[i]);
                }
                else if (!dtFilter.Rows[i]["In_Time"].ToString().Contains("00:00") && dtFilter.Rows[i]["Out_Time"].ToString().Contains("00:00"))
                {
                    if (!Convert.ToBoolean(dtFilter.Rows[i]["Is_Leave"].ToString()) && !Convert.ToBoolean(dtFilter.Rows[i]["Is_Holiday"].ToString()) && !Convert.ToBoolean(dtFilter.Rows[i]["Is_Week_Off"].ToString()))
                    {
                        dtFilter.Rows[i]["Field1"] = "Out";
                        dtReport.ImportRow(dtFilter.Rows[i]);
                    }
                }

                else if (dtFilter.Rows[i]["In_Time"].ToString().Contains("00:00") && !dtFilter.Rows[i]["Out_Time"].ToString().Contains("00:00"))
                {
                    if (!Convert.ToBoolean(dtFilter.Rows[i]["Is_Leave"].ToString()) && !Convert.ToBoolean(dtFilter.Rows[i]["Is_Holiday"].ToString()) && !Convert.ToBoolean(dtFilter.Rows[i]["Is_Week_Off"].ToString()))
                    {
                        dtFilter.Rows[i]["Field1"] = "In";
                        dtReport.ImportRow(dtFilter.Rows[i]);
                    }
                }
            }



            string CompanyName    = "";
            string CompanyAddress = "";
            string Imageurl       = "";

            DataTable DtCompany = objComp.GetCompanyMasterById(Session["CompId"].ToString());
            DataTable DtAddress = ObjAddress.GetAddressChildDataByAddTypeAndAddRefId("Company", Session["CompId"].ToString());
            if (DtCompany.Rows.Count > 0)
            {
                CompanyName = DtCompany.Rows[0]["Company_Name"].ToString();
                Imageurl    = "~/CompanyResource/" + Session["CompId"].ToString() + "/" + DtCompany.Rows[0]["Logo_Path"].ToString();
            }
            if (DtAddress.Rows.Count > 0)
            {
                CompanyAddress = DtAddress.Rows[0]["Address"].ToString();
            }
            RptShift.SetImage(Imageurl);
            RptShift.setTitleName("In Out Exception Report" + " From " + FromDate.ToString(objSys.SetDateFormat()) + " To " + ToDate.ToString(objSys.SetDateFormat()));
            RptShift.setcompanyname(CompanyName);
            RptShift.setaddress(CompanyAddress);


            RptShift.DataSource     = dtReport;
            RptShift.DataMember     = "sp_Att_AttendanceRegister_Report";
            rptViewer.Report        = RptShift;
            rptToolBar.ReportViewer = rptViewer;
        }
    }
    public void GetReport()
    {
        DateTime FromDate = new DateTime();
        DateTime ToDate   = new DateTime();
        string   Emplist  = string.Empty;

        if (Session["EmpList"] == null)
        {
            Response.Redirect("../Attendance_Report/AttendanceReport.aspx");
        }
        else
        {
            FromDate = objSys.getDateForInput(Session["FromDate"].ToString());
            ToDate   = objSys.getDateForInput(Session["ToDate"].ToString());

            Emplist = Session["EmpList"].ToString();

            DataTable dtFilter = new DataTable();

            AttendanceDataSet rptdata = new AttendanceDataSet();

            rptdata.EnforceConstraints = false;
            AttendanceDataSetTableAdapters.sp_Att_AttendanceRegister_ReportTableAdapter adp = new AttendanceDataSetTableAdapters.sp_Att_AttendanceRegister_ReportTableAdapter();

            adp.Fill(rptdata.sp_Att_AttendanceRegister_Report, Convert.ToDateTime(FromDate), Convert.ToDateTime(ToDate));



            if (Emplist != "")
            {
                dtFilter = new DataView(rptdata.sp_Att_AttendanceRegister_Report, "Emp_Id in (" + Emplist.Substring(0, Emplist.Length - 1) + ") ", "", DataViewRowState.CurrentRows).ToTable();
            }
            dtFilter = new DataView(dtFilter, "OverTime_Min<>'0' or Week_Off_Min<>'0' or Holiday_Min<>'0'", "", DataViewRowState.CurrentRows).ToTable();

            for (int k = 0; k < dtFilter.Rows.Count; k++)
            {
                if (dtFilter.Rows[k]["OverTime_Min"].ToString() != "0")
                {
                    dtFilter.Rows[k]["Field2"] = dtFilter.Rows[k]["OverTime_Min"];
                    dtFilter.Rows[k]["Field3"] = "Normal";
                }
                else if (dtFilter.Rows[k]["Week_Off_Min"].ToString() != "0")
                {
                    dtFilter.Rows[k]["Field2"] = dtFilter.Rows[k]["Week_Off_Min"];
                    dtFilter.Rows[k]["Field3"] = "Week Off";
                }
                else if (dtFilter.Rows[k]["Holiday_Min"].ToString() != "0")
                {
                    dtFilter.Rows[k]["Field2"] = dtFilter.Rows[k]["Holiday_Min"];
                    dtFilter.Rows[k]["Field3"] = "Holiday";
                }
            }



            string CompanyName    = "";
            string CompanyAddress = "";
            string Imageurl       = "";

            DataTable DtCompany = objComp.GetCompanyMasterById(Session["CompId"].ToString());
            DataTable DtAddress = ObjAddress.GetAddressChildDataByAddTypeAndAddRefId("Company", Session["CompId"].ToString());
            if (DtCompany.Rows.Count > 0)
            {
                CompanyName = DtCompany.Rows[0]["Company_Name"].ToString();
                Imageurl    = "~/CompanyResource/" + Session["CompId"].ToString() + "/" + DtCompany.Rows[0]["Logo_Path"].ToString();
            }
            if (DtAddress.Rows.Count > 0)
            {
                CompanyAddress = DtAddress.Rows[0]["Address"].ToString();
            }
            RptShift.SetImage(Imageurl);
            RptShift.setTitleName("Over Time Report" + " From " + FromDate.ToString("dd-MMM-yyyy") + " To " + ToDate.ToString("dd-MMM-yyyy"));
            RptShift.setcompanyname(CompanyName);
            RptShift.setaddress(CompanyAddress);


            RptShift.DataSource     = dtFilter;
            RptShift.DataMember     = "sp_Att_AttendanceRegister_Report";
            rptViewer.Report        = RptShift;
            rptToolBar.ReportViewer = rptViewer;
        }
    }
    public void GetReport()
    {
        DateTime FromDate  = new DateTime();
        DateTime ToDate    = new DateTime();
        DateTime FromDate1 = new DateTime();
        string   Emplist   = string.Empty;

        if (Session["EmpList"] == null)
        {
            Response.Redirect("../Attendance_Report/AttendanceReport.aspx");
        }
        else
        {
            FromDate  = objSys.getDateForInput(Session["FromDate"].ToString());
            ToDate    = objSys.getDateForInput(Session["ToDate"].ToString());
            FromDate1 = FromDate;
            Emplist   = Session["EmpList"].ToString();

            DataTable dtFilter = new DataTable();

            AttendanceDataSet rptdata = new AttendanceDataSet();

            rptdata.EnforceConstraints = false;
            AttendanceDataSetTableAdapters.sp_Att_AttendanceRegister_ReportTableAdapter adp = new AttendanceDataSetTableAdapters.sp_Att_AttendanceRegister_ReportTableAdapter();

            adp.Fill(rptdata.sp_Att_AttendanceRegister_Report, Convert.ToDateTime(FromDate), Convert.ToDateTime(ToDate));



            if (Emplist != "")
            {
                dtFilter = new DataView(rptdata.sp_Att_AttendanceRegister_Report, "Emp_Id in (" + Emplist.Substring(0, Emplist.Length - 1) + ") ", "", DataViewRowState.CurrentRows).ToTable();
            }

            DataTable dtEmp  = dtFilter.DefaultView.ToTable(true, "Emp_Id");
            DataTable dtTemp = new DataTable();

            DataTable dtSalary = new DataTable();
            dtSalary = dtFilter.Clone();
            int Total_Days          = 0;
            int Days_In_WorkMin     = 0;
            int Worked_Days         = 0;
            int Week_Off_Days       = 0;
            int Holiday_Days        = 0;
            int Leave_Days          = 0;
            int Absent_Days         = 0;
            int Assigned_Worked_Min = 0;


            double Basic_Salary              = 0;
            double Basic_Min_Salary          = 0;
            double Normal_OT_Salary          = 0;
            double Week_Off_OT_Salary        = 0;
            double Holiday_OT_Salary         = 0;
            double Absent_Penalty            = 0;
            double Late_Penalty_Min          = 0;
            double Early_Penalty_Min         = 0;
            double Partial_Penalty_Min       = 0;
            int    Total_Worked_Min          = 0;
            int    Holiday_OT_Min            = 0;
            int    Week_Off_OT_Min           = 0;
            int    Normal_OT_Min             = 0;
            int    Late_Min                  = 0;
            int    Early_Min                 = 0;
            int    Partial_Min               = 0;
            double Basic_Work_Salary         = 0;
            double Normal_OT_Work_Salary     = 0;
            double WeekOff_OT_Work_Salary    = 0;
            double Holiday_OT_Work_Salary    = 0;
            double Week_Off_Days_Salary      = 0;
            double Holiday_Days_Salary       = 0;
            double Leave_Days_Salary         = 0;
            double Absent_Day_Penalty        = 0;
            double Late_Min_Penalty          = 0;
            double Early_Min_Penalty         = 0;
            double Parital_Violation_Penalty = 0;


            bool   IsEmpLate            = false;
            bool   IsEmpEarly           = false;
            bool   IsEmpPartial         = false;
            string LateMethod           = string.Empty;
            string EarlyMethod          = string.Empty;
            string PartialMethod        = string.Empty;
            int    LatePenaltyDedMin    = 0;
            int    EarlyPenaltyDedMin   = 0;
            int    PartialPenaltyDedMin = 0;
            int    PartialMin           = 0;
            int    TotalOTMin           = 0;
            double TotalGrossSalary     = 0;
            int    j = 0;
            for (int i = 0; i < dtEmp.Rows.Count; i++)
            {
                FromDate             = FromDate1;
                IsEmpLate            = false;
                IsEmpEarly           = false;
                IsEmpPartial         = false;
                LateMethod           = string.Empty;
                EarlyMethod          = string.Empty;
                PartialMethod        = string.Empty;
                LatePenaltyDedMin    = 0;
                EarlyPenaltyDedMin   = 0;
                PartialPenaltyDedMin = 0;
                TotalOTMin           = 0;

                Assigned_Worked_Min = 0;


                Basic_Salary        = 0;
                Basic_Min_Salary    = 0;
                Normal_OT_Salary    = 0;
                Week_Off_OT_Salary  = 0;
                Holiday_OT_Salary   = 0;
                Absent_Penalty      = 0;
                Late_Penalty_Min    = 0;
                Early_Penalty_Min   = 0;
                Partial_Penalty_Min = 0;
                TotalGrossSalary    = 0;
                try
                {
                    IsEmpEarly   = Convert.ToBoolean(objEmpParam.GetEmployeeParameterByParameterName(dtEmp.Rows[i]["Emp_Id"].ToString(), "Field2"));
                    IsEmpLate    = Convert.ToBoolean(objEmpParam.GetEmployeeParameterByParameterName(dtEmp.Rows[i]["Emp_Id"].ToString(), "Field1"));
                    IsEmpPartial = Convert.ToBoolean(objEmpParam.GetEmployeeParameterByParameterName(dtEmp.Rows[i]["Emp_Id"].ToString(), "Is_Partial_Enable"));

                    LateMethod           = objAppParam.GetApplicationParameterValueByParamName("Is_Late_Penalty_Method", Session["CompId"].ToString());
                    EarlyMethod          = objAppParam.GetApplicationParameterValueByParamName("Is_Early_Penalty_Method", Session["CompId"].ToString());
                    PartialMethod        = objAppParam.GetApplicationParameterValueByParamName("Partial_Penalty_Method", Session["CompId"].ToString());
                    LatePenaltyDedMin    = int.Parse(objAppParam.GetApplicationParameterValueByParamName("Late_Penalty_Min_Deduct", Session["CompId"].ToString()));
                    EarlyPenaltyDedMin   = int.Parse(objAppParam.GetApplicationParameterValueByParamName("Early_Penalty_Min_Deduct", Session["CompId"].ToString()));
                    PartialPenaltyDedMin = int.Parse(objAppParam.GetApplicationParameterValueByParamName("Partial_Penalty_Min_Deduct", Session["CompId"].ToString()));
                    Total_Days           = ToDate.Subtract(FromDate).Days + 1;

                    Days_In_WorkMin = int.Parse(objEmpParam.GetEmployeeParameterByParameterName(dtEmp.Rows[i]["Emp_Id"].ToString(), "Assign_Min"));
                }
                catch
                {
                }

                try
                {
                    Basic_Salary = double.Parse(objEmpParam.GetEmployeeParameterByParameterName(dtEmp.Rows[i]["Emp_Id"].ToString(), "Basic_Salary"));
                }
                catch
                {
                }

                int assingmin = 0;
                try
                {
                    assingmin = int.Parse(objEmpParam.GetEmployeeParameterByParameterName(dtEmp.Rows[i]["Emp_Id"].ToString(), "Assign_Min"));
                }
                catch
                {
                }

                Basic_Min_Salary = Basic_Salary / (Total_Days * assingmin);
                if (Basic_Min_Salary.ToString() == "NaN")
                {
                    Basic_Min_Salary = 0;
                }

                Normal_OT_Salary   = GetOTOneMinSalary(dtEmp.Rows[i]["Emp_Id"].ToString(), "Normal", Basic_Min_Salary);
                Week_Off_OT_Salary = GetOTOneMinSalary(dtEmp.Rows[i]["Emp_Id"].ToString(), "WeekOff", Basic_Min_Salary);
                Holiday_OT_Salary  = GetOTOneMinSalary(dtEmp.Rows[i]["Emp_Id"].ToString(), "Holiday", Basic_Min_Salary);

                Absent_Penalty = OnDayAbsentSalary(Basic_Min_Salary, dtEmp.Rows[i]["Emp_Id"].ToString());

                Late_Penalty_Min = OnMinuteLatePenalty(Basic_Min_Salary, dtEmp.Rows[i]["Emp_Id"].ToString());

                Early_Penalty_Min = OnMinuteEarlyPenalty(Basic_Min_Salary, dtEmp.Rows[i]["Emp_Id"].ToString());

                Partial_Penalty_Min = OnMinuteParialPenalty(Basic_Min_Salary, dtEmp.Rows[i]["Emp_Id"].ToString());


                while (FromDate <= ToDate)
                {
                    PartialMin = 0;

                    Total_Worked_Min          = 0;
                    Holiday_OT_Min            = 0;
                    Week_Off_OT_Min           = 0;
                    Normal_OT_Min             = 0;
                    Late_Min                  = 0;
                    Early_Min                 = 0;
                    Partial_Min               = 0;
                    Basic_Work_Salary         = 0;
                    Normal_OT_Work_Salary     = 0;
                    WeekOff_OT_Work_Salary    = 0;
                    Holiday_OT_Work_Salary    = 0;
                    Week_Off_Days_Salary      = 0;
                    Holiday_Days_Salary       = 0;
                    Leave_Days_Salary         = 0;
                    Absent_Day_Penalty        = 0;
                    Late_Min_Penalty          = 0;
                    Early_Min_Penalty         = 0;
                    Parital_Violation_Penalty = 0;
                    PartialMin                = 0;


                    dtTemp = dtFilter.Clone();
                    dtTemp = new DataView(dtFilter, "Att_Date='" + FromDate.ToString("dd-MMM-yyyy") + "' and Emp_Id='" + dtEmp.Rows[i]["Emp_Id"].ToString() + "'   ", "", DataViewRowState.CurrentRows).ToTable();


                    if (dtTemp.Rows.Count > 0)
                    {
                        for (int k = 0; k < dtTemp.Rows.Count; k++)
                        {
                            dtSalary.ImportRow(dtTemp.Rows[k]);

                            dtSalary.Rows[j]["Field2"] = "";
                            dtSalary.Rows[j]["Field3"] = "";
                            dtSalary.Rows[j]["Field4"] = "";
                            //
                            Late_Min = int.Parse(dtTemp.Rows[k]["LateMin"].ToString());

                            if (IsEmpLate && LateMethod == "Min")
                            {
                                Late_Min = Late_Min * LatePenaltyDedMin;
                            }

                            Early_Min = int.Parse(dtTemp.Rows[k]["EarlyMin"].ToString());

                            if (IsEmpEarly && EarlyMethod == "Min")
                            {
                                Early_Min = Early_Min * EarlyPenaltyDedMin;
                            }

                            PartialMin       = int.Parse(dtTemp.Rows[k]["Partial_Violation_Min"].ToString());
                            Total_Worked_Min = int.Parse(dtTemp.Rows[k]["TotalAssign_Min"].ToString());
                            Days_In_WorkMin  = int.Parse(dtTemp.Rows[k]["EffectiveWork_Min"].ToString());

                            // Days_In_WorkMin = int.Parse(getWorkMinute(Days_In_WorkMin.ToString(),Total_Worked_Min.ToString()));

                            Normal_OT_Min   = int.Parse(dtTemp.Rows[k]["OverTime_Min"].ToString());
                            Week_Off_OT_Min = int.Parse(dtTemp.Rows[k]["Week_Off_Min"].ToString());
                            Holiday_OT_Min  = int.Parse(dtTemp.Rows[k]["Holiday_Min"].ToString());

                            Late_Min_Penalty          = Late_Min * Late_Penalty_Min;
                            Early_Min_Penalty         = Early_Penalty_Min * Early_Min;
                            Parital_Violation_Penalty = Partial_Penalty_Min * PartialMin;
                            Absent_Day_Penalty        = Absent_Penalty * Total_Worked_Min;

                            Basic_Work_Salary = Basic_Min_Salary * Days_In_WorkMin;

                            Normal_OT_Work_Salary  = Normal_OT_Salary * Normal_OT_Min;
                            WeekOff_OT_Work_Salary = Week_Off_OT_Salary * Week_Off_OT_Min;
                            Holiday_OT_Work_Salary = Holiday_OT_Salary * Holiday_OT_Min;

                            double TotalSalary = 0;

                            TotalOTMin += int.Parse(dtTemp.Rows[k]["OverTime_Min"].ToString());
                            if (Convert.ToBoolean(dtTemp.Rows[k]["Is_Week_Off"].ToString()))
                            {
                                dtSalary.Rows[j]["Field4"] = System.Math.Round(WeekOff_OT_Work_Salary, 2).ToString();
                                TotalSalary = Total_Worked_Min * Basic_Min_Salary;
                                dtSalary.Rows[j]["OverTime_Min"] = dtTemp.Rows[k]["Week_Off_Min"];
                                TotalOTMin += int.Parse(dtTemp.Rows[k]["Week_Off_Min"].ToString());
                            }
                            else if (Convert.ToBoolean(dtTemp.Rows[k]["Is_Holiday"].ToString()))
                            {
                                dtSalary.Rows[j]["Field4"] = System.Math.Round(Holiday_OT_Work_Salary, 2).ToString();
                                TotalSalary = Total_Worked_Min * Basic_Min_Salary;
                                dtSalary.Rows[j]["OverTime_Min"] = dtTemp.Rows[k]["Holiday_Min"];
                                TotalOTMin += int.Parse(dtTemp.Rows[k]["Holiday_Min"].ToString());
                            }
                            else if (Convert.ToBoolean(dtTemp.Rows[k]["Is_Leave"].ToString()))
                            {
                                TotalSalary = Total_Worked_Min * Basic_Min_Salary;
                                dtSalary.Rows[j]["Field4"] = "0";
                            }
                            else if (Convert.ToBoolean(dtTemp.Rows[k]["Is_Absent"].ToString()))
                            {
                                TotalSalary = Basic_Work_Salary - Absent_Day_Penalty;
                                dtSalary.Rows[j]["Field4"] = "0";
                            }
                            else if (Days_In_WorkMin != 0)
                            {
                                dtSalary.Rows[j]["Field4"] = System.Math.Round(Normal_OT_Work_Salary, 2).ToString();
                            }
                            TotalSalary = Basic_Work_Salary - Late_Min_Penalty - Early_Min_Penalty - Parital_Violation_Penalty;

                            dtSalary.Rows[j]["Field3"] = System.Math.Round(TotalSalary, 2).ToString();

                            dtSalary.Rows[j]["Field2"] = TotalOTMin.ToString();
                            try
                            {
                                TotalGrossSalary = TotalGrossSalary + TotalSalary + double.Parse(dtSalary.Rows[j]["Field4"].ToString());
                            }
                            catch
                            {
                                TotalGrossSalary = TotalGrossSalary + TotalSalary;
                            }
                            dtSalary.Rows[j]["Field5"] = System.Math.Round(TotalGrossSalary, 2).ToString();

                            //

                            j++;
                        }
                    }


                    FromDate = FromDate.AddDays(1);
                }
            }


            string CompanyName    = "";
            string CompanyAddress = "";
            string Imageurl       = "";

            DataTable DtCompany = objComp.GetCompanyMasterById(Session["CompId"].ToString());
            DataTable DtAddress = ObjAddress.GetAddressChildDataByAddTypeAndAddRefId("Company", Session["CompId"].ToString());
            if (DtCompany.Rows.Count > 0)
            {
                CompanyName = DtCompany.Rows[0]["Company_Name"].ToString();
                Imageurl    = "~/CompanyResource/" + Session["CompId"].ToString() + "/" + DtCompany.Rows[0]["Logo_Path"].ToString();
            }
            if (DtAddress.Rows.Count > 0)
            {
                CompanyAddress = DtAddress.Rows[0]["Address"].ToString();
            }
            RptShift.SetImage(Imageurl);
            RptShift.setTitleName("Daily Salary Report" + " From " + FromDate1.ToString(objSys.SetDateFormat()) + " To " + ToDate.ToString(objSys.SetDateFormat()));
            RptShift.setcompanyname(CompanyName);
            RptShift.setaddress(CompanyAddress);


            RptShift.DataSource     = dtSalary;
            RptShift.DataMember     = "sp_Att_AttendanceRegister_Report";
            rptViewer.Report        = RptShift;
            rptToolBar.ReportViewer = rptViewer;
        }
    }
    protected void btnApply_Click(object sender, EventArgs e)
    {
        int b = 0;

        if (rbtnOfficial.Checked == false && rbtnPersonal.Checked == false)
        {
            DisplayMessage("Please select Personal or Official");
            return;
        }

        if (txtEmpName.Text == "")
        {
            DisplayMessage("Enter Employee Name");
            txtEmpName.Focus();
            return;
        }

        if (txtApplyDate.Text == "")
        {
            DisplayMessage("Enter Apply Date");
            txtApplyDate.Focus();

            return;
        }
        else
        {
            try
            {
                objSys.getDateForInput(txtApplyDate.Text);
            }
            catch
            {
                DisplayMessage("Enter Correct Apply Date Format dd-MMM-yyyy");
                txtApplyDate.Focus();

                return;
            }
        }
        if (txtInTime.Text == "")
        {
            DisplayMessage("Enter In Time");
            txtInTime.Focus();

            return;
        }
        if (txtOuttime.Text == "")
        {
            DisplayMessage("Enter Out Time");
            txtOuttime.Focus();

            return;
        }
        if (txtDescription.Text == "")
        {
            DisplayMessage("Enter Description");
            txtDescription.Focus();

            return;
        }
        if (rbtnPersonal.Checked)
        {
            bool IsCompPartial = Convert.ToBoolean(objAppParam.GetApplicationParameterValueByParamName("Partial_Leave_Enable", Session["CompId"].ToString()));
            if (IsCompPartial)
            {
                DataTable dtEmpParam = objEmpParam.GetEmployeeParameterByEmpId(hdnEmpId.Value, Session["CompId"].ToString());

                if (dtEmpParam.Rows.Count > 0)
                {
                    bool IsEmpPartial = Convert.ToBoolean(dtEmpParam.Rows[0]["Is_Partial_Enable"].ToString());
                    if (IsEmpPartial)
                    {
                        int totalminutes = 0;
                        int useinday     = 0;

                        double leaveCount = 0;


                        totalminutes = int.Parse(dtEmpParam.Rows[0]["Partial_Leave_Mins"].ToString());
                        useinday     = int.Parse(dtEmpParam.Rows[0]["Partial_Leave_Day"].ToString());

                        leaveCount = double.Parse(dtEmpParam.Rows[0]["Partial_Leave_Mins"].ToString()) / double.Parse(dtEmpParam.Rows[0]["Partial_Leave_Day"].ToString());

                        leaveCount = System.Math.Round(leaveCount);

                        leaveCount = leaveCount - getCurrentMonthLeaveCount(objSys.getDateForInput(txtApplyDate.Text));

                        if (leaveCount > 0)
                        {
                            if (totalminutes > 0)
                            {
                                int CurrentUseMin = getCurrentMonth(objSys.getDateForInput(txtApplyDate.Text));
                                if (CurrentUseMin > 0)
                                {
                                    totalminutes = totalminutes - CurrentUseMin;
                                }

                                int OneDayMin = getMinuteInADay(objSys.getDateForInput(txtApplyDate.Text));
                                if (OneDayMin >= useinday)
                                {
                                    DisplayMessage("You cannot request more than " + useinday.ToString() + " minutes in a day");
                                    return;
                                }

                                int RequestMin = GetMinuteDiff(txtOuttime.Text, txtInTime.Text);
                                if (RequestMin <= totalminutes)
                                {
                                    if (RequestMin > useinday)
                                    {
                                        DisplayMessage("You cannot request more than " + useinday.ToString() + " minutes in a day");
                                        return;
                                    }
                                    else
                                    {
                                        int remainmin = totalminutes - RequestMin;
                                        if (hdnEdit.Value == "")
                                        {
                                            b = objPartial.InsertPartialLeaveRequest(Session["CompId"].ToString(), hdnEmpId.Value, "0", DateTime.Now.ToString(), objSys.getDateForInput(txtApplyDate.Text).ToString(), txtInTime.Text, txtOuttime.Text, "Pending", txtDescription.Text, "", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());

                                            if (b != 0)
                                            {
                                                DisplayMessage("Partial leave submitted");
                                                btnReset_Click(null, null);
                                                FillLeaveStatus();
                                            }
                                        }
                                        else
                                        {
                                            b = objPartial.UpdatePartialLeaveRequest(hdnEdit.Value, Session["CompId"].ToString(), hdnEmpId.Value, "1", DateTime.Now.ToString(), objSys.getDateForInput(txtApplyDate.Text).ToString(), txtInTime.Text, txtOuttime.Text, "Pending", txtDescription.Text, "", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());


                                            if (b != 0)
                                            {
                                                DisplayMessage("Partial leave updated");
                                                btnCancel_Click(null, null);
                                                FillLeaveStatus();
                                                hdnEdit.Value      = "";
                                                btnNew.Text        = Resources.Attendance.New;
                                                txtEmpName.Enabled = true;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    DisplayMessage("Employee does not have sufficient balance");
                                    return;
                                }
                            }
                            else
                            {
                                DisplayMessage("Employee does not have sufficient balance");
                                return;
                            }
                        }
                        else
                        {
                            DisplayMessage("Employee does not have sufficient balance");
                            return;
                        }
                    }
                    else
                    {
                        DisplayMessage("Partial leave cannot assign to this employee");
                        return;
                    }
                }
                else
                {
                    DisplayMessage("Partial leave cannot assign to this employee");
                    return;
                }
            }
            else
            {
                DisplayMessage("Company does not provide partial leave");
                return;
            }
        }
        else
        {
            bool IsCompPartial = Convert.ToBoolean(objAppParam.GetApplicationParameterValueByParamName("Partial_Leave_Enable", Session["CompId"].ToString()));
            if (IsCompPartial)
            {
                if (hdnEdit.Value == "")
                {
                    b = objPartial.InsertPartialLeaveRequest(Session["CompId"].ToString(), hdnEmpId.Value, "1", DateTime.Now.ToString(), objSys.getDateForInput(txtApplyDate.Text).ToString(), txtInTime.Text, txtOuttime.Text, "Pending", txtDescription.Text, "", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());

                    if (b != 0)
                    {
                        DisplayMessage("Partial leave submitted");
                        btnReset_Click(null, null);
                        FillLeaveStatus();
                    }
                }
                else
                {
                    b = objPartial.UpdatePartialLeaveRequest(hdnEdit.Value, Session["CompId"].ToString(), hdnEmpId.Value, "1", DateTime.Now.ToString(), objSys.getDateForInput(txtApplyDate.Text).ToString(), txtInTime.Text, txtOuttime.Text, "Pending", txtDescription.Text, "", "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());
                    if (b != 0)
                    {
                        DisplayMessage("Partial leave updated");
                        btnCancel_Click(null, null);
                        FillLeaveStatus();
                        hdnEdit.Value      = "";
                        btnNew.Text        = Resources.Attendance.New;
                        txtEmpName.Enabled = true;
                    }
                }
            }
            else
            {
                DisplayMessage("Company does not provide partial leave");
                return;
            }
        }
    }
Ejemplo n.º 10
0
    protected void btnGenerate_Click(object sender, EventArgs e)
    {
        int b = 0;
        // Selected Emp Id
        string empidlist = lblSelectRecord.Text;


        try
        {
            if (txtFromDate.Text == "")
            {
                DisplayMessage("From Date Required");
                txtFromDate.Focus();
                return;
            }
            if (txtToDate.Text == "")
            {
                DisplayMessage("To Date Required");
                txtToDate.Focus();
                return;
            }

            if (objSys.getDateForInput(txtFromDate.Text.ToString()) > objSys.getDateForInput(txtToDate.Text.ToString()))
            {
                DisplayMessage("To Date should be greater");



                return;
            }
        }
        catch (Exception)
        {
            DisplayMessage("Date not in proper format");

            return;
        }


        if (rbtnEmpSal.Checked)
        {
            if (empidlist == "")
            {
                DisplayMessage("Select Atleast One Employee");
                return;
            }
        }
        else
        {
            string GroupIds = string.Empty;
            string EmpIds   = string.Empty;


            for (int i = 0; i < lbxGroupSal.Items.Count; i++)
            {
                if (lbxGroupSal.Items[i].Selected)
                {
                    GroupIds += lbxGroupSal.Items[i].Value + ",";
                }
            }

            if (GroupIds != "")
            {
                empidlist = "";
                DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString());

                dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "'  and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable();
                DataTable dtEmpInGroup = objGroupEmp.GetGroup_EmployeeById(Session["CompId"].ToString());

                dtEmpInGroup = new DataView(dtEmpInGroup, "Group_Id in(" + GroupIds.Substring(0, GroupIds.Length - 1) + ")", "", DataViewRowState.CurrentRows).ToTable();

                for (int i = 0; i < dtEmpInGroup.Rows.Count; i++)
                {
                    if (!EmpIds.Split(',').Contains(dtEmpInGroup.Rows[i]["Emp_Id"].ToString()))
                    {
                        EmpIds += dtEmpInGroup.Rows[i]["Emp_Id"].ToString() + ",";
                    }
                }



                foreach (string str in EmpIds.Split(','))
                {
                    if (str != "")
                    {
                        empidlist += str + ",";
                    }
                }

                if (empidlist == "")
                {
                    DisplayMessage("Employees are not exists in selected groups");
                    return;
                }
            }
            else
            {
                DisplayMessage("Select Group First");
            }
        }
        Session["EmpList"]  = empidlist;
        Session["FromDate"] = txtFromDate.Text;
        Session["ToDate"]   = txtToDate.Text;
        pnlEmpAtt.Visible   = false;
        pnlReport.Visible   = true;

        //for (int i = 0; i < empidlist.Split(',').Length; i++)
        //{
        //    if (empidlist.Split(',')[i] == "")
        //    {
        //        continue;
        //    }

        //}
    }
    public void GetReport()
    {
        DateTime FromDate = new DateTime();
        DateTime ToDate   = new DateTime();
        string   Emplist  = string.Empty;

        if (Session["EmpList"] == null)
        {
            Response.Redirect("../Attendance_Report/AttendanceReport.aspx");
        }
        else
        {
            FromDate = ObjSys.getDateForInput(Session["FromDate"].ToString());
            ToDate   = ObjSys.getDateForInput(Session["ToDate"].ToString());

            Emplist = Session["EmpList"].ToString();

            DataTable dtFilter = new DataTable();

            AttendanceDataSet rptdata = new AttendanceDataSet();

            rptdata.EnforceConstraints = false;
            AttendanceDataSetTableAdapters.sp_Att_Employee_Leave_Trans_ReportTableAdapter adp = new AttendanceDataSetTableAdapters.sp_Att_Employee_Leave_Trans_ReportTableAdapter();

            adp.Fill(rptdata.sp_Att_Employee_Leave_Trans_Report, int.Parse(Session["CompId"].ToString()));

            DateTime JoiningDate        = new DateTime();
            int      FinancialYearMonth = 0;
            if (Emplist != "")
            {
                dtFilter = new DataView(rptdata.sp_Att_Employee_Leave_Trans_Report, "Emp_Id in (" + Emplist.Substring(0, Emplist.Length - 1) + ") ", "Shedule_Type", DataViewRowState.CurrentRows).ToTable();
            }
            DataTable dt = objAppParam.GetApplicationParameterByParamName("FinancialYearStartMonth", Session["CompId"].ToString());

            if (dt.Rows.Count > 0)
            {
                FinancialYearMonth = int.Parse(dt.Rows[0]["Param_Value"].ToString());
            }
            DateTime FinancialYearStartDate = new DateTime();
            DateTime FinancialYearEndDate   = new DateTime();
            if (JoiningDate.Month > FinancialYearMonth)
            {
                FinancialYearStartDate = new DateTime(DateTime.Now.Year, FinancialYearMonth, 1);
                FinancialYearEndDate   = FinancialYearStartDate.AddYears(1).AddDays(-1);
            }
            else
            {
                FinancialYearStartDate = new DateTime(DateTime.Now.Year, FinancialYearMonth, 1);
                FinancialYearEndDate   = FinancialYearStartDate.AddYears(1).AddDays(-1);
            }

            DataTable dtFilter1 = new DataTable();
            dtFilter1 = dtFilter;

            dtFilter1 = new DataView(dtFilter, "Year in('" + DateTime.Now.Year.ToString() + "','" + FinancialYearEndDate.Year.ToString() + "'  ) and Month='0'", "Shedule_Type", DataViewRowState.CurrentRows).ToTable();

            dtFilter = new DataView(dtFilter, "Year in('" + DateTime.Now.Year.ToString() + "','" + FinancialYearEndDate.Year.ToString() + "'  ) ", "Shedule_Type", DataViewRowState.CurrentRows).ToTable();

            string   Months = string.Empty;
            DateTime ftime  = DateTime.Now;
            while (ftime <= FinancialYearEndDate)
            {
                Months += ftime.Month + ",";

                ftime = ftime.AddMonths(1);
            }

            dtFilter = new DataView(dtFilter, "Month in(" + Months + ")", "Shedule_Type desc", DataViewRowState.CurrentRows).ToTable();
            dtFilter.Merge(dtFilter1);

            dtFilter = new DataView(dtFilter, "", "Shedule_Type desc", DataViewRowState.CurrentRows).ToTable();
            string CompanyName    = "";
            string CompanyAddress = "";
            string Imageurl       = "";

            DataTable DtCompany = objComp.GetCompanyMasterById(Session["CompId"].ToString());
            DataTable DtAddress = ObjAddress.GetAddressChildDataByAddTypeAndAddRefId("Company", Session["CompId"].ToString());
            if (DtCompany.Rows.Count > 0)
            {
                CompanyName = DtCompany.Rows[0]["Company_Name"].ToString();
                Imageurl    = "~/CompanyResource/" + Session["CompId"].ToString() + "/" + DtCompany.Rows[0]["Logo_Path"].ToString();
            }
            if (DtAddress.Rows.Count > 0)
            {
                CompanyAddress = DtAddress.Rows[0]["Address"].ToString();
            }
            RptShift.SetImage(Imageurl);
            RptShift.setTitleName("Leave Remaining Report");
            RptShift.setcompanyname(CompanyName);
            RptShift.setaddress(CompanyAddress);


            RptShift.DataSource     = dtFilter;
            RptShift.DataMember     = "sp_Att_Employee_Leave_Trans_Report";
            rptViewer.Report        = RptShift;
            rptToolBar.ReportViewer = rptViewer;
        }
    }