Exemplo n.º 1
0
        public void Insert_CarDetails(CarDetailsObj obj, long makerId, long modelId, long typeId)
        {
            try
            {
                string query = string.Format("INSERT INTO {0} " +
                                             "(maker_id, model_id, modeltype_id, maker, model, type, series, modeltypename, internal_class_name, model_start, model_end, " +
                                             "series_start, series_end, hsn, tsn, tsn2, car_tax, co2_class, base_price, engine_type, fuel, fuel2, " +
                                             "emission_control, engine_design, cylinder, fuel_type, charge, valves, cubic, power_kw, power_ps, " +
                                             "max_power, turning_moment, max_turning_moment, type_of_drive, gearing, gears, start_stop_automatic, " +
                                             "emission_class, length, width, height, chassis, doors, car_class, seats, speed_up, max_speed, tank, tank2) " +
                                             "VALUES" +
                                             "(@maker_id, @model_id, @modeltype_id, @maker, @model, @type, @series, @modeltypename, @internal_class_name, STR_TO_DATE(@model_start, '%d/%m/%Y'), STR_TO_DATE(@model_end, '%d/%m/%Y'), " +
                                             "STR_TO_DATE(@series_start, '%d/%m/%Y'), STR_TO_DATE(@series_end, '%d/%m/%Y'), @hsn, @tsn, @tsn2, @car_tax, @co2_class, @base_price, @engine_type, @fuel, @fuel2, " +
                                             "@emission_control, @engine_design, @cylinder, @fuel_type, @charge, @valves, @cubic, @power_kw, @power_ps, " +
                                             "@max_power, @turning_moment, @max_turning_moment, @type_of_drive, @gearing, @gears, @start_stop_automatic, " +
                                             "@emission_class, @length, @width, @height, @chassis, @doors, @car_class, @seats, @speed_up, @max_speed, @tank, @tank2)",
                                             MySQLExporter.DETAILS_TABLE);


                //open connection
                if (_mySqlExporter.connection.State == ConnectionState.Open || _mySqlExporter.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(query, _mySqlExporter.connection);

                    //cmd.CommandText = query;

                    SetSQLParameters(obj, cmd, makerId, modelId, typeId);

                    //Execute command
                    cmd.ExecuteNonQuery();

                    //close connection
                    _mySqlExporter.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                if (Core != null && Core.Log != null)
                {
                    Core.Log.Error(string.Format("SQLCarDetails::Insert_CarDetails : {0}", ex.Message));
                }
                else
                {
                    throw new Exception("SQLCarDetails::Insert_CarDetails", ex);
                }
            }
        }
Exemplo n.º 2
0
        public void Insert_CarModel(ModelObj obj, long makerId)
        {
            try
            {
                string query = string.Format("INSERT INTO {0} " +
                                             "(name, maker, maker_id, image, model_url, img_url) " +
                                             "VALUES" +
                                             "(@name, @maker, @maker_id, @image, @model_url, @img_url)",
                                             MySQLExporter.MODEL_TABLE);


                System.IO.FileStream     fs = new FileStream(obj.ModelLocalFile, FileMode.Open);
                System.IO.BufferedStream bf = new BufferedStream(fs);
                byte[] buffer = new byte[bf.Length];
                bf.Read(buffer, 0, buffer.Length);

                byte[] buffer_new = buffer;

                //open connection
                if (_mySqlExporter.connection.State == ConnectionState.Open || _mySqlExporter.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(query, _mySqlExporter.connection);

                    cmd.CommandText = query;

                    SetSQLParameters(obj, cmd, makerId, -1, buffer_new);

                    //Execute command
                    cmd.ExecuteNonQuery();

                    //close connection
                    _mySqlExporter.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                if (Core != null && Core.Log != null)
                {
                    Core.Log.Error(string.Format("SQLCarModel::Insert_CarModel : {0}", ex.Message));
                }
                else
                {
                    throw new Exception("SQLCarModel::Insert_CarModel", ex);
                }
            }
        }
Exemplo n.º 3
0
        public void Insert_CarMaker(MakerObj maker)
        {
            try
            {
                string query = string.Format("INSERT INTO {0} (name, url, logo) VALUES (@name, @url, @logo)",
                                             MySQLExporter.MAKER_TABLE);


                System.IO.FileStream     fs = new FileStream(maker.MakerLogoLocalFile, FileMode.Open);
                System.IO.BufferedStream bf = new BufferedStream(fs);
                byte[] buffer = new byte[bf.Length];
                bf.Read(buffer, 0, buffer.Length);

                byte[] buffer_new = buffer;

                //open connection
                if (_mySqlExporter.connection.State == ConnectionState.Open || _mySqlExporter.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(query, _mySqlExporter.connection);

                    cmd.Parameters.AddWithValue("@name", maker.MakerName);
                    cmd.Parameters.AddWithValue("@url", string.Empty);
                    cmd.Parameters.AddWithValue("@logo", buffer_new);


                    //Execute command
                    cmd.ExecuteNonQuery();

                    //close connection
                    _mySqlExporter.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                if (Core != null && Core.Log != null)
                {
                    Core.Log.Error(string.Format("SQLCarMaker::Insert_CarMaker : {0}", ex.Message));
                }
                else
                {
                    throw new Exception("SQLCarMaker::Insert_CarMaker", ex);
                }
            }
        }
        public void Insert_CarModelType(ModelTypeObj obj, long makerId, long modelId)
        {
            try
            {
                string query = string.Format("INSERT INTO {0} " +
                                             "(maker_id, model_id, modeltype_id, name, cubic, fuel, power, tank, from_year, to_year, chassis, doors, type_url) " +
                                             "VALUES" +
                                             "(@maker_id, @model_id, @modeltype_id, @name, @cubic, @fuel, @power, @tank, @from_year, @to_year, @chassis, @doors, @type_url)",
                                             MySQLExporter.MODELTYPE_TABLE);


                //open connection
                if (_mySqlExporter.connection.State == ConnectionState.Open || _mySqlExporter.OpenConnection() == true)
                {
                    //create command and assign the query and connection from the constructor
                    MySqlCommand cmd = new MySqlCommand(query, _mySqlExporter.connection);

                    //cmd.CommandText = query;

                    SetSQLParameters(obj, cmd, makerId, modelId);

                    //Execute command
                    cmd.ExecuteNonQuery();

                    //close connection
                    _mySqlExporter.CloseConnection();
                }
            }
            catch (Exception ex)
            {
                if (Core != null && Core.Log != null)
                {
                    Core.Log.Error(string.Format("SQLCarModelType::Insert_CarModel : {0}", ex.Message));
                }
                else
                {
                    throw new Exception("SQLCarModelType::Insert_CarModel", ex);
                }
            }
        }