Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Npgsql;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Data.SqlClient;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace WindowsFormsApp2
- {
- public partial class ChangeGoodInOrderForm : Form
- {
- NpgsqlConnection con;
- private DataSet ds = new DataSet();
- private DataTable dt = new DataTable();
- SqlDataReader dr;
- NpgsqlDataAdapter da;
- int id;
- int goodID, orderID;
- private void Update()
- {
- string sql = "Select * from goods";
- da = new NpgsqlDataAdapter(sql, con);
- ds.Reset();
- da.Fill(ds);
- dt = ds.Tables[0];
- comboBoxGood.DataSource = dt;
- comboBoxGood.DisplayMember = "name";
- comboBoxGood.ValueMember = "goodID";
- comboBoxGood.SelectedValue = goodID.ToString();
- }
- public ChangeGoodInOrderForm(NpgsqlConnection con, int id, int orderID, int goodID, int amount)
- {
- InitializeComponent();
- this.con = con;
- this.id = id;
- this.orderID = orderID;
- this.goodID = goodID;
- textBoxAmount.Text = amount.ToString();
- }
- private void buttonSave_Click(object sender, EventArgs e)
- {
- //try
- //{
- NpgsqlCommand command = new NpgsqlCommand("UPDATE orderEntries SET orderID = :orderID, goodID = :goodID, " +
- "amount = :amount WHERE orderEntriesID = :id", con);
- command.Parameters.AddWithValue("id", id);
- command.Parameters.AddWithValue("orderID", orderID);
- command.Parameters.AddWithValue("goodID", comboBoxGood.SelectedValue);
- command.Parameters.AddWithValue("amount", Convert.ToInt32(textBoxAmount.Text));
- command.ExecuteNonQuery();
- Close();
- //}
- //catch { }
- }
- private void ChangeGoodInOrderForm_Load(object sender, EventArgs e)
- {
- Update();
- }
- private void ChangeGoodInOrderForm_FormClosed(object sender, FormClosedEventArgs e)
- {
- Close();
- }
- }
- }
Add Comment
Please, Sign In to add comment