예제 #1
0
        public static int Addorderline(Order_lines ol)
        {
            NpgsqlConnection connection      = accountDB.GetConnection();
            string           insertStatement =
                "INSERT into order_lines " +
                "(order_id,cost_id,price,date) " +
                "VALUES (" + ol.morder_id + ", " + ol.mcost_id + "," + ol.mprice.ToString(System.Globalization.CultureInfo.InvariantCulture) + ",'" + ol.mdate + "') returning order_id";

            NpgsqlCommand insertCommand = new NpgsqlCommand(insertStatement, connection);

            try
            {
                connection.Open();
                int leerlingID = Convert.ToInt32(insertCommand.ExecuteScalar());
                return(leerlingID);
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
        }
예제 #2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            Order_lines ol = new Order_lines();

            ol.morder_id = ordersform.orderid;
            ol.mcost_id  = (int)cmbcosts.SelectedValue;
            ol.mprice    = Convert.ToDouble(txtprice.Text);
            ol.mdate     = dtpDate.Value;
            order_linesDB.Addorderline(ol);
            this.Close();
        }
예제 #3
0
        public static List <Order_lines> GetorderlinesList(Int32 order_id)
        {
            List <Order_lines> lineslist       = new List <Order_lines>();
            NpgsqlConnection   connection      = accountDB.GetConnection();
            string             selectStatement =
                "select *" +
                "from order_lines " +
                "WHERE order_id = @order_id;";
            NpgsqlCommand selectCommand = new NpgsqlCommand(selectStatement, connection);

            selectCommand.Parameters.AddWithValue("@order_id", order_id);
            try
            {
                connection.Open();
                NpgsqlDataReader reader = selectCommand.ExecuteReader();
                while (reader.Read())
                {
                    Order_lines ol = new Order_lines();
                    ol.mcost_id = (int)reader["cost_id"];
                    Cost c = new Cost();
                    c            = costDB.getcost(ol.mcost_id);
                    ol.mcostname = c.returnname;
                    ol.mprice    = Convert.ToDouble(reader["price"]);
                    ol.mdate     = Convert.ToDateTime(reader["date"]);
                    lineslist.Add(ol);
                }
                reader.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(lineslist);
        }