Beispiel #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            string name    = this.NameTextBox.Text.Trim();
            string address = this.AddressTextBox.Text.Trim();
            string city    = this.CityTextBox.Text.Trim();
            string phone   = this.PhoneTextBox.Text.Trim();

            if (name.Equals("") || address.Equals("") || city.Equals("") || phone.Equals(""))
            {
                MessageBox.Show("Не все поля заполнены");
            }
            else
            {
                if (db != null)
                {
                    string sql = "INSERT INTO `obruch`(name, address, city, phone) " +
                                 "VALUES('" + name + "', '" + address + "', '" + city + "', '" + phone + "')";
                    int count = db.ExNonQuery(sql, dbCurrent);
                    if (count > 0)
                    {
                        MessageBox.Show("Успешно");
                    }
                    else
                    {
                        MessageBox.Show("Не удалось добавить");
                    }
                }
                else
                {
                    MessageBox.Show("Нужно подключиться к базе");
                }
            }
        }
Beispiel #2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(this.textBox1.Text.Trim());

                if (db != null)
                {
                    if (dbCurrent != null || dbCurrent != "")
                    {
                        string sql   = "DELETE FROM `" + dbCurrent + "` WHERE `" + dbCurrent + "`.`id`=" + id.ToString();
                        int    count = db.ExNonQuery(sql, dbCurrent);
                        if (count > 0)
                        {
                            MessageBox.Show("Успешно");
                        }
                        else
                        {
                            MessageBox.Show("Возможно, такого id не существует");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Нужно выбрать бд");
                    }
                }
                else
                {
                    MessageBox.Show("Нет подключения к бд");
                }
            } catch (FormatException exc)
            {
                MessageBox.Show("Неверный формат");
            }
        }
Beispiel #3
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (this.textBox1.Text.Trim().Equals(""))
     {
         MessageBox.Show("Не все поля заполнены");
     }
     else
     {
         if (db != null)
         {
             string sql   = "UPDATE `deal` SET `end`=1 WHERE `id`=" + this.textBox1.Text.Trim();
             int    count = db.ExNonQuery(sql, "deal");
             if (count > 0)
             {
                 MessageBox.Show("Успешно");
             }
             else
             {
                 MessageBox.Show("Не удалось изменить");
             }
         }
         else
         {
             MessageBox.Show("Нужно подключиться к базе");
         }
     }
 }
Beispiel #4
0
        private void Button6_Click(object sender, EventArgs e)
        {
            string result = this.TimesTimePicker.SelectionRange.Start.ToLongDateString() + "-" + this.TimesHours.Value.ToString() + ":" + TimesMinutes.Value.ToString();
            string type   = null;

            if (!string.IsNullOrEmpty(this.TimesWho.Text))
            {
                type = Convert.ToString(this.TimesWho.SelectedIndex);
            }
            else
            {
                MessageBox.Show("А для кого?");
                return;
            }
            if (db != null)
            {
                if (db.QueryOnExist("SELECT * FROM `times` WHERE `dt`='" + result + "'"))
                {
                    MessageBox.Show("Такое время уже есть в таблице");
                    return;
                }
                else
                {
                    string sql = "INSERT INTO `times`(dt, used, type) " +
                                 "VALUES('" + result + "', '0', '" + type + "')";
                    int count = db.ExNonQuery(sql, dbCurrent);
                    if (count > 0)
                    {
                        MessageBox.Show("Успешно");
                        this.showTime();
                    }
                    else
                    {
                        MessageBox.Show("Не удалось добавить");
                    }
                }
            }
            else
            {
                MessageBox.Show("Нужно подключиться к базе");
            }
        }
Beispiel #5
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                int type   = Convert.ToInt32(this.comboBox1.SelectedIndex);
                int year   = Convert.ToInt32(this.YearTextBox.Text.Trim());
                int month  = Convert.ToInt32(this.MonthTextBox.Text.Trim());
                int day    = Convert.ToInt32(this.DayTextBox.Text.Trim());
                int hours  = Convert.ToInt32(this.HoursTextBox.Text.Trim());
                int minuts = Convert.ToInt32(this.MinuntsTextBox.Text.Trim());

                string result = year.ToString();


                if (month < 10)
                {
                    result += "-0" + month.ToString();
                }
                else
                {
                    result += "-" + month.ToString();
                }

                if (day < 10)
                {
                    result += "-0" + day.ToString();
                }
                else
                {
                    result += "-" + day.ToString();
                }

                if (hours < 10)
                {
                    result += " 0" + hours.ToString();
                }
                else
                {
                    result += " " + hours.ToString();
                }

                if (minuts < 10)
                {
                    result += ":0" + minuts.ToString();
                }
                else
                {
                    result += ":" + hours.ToString();
                }

                result += ":00";

                if (db != null)
                {
                    string sql = "INSERT INTO `times`(dt, used, type) " +
                                 "VALUES('" + result + "', '0', '" + type + "')";
                    int count = db.ExNonQuery(sql, dbCurrent);
                    if (count > 0)
                    {
                        MessageBox.Show("Успешно");
                    }
                    else
                    {
                        MessageBox.Show("Не удалось добавить");
                    }
                }
                else
                {
                    MessageBox.Show("Нужно подключиться к базе");
                }
            }
            catch (FormatException exc)
            {
                MessageBox.Show("Ошибка формата");
            }
        }