Exemplo n.º 1
0
 internal static long? DeleteProduct(Product product)
 {
     if(product != null)
     {
         string _query = string.Format("DELETE FROM Product WHERE ProductID = {0}", product.ProductID);
         return CaseStudyDB.ExecuteNonQuery(_query);
     }
     return null;
 }
Exemplo n.º 2
0
 public static long? AddProduct(Product product)
 {
     if (product != null)
     {
         string _query = string.Format("INSERT INTO Product (Name, Price, Description, Type) " +
             "VALUES('{0}', {1}, '{2}', '{3}')",
             product.Name, product.Price, product.Description, product.Type);
         return CaseStudyDB.ExecuteNonQuery(_query);
     }
     return null;
 }
Exemplo n.º 3
0
 public static long? ModifyProduct(Product product)
 {
     if(product != null)
     {
         string _query = string.Format("UPDATE Product " +
             "SET Name='{0}', Price={1}, Description='{2}', Type='{3}' " +
             "WHERE ProductID = {4}", product.Name, product.Price,
             product.Description, product.Type, product.ProductID);
         return CaseStudyDB.ExecuteNonQuery(_query);
     }
     return null;
 }
Exemplo n.º 4
0
 public frmModifyProduct(Product product)
 {
     InitializeComponent();
     if(product != null)
     {
         _productToModify = product;
         FillFormData();
     }
     else
     {
         this.Close();
     }
 }
Exemplo n.º 5
0
        internal virtual void btnSubmit_Click(object sender, EventArgs e)
        {
            if(IsValidData())
            {
                product = new Product();
                product.Name = txtName.Text;
                product.Description = txtDescription.Text;
                product.Price = int.Parse(txtPrice.Text);
                product.Type = (Product.Types)comboType.SelectedItem;

                ProductDB.AddProduct(product);
                this.Close();
            }
        }
Exemplo n.º 6
0
 public static List<Product> GetProducts()
 {
     List<Product> products = new List<Product>();
     string _query = "SELECT * FROM Product";
     using (SqlCeDataReader reader = CaseStudyDB.ExecuteReader(_query))
     {
         while(reader != null && reader.Read())
         {
             Product product = new Product();
             product.ProductID = (long?)reader["ProductID"];
             product.Name = reader["Name"].ToString();
             product.Description = reader["Description"].ToString();
             product.Price = (int?)reader["Price"];
             Product.Types type;
             Enum.TryParse<Product.Types>(reader["Type"].ToString(), out type);
             product.Type = type;
             products.Add(product);
         }
         return products;
     }
 }
Exemplo n.º 7
0
 private void lstProducts_SelectedIndexChanged(object sender, EventArgs e)
 {
     if(lstProducts.SelectedIndex != -1)
     {
         if (lstCustomers.SelectedIndex != -1)
         {
             numQuantity.Enabled = true;
         }
         _product = _products[lstProducts.SelectedIndex];
     }
 }