Exemple #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (!KontrolEt())
            {
                return;
            }
            Yemek y = new Yemek()
            {
                AD = txt_yemekadi.Text.ToUpper(), Kalori = Convert.ToInt32(txt_kalori.Text)
            };

            if (durum == 1)
            {
                Yemek.Ekle(y);
                MessageBox.Show("Eklendi:" + y.AD);
            }
            else if (durum == 2)
            {
                Yemek.Guncelle(y, dt.Rows[comboBox1.SelectedIndex]["AD"].ToString());
                MessageBox.Show("Eklendi:" + y.AD);
            }
            VerileriYukle();
            groupBox1.Enabled = false;
            durum             = 0;
        }
Exemple #2
0
        void VerileriYukle()
        {
            comboBox_ogun.SelectedIndex = 0;
            dt = Yemek.GetAll();

            if (dt.Rows.Count <= 0)
            {
                //MessageBox.Show("HİÇ YEMEK EKLENMEMİŞ");
                Form_Yemek f = new Form_Yemek();
                f.Show();
                this.Close();
            }
            foreach (DataRow item in dt.Rows)
            {
                comboBox1.Items.Add(item["AD"].ToString());
                comboBox2.Items.Add(item["AD"].ToString());
                comboBox3.Items.Add(item["AD"].ToString());
                comboBox4.Items.Add(item["AD"].ToString());
                comboBox5.Items.Add(item["AD"].ToString());
                comboBox6.Items.Add(item["AD"].ToString());
                comboBox7.Items.Add(item["AD"].ToString());
                //
                comboBox1.AutoCompleteCustomSource.Add(item["AD"].ToString());
                comboBox2.AutoCompleteCustomSource.Add(item["AD"].ToString());
                comboBox3.AutoCompleteCustomSource.Add(item["AD"].ToString());
                comboBox4.AutoCompleteCustomSource.Add(item["AD"].ToString());
                comboBox5.AutoCompleteCustomSource.Add(item["AD"].ToString());
                comboBox6.AutoCompleteCustomSource.Add(item["AD"].ToString());
                comboBox7.AutoCompleteCustomSource.Add(item["AD"].ToString());
            }

            if (comboBox1.Items.Count > 0)
            {
                comboBox1.SelectedIndex = 0;
                comboBox2.SelectedIndex = 0;
                comboBox3.SelectedIndex = 0;
                comboBox4.SelectedIndex = 0;
                comboBox5.SelectedIndex = 0;
                comboBox6.SelectedIndex = 0;
                comboBox7.SelectedIndex = 0;
            }

            if (yemek != null)
            {
                dateTimePicker1.Value      = Convert.ToDateTime(yemek.Tarih);
                comboBox_ogun.SelectedItem = yemek.Ogun;
                comboBox1.Text             = yemek.a1;
                comboBox2.Text             = yemek.a2;
                comboBox3.Text             = yemek.a3;
                comboBox4.Text             = yemek.a4;
                comboBox5.Text             = yemek.a5;
                comboBox6.Text             = yemek.a6;
                comboBox7.Text             = yemek.a7;
                lbl_kalori.Text            = yemek.ToplamKalori.ToString();
            }
        }
Exemple #3
0
        public static void Guncelle(Yemek a, string ad)
        {
            DataTable dt = GetAll();
            DataRow   r  = dt.Rows.Find(ad);

            r["AD"]     = a.AD;
            r["Kalori"] = a.Kalori;

            _dt_yemek.AcceptChanges();
            string path = Application.StartupPath + "\\veriler\\yemekler.xml";

            _dt_yemek.WriteXml(path);
        }
Exemple #4
0
        public static void Ekle(Yemek a)
        {
            DataTable dt = GetAll();
            DataRow   r  = dt.NewRow();

            r["AD"]     = a.AD;
            r["Kalori"] = a.Kalori;

            _dt_yemek.Rows.Add(r);
            _dt_yemek.AcceptChanges();
            string path = Application.StartupPath + "\\veriler\\yemekler.xml";

            _dt_yemek.WriteXml(path);
        }
Exemple #5
0
        public static void Sil(Yemek a)
        {
            //string sorgu = "delete from Arac where Plaka=@p";
            //Dictionary<string, object> param = new Dictionary<string, object>();
            //param.Add("@p", a.Plaka);
            //DB.ExecuteCommand(sorgu, param);
            DataTable dt = GetAll();
            DataRow   r  = dt.Rows.Find(a.AD);

            dt.Rows.Remove(r);
            _dt_yemek.AcceptChanges();
            string path = Application.StartupPath + "\\veriler\\yemekler.xml";

            _dt_yemek.WriteXml(path);
        }
Exemple #6
0
 //fonsiyonlar
 void VerileriYukle()
 {
     comboBox1.Items.Clear();
     dt = Yemek.GetAll();
     if (dt.Rows.Count <= 0)
     {
         MessageBox.Show("HİÇ YEMEK EKLENMEMİŞ");
     }
     foreach (DataRow item in dt.Rows)
     {
         comboBox1.Items.Add(item["AD"].ToString());
     }
     if (comboBox1.Items.Count > 0)
     {
         comboBox1.SelectedIndex = 0;
     }
 }
Exemple #7
0
        private void button3_Click(object sender, EventArgs e)
        {
            DialogResult sonuc = MessageBox.Show(comboBox1.SelectedItem.ToString() + "-Yemek Silinsin mi !", "Yemek Silme", MessageBoxButtons.YesNoCancel);

            if (sonuc == DialogResult.Yes)
            {
                Yemek y = new Yemek()
                {
                    AD = txt_yemekadi.Text.ToUpper(), Kalori = Convert.ToInt32(txt_kalori.Text)
                };
                MessageBox.Show("  Yemek Silindi!");
                Yemek.Sil(y);
                txt_kalori.Text   = txt_yemekadi.Text = "";
                groupBox1.Enabled = false;
                comboBox1.Text    = "";
                VerileriYukle();
            }
        }