コード例 #1
0
        private void btnCalcMoney_Click(object sender, EventArgs e)
        {
            try
            {
                CheckCorrectDateInput();
                DateTime   with     = Convert.ToDateTime(dateEditwith.Text);
                DateTime   until    = Convert.ToDateTime(dateEditUntil.Text);
                SQLAdapter sqdapter = new SQLAdapter();

                int countNum = 0;

                while (with.Date != until.Date)
                {
                    var query = string.Format($"select count(*) as count from VGuestBedsAccounting where \"{with.Date}\" BETWEEN  \"Дата заезда\"  and  \"Дата отъезда\"");
                    var row   = sqdapter.SelectActiveRow(query);
                    countNum += int.Parse(row["count"].ToString());
                    with      = with.AddDays(1);
                }
                MessageBox.Show(
                    $"Выручка хоcтела с период {dateEditwith.Text} по {dateEditUntil.Text} " +
                    $"составила {countNum * 500} рублей!",
                    "Внимание, конфиденциальная информация!",
                    MessageBoxButtons.OK, MessageBoxIcon.Information
                    );
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Произошла внутрення ошибка при рассчете выручки !  {ex.Message}!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
        private void AddGuestRegestration()
        {
            try
            {
                int    index       = this.searchLookUpEditClient.Properties.GetIndexByKeyValue(this.searchLookUpEditClient.EditValue);
                object selectedRow = this.searchLookUpEditClientView.GetRow(index);


                var idSelectedClient = this.searchLookUpEditClientView.GetRowCellValue(index, this.searchLookUpEditClientView.Columns["id"]);
                var dateArrival      = dateEditArrival.Text;
                var dateDeparture    = dateEditDeparture.Text;

                var numRoom = comboBoxRoom.SelectedValue;
                var numBed  = comboBoxBed.SelectedValue;

                var row         = sqlAdapter.SelectActiveRow(string.Format(Query.selectIDCouchette, numRoom, numBed));
                var idСouchette = row["idСouchette"];

                var newReservQuery = string.Format(Query.insertNewReserv, idSelectedClient, idСouchette, tbCost.Text, dateArrival, dateDeparture);
                sqlAdapter.RunQuery(newReservQuery);

                MessageBox.Show($"Клиент {searchLookUpEditClient.Text} успешно забронировал кровать № {numBed} в комнате {numRoom}!", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"Произошла внутренняя ошибка при заселения гостя!  {ex.ToString()} ", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #3
0
        private void LoadClientData()
        {
            try
            {
                string  query     = string.Format(Query.GetClientById, idClient);
                DataRow clietnRow = sqlAdapter.SelectActiveRow(query);

                if (clietnRow != null)
                {
                    textEditFirstName.Text  = clietnRow["FirstName"].ToString();
                    textEditSecondName.Text = clietnRow["SecondName"].ToString();
                    textEditMiddleName.Text = clietnRow["MiddleName"].ToString();
                    dateEditBirthday.Text   = clietnRow["Birthday"].ToString();
                    comboBoxGender.Text     = clietnRow["Gender"].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, $"Внимание, произошла ошибка при попытки загрузки клиента из БД с id {idClient}", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }