Exemple #1
0
 private void AddBN_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string sql = "SELECT [Login],[Password], EmployeeID FROM Users";
         for (int i = 0; i < WorkWithBD.outPutdb(sql).Tables[0].DefaultView.Count; i++)
         {
             if (LoginTB.Text == WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[0].ToString() && PasswordTB.Password.ToString() == WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[1].ToString())
             {
                 string id = WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[2].ToString();
                 sql = "SELECT FullName FROM Employee WHERE EmployeeID=" + id;
                 MainWindow.autoruzade = true;
                 MainWindow.USER       = WorkWithBD.outPutdb(sql).Tables[0].DefaultView[0].Row[0].ToString();
                 Close();
             }
         }
         if (MainWindow.autoruzade == false)
         {
             MessageBox.Show("Неверный логин или пароль.");
         }
     }
     catch { MessageBox.Show("Заполните поля"); }
 }
Exemple #2
0
        private static void TableStatment(string sql)
        {
            wordApplication.Selection.Find.Execute("@Table");
            Word.Range wordRange = wordApplication.Selection.Range;

            var wordTable = wordDocument.Tables.Add(wordRange,
                                                    1 + ((WorkWithBD.outPutdb(sql)).Tables[0].DefaultView.Count), 2);

            wordTable.Borders.InsideLineStyle  = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
            wordTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleDouble;

            wordTable.Cell(1, 1).Range.Text = "Услуга";
            wordTable.Cell(1, 2).Range.Text = "Цена";


            for (int i = 0; i < ((WorkWithBD.outPutdb(sql)).Tables[0].DefaultView.Count); i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    wordTable.Cell(i + 2, j + 1).Range.Text = (WorkWithBD.outPutdb(sql)).Tables[0].DefaultView[i].Row[j].ToString();
                }
            }
        }
Exemple #3
0
        private static void TableReport(string sql, string NameEmployee, DateTime StartDay, DateTime LasDay)
        {
            wordApplication.Selection.Find.Execute("@Table");
            Word.Range wordRange = wordApplication.Selection.Range;

            var wordTable = wordDocument.Tables.Add(wordRange,
                                                    1 + ((WorkWithBD.outPutdb(sql)).Tables[0].DefaultView.Count), 8);

            wordTable.Borders.InsideLineStyle  = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle;
            wordTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleDouble;

            wordTable.Cell(1, 1).Range.Text = "Номер регистрации";
            wordTable.Cell(1, 2).Range.Text = "ФИО клиента";
            wordTable.Cell(1, 3).Range.Text = "Номер комнаты";
            wordTable.Cell(1, 4).Range.Text = "Оплата за проживание";
            wordTable.Cell(1, 5).Range.Text = "Оплата за услуги";
            wordTable.Cell(1, 6).Range.Text = "Общая оплата";
            wordTable.Cell(1, 7).Range.Text = "Дата заселения";
            wordTable.Cell(1, 8).Range.Text = "Дата выселения";


            for (int i = 0; i < ((WorkWithBD.outPutdb(sql)).Tables[0].DefaultView.Count); i++)
            {
                for (int j = 0; j <= 7; j++)
                {
                    if (j == 6 || j == 7)
                    {
                        wordTable.Cell(i + 2, j + 1).Range.Text = Convert.ToDateTime((WorkWithBD.outPutdb(sql)).Tables[0].DefaultView[i].Row[j]).Date.ToString("d");
                    }
                    else
                    {
                        wordTable.Cell(i + 2, j + 1).Range.Text = (WorkWithBD.outPutdb(sql)).Tables[0].DefaultView[i].Row[j].ToString();
                    }
                }
            }
        }
        private void addRegistration()
        {
            string sql = "SELECT Registration.RegistrationID, Client.FullNameClient " +
                         "FROM Registration JOIN Client ON(Registration.ClientID=Client.ClientID) WHERE (Registration.Booked = 'Заселился' OR Registration.Booked = 'Забронировал')";

            for (int i = 0; i < ((WorkWithBD.outPutdb(sql)).Tables[0].DefaultView.Count); i++)
            {
                RegistrationIDCB.Items.Add((WorkWithBD.outPutdb(sql)).Tables[0].DefaultView[i].Row[0] + " " + (WorkWithBD.outPutdb(sql)).Tables[0].DefaultView[i].Row[1].ToString());
            }
        }
Exemple #5
0
        private void AddBN_Click(object sender, RoutedEventArgs e)
        {
            try {
                string sql = "UPDATE [Registration] SET [Booked] = '" + BookedCB.Text + "' " +
                             "WHERE [RegistrationID] = " + MainMenu.index;

                WorkWithBD.Update(sql);
                sql = "SELECT RoomID FROM Registration WHERE RegistrationID=" + MainMenu.index;
                sql = "UPDATE [Room] SET [Status] ='" + BookedCB.Text + "' WHERE RoomID=" + (WorkWithBD.outPutdb(sql)).Tables[0].DefaultView[0].Row[0];
                WorkWithBD.Update(sql);

                Close();
            }
            catch { System.Windows.Forms.MessageBox.Show("Введите корректные данные"); }
        }
Exemple #6
0
        private void checkRoom() // проверка, свободна ли комната в данный промежуток дней или нет
        {
            string sql = "SELECT Registration.AD, Registration.DD " +
                         "FROM Registration JOIN Room ON(Registration.RoomID = Room.RoomID) JOIN Type ON (Room.TypeID = Type.TypeID) " +
                         "WHERE " + //(((Registration.AD < '" + dDayAD + "' AND Registration.DD < '" + dDayAD + "' AND Registration.AD < '" + dDayDD + "' AND Registration.DD < '" + dDayDD + "') OR (Registration.AD > '" + dDayAD + "' AND Registration.DD < '" + dDayAD + "' AND Registration.AD < '" + dDayDD + "' AND Registration.DD < '" + dDayDD + "')) AND " +
                         "Registration.RoomID = " + sRoomIDCB + "";
            //if (WorkWithBD.outPutdb(sql).Tables[0].DefaultView.Count == 0) MessageBox.Show("Можно бронировать");
            //else { MessageBox.Show("Выберите другие дни"); }
            ////   WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[0];
            int buf = 0;

            for (int i = 0; i < WorkWithBD.outPutdb(sql).Tables[0].DefaultView.Count; i++)
            {
                if (((Convert.ToDateTime(WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[0]) < dDayAD && Convert.ToDateTime(WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[1]) < dDayAD) &&
                     ((Convert.ToDateTime(WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[0]) < dDayDD && Convert.ToDateTime(WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[1]) < dDayDD))) ||
                    ((Convert.ToDateTime(WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[0]) > dDayAD && Convert.ToDateTime(WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[1]) > dDayAD) &&
                     ((Convert.ToDateTime(WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[0]) > dDayDD && Convert.ToDateTime(WorkWithBD.outPutdb(sql).Tables[0].DefaultView[i].Row[1]) > dDayDD))))
                {
                    buf++;
                }
                else
                {
                    MessageBox.Show("Выберите другие дни"); return;
                }
            }
            if (buf == WorkWithBD.outPutdb(sql).Tables[0].DefaultView.Count)
            {
                MessageBox.Show("Можно бронировать");
            }
        }