Ejemplo n.º 1
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Product pro = new Product();
                pro.Name = txtNameProduct.Text;
                pro.Price = float.Parse(txtPrice.Text);
                ProductBLL.InsertProduct(pro);
                System.Windows.Forms.MessageBox.Show("Successfully");
                if (AddFinished != null)
                {
                    AddFinished(pro);
                }


            }
            catch (Exception g)
            {

                System.Windows.Forms.MessageBox.Show("Error: " + g.Message);
            }
            finally
            {
                this.Close();
            }
        }
Ejemplo n.º 2
0
 public InvoiceDetail(int invoiceID, Product product, int quantity)
 {
     InvoiceID = invoiceID;
     ProductID = product.ProductID;
     Quantity = quantity;
     SubTotal = product.Price * Quantity;
 }
Ejemplo n.º 3
0
        public static List<Product> SelectAllProduct()
        {
            List<Product> list = new List<Product>();
            string sql = "spGetAllProduct";
            try
            {
                SqlDataReader rd = DataProvider.ExecuteQueryWithDataReader(sql, System.Data.CommandType.StoredProcedure);
                if (rd.HasRows)
                {
                    while(rd.Read())
                    {
                        Product p = new Product()
                        {
                            ProductID = rd.GetInt32(0),
                            Name = rd.GetString(1),
                            Price = rd.GetDouble(2)

                        };
                        list.Add(p);
                    }
                }
            }catch(Exception g)
            {
                throw new Exception(g.Message);
            }
            return list;
        }
Ejemplo n.º 4
0
 public static bool InsertProduct(Product pro)
 {
     string sql = "spInsertProduct";
     SqlParameter Name = new SqlParameter("Name", pro.Name);
     SqlParameter Price = new SqlParameter("Price", pro.Price);
     return DataProvider.ExecuteNonQuery(sql, System.Data.CommandType.StoredProcedure, Name, Price);
 }
Ejemplo n.º 5
0
        public static bool UpdateProduct(Product Pro)
        {
          
            string sql = "spUpdateProduct";
            SqlParameter ProID = new SqlParameter("ProductID", Pro.ProductID);
            SqlParameter Name = new SqlParameter("Name", Pro.Name);
            SqlParameter Price = new SqlParameter("Price", Pro.Price);
            
            return DataProvider.ExecuteNonQuery(sql, CommandType.StoredProcedure, ProID,Name,Price);

        }
Ejemplo n.º 6
0
    private void btnEditProduct_Click(object sender, RoutedEventArgs e)
    {
 
        try
        {
            if (dtgProduct.SelectedIndex >= 0)
            {
                DataRow dr = dt.Rows[dtgProduct.SelectedIndex];
                Product pro = new Product();
                pro.ProductID = (int)dr["ProductID"];
                pro.Name = dr["Name"].ToString();
                pro.Price = (double)dr["Price"];
                Edit_Product product = new Edit_Product(pro);
                product.EditFinished += new HD(EditCurRow);
                product.ShowDialog();
          
            }
        }
        catch (Exception g)
        {
            System.Windows.Forms.MessageBox.Show(g.Message);
        }
    }
Ejemplo n.º 7
0
 public static bool UpdateProductByID(Product pro)
 {
     return ProductData.UpdateProduct(pro);
 }
Ejemplo n.º 8
0
 public static bool InsertProduct(Product pro)
 {
     return ProductData.InsertProduct(pro);
 }
Ejemplo n.º 9
0
 private void UpdateTable(Product pro)
 {
     dt.Rows.Add(pro.ProductID, pro.Name, pro.Price);
 }
Ejemplo n.º 10
0
    private void EditCurRow(Product a)
    {
        DataRow dr = dt.Rows.Find(a.ProductID);
        dr["Name"] = a.Name;
        dr["Price"] = a.Price;
      

    }