Пример #1
0
 //FORM LOAD
 private void Settings_Load(object sender, EventArgs e)
 {
     loadAllDataToForm();
     if (txtEmailFrom.Text == "")
     {
         //do nothing
     }
     else
     {
         //licence here
         DateTime today      = DateTime.Now;
         DateTime start_date = DateTime.Parse("09/28/2020");
         if ((today.Date - start_date.Date).TotalDays > 30)
         {
             MessageBox.Show("Your licence has expired, update your licence to continue using the application", "Licence Expired", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             BulkInvoicing bi = new BulkInvoicing();
             bi.ShowDialog();
             this.Hide();
             this.ShowInTaskbar = false;
         }
     }
     loadDatabase();
     loadPrinters();
 }
Пример #2
0
 //SAVE SETTINGS
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtEmailFrom.Text == "" || txtEmailPassword.Text == "" || txtEmailSMTPUser.Text == "")
     {
         MessageBox.Show("Settings can not be saved, fill all fields to proceed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else
     {
         try
         {
             using (SqlConnection sqlcon = new SqlConnection(connectionstring))
             {
                 if (sqlcon.State == ConnectionState.Closed)
                 {
                     sqlcon.Open();
                 }
                 SqlCommand cmd = new SqlCommand("WIZ_BulkInvoice_Settings_Proc", sqlcon);
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.AddWithValue("@SageServerName", txtCommonServer.Text);
                 cmd.Parameters.AddWithValue("@SageDatabaseName", comboCommonDB.Text);
                 cmd.Parameters.AddWithValue("@SageUsername", txtCommonUser.Text);
                 cmd.Parameters.AddWithValue("@SagePassword", txtCommonPassword.Text);
                 cmd.Parameters.AddWithValue("@EmailFrom", txtEmailFrom.Text);
                 cmd.Parameters.AddWithValue("@EmailPassword", txtEmailPassword.Text);
                 cmd.Parameters.AddWithValue("@EmailCC", txtEmailCC.Text);
                 cmd.Parameters.AddWithValue("@EmailSubject", txtEmailSubject.Text);
                 cmd.Parameters.AddWithValue("@EmailMessage", txtEmailMessage.Text);
                 cmd.Parameters.AddWithValue("@SMTP_ServerName", txtEmailSMTPServer.Text);
                 cmd.Parameters.AddWithValue("@SMTP_UserName", txtEmailSMTPUser.Text);
                 cmd.Parameters.AddWithValue("@SMTP_Password", txtEmailSMTPPassword.Text);
                 cmd.Parameters.AddWithValue("@SMTP_Port", txtEmailSMTPPort.Text);
                 cmd.Parameters.AddWithValue("@PrinterName", comboPrinter.Text);
                 cmd.Parameters.AddWithValue("@SMTP_Enable_SSL", SSL_yes);
                 cmd.ExecuteNonQuery();
                 MessageBox.Show("Settings saved successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 createDirectories();
                 Hide();
                 BulkInvoicing fb = new BulkInvoicing();
                 fb.ShowDialog();
                 WriteToFilE();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }