Beispiel #1
0
        private void btnCheckErrors_Click(object sender, EventArgs e)
        {
            DataTable dtEmpDetails = new DataTable("EmployeeTable");
            DataTable dtErrorsRpt  = new DataTable("ErrorTable");
            DataSet   dsErrorRpt   = new DataSet("ErrorTable");
            //dsDuplicateEPFNo = myReport2.GetDuplicateEPFNos();
            Boolean boolSuccess = true;
            //strPayrollDuplicates = myReport2.GetDuplicateEPFNosPayroll();
            //Error Report
            DataSet dsDivisionReport = new DataSet();

            //dtEmpDetails = empMaster.ListEmployeesDetails("%");

            dtEmpDetails = empMaster.ListEmployeesDetails("%");
            dsErrorRpt.Tables.Add(ValidateEmpMasterDetails(dtEmpDetails, true));

            //Report
            if (dsErrorRpt.Tables[0].Rows.Count > 0)
            {
                dsErrorRpt.WriteXml("EformErrors.xml");

                EformErrorsReportRPT objReport = new EformErrorsReportRPT();
                objReport.SetDataSource(dsErrorRpt);
                ReportViewerForm objReportViewer = new ReportViewerForm();

                objReport.SetParameterValue("Estate", EstDivBlock.ListEstates().Rows[0][0].ToString());
                objReport.SetParameterValue("CompanyName", FTSPayRollBL.Company.getCompanyName());
                objReportViewer.crystalReportViewer1.ReportSource = objReport;
                objReportViewer.Show();
            }
            else
            {
                MessageBox.Show("EFROM Employee Master Data Errors Not Found...!");
            }
        }
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            EformErrorsReportRPT rpt = new EformErrorsReportRPT();

            rpt.Site = this.Site;
            return(rpt);
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataSet   dsDuplicateEPFNo = new DataSet();
            DataSet   dsErroEmployerNo = new DataSet();
            DataTable dtEmpDetails     = new DataTable("EmployeeTable");
            DataTable dtErrorsRpt      = new DataTable("ErrorTable");
            DataSet   dsErrorRpt       = new DataSet("ErrorTable");
            //dsDuplicateEPFNo = myReport2.GetDuplicateEPFNos();
            //dsErroEmployerNo = myReport2.GetErrorEmployerNosInEmployeeMaster();
            Boolean boolSuccess               = true;
            String  strDupEntries             = "";
            String  strErrorEmployerNo        = "";
            String  strPayrollDuplicates      = "";
            String  strCheckrollDuplicates    = "";
            String  strEarningsEmployerErrors = "";

            //strPayrollDuplicates = myReport2.GetDuplicateEPFNosPayroll();
            strCheckrollDuplicates    = myReport2.GetDuplicateEPFNosCheckroll();
            strEarningsEmployerErrors = myReport2.GetEmpEarningsWithoutEmployerNo(Convert.ToInt32(cmbYear.Text), Convert.ToInt32(cmbMonth.SelectedValue.ToString()));

            //Error Report
            DataSet dsDivisionReport = new DataSet();

            //dtEmpDetails = empMaster.ListEmployeesDetails("%");
            dtEmpDetails = empMaster.ListEmployeesDetailsForEform("%", Convert.ToInt32(cmbYear.SelectedValue.ToString()), Convert.ToInt32(cmbMonth.SelectedValue.ToString()));
            dsErrorRpt.Tables.Add(ValidateEmpMasterDetails(dtEmpDetails, false));

            //Report
            if (dsErrorRpt.Tables[0].Rows.Count > 0)
            {
                MessageBox.Show("There Are Employee Master Data Errors");
                dsErrorRpt.WriteXml("EformErrors.xml");

                EformErrorsReportRPT objReport = new EformErrorsReportRPT();
                objReport.SetDataSource(dsErrorRpt);
                ReportViewerForm objReportViewer = new ReportViewerForm();

                objReport.SetParameterValue("Estate", EstDivBlock.ListEstates().Rows[0][0].ToString());
                objReport.SetParameterValue("CompanyName", FTSPayRollBL.Company.getCompanyName());
                objReportViewer.crystalReportViewer1.ReportSource = objReport;
                objReportViewer.Show();
            }
            else
            {
                if (strEarningsEmployerErrors.Length > 0)
                {
                    MessageBox.Show("Employer Numbers Of Following Employees Are Wrong, Please Correct Them And Re-generate \n" + strEarningsEmployerErrors, "Invalid Entries", MessageBoxButtons.OK);
                    boolSuccess = false;
                }
                //else if (strPayrollDuplicates.Length > 0)
                //{
                //    MessageBox.Show("Found Following Duplicate EPF Number(s) in Staff Payroll, Please Correct Them And Re-generate \n" + strPayrollDuplicates, "Invalid Entries", MessageBoxButtons.OK);
                //}
                else if (strCheckrollDuplicates.Length > 0)
                {
                    MessageBox.Show("Found Following Duplicate EPF Number(s) in Checkroll, Please Correct Them And Re-generate \n" + strCheckrollDuplicates, "Invalid Entries", MessageBoxButtons.OK);
                    boolSuccess = false;
                }
                //else if (dsDuplicateEPFNo.Tables[0].Rows.Count > 0)
                //{
                //    foreach (DataRow dtr in dsDuplicateEPFNo.Tables[0].Rows)
                //    {
                //        strDupEntries += "\n\n" +"Employer NO: "+ dtr[0].ToString() + " " +"EPF NO: "+ dtr[1].ToString();
                //    }
                //    MessageBox.Show("Found Following Duplicate EPF Number(s), Please Correct Them And Re-generate "+strDupEntries,"Invalid Entries",MessageBoxButtons.OK);
                //}
                //else if (dsErroEmployerNo.Tables[0].Rows.Count > 0)
                //{
                //    foreach (DataRow dtr1 in dsErroEmployerNo.Tables[0].Rows)
                //    {
                //        strErrorEmployerNo += "\n\n" + "Employer NO: " + dtr1[0].ToString() + " " + "DivisionID: " + dtr1[1].ToString() + " " + "EmpNo: " + dtr1[2].ToString() + " " + "EPFNO: " + dtr1[3].ToString();
                //    }
                //    //MessageBox.Show("Found Following Wrong Employer Number(s), Please Correct Them And Re-generate " + strErrorEmployerNo, "Invalid Entries", MessageBoxButtons.OK);
                //    if(strErrorEmployerNo.Length>100)
                //        MessageBox.Show("Found Following Wrong Employer Number(s), Please Correct Them And Re-generate " + strErrorEmployerNo.Substring(0, 100));
                //    else
                //        MessageBox.Show("Found Following Wrong Employer Number(s), Please Correct Them And Re-generate " + strErrorEmployerNo);
                //    boolSuccess = false;
                //}
                else if (dtEmpDetails.Rows.Count > 0)
                {
                    //employee details
                }
                if (!boolSuccess)
                {
                    MessageBox.Show("Create Failed");
                }
                else
                {
                    String  strContributionPeriod = cmbYear.Text.PadLeft(4, '0') + cmbMonth.SelectedValue.ToString().PadLeft(2, '0');
                    DataSet dsEVEMC = new DataSet();
                    try
                    {
                        //wRITE INTO THE EVEMC FILE
                        String DesktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\EForms\";

                        String dirPath    = DesktopPath;
                        String SDirectory = cmbYear.Text.PadLeft(4, '0') + cmbMonth.SelectedValue.ToString().PadLeft(2, '0') + FTSPayRollBL.User.StrEstate.ToString();
                        String filePath   = "";
                        String fileName   = "";
                        // Create a reference to a directory.
                        DirectoryInfo di           = new DirectoryInfo(dirPath);
                        DirectoryInfo SubDirectory = new DirectoryInfo(SDirectory);
                        DirectoryInfo SubDi        = new DirectoryInfo(dirPath + SDirectory);
                        // Create the directory only if it does not already exist.
                        if (di.Exists == false)
                        {
                        }
                        else if (SubDi.Exists == false)
                        {
                            SubDi.Create();
                        }
                        //else
                        //{
                        //    MessageBox.Show("Already Generated.\r\n If you want to Re-Generate \r\nPlease Delete The EForms Folder On Desktop And Re-Generate. ");
                        //}
                        if (SubDi.Exists == false)
                        {
                            di.Create();
                            DirectoryInfo dis = di.CreateSubdirectory(SDirectory);

                            fileName = "EVEMC";
                            filePath = dirPath + "\\" + SDirectory + "\\" + fileName + ".TXT";
                            if (File.Exists(filePath))
                            {
                                MessageBox.Show("Already Created");
                                //if (MessageBox.Show("Already Created, Do You Want To Replace", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                //{
                                //}
                            }
                            else
                            {
                                dsEVEMC = myReport2.GetEPF_EVEMC_Data(strContributionPeriod);
                                MessageBox.Show("EVEMC & EVEMP Files Generated Successfully!.");

                                foreach (DataRow dr2 in dsEVEMC.Tables[1].Rows)
                                {
                                    if (dr2.ItemArray[1].ToString() == "4543")
                                    {
                                        MessageBox.Show("error");
                                    }
                                    DataSet dsMC = new DataSet();
                                    dsMC     = myReport2.getEmployerWiseEVEMC(dr2.ItemArray[2].ToString(), dr2.ItemArray[1].ToString());
                                    filePath = dirPath + "\\" + SDirectory + "\\" + fileName + dr2.ItemArray[1].ToString() + ".TXT";
                                    if (File.Exists(filePath))
                                    {
                                        MessageBox.Show(fileName + "Already Created");
                                        //if (MessageBox.Show("Already Created, Do You Want To Replace", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                        //{
                                        //}
                                    }
                                    else
                                    {
                                        foreach (DataRow dr3 in dsMC.Tables[0].Rows)
                                        {
                                            String strLine = "";
                                            //strLine = dr3.ItemArray[0].ToString().PadLeft(1, ' ') + dr3.ItemArray[1].ToString().PadLeft(6, '0') + dr3.ItemArray[2].ToString().PadLeft(6, '0') + dr3.ItemArray[3].ToString().PadLeft(2, '0') + Convert.ToDecimal(dr3.ItemArray[4].ToString()).ToString("F2").PadLeft(12, '0') + dr3.ItemArray[5].ToString().PadLeft(5, '0') + dr3.ItemArray[6].ToString().PadLeft(1, ' ') + "70831150000010054204".PadRight(20, ' ') + dr3.ItemArray[8].ToString().PadLeft(10, ' ') + dr3.ItemArray[9].ToString().PadLeft(2, '0');
                                            //strLine = dr3.ItemArray[0].ToString().PadRight(20, ' ') + dr3.ItemArray[1].ToString().PadRight(40, ' ') + dr3.ItemArray[2].ToString().PadRight(20, ' ') + dr3.ItemArray[3].ToString().PadLeft(6, '0') + Convert.ToDecimal(dr3[4].ToString()).ToString("F2").PadLeft(10, '0') + Convert.ToDecimal(dr3.ItemArray[5].ToString()).ToString("F2").PadLeft(10, '0') + Convert.ToDecimal(dr3.ItemArray[6].ToString()).ToString("F2").PadLeft(10, '0') + Convert.ToDecimal(dr3.ItemArray[7].ToString()).ToString("F2").PadLeft(10, '0') + dr3.ItemArray[8].ToString().PadLeft(1, 'E') + dr3.ItemArray[9].ToString().PadLeft(1, ' ') + dr3.ItemArray[10].ToString().PadLeft(6, '0') + dr3.ItemArray[11].ToString().PadLeft(6, ' ') + dr3.ItemArray[12].ToString().PadLeft(2, '0') + dr3.ItemArray[13].ToString().PadLeft(5, '0') + dr3.ItemArray[14].ToString().PadLeft(3, '0') + dr3.ItemArray[15].ToString().PadLeft(2, '0');
                                            if (FTSPayRollBL.Company.getCompanyCode().ToUpper().Equals("BPL"))
                                            {
                                                strLine = dr3.ItemArray[0].ToString().PadRight(20, ' ') + dr3.ItemArray[1].ToString().PadRight(40, ' ') + dr3.ItemArray[2].ToString().PadRight(20, ' ') + dr3.ItemArray[3].ToString().PadLeft(6, '0') + Convert.ToDecimal(dr3[4].ToString()).ToString("F2").PadLeft(10, '0') + Convert.ToDecimal(dr3.ItemArray[5].ToString()).ToString("F2").PadLeft(10, '0') + Convert.ToDecimal(dr3.ItemArray[6].ToString()).ToString("F2").PadLeft(10, '0') + Convert.ToDecimal(dr3.ItemArray[7].ToString()).ToString("F2").PadLeft(12, '0') + dr3.ItemArray[8].ToString().PadLeft(1, 'E') + dr3.ItemArray[9].ToString().PadRight(1, ' ') + dr3.ItemArray[10].ToString().PadLeft(6, '0') + dr3.ItemArray[11].ToString().PadLeft(6, ' ') + dr3.ItemArray[12].ToString().PadLeft(2, ' ') + Convert.ToDecimal(dr3.ItemArray[13].ToString()).ToString().PadLeft(5, '0') + dr3.ItemArray[14].ToString().PadLeft(3, ' ');
                                            }
                                            else
                                            {
                                                strLine = dr3.ItemArray[0].ToString().PadRight(20, ' ') + dr3.ItemArray[1].ToString().PadRight(40, ' ') + dr3.ItemArray[2].ToString().PadRight(20, ' ') + dr3.ItemArray[3].ToString().PadLeft(6, ' ') + Convert.ToDecimal(dr3[4].ToString()).ToString("F2").PadLeft(10, ' ') + Convert.ToDecimal(dr3.ItemArray[5].ToString()).ToString("F2").PadLeft(10, ' ') + Convert.ToDecimal(dr3.ItemArray[6].ToString()).ToString("F2").PadLeft(10, ' ') + Convert.ToDecimal(dr3.ItemArray[7].ToString()).ToString("F2").PadLeft(12, ' ') + dr3.ItemArray[8].ToString().PadLeft(1, 'E') + dr3.ItemArray[9].ToString().PadRight(2, ' ') + dr3.ItemArray[10].ToString().PadLeft(5, '0') + dr3.ItemArray[11].ToString().PadLeft(6, ' ') + dr3.ItemArray[12].ToString().PadLeft(2, ' ') + Convert.ToDecimal(dr3.ItemArray[13].ToString()).ToString().PadLeft(5, ' ') + dr3.ItemArray[14].ToString().PadLeft(3, ' ');
                                            }
                                            try
                                            {
                                                using (System.IO.StreamWriter writer = new StreamWriter(filePath, true))
                                                {
                                                    writer.WriteLine(strLine);
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                MessageBox.Show("Error, " + ex.Message);
                                            }
                                        }
                                    }
                                }
                                //WRITE ON EVEMP
                                filePath = "";
                                fileName = "";
                                fileName = "EVEMP";
                                filePath = dirPath + "\\" + SDirectory + "\\" + fileName + ".TXT";
                                if (File.Exists(filePath))
                                {
                                    MessageBox.Show(fileName + "Alredy Created");
                                    //if (MessageBox.Show("Already Created, Do You Want To Replace", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.Yes)
                                    //{
                                    //}
                                }
                                else
                                {
                                    foreach (DataRow dr1 in dsEVEMC.Tables[1].Rows)
                                    {
                                        String strLine = "";
                                        strLine = dr1.ItemArray[0].ToString().PadLeft(1, ' ') + dr1.ItemArray[1].ToString().PadLeft(6, ' ') + dr1.ItemArray[2].ToString().PadLeft(6, '0') + dr1.ItemArray[3].ToString().PadLeft(2, '0') + Convert.ToDecimal(dr1.ItemArray[4].ToString()).ToString("F2").PadLeft(12, '0') + dr1.ItemArray[5].ToString().PadLeft(5, '0') + dr1.ItemArray[6].ToString().PadLeft(1, ' ') + "70831150000010054204".PadRight(20, ' ') + dr1.ItemArray[8].ToString().PadLeft(10, ' ') + dr1.ItemArray[9].ToString().PadLeft(2, '0');
                                        try
                                        {
                                            using (System.IO.StreamWriter writer = new StreamWriter(filePath, true))
                                            {
                                                writer.WriteLine(strLine);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            MessageBox.Show("Error, " + ex.Message);
                                        }
                                    }
                                }
                            }
                            //

                            MessageBox.Show("EVEMC & EVEMP Files Generated Successfully!.");
                        }
                        else
                        {
                            MessageBox.Show("Already Generated.\r\n If you want to Re-Generate \r\nPlease Delete The EForms Folder On Desktop And Re-Generate. ");
                        }
                    }
                    catch { }
                }
            }
        }