예제 #1
0
        public void Update(AbstractConnection c, AbstractTransaction t, DataSet1 ds)
        {
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            // SELECT
            String sqlSelect = "SELECT * FROM organization";

            adapter.SelectCommand = new MySqlCommand(sqlSelect, c.get(), t.get());

            //INSERT
            String sqlInsert = "INSERT INTO organization (okpo_number, organization_name) VALUES (@okpo_number, @organization_name)";

            adapter.InsertCommand = new MySqlCommand(sqlInsert, c.get(), t.get());
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "okpo_number",
                ParameterName = "@okpo_number"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "organization_name",
                ParameterName = "@organization_name"
            });


            //UPDATE
            String sqlUpdate = "Update organization SET okpo_number=@okpo_number, organization_name=@organization_name where id=@id";

            adapter.UpdateCommand = new MySqlCommand(sqlUpdate, c.get(), t.get());
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "okpo_number",
                ParameterName = "@okpo_number"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "organization_name",
                ParameterName = "@organization_name"
            });

            //DELETE
            String sqlDelete = "DELETE FROM organization WHERE id = @id";

            adapter.DeleteCommand = new MySqlCommand(sqlDelete, c.get(), t.get());
            adapter.DeleteCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });

            MySqlCommandBuilder mySqlCommandBuilder = new MySqlCommandBuilder(adapter);

            adapter.Update(ds, "organization");
        }
예제 #2
0
        public void Update(AbstractConnection c, AbstractTransaction t, DataSet1 ds)
        {
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            // SELECT
            String sqlSelect = "SELECT * FROM material";

            adapter.SelectCommand = new MySqlCommand(sqlSelect, c.get(), t.get());

            //INSERT
            String sqlInsert = "INSERT INTO material (name_material, code_material) VALUES (@name_material, @code_material)";

            adapter.InsertCommand = new MySqlCommand(sqlInsert, c.get(), t.get());
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "name_material",
                ParameterName = "@name_material"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "code_material",
                ParameterName = "@code_material"
            });

            //UPDATE
            String sqlUpdate = "Update material SET name_material=@name_material, code_material=@code_material where id=@id";

            adapter.UpdateCommand = new MySqlCommand(sqlUpdate, c.get(), t.get());
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "name_material",
                ParameterName = "@name_material"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "code_material",
                ParameterName = "@code_material"
            });

            //DELETE
            String sqlDelete = "DELETE FROM material WHERE id = @id";

            adapter.DeleteCommand = new MySqlCommand(sqlDelete, c.get(), t.get());
            adapter.DeleteCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });

            MySqlCommandBuilder mySqlCommandBuilder = new MySqlCommandBuilder(adapter);

            adapter.Update(ds, "material");
        }
예제 #3
0
        public void Read(AbstractConnection c, AbstractTransaction t, DataSet1 ds)
        {
            MySqlDataAdapter a = new MySqlDataAdapter();

            a.SelectCommand = new MySqlCommand("SELECT * FROM unit_of_measurement", c.get(), t.get());
            a.Fill(ds, "unit_of_measurement");
        }
예제 #4
0
        public void Read(AbstractConnection c, AbstractTransaction t, DataSet1 ds)
        {
            MySqlDataAdapter a = new MySqlDataAdapter();

            a.SelectCommand = new MySqlCommand("SELECT * FROM invoice", c.get(), t.get());
            a.Fill(ds, "invoice");
        }
예제 #5
0
        public static void init()
        {
            // Дропаем все таблицы
            AbstractConnection  connection_Truncate  = null;
            AbstractTransaction transaction_Truncate = null;

            try
            {
                connection_Truncate = DBFactory.createConnection();
                connection_Truncate.open();
                transaction_Truncate = connection_Truncate.beginTransaction();
                string      path   = Path.Combine(@"C:\SQL", TruncateSql);
                String      str    = File.ReadAllText(path);
                MySqlScript script = new MySqlScript(connection_Truncate.get(), str);
                script.Execute();
                transaction_Truncate.commit();
            }
            catch (Exception e)
            {
                transaction_Truncate.rollback();
            }
            finally
            {
                connection_Truncate.close();
            }

            // Создаем базу заново
            AbstractConnection  connection_Insert  = null;
            AbstractTransaction transaction_Insert = null;

            try
            {
                connection_Insert = DBFactory.createConnection();
                connection_Insert.open();
                transaction_Insert = connection_Insert.beginTransaction();
                string      path   = Path.Combine(@"C:\SQL", InsertSql);
                String      str    = File.ReadAllText(path);
                MySqlScript script = new MySqlScript(connection_Insert.get(), str);
                script.Execute();
                transaction_Insert.commit();
            }
            catch (Exception e)
            {
                transaction_Insert.rollback();
            }
            finally
            {
                connection_Insert.close();
            }
        }
