Example #1
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ويجب ان تضل قيمه رقميه في قيمه الكاش");
            }
        }