private void btnRemoveDocTemplate_Click(object sender, EventArgs e)
        {
            if (cbDocTemplate.SelectedIndex > -1)
            {
                if (MsgBoxHelper.Confirm("Remove this template?") == DialogResult.OK)
                {
                    try
                    {
                        // delete tempalte file
                        var selectedFile = Path.Combine(_configContent.DocTemplateLocation, cbDocTemplate.SelectedItem.ToString());
                        File.Delete(selectedFile);

                        // remove file name in list
                        cbDocTemplate.Items.RemoveAt(cbDocTemplate.SelectedIndex);
                        cbDocTemplate.Text = string.Empty;
                    }
                    catch (Exception ex)
                    {
                        MsgBoxHelper.Error("Failure: " + ex.Message);
                    }
                }
            }
            else
            {
                MsgBoxHelper.Warning("Please choose a template!");
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            // update values
            _configContent.Connections            = cbConnection.Items.Cast <Connection>().ToList();
            _configContent.CurrentConnectionName  = cbConnection.SelectedIndex > -1 ? cbConnection.SelectedItem.ToString() : "";
            _configContent.CurrentDocTemplateName = cbDocTemplate.SelectedIndex > -1 ? cbDocTemplate.SelectedItem.ToString() : "";

            var msg = new StringWriter();

            if (_configContent.IsValid(ref msg))
            {
                // decide need to refresh tables in main form or not
                IsCurrentConnectionChanged =
                    !string.Equals(_configContent.CurrentConnection.Str, Config.GetInstance().Content.CurrentConnection.Str);

                try
                {
                    // save to config
                    Config.GetInstance().Content = _configContent;
                    Config.GetInstance().SaveConfig();

                    // close
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                catch (Exception ex)
                {
                    MsgBoxHelper.Error("Failure: " + ex.Message);
                }
            }
            else
            {
                MsgBoxHelper.Warning(msg.ToString());
            }
        }
        private void btnRememberCheckedTables_Click(object sender, EventArgs e)
        {
            var checkedTables = GetCheckedTableNames();

            if (checkedTables.Count > 0)
            {
                try
                {
                    // save to config
                    var connName = Config.GetInstance().Content.CurrentConnectionName;
                    Config.GetInstance().Content.DocTablePackages[connName] = checkedTables;
                    Config.GetInstance().SaveConfig();

                    MsgBoxHelper.Done();
                }
                catch (Exception ex)
                {
                    MsgBoxHelper.Error("Failure: " + ex.Message);
                }
            }
            else
            {
                MsgBoxHelper.Warning("Please select table!");
            }
        }
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            var checkedTableNames = GetCheckedTableNames();

            if (checkedTableNames.Count > 0)
            {
                try
                {
                    // generate db document
                    string templatePath = Config.GetInstance().Content.CurrentDocTemplatePath;
                    string outputPath   = Config.GetInstance().Content.OutputDocLocation + Guid.NewGuid().ToString() + ".xlsx";
                    _dbManager.GenerateDocument(checkedTableNames, templatePath, outputPath);

                    // open it
                    Process.Start(outputPath);
                }
                catch (Exception ex)
                {
                    MsgBoxHelper.Error("Failure: " + ex.Message);
                }
            }
            else
            {
                MsgBoxHelper.Warning("Please select table!");
            }
        }
 // Event Handler
 private void btnCreate_Click(object sender, EventArgs e)
 {
     if (this.NewConnection.IsValid())
     {
         this.DialogResult = DialogResult.OK;
         this.Close();
     }
     else
     {
         MsgBoxHelper.Warning("Please fill all info!");
     }
 }
 private void btnConnTest_Click(object sender, EventArgs e)
 {
     try
     {
         using (var connection = new SqlConnection(NewConnection.Str))
         {
             connection.Open();
             MsgBoxHelper.Done("SQL Connection successful.");
         }
     }
     catch (Exception ex)
     {
         MsgBoxHelper.Warning("Failure: " + ex.Message);
     }
 }
 private void btnRemoveConnection_Click(object sender, EventArgs e)
 {
     if (cbConnection.SelectedIndex > -1)
     {
         if (MsgBoxHelper.Confirm("Remove this connection?") == DialogResult.OK)
         {
             cbConnection.Items.RemoveAt(cbConnection.SelectedIndex);
             cbConnection.Text = string.Empty;
             txtConnStr.Text   = string.Empty;
         }
     }
     else
     {
         MsgBoxHelper.Warning("Please choose a connection!");
     }
 }
 private void btnExportDocTemplate_Click(object sender, EventArgs e)
 {
     if (cbDocTemplate.SelectedIndex > -1)
     {
         using (var dialog = new SaveFileDialog())
         {
             dialog.Filter = "Excel File|*.xlsx";
             dialog.Title  = "Export Doc Tempalte File";
             dialog.ShowDialog();
             if (!string.IsNullOrWhiteSpace(dialog.FileName))
             {
                 var selectedFile = Path.Combine(_configContent.DocTemplateLocation, cbDocTemplate.SelectedItem.ToString());
                 File.Copy(selectedFile, dialog.FileName, true);
                 MsgBoxHelper.Done();
             }
         }
     }
     else
     {
         MsgBoxHelper.Warning("Please choose a template!");
     }
 }
예제 #9
0
 private void LogInSystem(object sender, RoutedEventArgs e)
 {
     if (capch.CapchText == CapchText.Text)
     {
         var user = Help.Auth(Login.Text, Pass.Text);
         if (user != null)
         {
             if (SaveMe.IsChecked.Value)
             {
                 Help.AuthCreateFile(Login.Text, Pass.Text);
             }
             LockHelper.DeleteLock(Login.Text);
             SaveUserLog.SaveUser(user.Login);
             Main.Main main = new Main.Main(user);
             main.Show();
             MainWindow mainWindow = (MainWindow)Window.GetWindow(this);
             mainWindow.Close();
         }
         else
         {
             if (LockHelper.IsUserLock(Login.Text))
             {
                 this.IsEnabled = false;
                 timerLock.Start();
             }
             else
             {
                 LockHelper.IncrementLockUser(Login.Text);
             }
             MsgBoxHelper.Warning("Такого пользователя нет");
         }
     }
     else
     {
         MsgBoxHelper.Warning("Капча введена не верно");
     }
 }
예제 #10
0
 private void RegUser(object sender, RoutedEventArgs e)
 {
     Helpers.Authhelper authhelper = new Helpers.Authhelper();
     if (Helpers.Validation.ValidationUser(
             Pass.Text,
             email.Text,
             date.SelectedDate.Value,
             FirstName.Text,
             LastName.Text))
     {
         if (context.user.Where(i => i.Login == email.Text).Count() < 1)
         {
             context.user.Add(
                 new Model.user
             {
                 Login       = email.Text,
                 Password    = Helpers.Encrypt.EncryptData(Pass.Text),
                 FistName    = FirstName.Text,
                 LastName    = LastName.Text,
                 MiddleName  = MiddleName.Text,
                 DateOfBirth = date.SelectedDate
             });
             context.SaveChanges();
             MsgBoxHelper.Info("Пользователь добавлен");
             NavigationService.GoBack();
         }
         else
         {
             MsgBoxHelper.Error("Пользователь уже существует");
         }
     }
     else
     {
         MsgBoxHelper.Warning("Не все поля заполнены");
     }
 }