예제 #6
0
        public void Update(AbstractConnection c, AbstractTransaction t, DataSet1 ds)
        {
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            // SELECT
            String sqlSelect = "SELECT * FROM unit_of_measurement";

            adapter.SelectCommand = new MySqlCommand(sqlSelect, c.get(), t.get());

            //INSERT
            String sqlInsert = "INSERT INTO unit_of_measurement (code, unit_name, national_symbol, code_letter) VALUES (@code, @unit_name, @national_symbol, @code_letter)";

            adapter.InsertCommand = new MySqlCommand(sqlInsert, c.get(), t.get());
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "code",
                ParameterName = "@code"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "unit_name",
                ParameterName = "@unit_name"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "national_symbol",
                ParameterName = "@national_symbol"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "code_letter",
                ParameterName = "@code_letter"
            });

            //UPDATE
            String sqlUpdate = "Update unit_of_measurement SET code=@code, unit_name=@unit_name, national_symbol=@national_symbol, code_letter=@code_letter where id=@id";

            adapter.UpdateCommand = new MySqlCommand(sqlUpdate, c.get(), t.get());
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "code",
                ParameterName = "@code"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "unit_name",
                ParameterName = "@unit_name"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "national_symbol",
                ParameterName = "@national_symbol"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "code_letter",
                ParameterName = "@code_letter"
            });


            //DELETE
            String sqlDelete = "DELETE FROM unit_of_measurement WHERE id = @id";

            adapter.DeleteCommand = new MySqlCommand(sqlDelete, c.get(), t.get());
            adapter.DeleteCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });

            MySqlCommandBuilder mySqlCommandBuilder = new MySqlCommandBuilder(adapter);

            adapter.Update(ds, "unit_of_measurement");
        }
예제 #7
0
        public void Update(AbstractConnection c, AbstractTransaction t, DataSet1 ds)
        {
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            // SELECT
            String sqlSelect = "SELECT * FROM position_in_mat_delivery_note";

            adapter.SelectCommand = new MySqlCommand(sqlSelect, c.get(), t.get());

            //INSERT
            String sqlInsert = "INSERT INTO position_in_mat_delivery_note (amount, invoice_id, material_id, unit_of_measurement_id) VALUES (@amount, @invoice_id, @material_id, @unit_of_measurement_id)";

            adapter.InsertCommand = new MySqlCommand(sqlInsert, c.get(), t.get());
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "amount",
                ParameterName = "@amount"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "invoice_id",
                ParameterName = "@invoice_id"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "material_id",
                ParameterName = "@material_id"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "unit_of_measurement_id",
                ParameterName = "@unit_of_measurement_id"
            });

            //UPDATE
            String sqlUpdate = "UPDATE position_in_mat_delivery_note SET amount=@amount, invoice_id=@invoice_id, material_id=@material_id, unit_of_measurement_id=@unit_of_measurement_id where id=@id";

            adapter.UpdateCommand = new MySqlCommand(sqlUpdate, c.get(), t.get());
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "amount",
                ParameterName = "@amount"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "invoice_id",
                ParameterName = "@invoice_id"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "material_id",
                ParameterName = "@material_id"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "unit_of_measurement_id",
                ParameterName = "@unit_of_measurement_id"
            });


            //DELETE
            String sqlDelete = "DELETE FROM position_in_mat_delivery_note WHERE id = @id";

            adapter.DeleteCommand = new MySqlCommand(sqlDelete, c.get(), t.get());
            adapter.DeleteCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });

            MySqlCommandBuilder mySqlCommandBuilder = new MySqlCommandBuilder(adapter);

            adapter.Update(ds, "position_in_mat_delivery_note");
        }
예제 #8
0
        public void Read(AbstractConnection c, AbstractTransaction t, DataSet1 ds)
        {
            MySqlDataAdapter a = new MySqlDataAdapter();

            a.SelectCommand = new MySqlCommand("SELECT * FROM position_in_mat_delivery_note", c.get(), t.get());
            a.Fill(ds, "position_in_mat_delivery_note");
        }
예제 #9
0
        public void Update(AbstractConnection c, AbstractTransaction t, DataSet1 ds)
        {
            MySqlDataAdapter adapter = new MySqlDataAdapter();

            // SELECT
            String sqlSelect = "SELECT * FROM invoice";

            adapter.SelectCommand = new MySqlCommand(sqlSelect, c.get(), t.get());

            //INSERT
            String sqlInsert = "INSERT INTO invoice (invoice_number, date_of_creation, organization_id) VALUES (@invoice_number, @date_of_creation, @organization_id)";

            adapter.InsertCommand = new MySqlCommand(sqlInsert, c.get(), t.get());
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "invoice_number",
                ParameterName = "@invoice_number"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "date_of_creation",
                ParameterName = "@date_of_creation"
            });
            adapter.InsertCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "organization_id",
                ParameterName = "@organization_id"
            });

            //UPDATE
            String sqlUpdate = "UPDATE invoice SET invoice_number=@invoice_number, date_of_creation=@date_of_creation, organization_id=@organization_id where id=@id";

            adapter.UpdateCommand = new MySqlCommand(sqlUpdate, c.get(), t.get());
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "invoice_number",
                ParameterName = "@invoice_number"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "date_of_creation",
                ParameterName = "@date_of_creation"
            });
            adapter.UpdateCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "organization_id",
                ParameterName = "@organization_id"
            });

            //DELETE
            String sqlDelete = "DELETE FROM invoice WHERE id = @id";

            adapter.DeleteCommand = new MySqlCommand(sqlDelete, c.get(), t.get());
            adapter.DeleteCommand.Parameters.Add(new MySqlParameter()
            {
                SourceColumn  = "id",
                ParameterName = "@id"
            });

            MySqlCommandBuilder mySqlCommandBuilder = new MySqlCommandBuilder(adapter);

            adapter.Update(ds, "invoice");
        }