private void btn_save_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(text_new_category.Text)) { MessageBox.Show("حقل فارغ", "رسالة خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); text_new_category.Focus(); return; } string sql = string.Format("INSERT INTO categories VALUES (NULL, '{0}')", text_new_category.Text); DataAccessLayer.DBHandler db = new DataAccessLayer.DBHandler(); if (db.ExecuteNonQuery(sql) == "Constraint") { MessageBox.Show("هذا القسم موجود بالفعل !", "رسالة خطأ", MessageBoxButtons.OK, MessageBoxIcon.Error); text_new_category.Focus(); text_new_category.SelectAll(); return; } (new System.Windows.Forms.NotifyIcon() { Visible = true, Icon = System.Drawing.SystemIcons.Information, BalloonTipText = "تم الحفظ بنجاح", }).ShowBalloonTip(1000); OnCategoriewUpdated(); }
public void Start(DataTable categories, DataTable units) { if (db == null) { db = new DataAccessLayer.DBHandler(); } combo_categories.DisplayMember = "category"; combo_categories.ValueMember = "id"; combo_categories.DataSource = categories; combo_units.DisplayMember = "unit"; combo_units.ValueMember = "id"; combo_units.DataSource = units; combo_base_units.BindingContext = new System.Windows.Forms.BindingContext(); combo_base_units.DisplayMember = "unit"; combo_base_units.ValueMember = "id"; combo_base_units.DataSource = units; combo_sub_units.DisplayMember = "unit"; combo_sub_units.ValueMember = "id"; combo_sub_units.DataSource = units; combo_sub_units.BindingContext = new System.Windows.Forms.BindingContext(); combo_categories.SelectedValueChanged += combo_categories_SelectedValueChanged; combo_categories_SelectedValueChanged(combo_categories, EventArgs.Empty); combo_existed_products_names.SelectedValueChanged += combo_existed_products_names_SelectedValueChanged; combo_existed_products_names_SelectedValueChanged(combo_categories, EventArgs.Empty); }
public void Start() { if (db == null) { db = new DataAccessLayer.DBHandler(); } }
private void btn_save_Click(object sender, EventArgs e) { DataAccessLayer.DBHandler db = new DataAccessLayer.DBHandler(); DataTable tbl = (DataTable)dgv_product_name_data.DataSource; foreach (DataRow row in tbl.Rows) { string sql = string.Format("UPDATE products SET selling_price = {1} , purchasing_price = {0}, profit_margin = {2} WHERE product_id = {3} ", row[3].ToString(), row[4].ToString(), row[5].ToString(), row[0].ToString()); db.ExecuteSQL(sql); } this.Close(); }
public void GetAllProductData() { DataAccessLayer.DBHandler db = new DataAccessLayer.DBHandler(); string query = string.Format(@"SELECT products.product_id, products_names.product_name, units.unit FROM products JOIN products_names ON products.product_name_id = products_names.product_name_id JOIN units ON products.unit_id = units.id WHERE products.product_name_id = {0} AND products.unit_id = {1}", this.ProductNameID, this.UnitID); System.Data.DataRow row = db.ExecuteSQLOneRow(query); this.ProductName = row["product_name"].ToString(); this.UnitName = row["unit"].ToString(); this.ProductID = row["product_id"].ToString(); }