Пример #1
0
    void GetReport()
    {
        DataTable dt = new DataTable();

        dt.Columns.Add("Company_Name");
        dt.Columns.Add("Image");
        dt.Columns.Add("Month");
        dt.Columns.Add("Year");
        dt.Columns.Add("Emp_Id");
        dt.Columns.Add("Emp_Name");
        dt.Columns.Add("Claim_Name");
        dt.Columns.Add("Claim_Amount");
        dt.Columns.Add("Sum_Claim");

        string Id        = (string)Session["Querystring"];
        int    ClaimType = (int)Session["ClaimType"];
        double SumClaim  = 0;

        foreach (string str in Id.Split(','))
        {
            if (str != "")
            {
                DataTable dtClaimRecod = (DataTable)Session["ClaimRecord"];
                dtClaimRecod = new DataView(dtClaimRecod, "Emp_Id=" + str + "", "", DataViewRowState.CurrentRows).ToTable();
                if (dtClaimRecod.Rows.Count > 0)
                {
                    DataTable dtsalary = ObjSalary.GetEmployeeParameterByEmpId(str, Session["CompId"].ToString());
                    string[]  Montharr = new string[12];


                    Montharr[0]  = "January";
                    Montharr[1]  = "February";
                    Montharr[2]  = "March";
                    Montharr[3]  = "April";
                    Montharr[4]  = "May";
                    Montharr[5]  = "June";
                    Montharr[6]  = "July";
                    Montharr[7]  = "August";
                    Montharr[8]  = "September";
                    Montharr[9]  = "October";
                    Montharr[10] = "November";
                    Montharr[11] = "December";
                    for (int i = 0; i < dtClaimRecod.Rows.Count; i++)
                    {
                        string salary = string.Empty;
                        if (dtsalary.Rows.Count > 0)
                        {
                            salary = dtsalary.Rows[0]["Basic_Salary"].ToString();
                        }
                        string Claimamount = string.Empty;
                        if (dtClaimRecod.Rows[i]["Value_Type"].ToString() == "2")
                        {
                            string value = dtClaimRecod.Rows[i]["Value"].ToString();
                            Claimamount = (float.Parse(salary) * float.Parse(value) / 100).ToString("0.000");
                        }
                        else
                        {
                            Claimamount = Convert.ToDouble(dtClaimRecod.Rows[i]["Value"]).ToString("0.000");
                        }

                        int Month = Convert.ToInt32(dtClaimRecod.Rows[i]["Claim_Month"]);

                        DataRow dr = dt.NewRow();
                        dr[0]     = "";
                        dr[1]     = "";
                        dr[2]     = Montharr[Month - 1].ToString();
                        dr[3]     = dtClaimRecod.Rows[i]["Claim_Year"].ToString();
                        dr[4]     = dtClaimRecod.Rows[i]["Emp_Id"].ToString();
                        dr[5]     = dtClaimRecod.Rows[i]["Emp_Name"].ToString();
                        dr[6]     = dtClaimRecod.Rows[i]["Claim_Name"].ToString();
                        dr[7]     = Claimamount;
                        SumClaim += double.Parse(Claimamount);

                        dr[8] = SumClaim.ToString("0.000");



                        //dr[7] = System.Math.Round(Claimamount, 3);
                        dt.Rows.Add(dr);
                    }
                }
            }
        }



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

        DataTable DtCompany = Objcompany.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();
        }

        Objreport.SetImage(Imageurl);
        Objreport.SetCompanyName(CompanyName);
        Objreport.SetAddress(CompanyAddress);
        Objreport.setSumClaimAmount(SumClaim);
        if (ClaimType == 1)
        {
            Objreport.setTitleName("Claim Approved Report");
        }
        if (ClaimType == 2)
        {
            Objreport.setTitleName("Claim Cancelled Report");
        }
        if (ClaimType == 3)
        {
            Objreport.setTitleName("Claim Pending Report");
        }

        Objreport.DataSource        = dt;
        Objreport.DataMember        = "EmployeeClaim";
        ReportViewer1.Report        = Objreport;
        ReportToolbar1.ReportViewer = ReportViewer1;
    }
    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;
            }
        }
    }
Пример #3
0
    void GetReport()
    {
        DataTable dt = new DataTable();

        dt.Columns.Add("EmpId");
        dt.Columns.Add("EmpName");
        dt.Columns.Add("Penalty_Name");
        dt.Columns.Add("Penalty_Value");
        dt.Columns.Add("Penalty_Date");

        dt.Columns.Add("Month");
        dt.Columns.Add("Year");


        string Id = (string)Session["Querystring"];
        //int ClaimType = (int)Session["ClaimType"];
        double Penaltysum = 0;

        foreach (string str in Id.Split(','))
        {
            if (str != "")
            {
                DataTable dtClaimRecod = (DataTable)Session["ClaimRecord"];
                dtClaimRecod = new DataView(dtClaimRecod, "Emp_Id=" + str + "", "", DataViewRowState.CurrentRows).ToTable();
                if (dtClaimRecod.Rows.Count > 0)
                {
                    DataTable dtsalary = ObjSalary.GetEmployeeParameterByEmpId(str, Session["CompId"].ToString());
                    string[]  Montharr = new string[12];


                    Montharr[0]  = "January";
                    Montharr[1]  = "February";
                    Montharr[2]  = "March";
                    Montharr[3]  = "April";
                    Montharr[4]  = "May";
                    Montharr[5]  = "June";
                    Montharr[6]  = "July";
                    Montharr[7]  = "August";
                    Montharr[8]  = "September";
                    Montharr[9]  = "October";
                    Montharr[10] = "November";
                    Montharr[11] = "December";
                    double salary = 0;
                    for (int i = 0; i < dtClaimRecod.Rows.Count; i++)
                    {
                        if (dtsalary.Rows.Count > 0)
                        {
                            salary = Convert.ToDouble(dtsalary.Rows[0]["Basic_Salary"]);
                        }
                        double Claimamount = 0;
                        if (dtClaimRecod.Rows[i]["Value_Type"].ToString() == "2")
                        {
                            int value = Convert.ToInt32(dtClaimRecod.Rows[i]["Value"]);
                            Claimamount = salary * value / 100;
                        }
                        else
                        {
                            Claimamount = Convert.ToDouble(dtClaimRecod.Rows[i]["Value"].ToString());
                        }

                        int Month = Convert.ToInt32(dtClaimRecod.Rows[i]["Penalty_Month"]);

                        DataRow dr = dt.NewRow();
                        dr[0]       = dtClaimRecod.Rows[i]["Emp_Id"].ToString();
                        dr[1]       = dtClaimRecod.Rows[i]["Emp_Name"].ToString();
                        dr[2]       = dtClaimRecod.Rows[i]["Penalty_Name"].ToString();
                        dr[3]       = Claimamount.ToString("0.000");
                        dr[4]       = dtClaimRecod.Rows[i]["Penalty_Date"].ToString();
                        dr[5]       = Montharr[Month - 1].ToString();
                        dr[6]       = dtClaimRecod.Rows[i]["Penalty_Year"].ToString();
                        Penaltysum += Claimamount;

                        dt.Rows.Add(dr);
                    }
                }
            }
        }
        string CompanyName    = "";
        string CompanyAddress = "";
        string Imageurl       = "";

        DataTable DtCompany = Objcompany.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();
        }
        objReport.SetImage(Imageurl);
        objReport.setTitleName("Employee Penalty Report");
        objReport.SetCompanyName(CompanyName);
        objReport.SetAddress(CompanyAddress);
        objReport.setSum(Penaltysum);


        objReport.DataSource        = dt;
        objReport.DataMember        = "EmpPenalty";
        ReportViewer1.Report        = objReport;
        ReportToolbar1.ReportViewer = ReportViewer1;
    }