private void BtnSubmit_Click(object sender, EventArgs e)
        {
            FormViewEventRecordr formViewEventRecordr = new FormViewEventRecordr();

            formViewEventRecordr.Hide();
            formViewEventRecordr.Show();
        }
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string passsword = textBoxPassword.Text.Trim();
                string query     = "SELECT `UserId`, `UserName` " +
                                   "FROM `User` " +
                                   "WHERE `UserName`='" + textBoxUsername.Text.Trim() + "' ";// +
                //"AND `UserPassword`='" + password + "'";

                ConnectMDB myDataTable = new ConnectMDB(query);

                if (myDataTable.ConnectDB() == null)
                {
                    //this.Close();
                }

                int userCount = myDataTable.ConnectDB().AsEnumerable().ToArray().Count();

                if (userCount == 1)
                {
                    User user = new User
                    {
                        UserId = myDataTable.ConnectDB().AsEnumerable()
                                 .Select(i => i.Field <int>("UserID"))
                                 .ToArray()[0],
                        UserName = myDataTable.ConnectDB().AsEnumerable()
                                   .Select(i => i.Field <string>("UserName"))
                                   .ToArray()[0]
                    };

                    //FormMain formMain = new FormMain();
                    FormViewEventRecordr formViewEventRecordr = new FormViewEventRecordr();
                    this.Hide();

                    //formMain.Show();
                    formViewEventRecordr.ShowDialog();
                }
                else
                {
                    throw new Exception("Проверете потребителското име и паролата.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                //throw;
            }
        }
Exemple #3
0
        public void ShowErrorMessage(string startSearchData, string endSearchData,
                                     string startSearchTime, string endSearchTime,
                                     int ordinalOptional, int searchDepartment, string searchUserName)
        {
            FormViewEventRecordr formViewEventRecordr = new FormViewEventRecordr();

            DateTime startSearchDataParse = DateTime
                                            .ParseExact(startSearchData, DATE_FORMAT, CultureInfo.InvariantCulture);
            DateTime endSearchDataParse = DateTime
                                          .ParseExact(endSearchData, DATE_FORMAT, CultureInfo.InvariantCulture);

            if (startSearchDataParse > endSearchDataParse)
            {
                throw new Exception("Некоректно поълнена начална или крайна дата");
            }

            DateTime startSearchTimeParse = DateTime
                                            .ParseExact(startSearchTime, TIME_FORMAT, CultureInfo.InvariantCulture);
            DateTime endSearchTimeParse = DateTime
                                          .ParseExact(endSearchTime, TIME_FORMAT, CultureInfo.InvariantCulture);

            if (startSearchTimeParse > endSearchTimeParse)
            {
                throw new Exception("Некоректно поълнен начален или краен час");
            }

            if (ordinalOptional == -1)
            {
                throw new Exception("Трябва да изберете \"ВХОД\" или \"ИЗХОД\"");
            }

            if (searchDepartment == 0)
            {
                //throw new Exception("Трябва да изберете \"отдел\"");
                //formViewEventRecordr.FormView();
            }

            if (searchUserName.Length == 0)
            {
                //throw new Exception("Трябва да изберете \"служител\"");
                //formViewEventRecordr.FormView();
            }
        }