Esempio n. 1
0
        private void UpdateProductData(Product existed_product)
        {
            List <string> old_data = new List <string>();
            List <string> new_data = new List <string>();

            new_data.Add(combo_units.Text);
            new_data.Add(text_amount.Text);
            new_data.Add(text_purchasing_price.Text);
            new_data.Add(text_selling_price.Text);
            new_data.Add(text_profit_margin.Text);

            if (new FormExistedDataMessage().ShowDialog(combo_categories.Text, existed_product, new_data) == DialogResult.OK)
            {
                string update_product_data = string.Format(@"
UPDATE products
SET unit_id = {0},
    amount = {1},
    purchasing_price = {2},
    selling_price = {3},
    profit_margin = {4}
WHERE product_id = {5}
"
                                                           , combo_units.SelectedValue.ToString(),
                                                           text_amount.Text,
                                                           text_purchasing_price.Text,
                                                           text_selling_price.Text,
                                                           text_profit_margin.Text,
                                                           existed_product.ProductID);
                db.ExecuteNonQuery(update_product_data);
            }
        }
Esempio n. 2
0
        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();
        }