Exemplo n.º 1
0
        //Update button
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                bool res = true;

                //Get values from form
                MainInformation.Add_ID    = _UPDID.Text;
                MainInformation.Add_Bonus = _UPDBONUS.Text;

                //Check values
                if (MainInformation.Add_ID == "" || MainInformation.Add_Bonus == "")
                {
                    MessageBox.Show("Заполните все поля");
                }

                else
                {
                    //Check numbers
                    foreach (char c in MainInformation.Add_ID)
                    {
                        if (!Char.IsDigit(c))
                        {
                            MessageBox.Show("ID: неверный формат");

                            MainInformation.ResetValues();
                            res = false;
                            break;
                        }

                        else
                        {
                            foreach (char c1 in MainInformation.Add_Bonus)
                            {
                                if (!Char.IsDigit(c1))
                                {
                                    MessageBox.Show("Скидка: неверный формат");

                                    MainInformation.ResetValues();
                                    res = false;
                                    break;
                                }
                            }
                        }
                    }

                    //Success
                    if (res)
                    {
                        this.Close();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ошибка обновления");
            }
        }
Exemplo n.º 2
0
        // Update button
        private void Button6_Click(object sender, EventArgs e)
        {
            Form ifrm4 = new UpdateForm();

            ifrm4.ShowDialog();

            if (MainInformation.Add_Bonus != "" && MainInformation.Add_ID != "")
            {
                ComplexSQL(@"UPDATE CLIENTS SET BONUS = " + MainInformation.Add_Bonus + " WHERE ID = " + MainInformation.Add_ID + ";", "Запись изменена", false);
                MainInformation.ResetValues();
            }
        }
Exemplo n.º 3
0
        //Delete button
        private void Button5_Click(object sender, EventArgs e)
        {
            Form ifrm2 = new FindForm();

            ifrm2.ShowDialog();

            if (MainInformation.Add_ID != "")
            {
                ComplexSQL(@"DELETE FROM CLIENTS WHERE ID = " + MainInformation.Add_ID + ";", "Запись удалена", false);
                MainInformation.ResetValues();
            }
        }
Exemplo n.º 4
0
        // select button
        private void Button4_Click(object sender, EventArgs e)
        {
            Form ifrm2 = new FindForm();

            label_IDvalue.Text    = "-";
            label_NAMEvalue.Text  = "-";
            label_PHONEvalue.Text = "-";
            label_BONUS.Text      = "%";

            ifrm2.ShowDialog();

            if (MainInformation.Add_ID != "")
            {
                ComplexSQL("", "", true);
            }

            MainInformation.ResetValues();
        }
Exemplo n.º 5
0
        //Find/delete button
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                bool res = true;
                MainInformation.Add_ID = _FINDID.Text;

                //Check value
                if (MainInformation.Add_ID == "")
                {
                    MessageBox.Show("Введите ID");
                }

                else
                {
                    //Check number
                    foreach (char c in MainInformation.Add_ID)
                    {
                        if (!Char.IsDigit(c))
                        {
                            MessageBox.Show("ID: неверный формат");

                            MainInformation.ResetValues();
                            res = false;
                            break;
                        }
                    }
                    //Success
                    if (res)
                    {
                        this.Close();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ошибка поиска");
            }
        }
Exemplo n.º 6
0
        //Insert button
        private void Button3_Click(object sender, EventArgs e)
        {
            Form ifrm3 = new AddForm();

            ifrm3.ShowDialog();

            if (MainInformation.Add_ID != "" || MainInformation.Add_Name != "" || MainInformation.Add_Phone != "" || MainInformation.Add_Bonus != "")
            {
                try
                {
                    // query
                    RunSQL(@"INSERT INTO CLIENTS (ID,NAME,PHONE,BONUS)   
                                VALUES (" + MainInformation.Add_ID + ", '" + MainInformation.Add_Name + "', '" + MainInformation.Add_Phone + "', " + MainInformation.Add_Bonus + ");");

                    MessageBox.Show("Запись добавлена");

                    MainInformation.ResetValues();
                }
                catch (Exception)
                {
                    MessageBox.Show("Ошибка добавления: ID уже существует");
                }
            }
        }