Пример #1
0
        public void updateTableService()
        {
            DateTime date = DateTime.Now;

            if (dtStartDate.Value.Date <= dtEndDate.Value.Date && dtStartDate.Value.Date >= date)
            {
                Helper        helper = new Helper();
                ActionWithDB  api    = new ActionWithDB();
                SqlDataReader reader = api.addServices();
                if (tbClubCard.Text != "")
                {
                    int Ccard   = Int32.Parse(tbClubCard.Text);
                    int discont = api.getDiscont(Ccard);

                    helper.clearDataGridView(dGVServices);
                    int i = 0;
                    while (reader.Read())
                    {
                        dGVServices.RowCount++;
                        dGVServices.Rows[i].Cells[0].Value = reader[0].ToString();
                        dGVServices.Rows[i].Cells[1].Value = reader[1].ToString();
                        dGVServices.Rows[i].Cells[2].Value = reader[2].ToString();
                        dGVServices.Rows[i].Cells[3].Value = discont;
                        dGVServices.Rows[i].Cells[4].Value = api.getTotalCost(discont, dGVServices.Rows[i].Cells[2].Value.ToString());
                        i++;
                    }
                }
            }
            else
            {
                Helper helper = new Helper();
                helper.clearDataGridView(dGVFreePlace);
            }
        }
