Ejemplo n.º 1
0
        public PaymentsCtrl()
        {
            InitializeComponent();

            try
            {
                bsSupplierTypes.DataSource = Data_SupplierType.GetSupplierTypes();
                bsBankAccounts.DataSource  = Data_BankAccount.GetBankAccounts();
                txtReference.Text          = Data_SystemParameters.GetPaymentRef();

                String  regAmount = Utils.GetRegistryValue("PaymentAmount") == null ? "0" : Utils.GetRegistryValue("PaymentAmount").ToString();
                decimal amount;
                if (!Decimal.TryParse(regAmount, out amount))
                {
                    throw new Exception("Error retrieving Amount from Registry! Invalid decimal type.");
                }
                numAmount.Value = amount;


                GetRecords();
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrWhiteSpace(txtCompanyName.Text))
            {
                Utils.ShowInformation("You must enter a Company Name!");
                txtCompanyName.Focus();
            }
            else
            {
                Global.CompanyName = txtCompanyName.Text.Trim();
                Data_SystemParameters.SaveSystemParameters(new Data_SystemParameters()
                {
                    CompanyName = txtCompanyName.Text.Trim(),
                    Address1    = txtAddress1.Text.Trim(),
                    Address2    = txtAddress2.Text.Trim(),
                    Address3    = txtAddress3.Text.Trim(),
                    Address4    = txtAddress4.Text.Trim(),
                    Address5    = txtAddress5.Text.Trim(),
                    Phone       = txtPhone.Text.Trim(),
                    VatRegNo    = txtVatRegNo.Text.Trim(),
                    HideSensitiveSupplierFields = chkHideSupplierFields.Checked
                });

                Global.RefreshGlobalVariables();
                DialogResult = DialogResult.OK;
            }
        }
Ejemplo n.º 3
0
 private bool VerifyDatabaseVersion()
 {
     try
     {
         return(Data_SystemParameters.GetDatabaseVersion() == Global.DBVERSION);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 4
0
 public static void RefreshGlobalVariables()
 {
     try {
         Data_SystemParameters systemParams = Data_SystemParameters.GetSystemParameters();
         if (systemParams != null)
         {
             CompanyName = systemParams.CompanyName;
             HideSensitiveSupplierFields = systemParams.HideSensitiveSupplierFields;
         }
     } catch (Exception ex) {
         Utils.ShowException(ex);
     }
 }
Ejemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
#if DEBUG
                DialogResult = DialogResult.OK;
                int test = loginAttemps;
                Global.InitGlobalVariables("Admin", true, "Irish School of English", false);
#else
                Cursor.Current = Cursors.WaitCursor;
                Data_User user = Data_User.LoginUser(txtUsername.Text.Trim(), txtPassword.Text);

                if (user != null)
                {
                    if (!VerifyDatabaseVersion())
                    {
                        Utils.ShowError("The database is out of date for the current system. System load cannot continue. Please contact your administrator.");
                        Application.Exit();
                    }

                    //String companyName = Data_SystemParameters.GetCompanyName();
                    Data_SystemParameters systemParams = Data_SystemParameters.GetSystemParameters();
                    Global.InitGlobalVariables(user.Username, user.IsAdmin, systemParams.CompanyName, systemParams.HideSensitiveSupplierFields);
                    Utils.SaveRegistryValue(Common.KEY_USERLOGIN, txtUsername.Text);
                    DialogResult = DialogResult.OK;
                }
                else
                {
                    String errorMsg = "Incorrect Username or Password!";
                    loginAttemps++;

                    if (loginAttemps == 3)
                    {
                        Utils.ShowError(String.Format("{0} System will now close.", errorMsg));
                        Application.Exit();
                    }

                    Utils.ShowError(errorMsg);
                    txtUsername.Focus();
                }
#endif
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 6
0
 private void BindControls(Data_SystemParameters systemParams)
 {
     txtDatabaseVersion.Text       = systemParams.DatabaseVersion;
     txtCompanyName.Text           = systemParams.CompanyName;
     txtAddress1.Text              = systemParams.Address1;
     txtAddress2.Text              = systemParams.Address2;
     txtAddress3.Text              = systemParams.Address3;
     txtAddress4.Text              = systemParams.Address4;
     txtAddress5.Text              = systemParams.Address5;
     txtPhone.Text                 = systemParams.Phone;
     txtVatRegNo.Text              = systemParams.VatRegNo;
     txtSepaFileCount.Text         = systemParams.SepaFileCount.ToString().PadLeft(6, '0');
     chkHideSupplierFields.Checked = systemParams.HideSensitiveSupplierFields;
 }
Ejemplo n.º 7
0
        public CompanyInfoDialogFrm()
        {
            InitializeComponent();

            try
            {
                if (!Global.IsAdmin)
                {
                    chkHideSupplierFields.Enabled = false;
                }

                Data_SystemParameters systemParams = Data_SystemParameters.GetSystemParameters();

                if (systemParams != null)
                {
                    BindControls(systemParams);
                }
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
Ejemplo n.º 8
0
        private void btnCreateFile_Click(object sender, EventArgs e)
        {
            try {
                if (String.IsNullOrWhiteSpace(luBankAccounts.Text))
                {
                    Utils.ShowInformation("You must select a Bank Account!");
                    luBankAccounts.Focus();
                }
                else if (String.IsNullOrWhiteSpace(dtPaymentDate.Text))
                {
                    Utils.ShowInformation("You must select a Payment Date!");
                    dtPaymentDate.Focus();
                }
                else
                {
                    List <Data_PaymentStaging> suppliers = bsRecords.DataSource as List <Data_PaymentStaging>;

                    if (suppliers.Count == 0)
                    {
                        Utils.ShowInformation("No Suppliers have been selected for payment!");
                        return;
                    }

                    if (suppliers.Sum(a => a.Amount) == 0)
                    {
                        Utils.ShowInformation("No payments entered!");
                        return;
                    }

                    String sepaFileCount = (Data_SystemParameters.GetSepaFileCount() + 1).ToString().PadLeft(6, '0');
                    dlgSaveFile.FileName = String.Format("SEPA-{0:ddMMyyyy}-{1}", DateTime.Now, sepaFileCount);
                    if (dlgSaveFile.ShowDialog() == DialogResult.OK)
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        List <Data_Payment> payments = new List <Data_Payment>();

                        if (suppliers != null)
                        {
                            String bankAccountCode = luBankAccounts.SelectedValue.ToString();

                            foreach (var i in suppliers)
                            {
                                if (i.Amount != 0)
                                {
                                    payments.Add(new Data_Payment()
                                    {
                                        SupplierID      = i.SuppplierId,
                                        BankAccountCode = bankAccountCode,
                                        Username        = Global.Username,
                                        Amount          = i.Amount
                                    });
                                }
                            }

                            SavePaymentStaging();
                            int    batch = 0;
                            String xml   = Data_Procedures.GenerateSEPAPaymentsXML(bankAccountCode, dtPaymentDate.Value, txtReference.Text.Trim(), Global.Username, ref batch);

                            using (StreamWriter sw = new StreamWriter(dlgSaveFile.FileName)) {
                                sw.WriteLine(xml);
                            }

                            bsRecords.DataSource = null;
                            Utils.ShowInformation("SEPA Payment file created!");

                            new PaymentDetailByBatchReportFrm(batch).ShowDialog();
                        }
                    }
                }
            } catch (Exception ex) {
                Utils.ShowException(ex);
            } finally {
                Cursor.Current = Cursors.Default;
            }
        }