Example #1
0
        public List <Beng> GetBengs()
        {
            List <Beng> Bengs = new List <Beng>();

            SqlCommand command = new SqlCommand();

            command.Connection  = connect;
            command.CommandText = "Select * From Beng";
            connect.Open();
            SqlDataReader read = command.ExecuteReader();

            while (read.Read())
            {
                Beng beng = new Beng();
                beng.ID          = Convert.ToInt32(read["ID"]);
                beng.path_number = Convert.ToInt32(read["path_Number"]);

                beng.time.hour      = Convert.ToInt32(read["hour"].ToString().Trim());
                beng.time.minute    = Convert.ToInt32(read["minute"].ToString().Trim());
                beng.time.monday    = (bool)read["monday"];
                beng.time.tuesday   = (bool)read["tuesday"];
                beng.time.wednesday = (bool)read["wednesday"];
                beng.time.thursday  = (bool)read["thursday"];
                beng.time.friday    = (bool)read["friday"];
                beng.time.saturday  = (bool)read["saturday"];
                beng.time.sunday    = (bool)read["sunday"];

                Bengs.Add(beng);
            }

            connect.Close();
            return(Bengs);
        }
Example #2
0
        public void InsertBeng(Beng beng)
        {
            SqlCommand command = new SqlCommand();

            command.Connection  = connect;
            command.CommandText = "Insert Into Beng (ID, path_Number, hour, minute, monday, tuesday, wednesday, thursday, friday, saturday, sunday) Values('" + beng.ID + "', '" + beng.path_number + "', '" + beng.time.hour + "', '" + beng.time.minute + "', '" + beng.time.monday + "', '" + beng.time.tuesday + "', '" + beng.time.wednesday + "', '" + beng.time.thursday + "', '" + beng.time.friday + "', '" + beng.time.saturday + "', '" + beng.time.sunday + "')";
            connect.Open();
            command.ExecuteNonQuery();
            connect.Close();
        }
Example #3
0
        private void btnSaveTime_Click(object sender, EventArgs e)
        {
            int hour, minute;

            try
            {
                hour   = Convert.ToInt32(cbHour.Text);
                minute = Convert.ToInt32(cbMinute.Text);
                if (hour >= 0 && hour < 24 && minute >= 0 && minute < 60)
                {
                    Time time = new Time();
                    time.hour   = hour;
                    time.minute = minute;

                    int last_Count;
                    if (Bengs.Count != 0)
                    {
                        last_Count = Bengs[Bengs.Count - 1].ID + 1;
                    }
                    else
                    {
                        last_Count = 1;
                    }

                    try
                    {
                        Beng beng = new Beng(last_Count, time, 0);
                        Bengs.Add(beng);
                        DbConnection db = new DbConnection();
                        db.InsertBeng(beng);
                    }
                    catch
                    {
                        MessageBox.Show("Veritabanına zil sesi zamanı eklemede sorun var! \"[email protected]\" mail adresine sorunu bildirin.");
                    }

                    lstBengTimes.Items.Add(cbHour.Text + " : " + cbMinute.Text);
                    errorProvider1.Clear();

                    grpSaveTime.Visible = false;
                    btnAddBeng.Enabled  = true;
                    btnAddMusic.Enabled = true;
                    btnDelBeng.Enabled  = true;
                }
                else
                {
                    errorProvider1.SetError(cbHour, "Saat formatına uygun değerler girin! (Saat -> 0 - 23 | Dakika -> 0 - 59)");
                }
            }
            catch
            {
                errorProvider1.SetError(cbHour, "Girilen değerlerde hata var!");
            }
        }