Exemple #1
0
        private void save_Click(object sender, EventArgs e)
        {
            string name  = name_txt.Text;
            string type  = type_combo.SelectedItem.ToString();
            string email = email_txt.Text;

            if (name != "" && type != "")
            {
                if (cases == 1)
                {
                    string insert_query = "INSERT INTO customer (cust_name,cust_type,cust_email) VALUES('" + name + "','" + type + "','" + email + "')";
                    if (db.insertDB(insert_query))
                    {
                        int id = db.SelectID("SELECT cust_id FROM customer WHERE cust_name='" + name + "'");
                        for (int i = 0; i < phone_list.Items.Count; i++)
                        {
                            string p     = phone_list.Items[i].Text;
                            string query = "INSERT INTO phones VALUES('" + p + "'," + id + ")";
                            if (db.insertDB(query))
                            {
                            }
                        }
                        MessageBox.Show("تم اضافه الزبون");
                        this.Close();
                        form.RefreshCust(form.cust_query);
                    }
                }
                else if (cases == 2)
                {
                    string update_query = "UPDATE customer SET cust_name='" + name + "',cust_type='" + type + "',cust_email='" + email + "' WHERE cust_id=" + id;
                    if (db.updateDB(update_query))
                    {
                        db.deleteDB("DELETE FROM phones WHERE cust_id=" + id);
                        for (int i = 0; i < phone_list.Items.Count; i++)
                        {
                            string p     = phone_list.Items[i].Text;
                            string query = "INSERT INTO phones VALUES('" + p + "'," + id + ")";
                            if (db.insertDB(query))
                            {
                            }
                        }
                        MessageBox.Show("تم تعديل معلومات الزبون الزبون");
                        this.Close();
                        form.RefreshCust(form.cust_query);
                    }
                }
            }
            else
            {
                MessageBox.Show("ادخل معلومات صحيحه");
            }
        }
Exemple #2
0
 private void add_Click(object sender, EventArgs e)
 {
     if (seller_combo.SelectedItem.ToString() != "" && data != null)
     {
         int    seller_id     = db.SelectID("SELECT sell_id FROM seller WHERE sell_name='" + seller_combo.SelectedItem + "'");
         string insert_query1 = "INSERT INTO sell_bill (sell_id,sbill_price) VALUES(" + seller_id + "," + price_txt.Text + ")";
         if (db.insertDB(insert_query1))
         {
             int real_id = Convert.ToInt32(db.ListOF("SELECT sbill_id FROM sell_bill").Last());
             for (int i = 0; i < data.GetLength(0); i++)
             {
                 string insert_query2 = "INSERT INTO sell_bill_items VALUES('" + real_id + "','" + data[i, 0] + "','" + data[i, 1] + "','" + data[i, 2] + "')";
                 db.insertDB(insert_query2);
             }
             MessageBox.Show("تم اضافه الفاتوره");
             this.Close();
             form.RefreshSellBill(form.sell_bill_query);
         }
     }
 }