public static Boolean updateStockQty(ItemDTO item) { int result = 0; try { string query = "update pos.item SET quantity=@quantity where itemcode=@itemcode"; MySqlCommand command = new MySqlCommand(query, conn); command.Parameters.AddWithValue("@quantity", item.getQuantity()); command.Parameters.AddWithValue("@itemcode", item.getItemCode()); conn.Open(); result = command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); conn.Close(); return(false); } Console.Read(); conn.Close(); if (result > 0) { return(true); } else { return(false); } }
private void CmbItemCode_SelectedIndexChanged(object sender, EventArgs e) { /*ItemDTO item = new ItemDTO(); * item = ItemController.searchItem((cmbItemCode.SelectedItem).ToString()); * txtItemDescription.Text = item.getItemName(); * txtQtyOnHand.Text = (item.getQuantity()).ToString(); * txtUnitPrice.Text = (item.getPrice()).ToString(); * codeOfItem = item.getItemCode();*/ ItemDTO item = new ItemDTO(); item = ItemController.searchItemDescription((cmbItemDescription.SelectedItem).ToString()); txtItemCode.Text = item.getItemCode(); txtQtyOnHand.Text = (item.getQuantity()).ToString(); txtUnitPrice.Text = (item.getPrice()).ToString(); codeOfItem = item.getItemCode(); }
public static Boolean addNewItem(ItemDTO itemDTO) { int result = 0; try { String query = "INSERT INTO pos.item (itemcode,itemname,quantity,price) VALUES (@itemcode, @itemname, @quantity,@price)"; MySqlCommand command = new MySqlCommand(query, conn); //Console.WriteLine(custDTO.getNic() + " " + custDTO.getName()); command.Parameters.AddWithValue("@itemcode", itemDTO.getItemCode()); command.Parameters.AddWithValue("@itemname", itemDTO.getItemName()); command.Parameters.AddWithValue("@quantity", itemDTO.getQuantity()); command.Parameters.AddWithValue("@price", itemDTO.getPrice()); conn.Open(); result = command.ExecuteNonQuery(); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); // MessageBox.Show("exception occured"); conn.Close(); return(false); } Console.Read(); conn.Close(); if (result > 0) { return(true); } else { return(false); } }