Ejemplo n.º 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the t_Insurance_data EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTot_Insurance_data(t_Insurance_data t_Insurance_data)
 {
     base.AddObject("t_Insurance_data", t_Insurance_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_Insurance_data object.
 /// </summary>
 /// <param name="id_id">Initial value of the id_id property.</param>
 /// <param name="policy_no">Initial value of the policy_no property.</param>
 /// <param name="ic_breg_no">Initial value of the ic_breg_no property.</param>
 /// <param name="customer_name">Initial value of the customer_name property.</param>
 /// <param name="address_1">Initial value of the address_1 property.</param>
 /// <param name="post_code">Initial value of the post_code property.</param>
 /// <param name="city">Initial value of the city property.</param>
 /// <param name="account_no">Initial value of the account_no property.</param>
 /// <param name="property_type">Initial value of the property_type property.</param>
 /// <param name="property_city">Initial value of the property_city property.</param>
 /// <param name="property_post_code">Initial value of the property_post_code property.</param>
 /// <param name="insurance_company">Initial value of the insurance_company property.</param>
 /// <param name="insurance_type">Initial value of the insurance_type property.</param>
 /// <param name="coverage_type">Initial value of the coverage_type property.</param>
 /// <param name="participant_name">Initial value of the participant_name property.</param>
 /// <param name="risk_address_1">Initial value of the risk_address_1 property.</param>
 /// <param name="risk_post_code">Initial value of the risk_post_code property.</param>
 /// <param name="risk_city">Initial value of the risk_city property.</param>
 /// <param name="risk_state_code">Initial value of the risk_state_code property.</param>
 /// <param name="start_date">Initial value of the start_date property.</param>
 /// <param name="end_date">Initial value of the end_date property.</param>
 /// <param name="premium_amt">Initial value of the premium_amt property.</param>
 /// <param name="sum_insured_amt">Initial value of the sum_insured_amt property.</param>
 public static t_Insurance_data Createt_Insurance_data(global::System.Int32 id_id, global::System.String policy_no, global::System.String ic_breg_no, global::System.String customer_name, global::System.String address_1, global::System.String post_code, global::System.String city, global::System.String account_no, global::System.String property_type, global::System.String property_city, global::System.String property_post_code, global::System.String insurance_company, global::System.String insurance_type, global::System.String coverage_type, global::System.String participant_name, global::System.String risk_address_1, global::System.String risk_post_code, global::System.String risk_city, global::System.String risk_state_code, global::System.DateTime start_date, global::System.DateTime end_date, global::System.String premium_amt, global::System.String sum_insured_amt)
 {
     t_Insurance_data t_Insurance_data = new t_Insurance_data();
     t_Insurance_data.id_id = id_id;
     t_Insurance_data.policy_no = policy_no;
     t_Insurance_data.ic_breg_no = ic_breg_no;
     t_Insurance_data.customer_name = customer_name;
     t_Insurance_data.address_1 = address_1;
     t_Insurance_data.post_code = post_code;
     t_Insurance_data.city = city;
     t_Insurance_data.account_no = account_no;
     t_Insurance_data.property_type = property_type;
     t_Insurance_data.property_city = property_city;
     t_Insurance_data.property_post_code = property_post_code;
     t_Insurance_data.insurance_company = insurance_company;
     t_Insurance_data.insurance_type = insurance_type;
     t_Insurance_data.coverage_type = coverage_type;
     t_Insurance_data.participant_name = participant_name;
     t_Insurance_data.risk_address_1 = risk_address_1;
     t_Insurance_data.risk_post_code = risk_post_code;
     t_Insurance_data.risk_city = risk_city;
     t_Insurance_data.risk_state_code = risk_state_code;
     t_Insurance_data.start_date = start_date;
     t_Insurance_data.end_date = end_date;
     t_Insurance_data.premium_amt = premium_amt;
     t_Insurance_data.sum_insured_amt = sum_insured_amt;
     return t_Insurance_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;
            }
        }