Ejemplo n.º 1
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (Checker())
     {
         if (txtItemID.Text != "")
         {
             ItemModelEdit item = new ItemModelEdit(
                 Convert.ToInt32(txtItemID.Text),
                 txtItemName.Text,
                 Convert.ToDecimal(txtSelfCost.Text),
                 Convert.ToInt32(cmbItemCategory.SelectedValue)
                 );
             SqliteDataAccess.EditItem(item);
         }
         else
         {
             ItemModelEdit item = new ItemModelEdit(
                 txtItemName.Text,
                 Convert.ToDecimal(txtSelfCost.Text),
                 Convert.ToDecimal(txtItemPrice.Text),
                 Convert.ToInt32(cmbItemCategory.SelectedValue),
                 DateTime.Now
                 );
             SqliteDataAccess.CreateItem(item);
         }
     }
     GenerateBarcode();
     this.Close();
 }
Ejemplo n.º 2
0
 public static void CreateItem(ItemModelEdit item)
 {
     using (IDbConnection cnn = new MySqlConnection(LoadConnectionString()))
     {
         cnn.Execute("INSERT INTO items (ItemName, ItemBarcode, SelfCost, ItemPrice, ItemCategoryID, ItemAddedDate) " +
                     "VALUES (@ItemName, '', @SelfCost, @ItemPrice, @ItemCategoryID, @ItemAddedDate)", item);
     }
 }
Ejemplo n.º 3
0
 public static void EditItem(ItemModelEdit item)
 {
     using (IDbConnection cnn = new MySqlConnection(LoadConnectionString()))
     {
         cnn.Execute("UPDATE items SET ItemName = @ItemName, " +
                     "SelfCost = @SelfCost, " +
                     "ItemCategoryID = @ItemCategoryID " +
                     "WHERE ItemID = @ItemID ", item);
     }
 }