Ejemplo n.º 1
0
        static void InsertBusinessAddress(Business_Address business_address)
        {
            using (SqlConnection con = new SqlConnection(contact_connectionString))
            {
                SqlCommand cmd = new SqlCommand("AddBusinessAddress", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@business_id", business_address.Business_ID);
                cmd.Parameters.AddWithValue("@main_address", business_address.Main_Address);
                cmd.Parameters.AddWithValue("@address_type", ReplaceEmpty(business_address.Address_Type));
                cmd.Parameters.AddWithValue("@street_number", ReplaceEmpty(business_address.Street_Number));
                cmd.Parameters.AddWithValue("@pre_direction", ReplaceEmpty(business_address.Pre_Direction));
                cmd.Parameters.AddWithValue("@street_name", ReplaceEmpty(business_address.Street_Name));
                cmd.Parameters.AddWithValue("@street_type", ReplaceEmpty(business_address.Street_Type));
                cmd.Parameters.AddWithValue("@post_direction", ReplaceEmpty(business_address.Post_Direction));
                cmd.Parameters.AddWithValue("@unit_suite_number", ReplaceEmpty(business_address.Unit_Suite_Number));
                cmd.Parameters.AddWithValue("@address_line_3", ReplaceEmpty(business_address.Address_Line_3));
                cmd.Parameters.AddWithValue("@po_box", ReplaceEmpty(business_address.PO_Box));
                cmd.Parameters.AddWithValue("@city", ReplaceEmpty(business_address.City));
                cmd.Parameters.AddWithValue("@state_code", ReplaceEmpty(business_address.State_Code));
                cmd.Parameters.AddWithValue("@zip", ReplaceEmpty(business_address.Zip));
                cmd.Parameters.AddWithValue("@county_code", ReplaceEmpty(business_address.County_Code));
                cmd.Parameters.AddWithValue("@country_code", ReplaceEmpty(business_address.Country_Code));
                cmd.Parameters.AddWithValue("@country_type", ReplaceEmpty(business_address.Country_Type));
                cmd.Parameters.AddWithValue("@last_update_date", ReplaceEmpty(business_address.Last_Update_Date));
                cmd.Parameters.AddWithValue("@last_update_user", ReplaceEmpty(business_address.Last_Update_User));

                con.Open();
                int j = cmd.ExecuteNonQuery();
                con.Close();

                if (j >= 1)
                {
                    Console.WriteLine("Sucessfully wrote Business Address with ID: " + business_address.Business_ID);
                }
                else
                {
                    Console.WriteLine("Error writing Business Address with ID: " + business_address.Business_ID);
                }
            }
        }
Ejemplo n.º 2
0
        static void ProcessBusiness(EnerGovSource source)
        {
            string[] split = source.BTR_IDs.Split(";");
            Console.WriteLine("Processing Business Object with Contact ID of " + source.Contact_ID + " and " + split[0]);

            using (SqlConnection bus_con = new SqlConnection(contact_connectionString))
            {
                SqlCommand bus_command = new SqlCommand("GetBusinessInfo", bus_con);
                bus_command.CommandType = CommandType.StoredProcedure;

                bus_command.Parameters.AddWithValue("@refnum", split[0]);

                bus_con.Open();

                SqlDataReader bus_rdr = bus_command.ExecuteReader();

                while (bus_rdr.Read())
                {
                    Globals.counter = Globals.counter + 1;
                    Business business = new Business()
                    {
                        Business_ID          = ReturnFormattedID(Globals.counter),
                        Contact_ID           = source.Contact_ID,
                        Ownership_Type       = bus_rdr["Ownership"].ToString(),
                        Location_Type        = "Commercial",
                        Business_Status      = "Active",
                        District             = bus_rdr["district"].ToString(),
                        Open_Date            = bus_rdr["open_date"].ToString(),
                        Business_Description = "",
                        Closed_Date          = "",
                        Federal_ID_Number    = bus_rdr["federal_id_number"].ToString(),
                        State_ID_Number      = "",
                        DBA = "",
                        Legacy_Data_Source_Name = "BTR"
                    };

                    Console.WriteLine("New Business Object created with ID: " + ReturnFormattedID(Globals.counter));

                    Business_Address business_address = new Business_Address()
                    {
                        Business_ID       = ReturnFormattedID(Globals.counter),
                        Main_Address      = true,
                        Address_Type      = "Location",
                        Street_Number     = bus_rdr["street_number"].ToString(),
                        Pre_Direction     = bus_rdr["pre_direction"].ToString(),
                        Street_Name       = bus_rdr["street_name"].ToString(),
                        Street_Type       = bus_rdr["street_type"].ToString(),
                        Post_Direction    = "",
                        Unit_Suite_Number = bus_rdr["unit_suite_number"].ToString(),
                        Address_Line_3    = "",
                        PO_Box            = "",
                        City             = bus_rdr["city"].ToString(),
                        State_Code       = "FL",
                        Zip              = bus_rdr["zip"].ToString(),
                        County_Code      = "",
                        Country_Code     = "",
                        Country_Type     = "US",
                        Last_Update_Date = "",
                        Last_Update_User = ""
                    };



                    Business_Note business_note = new Business_Note()
                    {
                        Business_ID = ReturnFormattedID(Globals.counter),
                        Note_Text   = bus_rdr["note_text"].ToString(),
                        Note_User   = "",
                        Note_Date   = ""
                    };



                    /*
                     * Business_Parcel business_parcel = new Business_Parcel()
                     * {
                     *  Business_ID = ReturnFormattedID(Globals.counter),
                     *  Parcel_Number = bus_rdr["note_text"].ToString(),
                     *  Main_Parcel = true
                     * };*/

                    /*
                     * //Business Additional Fields
                     * Business_Additional_Fields business_additional_fields = new Business_Additional_Fields
                     * {
                     *  Business_ID = ReturnFormattedID(Globals.counter),
                     *  Exemptions = bus_rdr["Exemption"].ToString(),
                     *  NewHomeBasedBusiness  = bus_rdr["NewHomeBasedBusiness"].ToString(),
                     *  NotForProfitBusiness = bus_rdr["NotForProfitBusiness"].ToString(),
                     *  OfAdditionalClassifications = Convert.ToDecimal(bus_rdr["OfAdditionalClassifications"])
                     * };*/

                    InsertBusiness(business);
                    InsertBusinessAddress(business_address);
                    // InsertBusinessParcel(business_parcels);
                    InsertBusinessNote(business_note);
                    // InsertBusinessAdditionalFields(business_additional_fields);
                }
            }
        }