/// <summary>
        /// Tax -Adds a employer quarter data in agent list to create file
        /// </summary>
        /// <returns></returns>
        public ArrayList AddEmployerToAgentList()
        {
            ArrayList larrResult = new ArrayList();

            ValidateForm();
            iclbAgentData = new Collection <busWageFileGeneratorEmployerData>();
            busWageFileGeneratorEmployerData lbusWageFileGeneratorEmployerData = new busWageFileGeneratorEmployerData();
            busAgentFileDataItems            lbusAgentFileDataItem             = iclbAgentFileData.Pop();

            lbusWageFileGeneratorEmployerData.istrEAN  = lbusAgentFileDataItem.istrEAN;
            lbusWageFileGeneratorEmployerData.istrFEIN = lbusAgentFileDataItem.istrFEIN;
            int.TryParse(lbusAgentFileDataItem.istrReportQuarter, out iintQuarter);
            lbusWageFileGeneratorEmployerData.iintReportQuarter = iintQuarter;
            int.TryParse(lbusAgentFileDataItem.istrReportYear, out iintYear);
            lbusWageFileGeneratorEmployerData.iintReportYear = iintYear;
            int.TryParse(lbusAgentFileDataItem.istrSSNCounts, out iintSSNCounts);
            lbusWageFileGeneratorEmployerData.iintSSNCounts    = iintSSNCounts;
            lbusWageFileGeneratorEmployerData.istrEmployerName = istrEmployerAgentName;
            iclbAgentData.Add(lbusWageFileGeneratorEmployerData);
            istrReportYear = istrReportQuarter = istrSSNCount = iintEAN = istrFEIN = string.Empty;
            return(larrResult);
        }
Beispiel #2
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            string[] strArr;
            InitiliazeDataConnection();
            connection.Open();
            objWageFileGenerator.iclbAgentFileData = new Stack <busAgentFileDataItems>();
            int i = 0, j = 0;

            // 1. Check if file is present and is not empty
            foreach (string line in File.ReadLines(FName))
            {
                if (i == 0)
                {
                    strArr = line.Split(',');
                    // 2. Check if first element matches one of the predefined file types
                    // 3. Check if second element matches one of the predefined user types (employer/agent)
                    objWageFileGenerator.istrFileType = strArr[0].ToUpper();
                    objWageFileGenerator.istrUserType = strArr[1].ToLower();
                    Array.Clear(strArr, 0, strArr.Length);
                    i++;
                }
                else if (objWageFileGenerator.istrUserType == "employer")
                {
                    // 4. Validate all the data.
                    strArr = line.Split(',');
                    objWageFileGenerator.iintEAN           = strArr[0];
                    objWageFileGenerator.istrFEIN          = strArr[1];
                    objWageFileGenerator.istrReportQuarter = strArr[2];
                    objWageFileGenerator.istrReportYear    = strArr[3];
                    objWageFileGenerator.istrSSNCount      = strArr[4];
                    dataExist = true;
                    using (SqlCommand command = new SqlCommand(
                               "select  employer_account_id, fein " +
                               "from sgt_employer where employer_account_id = @ean", connection))
                    {
                        //connection.Open();
                        command.Parameters.Add(new SqlParameter("ean", objWageFileGenerator.iintEAN));
                        reader = command.ExecuteReader();
                        if (reader.HasRows)
                        {
                            while (reader.Read())
                            {
                                if ((reader.GetInt32(0) != Int32.Parse(objWageFileGenerator.iintEAN)) || (reader.GetString(1) != objWageFileGenerator.istrFEIN))
                                {
                                    MessageBox.Show(objWageFileGenerator.iintEAN + " does not exist in the database");
                                    dataExist = false;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show(objWageFileGenerator.iintEAN + " does not exist in the database");
                            dataExist = false;
                        }
                        reader.Close();
                    }
                    if (dataExist == true)
                    {
                        objWageFileGenerator.GenerateFile();
                        Thread.Sleep(2000);

                        Array.Clear(strArr, 0, strArr.Length);
                    }
                    else
                    {
                        dataExist = true;
                    }
                }
                else if (objWageFileGenerator.istrUserType == "agent")
                {
                    if (j == 0)
                    {
                        strArr = line.Split(',');
                        objWageFileGenerator.istrAgentFEIN = strArr[0];
                        objWageFileGenerator.istrEANCount  = strArr[1];
                        Int32.TryParse(objWageFileGenerator.istrEANCount, out j);
                    }
                    else if (j > 0)
                    {
                        objAgentFileDataItems = new busAgentFileDataItems();
                        strArr = line.Split(',');
                        objAgentFileDataItems.istrEAN           = strArr[0];
                        objAgentFileDataItems.istrReportQuarter = strArr[1];
                        objAgentFileDataItems.istrReportYear    = strArr[2];
                        objAgentFileDataItems.istrSSNCounts     = strArr[3];
                        objWageFileGenerator.iclbAgentFileData.Push(objAgentFileDataItems);
                        Array.Clear(strArr, 0, strArr.Length);
                        if (j == 1)
                        {
                            objWageFileGenerator.GenerateFile();
                            Thread.Sleep(2000);
                        }
                        j--;
                    }
                }
            }
            MessageBox.Show("Done");
            connection.Close();
        }