Пример #2
0
        private void btnGetService_Click(object sender, EventArgs e)
        {
            if (cbChoosePassrport.Text.Length != 0)
            {
                string        nRecords = "";
                string        str      = cbChoosePassrport.Text;
                string        passport = str.Substring(0, 10);
                ActionWithDB  api      = new ActionWithDB();
                SqlDataReader reader   = api.searchRecord(passport);
                while (reader.Read())
                {
                    nRecords = reader[0].ToString();
                }
                int    NRecord  = int.Parse(nRecords);
                int    index    = dGVServices.CurrentRow.Index;
                string nService = dGVServices.Rows[index].Cells[0].Value.ToString();
                int    NService = int.Parse(nService);

                api.addRecordOfService(NService, NRecord);
                MessageBox.Show("Услуги приобретена успешно!", "Успешно", MessageBoxButtons.OK,
                                MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Выберите паспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #3
0
        private void btnBuy_Click(object sender, EventArgs e)
        {
            ActionWithDB api = new ActionWithDB();

            api.addRecordInHotel(number, login, document, discount, cCard, dateBegin, dateEnd, price, priceInDiscount);
            MessageBox.Show("Номер успешно куплен на дату с " + dateBegin.Date.ToString() + " по " + dateEnd.Date.ToString(), "Успешно", MessageBoxButtons.OK,
                            MessageBoxIcon.Information);
            this.Close();
        }
Пример #4
0
        private void добавитьПаспортToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            DocumentAdd documentAdd = new DocumentAdd(loginUser);

            documentAdd.ShowDialog();
            cbChoosePassrport.Items.Clear();
            ActionWithDB  api    = new ActionWithDB();
            SqlDataReader reader = api.enterDocument(loginUser);

            while (reader.Read())
            {
                cbChoosePassrport.Items.Add(reader[0].ToString());
            }
        }
Пример #5
0
        private void cbChoosePassrport_SelectedIndexChanged(object sender, EventArgs e)
        {
            ActionWithDB  api      = new ActionWithDB();
            string        str      = cbChoosePassrport.Text;
            string        passport = str.Substring(0, 10);
            SqlDataReader reader   = api.seachDocument(passport);

            while (reader.Read())
            {
                lbSurname.Text = "Surname(Фамилия): " + reader[1];
                lbName.Text    = "Name(Имя): " + reader[0];
                lbSName.Text   = "Second Name(Отчество): " + reader[2];
            }
        }
Пример #6
0
        private void UserForm_Load(object sender, EventArgs e)
        {
            dGVFreePlace.RowHeadersVisible = false;
            this.Text = "Вы зашли под логином - " + loginUser;
            ActionWithDB api = new ActionWithDB();

            if (!api.isChekingUserDocument(loginUser))
            {
                MessageBox.Show("Отсутстует паспорт у пользователя - " + loginUser, "Добавьте паспорт", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            SqlDataReader reader = api.enterDocument(loginUser);

            while (reader.Read())
            {
                cbChoosePassrport.Items.Add(reader[0].ToString() + " ");
            }
        }
Пример #7
0
        private void btnCheckAndBuy_Click(object sender, EventArgs e)
        {
            DateTime date = DateTime.Now;

            if (dtStartDate.Value.Date < dtEndDate.Value.Date && dtStartDate.Value.Date >= date)
            {
                if (cbChoosePassrport.Text.Length != 0)
                {
                    string        name     = "";
                    string        SName    = "";
                    string        surname  = "";
                    string        str      = cbChoosePassrport.Text;
                    string        passport = str.Substring(0, 10);
                    int           Ccard    = Int32.Parse(tbClubCard.Text);
                    ActionWithDB  api      = new ActionWithDB();
                    SqlDataReader reader   = api.seachDocument(passport);
                    while (reader.Read())
                    {
                        surname = reader[1].ToString();
                        name    = reader[0].ToString();
                        SName   = reader[2].ToString();
                    }
                    int    index         = dGVFreePlace.CurrentRow.Index;
                    string price         = dGVFreePlace.Rows[index].Cells[2].Value.ToString();
                    string discount      = dGVFreePlace.Rows[index].Cells[3].Value.ToString();
                    string priceDiscount = dGVFreePlace.Rows[index].Cells[4].Value.ToString();
                    string typeNumber    = dGVFreePlace.Rows[index].Cells[1].Value.ToString();
                    string numberHostel  = dGVFreePlace.Rows[index].Cells[0].Value.ToString();

                    RecordCheck recordCheck = new RecordCheck(loginUser, surname, name, SName, Double.Parse(price), int.Parse(discount),
                                                              Double.Parse(priceDiscount), passport, typeNumber, int.Parse(numberHostel), dtStartDate.Value.Date, dtEndDate.Value.Date, Ccard);
                    recordCheck.ShowDialog();
                    updateTable();
                }
                else
                {
                    MessageBox.Show("Выберите паспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Выбранная дата некорректна", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnRegister_Click(object sender, EventArgs e)
        {
            if (tbLogin.Text.Length != 0 && tbPassword.Text.Length != 0 && tbRePassword.Text.Length != 0)
            {
                if (!tbLogin.Text.Contains("@"))
                {
                    ActionWithDB api = new ActionWithDB();
                    if (api.checkingUser(tbLogin.Text) == 0)
                    {
                        if (tbPassword.Text == tbRePassword.Text)
                        {
                            api.addUser(tbLogin.Text, tbPassword.Text);
                            Helper helper = new Helper();
                            helper.clearAllTextBox(tbLogin, tbPassword, tbRePassword);
                            MessageBox.Show("Регистрация прошла успешна", "Успех!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }


                        else
                        {
                            MessageBox.Show("Пароли не совпадают", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Пользователь с таким логином зарегестрирован", "Ошибка"
                                        , MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Имееться спец символ '@'", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Введите все данные", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #9
0
        private void StartForm_Load(object sender, EventArgs e)
        {
            tbLogin.Text    = "123";
            tbPassword.Text = "123";

            string       addStr;
            ActionWithDB api        = new ActionWithDB();
            bool         flagConect = api.isVerificationConnect();

            if (flagConect)
            {
                addStr          = "активно";
                btnAdit.Enabled = true;
                регистрацияToolStripMenuItem.Enabled = true;
            }
            else
            {
                addStr          = "не активно";
                btnAdit.Enabled = false;
                регистрацияToolStripMenuItem.Enabled = false;
            }
            lbConnection.Text += " " + addStr;
        }
 private void btAdd_Click(object sender, EventArgs e)
 {
     if (tbFirstName.Text.Length != 0 && tbLastName.Text.Length != 0 && tbPassport.Text.Length != 0)
     {
         ActionWithDB api = new ActionWithDB();
         if (!api.ischeckingDocumentForPassport(tbLastName.Text, tbPassport.Text))
         {
             api.addDocument(login, tbLastName.Text, tbFirstName.Text, tbSecondName.Text, tbPassport.Text);
             Helper helper = new Helper();
             helper.clearAllTextBox(tbLastName, tbFirstName, tbSecondName, tbPassport);
             MessageBox.Show("Добавлено", "Успешно", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             this.Close();
         }
         else
         {
             MessageBox.Show("Ошибка", "Такие данные существуют", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Ошибка", "Не заполненные поля ввода", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #11
0
        private void btnAdit_Click(object sender, EventArgs e)
        {
            if (!(tbLogin.Text.Length == 0 && tbPassword.Text.Length == 0))
            {
                Helper       helper = new Helper();
                ActionWithDB api    = new ActionWithDB();

                if (api.verificationLoginAdnPassword(tbLogin.Text, tbPassword.Text) == 1)
                {
                    UserForm userForm = new UserForm(tbLogin.Text);
                    userForm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Неправльный логин или пароль", "Ошибка",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Введите логин и пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }