I have problem with my application, I have 2 tables: rm_bag & rm_bag_item
Code: Select all
CREATE TABLE rm_bag
(
bag_id serial NOT NULL,
bag_computer text NOT NULL,
bag_type character(1) NOT NULL,
bag_sortcode integer NOT NULL,
report_id integer,
bag_items_count integer NOT NULL DEFAULT 0,
bag_weight integer NOT NULL DEFAULT 0,
bag_start_time timestamp without time zone NOT NULL DEFAULT now(),
bag_done boolean NOT NULL DEFAULT false,
bag_done_time timestamp without time zone
)
WITH (OIDS=FALSE);
Code: Select all
CREATE TABLE rm_bag_item
(
bag_item_id serial NOT NULL,
bag_id integer NOT NULL,
bag_item_weight integer NOT NULL,
bag_item_date timestamp without time zone NOT NULL DEFAULT now()
)
WITH (OIDS=FALSE);
Code: Select all
CREATE OR REPLACE FUNCTION rm_reset_bag(id integer) RETURNS void AS $$
BEGIN
DELETE FROM rm_bag_item WHERE bag_id=id;
DELETE FROM rm_bag WHERE bag_id=id;
END;
$$ LANGUAGE 'plpgsql';
Code: Select all
if(dataGridView.CurrentRow.Index >= 0 && PostgreSQL.State == ConnectionState.Open)
{
using (PgSqlCommand sql = PostgreSQL.CreateCommand())
{
sql.CommandType = CommandType.StoredProcedure;
sql.Parameters.Add("id", PgSqlType.Int).Value = (int)dataGridView[0, dataGridView.CurrentRow.Index].Value;
sql.CommandText = @"rm_reset_bag";
try
{
sql.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
mr-owl
PostgreSQL 8.3.1, Visual Studio 2005 Standard SP1, PostgreSQLDirect .NET 3.50.25