Beispiel #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("ادخل معلومات صحيحه");
            }
        }
Beispiel #2
0
        public void SetSale(double result, DateTime date, String discount)
        {
            sale_label.Text = result + "";
            double sale          = Convert.ToDouble(total.Text) - result;
            string insert_query2 = "INSERT INTO discounts " +
                                   "(cust_id,dis_date,dis_total,dis_ratio,dis_price,user_id) " +
                                   "VALUES (" + Id + " , '" + FormatDate(date) + "' " +
                                   ", '" + final_amount + "' , '" + discount + "' " +
                                   ", '" + (final_amount - result) + "' , '" + User_id + "')";

            if (db.insertDB(insert_query2))
            {
                RefreshData();
                discounts_tab.Select();
            }
        }
Beispiel #3
0
        private void add_payment_btn_Click(object sender, EventArgs e)
        {
            date = dateTimePicker1.Value;
            int n;

            if (customer_combo.SelectedIndex >= 0 && int.TryParse(price_text.Text, out n))
            {
                String query = "INSERT INTO payments (cust_id,pay_price,pay_date,pay_note,user_id)" +
                               "VALUES((SELECT cust_id from customer where cust_name='" + customer_combo.SelectedItem + "') , '" + price_text.Text + "' , '" + FormatDate(date) + "', '" + textBox1.Text + "' ,'" + form.Id + "' )";
                if (db.insertDB(query))
                {
                    if (ch != null)
                    {
                        if (ch.IMG == null)
                        {
                            string query2 = "INSERT INTO checks VALUES('" + ch.Id + "', (SELECT MAX(pay_id) from payments) ,'" + ch.Bank + "'" +
                                            ",'" + ch.Owner + "' , '" + FormatDate(ch.Delv_Date) + "' ," + ch.Price + " ,'" + ch.Notes + "')";
                            db.insertDB(query2);
                        }
                        else
                        {
                            string query2 = "INSERT INTO checks VALUES('" + ch.Id + "', (SELECT MAX(pay_id) from payments) ,'" + ch.Bank + "'" +
                                            ",'" + ch.Owner + "' , '" + FormatDate(ch.Delv_Date) + "' ," + ch.Price + " ,'" + ch.Notes + "',@picture)";
                            db.insertImg(query2, ch.IMG);
                        }
                    }
                    this.Close();
                    if (form != null)
                    {
                        form.RefreshPayment(form.payment_query);
                    }
                    if (cust_form != null)
                    {
                        cust_form.RefreshData();
                    }
                }
            }
            else
            {
                MessageBox.Show("يحب ان تختار زبون\nويجب ان تضل قيمه رقميه في قيمه الكاش");
            }
        }
Beispiel #4
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);
         }
     }
 }
Beispiel #5
0
        private void add_debit_btn_Click(object sender, EventArgs e)
        {
            date = dateTimePicker1.Value;
            int n;

            if (customer_combo.SelectedIndex >= 0 && int.TryParse(price_text.Text, out n))
            {
                string query = "INSERT INTO debits (cust_id,deb_date,deb_price,user_id) VALUES((SELECT cust_id from customer where cust_name='" + customer_combo.SelectedItem + "'),'" + FormatDate(date) + "','" + price_text.Text + "','" + form.Id + "')";
                if (db.insertDB(query))
                {
                    MessageBox.Show("تم اضافه الدين");
                    this.Close();
                }
            }
        }
Beispiel #6
0
 private void add_teeth_Click(object sender, EventArgs e)
 {
     if (teeth_txt.Text != "" && price_txt.Text != "")
     {
         try
         {
             double price = Convert.ToDouble(price_txt.Text);
             if (db.insertDB("INSERT INTO teeth_type VALUES('" + teeth_txt.Text + "','" + price + "')"))
             {
                 RefreshTeeth();
                 teeth_txt.Clear();
                 price_txt.Clear();
             }
         }
         catch (FormatException)
         {
             MessageBox.Show("ادخل سعر حقيقي");
         }
     }
     else
     {
         MessageBox.Show("يجب ملئ الخانه لاضافه نوع");
     }
 }
Beispiel #7
0
 private void add_Click(object sender, EventArgs e)
 {
     try
     {
         if (name_combo.SelectedItem.ToString() != "")
         {
             int    amount = Convert.ToInt32(amount_txt.Text);
             string insert = "INSERT INTO need (need_name,need_amount,need_date) VALUES('" + name_combo.SelectedItem + "','" + amount + "','" + FormatDate(DateTime.Today) + "')";
             if (db.insertDB(insert))
             {
                 this.Close();
                 MessageBox.Show("تم ادخاله الناقص");
                 form.RefreshNeed(form.need_query);
             }
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("ادخل كميه صحيحه");
     }
 }
Beispiel #8
0
 private void add_Click(object sender, EventArgs e)
 {
     try {
         string type  = type_combo.SelectedItem.ToString();
         double price = Convert.ToDouble(price_txt.Text);
         if (type != "")
         {
             string insert_query = "INSERT INTO outcome (out_type,out_price,out_date) VALUES('" + type + "','" + price + "','" + FormatDate(date_pic.Value) + "')";
             if (db.insertDB(insert_query))
             {
                 this.Close();
                 MessageBox.Show("تم اضافه المصروف");
                 form.RefreshOut(form.out_query);
             }
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("لقد ادخلت سعر غير صحيح");
     }
 }
Beispiel #9
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (name_txt.Text != "" && phone_txt.Text != "")
         {
             if (casses == 1)
             {
                 string insert_query = "INSERT INTO seller (sell_name,sell_no,sell_email) VALUES('" + name_txt.Text + "','" + phone_txt.Text + "','" + email_txt.Text + "')";
                 if (db.insertDB(insert_query))
                 {
                     MessageBox.Show("تم ادخال التاجر");
                     this.Close();
                     form.RefreshSell(form.sell_query);
                 }
             }
             else if (casses == 2)
             {
                 string update_query = "UDPATE seller SET sell_name='" + name_txt.Text + "',sell_no='" + phone_txt.Text + "',sell_email='" + email_txt.Text + "' WHERE sell_id=" + this.id;
                 if (db.updateDB(update_query))
                 {
                     MessageBox.Show("تم تعديل التاجر");
                     this.Close();
                     form.RefreshSell(form.sell_query);
                 }
             }
         }
         else
         {
             MessageBox.Show("يجب ملئ خانتي الاسم والرقم");
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("ادخل رقم هاتف صحيح");
     }
 }