Ejemplo n.º 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the t_Bank_data EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTot_Bank_data(t_Bank_data t_Bank_data)
 {
     base.AddObject("t_Bank_data", t_Bank_data);
 }
Ejemplo n.º 2
0
        private void verify_xls()
        {
            Boolean error = false;
            Boolean emptyfound = false;
            /* EMPTY THE LIST */
            insList = new List<t_Insurance_data>();
            bankList = new List<t_Bank_data>();
            int rowEmptyBank=-1;
            int colEmptyBank=-1;

            int rowEmptyInsurance = -1;
            int colEmptyInsurance = -1;

            /* BANK DATA */
            string x="";
            try
            {

                InitializeWorkbook(txtBank.Text);

                ISheet sheet = hssfworkbook.GetSheetAt(0);
                System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
                rows.MoveNext();
                while (rows.MoveNext())
                {
                    t_Bank_data objBank = new t_Bank_data();
                    IRow row = (HSSFRow)rows.Current;

                    for (int i = 0; i < row.LastCellNum; i++)
                    {
                        ICell cell = row.GetCell(i);
                        if (cell == null && rowEmptyInsurance == -1 && (i != 2 && i != 5 && i != 6 && i != 7 && i != 8 && i != 12 && i != 13 && i != 14 && i != 15))
                        {
                            emptyfound = true;
                            rowEmptyBank = row.RowNum + 1;
                            colEmptyBank = i + 1;
                            return;
                        }
                        else
                        {
                            if (Convert.ToString(cell) == "" && rowEmptyBank == -1 && (i != 2 && i != 5 && i != 6 && i != 7 && i != 8 && i != 12 && i != 13 && i != 14 && i != 15))
                            {
                                emptyfound = true;
                                rowEmptyBank = row.RowNum + 1;
                                colEmptyBank = i + 1;
                            }
                            else
                            {
                                if (i == 0)
                                {
                                    objBank.bank_ref_number = Convert.ToString(cell);
                                }
                                if (i == 1)
                                {
                                    objBank.nric = Convert.ToString(cell);
                                }
                                if (i == 2)
                                {
                                    objBank.old_ic = Convert.ToString(cell);
                                }
                                if (i == 3)
                                {
                                    objBank.participant_name = Convert.ToString(cell);
                                }
                                if (i == 4)
                                {
                                    objBank.customer_address_1 = Convert.ToString(cell);
                                }
                                if (i == 5)
                                {
                                    objBank.customer_address_2 = Convert.ToString(cell);
                                }
                                if (i == 6)
                                {
                                    objBank.customer_address_3 = Convert.ToString(cell);
                                }
                                if (i == 7)
                                {
                                    objBank.customer_address_4 = Convert.ToString(cell);
                                }
                                if (i == 8)
                                {
                                    objBank.customer_address_5 = Convert.ToString(cell);
                                }
                                if (i == 9)
                                {
                                    objBank.customer_post_code = Convert.ToString(cell);
                                }
                                if (i == 10)
                                {
                                    objBank.property_type = Convert.ToString(cell);
                                }
                                if (i == 11)
                                {
                                    objBank.property_address = Convert.ToString(cell);
                                }
                                if (i == 12)
                                {
                                    objBank.property_address_1 = Convert.ToString(cell);
                                }
                                if (i == 13)
                                {
                                    objBank.property_address_2 = Convert.ToString(cell);
                                }
                                if (i == 14)
                                {
                                    objBank.property_address_3 = Convert.ToString(cell);
                                }
                                if (i == 15)
                                {
                                    objBank.property_address_4 = Convert.ToString(cell);
                                }
                                if (i == 16)
                                {
                                    objBank.property_post_code = Convert.ToString(cell);
                                }
                                if (i == 17)
                                {
                                    objBank.risk_type = Convert.ToString(cell);
                                }
                                if (i == 18)
                                {
                                    objBank.policy_effective_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                }
                                if (i == 19)
                                {
                                    objBank.policy_expired_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                }
                                if (i == 20)
                                {
                                    objBank.sum_covered = (Convert.ToString(cell) == "") ? Convert.ToDecimal("0") : Convert.ToDecimal(Convert.ToString(cell));
                                }
                                if (i == 21)
                                {
                                    objBank.policy_no = Convert.ToString(cell);
                                }
                            }
                        }

                    }
                    bankList.Add(objBank);
                }

                /*EOF BANK DATA*/

            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("2007") > 0)
                {
                    try
                    {
                        InitializeWorkbook2(txtBank.Text);

                        ISheet sheet = xssfworkbook.GetSheetAt(0);
                        System.Collections.IEnumerator rows = sheet.GetRowEnumerator();
                        rows.MoveNext();
                        while (rows.MoveNext())
                        {
                            t_Bank_data objBank = new t_Bank_data();
                            IRow row = (XSSFRow)rows.Current;

                            for (int i = 0; i < row.LastCellNum; i++)
                            {
                                ICell cell = row.GetCell(i);
                                if (cell == null && rowEmptyInsurance == -1 && (i != 2 && i != 5 && i != 6 && i != 7 && i != 8 && i != 12 && i != 13 && i != 14 && i != 15))
                                {
                                    emptyfound = true;
                                    rowEmptyBank = row.RowNum + 1;
                                    colEmptyBank = i + 1;
                                    return;
                                }
                                else
                                {
                                    if (Convert.ToString(cell) == "" && rowEmptyBank == -1 && (i != 2 && i != 5 && i != 6 && i != 7 && i != 8 && i != 12 && i != 13 && i != 14 && i != 15))
                                    {
                                        emptyfound = true;
                                        rowEmptyBank = row.RowNum + 1;
                                        colEmptyBank = i + 1;
                                    }
                                    else
                                    {
                                        if (i == 0)
                                        {
                                            objBank.bank_ref_number = Convert.ToString(cell);
                                        }
                                        if (i == 1)
                                        {
                                            objBank.nric = Convert.ToString(cell);
                                        }
                                        if (i == 2)
                                        {
                                            objBank.old_ic = Convert.ToString(cell);
                                        }
                                        if (i == 3)
                                        {
                                            objBank.participant_name = Convert.ToString(cell);
                                        }
                                        if (i == 4)
                                        {
                                            objBank.customer_address_1 = Convert.ToString(cell);
                                        }
                                        if (i == 5)
                                        {
                                            objBank.customer_address_2 = Convert.ToString(cell);
                                        }
                                        if (i == 6)
                                        {
                                            objBank.customer_address_3 = Convert.ToString(cell);
                                        }
                                        if (i == 7)
                                        {
                                            objBank.customer_address_4 = Convert.ToString(cell);
                                        }
                                        if (i == 8)
                                        {
                                            objBank.customer_address_5 = Convert.ToString(cell);
                                        }
                                        if (i == 9)
                                        {
                                            objBank.customer_post_code = Convert.ToString(cell);
                                        }
                                        if (i == 10)
                                        {
                                            objBank.property_type = Convert.ToString(cell);
                                        }
                                        if (i == 11)
                                        {
                                            objBank.property_address = Convert.ToString(cell);
                                        }
                                        if (i == 12)
                                        {
                                            objBank.property_address_1 = Convert.ToString(cell);
                                        }
                                        if (i == 13)
                                        {
                                            objBank.property_address_2 = Convert.ToString(cell);
                                        }
                                        if (i == 14)
                                        {
                                            objBank.property_address_3 = Convert.ToString(cell);
                                        }
                                        if (i == 15)
                                        {
                                            objBank.property_address_4 = Convert.ToString(cell);
                                        }
                                        if (i == 16)
                                        {
                                            objBank.property_post_code = Convert.ToString(cell);
                                        }
                                        if (i == 17)
                                        {
                                            objBank.risk_type = Convert.ToString(cell);
                                        }
                                        if (i == 18)
                                        {
                                            objBank.policy_effective_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                        }
                                        if (i == 19)
                                        {
                                            objBank.policy_expired_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                        }
                                        if (i == 20)
                                        {
                                            objBank.sum_covered = (Convert.ToString(cell) == "") ? Convert.ToDecimal("0") : Convert.ToDecimal(Convert.ToString(cell));
                                        }
                                        if (i == 21)
                                        {
                                            objBank.policy_no = Convert.ToString(cell);
                                        }
                                    }
                                }

                            }
                            bankList.Add(objBank);
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                        error = true;
                    }
                }
                else
                {
                    MessageBox.Show(ex.Message);
                    error = true;
                }
            }

            /* INSURANCE DATA */

            try
            {

                InitializeWorkbook(txtInsurance.Text);

                ISheet sheet = hssfworkbook.GetSheetAt(0);
                System.Collections.IEnumerator rows = sheet.GetRowEnumerator();

                /*GO TO ROW 3*/
            //                rows.MoveNext();
            //                rows.MoveNext();
                rows.MoveNext();

                while (rows.MoveNext())
                {
                    t_Insurance_data objIns = new t_Insurance_data();
                    IRow row = (HSSFRow)rows.Current;

                    for (int i = 0; i < row.LastCellNum; i++)
                    {
                        ICell cell = row.GetCell(i);
                        if (cell == null && rowEmptyInsurance == -1 && (i != 2 && i != 9 && i != 10 && i != 11 && i != 12 && i != 13 && i != 14 && i != 15 && i != 16 && i != 17 && i != 18 && i != 19 && i != 20 && i != 21 && i != 22 && i != 23 && i != 24 && i != 25 && i != 26 && i != 28 && i != 29 && i != 30 && i != 34 && i != 35 && i != 38 && i != 39 && i != 40 && i != 41 && i != 26 && i != 47 && i != 48 && i != 51 && i != 53 && i != 58))
                        {

                            emptyfound = true;
                            rowEmptyInsurance = row.RowNum + 1;
                            colEmptyInsurance = i + 1;
                            return;
                        }
                        else
                        {
                            if (Convert.ToString(cell) == "" && rowEmptyInsurance == -1 && (i != 2 && i != 9 && i != 10 && i != 11 && i != 12 && i != 13 && i != 14 && i != 15 && i != 16 && i != 17 && i != 18 && i != 19 && i != 20 && i != 21 && i != 22 && i != 23 && i != 24 && i != 25 && i != 26 && i != 28 && i != 29 && i != 30 && i != 34 && i != 35 && i != 38 && i != 39 && i != 40 && i != 41 && i != 26 && i != 47 && i != 48 && i != 51 && i != 53 && i != 58))
                            {
                                emptyfound = true;
                                rowEmptyInsurance = row.RowNum + 1;
                                colEmptyInsurance = i + 1;
                            }
                            else
                            {
                                if (i == 0)
                                {
                                    objIns.ic_breg_no = Convert.ToString(cell);
                                }
                                if (i == 1)
                                {
                                    objIns.customer_name = Convert.ToString(cell);
                                }
                                if (i == 2)
                                {
                                    objIns.bank_staff = Convert.ToString(cell);
                                }
                                if (i == 3)
                                {
                                    objIns.address_1 = Convert.ToString(cell);
                                }
                                if (i == 4)
                                {
                                    objIns.address_2 = Convert.ToString(cell);
                                }
                                if (i == 5)
                                {
                                    objIns.address_3 = Convert.ToString(cell);
                                }
                                if (i == 6)
                                {
                                    objIns.post_code = Convert.ToString(cell);
                                }
                                if (i == 7)
                                {
                                    objIns.city = Convert.ToString(cell);
                                }
                                if (i == 8)
                                {
                                    objIns.account_no = Convert.ToString(cell);
                                }
                                if (i == 9)
                                {
                                    objIns.triton_account_no = Convert.ToString(cell);
                                }
                                if (i == 10)
                                {
                                    objIns.branch_code = Convert.ToString(cell);
                                }
                                if (i == 11)
                                {
                                    objIns.facility_type = Convert.ToString(cell);
                                }
                                if (i == 12)
                                {
                                    objIns.approved_limit = Convert.ToString(cell);
                                }
                                if (i == 13)
                                {
                                    objIns.approved_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                }
                                if (i == 14)
                                {
                                    objIns.balance_outstanding = Convert.ToString(cell);
                                }
                                if (i == 15)
                                {
                                    objIns.cost_outstanding = Convert.ToString(cell);
                                }
                                if (i == 16)
                                {
                                    objIns.principal_outstanding = Convert.ToString(cell);
                                }
                                if (i == 17)
                                {
                                    objIns.uei_outstanding = Convert.ToString(cell);
                                }
                                if (i == 18)
                                {
                                    objIns.month_arrears = Convert.ToString(cell);
                                }
                                if (i == 19)
                                {
                                    objIns.credit_status = Convert.ToString(cell);
                                }
                                if (i == 20)
                                {
                                    objIns.credit_stat_change_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                }
                                if (i == 21)
                                {
                                    objIns.npf_status = Convert.ToString(cell);
                                }
                                if (i == 22)
                                {
                                    objIns.income_arrears = Convert.ToString(cell);
                                }
                                if (i == 23)
                                {
                                    objIns.curr_balance_outstanding = Convert.ToString(cell);
                                }
                                if (i == 24)
                                {
                                    objIns.collateral_ref_number = Convert.ToString(cell);
                                }
                                if (i == 25)
                                {
                                    objIns.claim_type = Convert.ToString(cell);
                                }
                                if (i == 26)
                                {
                                    objIns.property_type = Convert.ToString(cell);
                                }
                                if (i == 27)
                                {
                                    objIns.credit_status = Convert.ToString(cell);
                                }
                                if (i == 28)
                                {
                                    objIns.title_no = Convert.ToString(cell);
                                }
                                if (i == 29)
                                {
                                    objIns.land_office = Convert.ToString(cell);
                                }
                                if (i == 30)
                                {
                                    objIns.lot_number = Convert.ToString(cell);
                                }
                                if (i == 31)
                                {
                                    objIns.property_address_1= Convert.ToString(cell);
                                }
                                if (i == 32)
                                {
                                    objIns.property_address_2 = Convert.ToString(cell);
                                }
                                if (i == 33)
                                {
                                    objIns.property_address_3 = Convert.ToString(cell);
                                }
                                if (i == 34)
                                {
                                    objIns.property_district = Convert.ToString(cell);
                                }
                                if (i == 35)
                                {
                                    objIns.mukim = Convert.ToString(cell);
                                }
                                if (i == 36)
                                {
                                    objIns.property_city = Convert.ToString(cell);
                                }
                                if (i == 37)
                                {
                                    objIns.property_post_code = Convert.ToString(cell);
                                }
                                if (i == 38)
                                {
                                    objIns.security_value = Convert.ToString(cell);
                                }
                                if (i == 39)
                                {
                                    objIns.property_desc= Convert.ToString(cell);
                                }
                                if (i == 40)
                                {
                                    objIns.property_owner_1 = Convert.ToString(cell);
                                }
                                if (i == 41)
                                {
                                    objIns.property_owner_2 = Convert.ToString(cell);
                                }
                                if (i == 42)
                                {
                                    objIns.insurance_company = Convert.ToString(cell);
                                }
                                if (i == 43)
                                {
                                    objIns.policy_no = Convert.ToString(cell);
                                }
                                if (i == 44)
                                {
                                    objIns.insurance_type = Convert.ToString(cell);
                                }
                                if (i == 45)
                                {
                                    objIns.coverage_type = Convert.ToString(cell);
                                }
                                if (i == 46)
                                {
                                    objIns.participant_name = Convert.ToString(cell);
                                }
                                if (i == 47)
                                {
                                    objIns.risk_address_1 = Convert.ToString(cell);
                                }
                                if (i == 48)
                                {
                                    objIns.risk_address_2 = Convert.ToString(cell);
                                }
                                if (i == 49)
                                {
                                    objIns.risk_address_3 = Convert.ToString(cell);
                                }
                                if (i == 50)
                                {
                                    objIns.risk_post_code = Convert.ToString(cell);
                                }
                                if (i == 51)
                                {
                                    objIns.risk_city = Convert.ToString(cell);
                                }
                                if (i == 52)
                                {
                                    objIns.risk_state_code = Convert.ToString(cell);
                                }
                                if (i == 53)
                                {
                                    objIns.risk_country_code = Convert.ToString(cell);
                                }
                                if (i == 54)
                                {
                                    objIns.start_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                }
                                if (i == 55)
                                {
                                    objIns.end_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                }
                                if (i == 56)
                                {
                                    objIns.premium_amt = Convert.ToString(cell);
                                }
                                if (i == 57)
                                {
                                    objIns.sum_insured_amt = Convert.ToString(cell);
                                }
                                if (i == 58)
                                {
                                    objIns.insurance_last_modified_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                }

                            }
                        }

                    }
                    insList.Add(objIns);
                }

            }
            catch (Exception e)
            {
                if (e.Message.IndexOf("2007") > 0)
                {
                    try
                    {
                        InitializeWorkbook2(txtInsurance.Text);

                        ISheet sheet = xssfworkbook.GetSheetAt(0);
                        System.Collections.IEnumerator rows = sheet.GetRowEnumerator();

                        int rowcount = sheet.LastRowNum;
                        /*GO TO ROW 2*/
                        //rows.MoveNext();
                        //rows.MoveNext();
                        rows.MoveNext();
            //                        MessageBox.Show(rowcount.ToString());
                        while (rows.MoveNext())
                        {
                            t_Insurance_data objIns = new t_Insurance_data();
                            IRow row = (XSSFRow)rows.Current;

                            for (int i = 0; i < row.LastCellNum; i++)
                            {
                                ICell cell = row.GetCell(i);
                                if (cell == null && rowEmptyInsurance == -1 && i != 2 && i != 9 && i != 10 && i != 11 && i != 12 && i != 13 && i != 14 && i != 15 && i != 16 && i != 17 && i != 18 && i != 19 && i != 20 && i != 21 && i != 22 && i != 23 && i != 24 && i != 25 && i != 26 && i != 28 && i != 29 && i != 30 && i != 34 && i != 35 && i != 38 && i != 39 && i != 40 && i != 41 && i != 26 && i != 47 && i != 48 && i != 51 && i != 53 && i != 58)
                                {

                                    emptyfound = true;
                                    rowEmptyInsurance = row.RowNum + 1;
                                    colEmptyInsurance = i + 1;
                                    return;
                                }
                                else
                                {
                                    if (Convert.ToString(cell) == "" && rowEmptyInsurance == -1 && (i != 2 && i != 9 && i != 10 && i != 11 && i != 12 && i != 13 && i != 14 && i != 15 && i != 16 && i != 17 && i != 18 && i != 19 && i != 20 && i != 21 && i != 22 && i != 23 && i != 24 && i != 25 && i != 26 && i != 28 && i != 29 && i != 30 && i != 34 && i != 35 && i != 38 && i != 39 && i != 40 && i != 41 && i != 26 && i != 47 && i != 48 && i != 51 && i != 53 && i != 58))
                                    {
                                        emptyfound = true;
                                        rowEmptyInsurance = row.RowNum + 1;
                                        colEmptyInsurance = i + 1;
                                    }
                                    else
                                    {
                                        if (i == 0)
                                        {
                                            objIns.ic_breg_no = Convert.ToString(cell);
                                        }
                                        if (i == 1)
                                        {
                                            objIns.customer_name = Convert.ToString(cell);
                                        }
                                        if (i == 2)
                                        {
                                            objIns.bank_staff = Convert.ToString(cell);
                                        }
                                        if (i == 3)
                                        {
                                            objIns.address_1 = Convert.ToString(cell);
                                        }
                                        if (i == 4)
                                        {
                                            objIns.address_2 = Convert.ToString(cell);
                                        }
                                        if (i == 5)
                                        {
                                            objIns.address_3 = Convert.ToString(cell);
                                        }
                                        if (i == 6)
                                        {
                                            objIns.post_code = Convert.ToString(cell);
                                        }
                                        if (i == 7)
                                        {
                                            objIns.city = Convert.ToString(cell);
                                        }
                                        if (i == 8)
                                        {
                                            objIns.account_no = Convert.ToString(cell);
                                        }
                                        if (i == 9)
                                        {
                                            objIns.triton_account_no = Convert.ToString(cell);
                                        }
                                        if (i == 10)
                                        {
                                            objIns.branch_code = Convert.ToString(cell);
                                        }
                                        if (i == 11)
                                        {
                                            objIns.facility_type = Convert.ToString(cell);
                                        }
                                        if (i == 12)
                                        {
                                            objIns.approved_limit = Convert.ToString(cell);
                                        }
                                        if (i == 13)
                                        {
                                            objIns.approved_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                        }
                                        if (i == 14)
                                        {
                                            objIns.balance_outstanding = Convert.ToString(cell);
                                        }
                                        if (i == 15)
                                        {
                                            objIns.cost_outstanding = Convert.ToString(cell);
                                        }
                                        if (i == 16)
                                        {
                                            objIns.principal_outstanding = Convert.ToString(cell);
                                        }
                                        if (i == 17)
                                        {
                                            objIns.uei_outstanding = Convert.ToString(cell);
                                        }
                                        if (i == 18)
                                        {
                                            objIns.month_arrears = Convert.ToString(cell);
                                        }
                                        if (i == 19)
                                        {
                                            objIns.credit_status = Convert.ToString(cell);
                                        }
                                        if (i == 20)
                                        {
                                            objIns.credit_stat_change_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                        }
                                        if (i == 21)
                                        {
                                            objIns.npf_status = Convert.ToString(cell);
                                        }
                                        if (i == 22)
                                        {
                                            objIns.income_arrears = Convert.ToString(cell);
                                        }
                                        if (i == 23)
                                        {
                                            objIns.curr_balance_outstanding = Convert.ToString(cell);
                                        }
                                        if (i == 24)
                                        {
                                            objIns.collateral_ref_number = Convert.ToString(cell);
                                        }
                                        if (i == 25)
                                        {
                                            objIns.claim_type = Convert.ToString(cell);
                                        }
                                        if (i == 26)
                                        {
                                            objIns.property_type = Convert.ToString(cell);
                                        }
                                        if (i == 27)
                                        {
                                            objIns.credit_status = Convert.ToString(cell);
                                        }
                                        if (i == 28)
                                        {
                                            objIns.title_no = Convert.ToString(cell);
                                        }
                                        if (i == 29)
                                        {
                                            objIns.land_office = Convert.ToString(cell);
                                        }
                                        if (i == 30)
                                        {
                                            objIns.lot_number = Convert.ToString(cell);
                                        }
                                        if (i == 31)
                                        {
                                            objIns.property_address_1 = Convert.ToString(cell);
                                        }
                                        if (i == 32)
                                        {
                                            objIns.property_address_2 = Convert.ToString(cell);
                                        }
                                        if (i == 33)
                                        {
                                            objIns.property_address_3 = Convert.ToString(cell);
                                        }
                                        if (i == 34)
                                        {
                                            objIns.property_district = Convert.ToString(cell);
                                        }
                                        if (i == 35)
                                        {
                                            objIns.mukim = Convert.ToString(cell);
                                        }
                                        if (i == 36)
                                        {
                                            objIns.property_city = Convert.ToString(cell);
                                        }
                                        if (i == 37)
                                        {
                                            objIns.property_post_code = Convert.ToString(cell);
                                        }
                                        if (i == 38)
                                        {
                                            objIns.security_value = Convert.ToString(cell);
                                        }
                                        if (i == 39)
                                        {
                                            objIns.property_desc = Convert.ToString(cell);
                                        }
                                        if (i == 40)
                                        {
                                            objIns.property_owner_1 = Convert.ToString(cell);
                                        }
                                        if (i == 41)
                                        {
                                            objIns.property_owner_2 = Convert.ToString(cell);
                                        }
                                        if (i == 42)
                                        {
                                            objIns.insurance_company = Convert.ToString(cell);
                                        }
                                        if (i == 43)
                                        {
                                            objIns.policy_no = Convert.ToString(cell);
                                        }
                                        if (i == 44)
                                        {
                                            objIns.insurance_type = Convert.ToString(cell);
                                        }
                                        if (i == 45)
                                        {
                                            objIns.coverage_type = Convert.ToString(cell);
                                        }
                                        if (i == 46)
                                        {
                                            objIns.participant_name = Convert.ToString(cell);
                                        }
                                        if (i == 47)
                                        {
                                            objIns.risk_address_1 = Convert.ToString(cell);
                                        }
                                        if (i == 48)
                                        {
                                            objIns.risk_address_2 = Convert.ToString(cell);
                                        }
                                        if (i == 49)
                                        {
                                            objIns.risk_address_3 = Convert.ToString(cell);
                                        }
                                        if (i == 50)
                                        {
                                            objIns.risk_post_code = Convert.ToString(cell);
                                        }
                                        if (i == 51)
                                        {
                                            objIns.risk_city = Convert.ToString(cell);
                                        }
                                        if (i == 52)
                                        {
                                            objIns.risk_state_code = Convert.ToString(cell);
                                        }
                                        if (i == 53)
                                        {
                                            objIns.risk_country_code = Convert.ToString(cell);
                                        }
                                        if (i == 54)
                                        {
                                            objIns.start_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                        }
                                        if (i == 55)
                                        {
                                            objIns.end_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                        }
                                        if (i == 56)
                                        {
                                            objIns.premium_amt = Convert.ToString(cell);
                                        }
                                        if (i == 57)
                                        {
                                            objIns.sum_insured_amt = Convert.ToString(cell);
                                        }
                                        if (i == 58)
                                        {
                                            objIns.insurance_last_modified_date = (Convert.ToString(cell) == "") ? Convert.ToDateTime("01/01/1970") : Convert.ToDateTime(Convert.ToString(cell));
                                        }

                                    }
                                }

                            }
                            insList.Add(objIns);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                        error = true;
                    }

                }
                else
                {
                    MessageBox.Show(e.Message);
                    error = true;
                }
            }
            dataGridView1.DataSource = bankList;
            dataGridView2.DataSource = insList;

            foreach (DataGridViewRow rw in this.dataGridView1.Rows)
            {
              for (int i = 0; i < rw.Cells.Count; i++)
              {
                if (rw.Cells[i].Value == null && rw.Cells[i].Value == DBNull.Value && rw.Cells[i].Value.ToString() == "")
                {
                  rw.Cells[i].ErrorText = "Empty";
                }
              }
            }
            foreach (DataGridViewRow rw in this.dataGridView2.Rows)
            {
                for (int i = 0; i < rw.Cells.Count; i++)
                {
                    if (rw.Cells[i].Value == null && rw.Cells[i].Value == DBNull.Value && rw.Cells[i].Value.ToString() == "")
                    {
                        rw.Cells[i].ErrorText = "Empty";
                    }
                }
            }
            if (error == false)
            {
            //                MessageBox.Show("Import Sukses", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
            /*                var hashset = new HashSet<Bank>();
                foreach (Bank name in bankList)
                {
                    if (!hashset.Add(name))
                    {
                        MessageBox.Show("Found Duplicate data in Bank File", "Found Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        error = true;
                    }
                }
                var hashset2 = new HashSet<Insurance>();
                foreach (Insurance name in insList)
                {
                    if (!hashset2.Add(name))
                    {
                        MessageBox.Show("Found Duplicate data in Bank File", "Found Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        error = true;
                    }
                }
            */
                if (insList.Count != insList.Select(c => new { c.policy_no }).Distinct().Count())
                {
                    MessageBox.Show("Found Duplicate Lines of data in Insurance File", "Found Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    error = true;
                }
                if (bankList.Count != bankList.Select(c => new { c.policy_no }).Distinct().Count())
                {
                    MessageBox.Show("Found Duplicate Lines of data in Bank File", "Found Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    error = true;
                }
                //if (bankList.Count != bankList.Select(c => new { c }).Distinct().Count())
                //{
                //    MessageBox.Show("Found Duplicate IC Number in Bank File", "Found Duplicate IC Number", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //    error = true;
                //}
                if (emptyfound == true)
                {
                    MessageBox.Show("Found Empty Column, System can't merge it!", "Found Empty Column", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    error = true;
                }
                if (rowEmptyBank != -1)
                {
                    lblErrorBank.Text += "Empty value in Bank Data, row " + rowEmptyBank.ToString() + ", column " + colEmptyBank.ToString() + "";
                    error = true;
                }
                if (rowEmptyInsurance != -1)
                {
                    lblErrorInsurance.Text += "Empty value in Insurance Data, row " + rowEmptyInsurance.ToString() + ", column " + colEmptyInsurance.ToString() + "";
                    error = true;
                }
            }

            if (error == true)
            {
                btnNext_2.Enabled = false;
                btnFinish_2.Enabled = false;
            }
            else
            {
                btnNext_2.Enabled = true;
                btnFinish_2.Enabled = false;
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Create a new t_Bank_data object.
 /// </summary>
 /// <param name="bd_id">Initial value of the bd_id property.</param>
 /// <param name="policy_no">Initial value of the policy_no property.</param>
 /// <param name="bank_ref_number">Initial value of the bank_ref_number property.</param>
 /// <param name="nric">Initial value of the nric property.</param>
 /// <param name="old_ic">Initial value of the old_ic property.</param>
 /// <param name="participant_name">Initial value of the participant_name property.</param>
 /// <param name="customer_address_1">Initial value of the customer_address_1 property.</param>
 /// <param name="customer_post_code">Initial value of the customer_post_code property.</param>
 /// <param name="property_type">Initial value of the property_type property.</param>
 /// <param name="property_address">Initial value of the property_address property.</param>
 /// <param name="property_post_code">Initial value of the property_post_code property.</param>
 /// <param name="risk_type">Initial value of the risk_type property.</param>
 /// <param name="policy_effective_date">Initial value of the policy_effective_date property.</param>
 /// <param name="policy_expired_date">Initial value of the policy_expired_date property.</param>
 /// <param name="sum_covered">Initial value of the sum_covered property.</param>
 public static t_Bank_data Createt_Bank_data(global::System.Int32 bd_id, global::System.String policy_no, global::System.String bank_ref_number, global::System.String nric, global::System.String old_ic, global::System.String participant_name, global::System.String customer_address_1, global::System.String customer_post_code, global::System.String property_type, global::System.String property_address, global::System.String property_post_code, global::System.String risk_type, global::System.DateTime policy_effective_date, global::System.DateTime policy_expired_date, global::System.Decimal sum_covered)
 {
     t_Bank_data t_Bank_data = new t_Bank_data();
     t_Bank_data.bd_id = bd_id;
     t_Bank_data.policy_no = policy_no;
     t_Bank_data.bank_ref_number = bank_ref_number;
     t_Bank_data.nric = nric;
     t_Bank_data.old_ic = old_ic;
     t_Bank_data.participant_name = participant_name;
     t_Bank_data.customer_address_1 = customer_address_1;
     t_Bank_data.customer_post_code = customer_post_code;
     t_Bank_data.property_type = property_type;
     t_Bank_data.property_address = property_address;
     t_Bank_data.property_post_code = property_post_code;
     t_Bank_data.risk_type = risk_type;
     t_Bank_data.policy_effective_date = policy_effective_date;
     t_Bank_data.policy_expired_date = policy_expired_date;
     t_Bank_data.sum_covered = sum_covered;
     return t_Bank_data;
 }
Ejemplo n.º 4
0
        private void btnSaveData_Click(object sender, EventArgs e)
        {
            Boolean error = false;
            try
            {
                /* SAVE BANK DATA */
                foreach (t_Bank_data bankObj in bankList)
                {

                    Entities1 mdl = new Entities1();
                    mdl.Connection.Open();
                    t_Bank_data selectBank = new t_Bank_data();
                    selectBank = (from c in mdl.t_Bank_data
                                  where (c.policy_no == bankObj.policy_no)
                                  select c).FirstOrDefault();

                    /*IF NOT EXIST, DO INSERT*/
                    if (selectBank == null)
                    {

                        mdl.AddTot_Bank_data(bankObj);
                        mdl.SaveChanges();
                        mdl.Connection.Close();
                    }
                }

                t_Insurance_data temp = new t_Insurance_data();
                /* SAVE INSURANCE DATA */
                foreach (t_Insurance_data insObj in insList)
                {

                    Entities1 mdl = new Entities1();
                    mdl.Connection.Open();
                    t_Insurance_data selectIns = new t_Insurance_data();
                    selectIns = (from c in mdl.t_Insurance_data
                                 where (c.policy_no == insObj.policy_no)&& (c.ic_breg_no == insObj.ic_breg_no)
                                 select c).FirstOrDefault();

                    /*IF NOT EXIST, DO INSERT*/
                    if (selectIns == null)
                    {
                        temp=insObj;
                        mdl.AddTot_Insurance_data(temp);
                        mdl.SaveChanges();
                        mdl.Connection.Close();
                    }
                }

                /*SAVE DMMS*/
                foreach(t_dmms_master mergeObj in mrgList)
                {
                    Entities1 mdl = new Entities1();
                    mdl.Connection.Open();
            //                    mergeObj.SETTLEMENT_DATE = Convert.ToDateTime("01/01/1970");
            //                    mergeObj.ADD_NEW_CUSTOMER_DATE = Convert.ToDateTime("01/01/1970");
                    mdl.AddTot_dmms_master(mergeObj);
                    mdl.SaveChanges();
                    mdl.Connection.Close();

                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " Inner Exception : " + ex.InnerException + " " + ex.Source + ex.StackTrace);
                error = true;
                btnFinish_4.Enabled = false;
                btnSaveData.Enabled = true;
            }
            if (error == false)
            {
                MessageBox.Show("Save Success");
                btnFinish_4.Enabled = true;
                btnSaveData.Enabled = false;
            }
        }