Exemple #1
0
        private void show_expenses()
        {
            Expensess expensess = new Expensess();

            expensess.Day = comboBox_dayno_borrows.SelectedItem.ToString();
            string day = expensess.Day;

            expensess.Month = date_month.SelectedItem.ToString();
            String month = expensess.Month;

            expensess.Year = date_year.SelectedItem.ToString();
            String year = expensess.Year;

            string query = "SELECT price FROM expenses WHERE day='" + day + "' AND month ='" + month + "' AND year='" + year + "'";


            MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, databaseConnection);
            DataTable        dataTable        = new DataTable();

            mySqlDataAdapter.Fill(dataTable);
            dataGridView3.Rows.Clear();

            foreach (DataRow datarow in dataTable.Rows)
            {
                int n = dataGridView3.Rows.Add();
                dataGridView3.Rows[n].Cells[0].Value = datarow[0].ToString();
                sum_day_expenses += double.Parse(datarow[0].ToString());

                label7.Text = sum_day_expenses + " JD";
            }
            // MessageBox.Show("sum_Month_borrowing : " + sum_day_borrowing);
        }
Exemple #2
0
        private void insert_data_exp()
        {
            MySqlCommand commandDatabase = new MySqlCommand("", databaseConnection);

            commandDatabase.CommandTimeout = 60;

            try
            {
                int    select    = comboBox_type.SelectedIndex;
                string id_expens = "";
                for (int i = 0; i < 2000; i++)
                {
                    if (select == i)
                    {
                        id_expens = id_exp[i];
                    }
                }

                Expensess expensess = new Expensess();

                expensess.Name_exp = textBox_consum.Text;
                String price = expensess.Name_exp;

                expensess.Date_exp = dateTimePicker1.Text;
                String date = expensess.Date_exp;

                // MessageBox.Show("Month" + dateTimePicker1.Value.Month + "");
                //MessageBox.Show("Year" + dateTimePicker1.Value.Year + "");
                int month = dateTimePicker1.Value.Month;
                int year  = dateTimePicker1.Value.Year;
                int day   = dateTimePicker1.Value.Day;



                commandDatabase.CommandText = "INSERT INTO expenses(id,id_exp, date,price,consumer,month,year,day)VALUES(NULL,'" + id_expens + "','" + date + "','" + price + "','" + consumer + "','" + month + "','" + year + "','" + day + "')";
                commandDatabase.ExecuteNonQuery();
                commandDatabase.Dispose();



                txt_name_consumer.Text = "";
                dateTimePicker1.Text   = "";
                textBox_consum.Text    = "";
                comboBox_type.Text     = "";
            }
            catch (Exception e)
            {
                MessageBox.Show("Query Error :" + e.Message);
            }
        }
Exemple #3
0
        private void add_new_type()
        {
            if (comboBox_type.Items.Contains(textBox_new_type.Text))
            {
                int index = comboBox_type.FindString(textBox_new_type.Text);
                comboBox_type.SelectedIndex = index;

                MessageBox.Show("المصروف   " + textBox_new_type.Text + "   موجود بالفعل");
            }
            else
            {
                comboBox_type.Items.Clear();
                MySqlCommand commandDatabase = new MySqlCommand("", databaseConnection);

                commandDatabase.CommandTimeout = 60;

                try
                {
                    Expensess expensess = new Expensess();

                    expensess.New_type_exp = textBox_new_type.Text;
                    String new_type_exp = expensess.New_type_exp;



                    commandDatabase.CommandText = "INSERT INTO exp(id,name)VALUES(NULL,'" + new_type_exp + "')";
                    commandDatabase.ExecuteNonQuery();
                    commandDatabase.Dispose();


                    load_type_exp();

                    comboBox_type.SelectedIndex = comboBox_type.Items.Count - 1;

                    MessageBox.Show("Query successfully excuted");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Query Error :" + ex.Message);
                }
            }
        }