Example #1
0
 private void update()
 {
     if (this.txtName.TextLength <= 0 || MessageBox.Show("Güncellenicektir!!! Emin misiniz?", "Uyarı", MessageBoxButtons.YesNo) != DialogResult.Yes)
     return;
       Product product = (Product)this.cbProducts.SelectedItem;
       ProductType productType = (ProductType)this.cbProTypes.SelectedItem;
       if (product.Name == "Yeni")
       {
     product = new Product();
     product.ID = 0;
       }
       int status = 2;
       if (!this.cbStatus.Checked)
     status = 1;
       Decimal price = Convert.ToDecimal(this.txtPrice.Text);
       Product.Products_Update(product.ID, this.txtName.Text, productType.ID, status, price);
       this.Fill();
 }
Example #2
0
        public static List<Product> Products_GetAll()
        {
            string query = "Products_GetAll";

              DataTable dt = Connection.runQuery(query, new SqlParameter[0]);

              List<Product> res = new List<Product>();

              for (int i = 0; i < dt.Rows.Count; i++)
              {
            Product tmp = new Product();

            tmp.ID = Convert.ToInt32(dt.Rows[i]["ID"].ToString());
            tmp.Name = dt.Rows[i]["Name"].ToString();
            tmp.Type = Convert.ToInt32(dt.Rows[i]["Type"].ToString());
            tmp.Status = Convert.ToInt32(dt.Rows[i]["Status"].ToString());
            tmp.Price = Convert.ToDecimal(dt.Rows[i]["Price"].ToString());

            res.Add(tmp);
              }
              return res;
        }
Example #3
0
        public static Product Products_GetByID(int id)
        {
            string query = "Products_GetByID";

              List<SqlParameter> prms = new List<SqlParameter>();

              prms.Add(new SqlParameter("@ID", id));

              DataTable dt = Connection.runQuery(query, prms.ToArray());

              Product res = new Product();

              for (int i = 0; i < dt.Rows.Count; i++)
              {
            Product tmp = new Product();

            tmp.ID = Convert.ToInt32(dt.Rows[i]["ID"].ToString());
            tmp.Name = dt.Rows[i]["Name"].ToString();
            tmp.Type = Convert.ToInt32(dt.Rows[i]["Type"].ToString());
            tmp.Status = Convert.ToInt32(dt.Rows[i]["Status"].ToString());
            tmp.Price = Convert.ToDecimal(dt.Rows[i]["Price"].ToString());

            res=tmp;
              }
              return res;
        }