public static List<ProductObj> getAll() { List<ProductObj> list = new List<ProductObj>(); try { Connection c = new Connection(); MySqlCommand cmd = c.con.CreateCommand(); cmd.CommandText = "select * from product"; c.con.Open(); MySqlDataReader r = cmd.ExecuteReader(); while (r.Read()) { ProductObj product = new ProductObj(); product.id = r.GetInt32("id"); product.name = r.GetString("name"); product.price_in = r.GetFloat("price_in"); product.price_out = r.GetFloat("price_out"); product.unit = r.GetString("unit"); list.Add(product); } } catch (MySqlException me) { MessageBox.Show(me.Message); } return list; }
public SellDialog() { InitializeComponent(); data.Columns.Add("id", "Id"); data.Columns.Add("cant", "Cant"); data.Columns.Add("producto", "Producto"); data.Columns.Add("unidad", "Unidad"); data.Columns.Add("pu", "Precio Unitario"); data.Columns.Add("total", "Total"); data.Columns[0].Width = 50; data.Columns[1].Width = 50; data.Columns[2].Width = 200; data.Columns[3].Width = 100; data.Columns[4].Width = 100; data.Columns[5].Width = 100; lp = PersonObj.getAllByKindId(1); foreach (PersonObj p in lp) { client_.Items.Add(p.name + " " + p.lastname); } List <SellObj> sell = SellObj.sell; float total = 0; for (int i = 0; i < sell.Count; i++) { ProductObj product = ProductObj.getById(sell[i].product_id); data.Rows.Add(product.id, sell[i].q, product.name, product.unit, product.price_out, sell[i].q * product.price_out); total += sell[i].q * product.price_out; } data.Rows.Add("", "", "Total", "", "", total); }
private void button1_Click(object sender, EventArgs e) { if (thelist.SelectedIndex != -1) { data.Rows.Clear(); List <OperationObj> ops = OperationObj.getAllBySellId(sells[thelist.SelectedIndex].id); float total = 0; foreach (OperationObj op in ops) { ProductObj p = ProductObj.getById(op.product_id); float price = 0; if (operation_type == 1) { price = p.price_in; } else if (operation_type == 2) { price = p.price_out; } data.Rows.Add(p.id, p.unit, p.name, op.q, price, op.q * price); total += op.q * price; } data.Rows.Add("", "", "Total", "", "", total); } }
public static List <ProductObj> getAll() { List <ProductObj> list = new List <ProductObj>(); try { Connection c = new Connection(); MySqlCommand cmd = c.con.CreateCommand(); cmd.CommandText = "select * from product"; c.con.Open(); MySqlDataReader r = cmd.ExecuteReader(); while (r.Read()) { ProductObj product = new ProductObj(); product.id = r.GetInt32("id"); product.name = r.GetString("name"); product.price_in = r.GetFloat("price_in"); product.price_out = r.GetFloat("price_out"); product.unit = r.GetString("unit"); list.Add(product); } } catch (MySqlException me) { MessageBox.Show(me.Message); } return(list); }
public void load_products() { dataGridView1.Rows.Clear(); List <ProductObj> list = ProductObj.getAll(); for (int i = 0; i < list.Count; i++) { //MessageBox.Show(input + " - " + output); dataGridView1.Rows.Add(list[i].id, list[i].unit, list[i].name, list[i].price_in, list[i].price_out); } }
public void load_products() { dataGridView1.Rows.Clear(); List <ProductObj> list = ProductObj.getAll(); for (int i = 0; i < list.Count; i++) { int input = OperationObj.getSumByProduct(list[i].id, 1); int output = OperationObj.getSumByProduct(list[i].id, 2); //MessageBox.Show(input + " - " + output); dataGridView1.Rows.Add(list[i].id, list[i].name, (input - output)); } }
public static ProductObj getById(int product_id) { Connection c = new Connection(); MySqlCommand cmd = c.con.CreateCommand(); cmd.CommandText = "select * from product where id=" + product_id; c.con.Open(); MySqlDataReader r = cmd.ExecuteReader(); ProductObj product = new ProductObj(); while (r.Read()) { product.id= r.GetInt32("id"); product.name = r.GetString("name"); product.price_in = r.GetFloat("price_in"); product.price_out = r.GetFloat("price_out"); product.unit = r.GetString("unit"); break; } return product; }
public static ProductObj getById(int product_id) { Connection c = new Connection(); MySqlCommand cmd = c.con.CreateCommand(); cmd.CommandText = "select * from product where id=" + product_id; c.con.Open(); MySqlDataReader r = cmd.ExecuteReader(); ProductObj product = new ProductObj(); while (r.Read()) { product.id = r.GetInt32("id"); product.name = r.GetString("name"); product.price_in = r.GetFloat("price_in"); product.price_out = r.GetFloat("price_out"); product.unit = r.GetString("unit"); break; } return(product); }
public Re() { InitializeComponent(); prods = ProductObj.getAll(); provs = PersonObj.getAllByKindId(2); foreach (ProductObj p in prods) { product.Items.Add(p.name); } foreach (PersonObj p in provs) { provider.Items.Add(p.name + " " + p.lastname); } data.Columns.Add("id", "Id"); data.Columns.Add("unidad", "Unidad"); data.Columns.Add("nombre", "Nombre"); data.Columns.Add("cantidad", "Cantidad"); data.Columns.Add("precio", "Precio"); data.Columns[0].Width = 50; data.Columns[1].Width = 100; data.Columns[2].Width = 350; data.Columns[3].Width = 100; data.Columns[4].Width = 100; }
public ProductObj getProduct() { return(ProductObj.getById(this.product_id)); }