public SupplierDialogFrm(Common.FormMode formMode, Data_Supplier supplier)
        {
            InitializeComponent();

            try {
                this.formMode = formMode;
                if (Global.HideSensitiveSupplierFields)
                {
                    HideSensitiveFields();
                }

                bsSupplierTypes.DataSource = Data_SupplierType.GetSupplierTypes();
                if (formMode == Common.FormMode.Add)
                {
                    supplierID = -1;
                    luSupplierType.SelectedIndex = -1;
                }
                else
                {
                    BindControls(supplier);

                    if (formMode == Common.FormMode.View)
                    {
                        Utils.DisableAllControls(this);
                        this.Text = String.Format("View Supplier {0} ({1})", supplier.SupplierID, supplier.Name);
                        return;
                    }

                    this.Text = String.Format("Edit Supplier {0} ({1})", supplier.SupplierID, supplier.Name);
                }
            } catch (Exception ex) {
                Utils.ShowException(ex);
            }
        }
        private void BindControls(Data_Supplier supplier)
        {
            supplierID        = supplier.SupplierID;
            txtFirstName.Text = supplier.FirstName;
            txtSurname.Text   = supplier.Surname;
            txtAddress1.Text  = supplier.Address1;
            txtAddress2.Text  = supplier.Address2;
            txtAddress3.Text  = supplier.Address3;
            txtAddress4.Text  = supplier.Address4;
            txtAddress5.Text  = supplier.Address5;
            txtPhone.Text     = supplier.Phone;
            txtMobile.Text    = supplier.Mobile;
            txtPPSVat.Text    = supplier.PPSVat;

            if (!String.IsNullOrWhiteSpace(supplier.SupplierTypeCode))
            {
                luSupplierType.SelectedValue = supplier.SupplierTypeCode;
            }

            txtBankName.Text      = supplier.BankName;
            txtBankAddress1.Text  = supplier.BankAddress1;
            txtBankAddress2.Text  = supplier.BankAddress2;
            txtBankAddress3.Text  = supplier.BankAddress3;
            txtBankAddress4.Text  = supplier.BankAddress4;
            txtBankAddress5.Text  = supplier.BankAddress5;
            txtBankAccNumber.Text = supplier.BankAccNumber;
            txtSortCode.Text      = supplier.SortCode;
            txtBIC.Text           = supplier.BIC;
            txtIBAN.Text          = supplier.IBAN;
        }
        protected override void EditRecord()
        {
            try
            {
                Data_Supplier record = Utils.GetCurrentRecord <Data_Supplier>(bsRecords);

                if (record != null)
                {
                    Data_Supplier supplier = Data_Supplier.GetSupplier(record.SupplierID);

                    if (supplier != null)
                    {
                        SupplierDialogFrm frm = new SupplierDialogFrm(Common.FormMode.Edit, supplier);

                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            GetRecords();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
        protected override void DeleteRecord()
        {
            try
            {
                Data_Supplier supplier = Utils.GetCurrentRecord <Data_Supplier>(bsRecords);

                if (supplier != null)
                {
                    if (Utils.AskQuestion(String.Format("Are you sure you want to delete supplier {0}?", supplier.SupplierID)) == DialogResult.Yes)
                    {
                        Data_Supplier.DeleteSupplier(supplier.SupplierID);
                        GetRecords();
                    }
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    if (ex.InnerException.InnerException != null)
                    {
                        if (ex.InnerException.InnerException.Message.Contains("The DELETE statement conflicted with the REFERENCE constraint"))
                        {
                            Utils.ShowInformation("Cannot delete! Supplier is associated with one or more transactions.");
                            return;
                        }
                    }
                }

                Utils.ShowException(ex);
            }
        }
 private void btnRefresh_Click(object sender, EventArgs e)
 {
     try
     {
         suppliers = Data_Supplier.SearchSuppliers(Global.Username, txtSearchKeyword.Text.Trim(), luSupplierType.Text.Trim(), false);
         bsSuppliers.DataSource = suppliers;
     }
     catch (Exception ex)
     {
         Utils.ShowException(ex);
     }
 }
 private void GetRecords()
 {
     try
     {
         Cursor.Current       = Cursors.WaitCursor;
         bsRecords.DataSource = Data_Supplier.GetSortableSuppliers();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
        public SupplierSelectDialogFrm(decimal amount = 0)
        {
            InitializeComponent();

            try
            {
                bsSupplierTypes.DataSource = Data_SupplierType.GetSupplierTypes();
                this.amount = amount;

                suppliers = Data_Supplier.GetSuppliersWithPaymentStagingCheck(Global.Username);
                bsSuppliers.DataSource = suppliers;

                luSupplierType.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
Beispiel #8
0
        private void btnViewSupplier_Click(object sender, EventArgs e)
        {
            try
            {
                Data_Payment payment = Utils.GetCurrentRecord <Data_Payment>(bsRecords);

                if (payment != null)
                {
                    Data_Supplier supplier = Data_Supplier.GetSupplier(payment.SupplierID);

                    if (supplier != null)
                    {
                        SupplierDialogFrm frm = new SupplierDialogFrm(Common.FormMode.View, supplier);
                        frm.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
Beispiel #9
0
        public PaymentEnquiryCtrl()
        {
            InitializeComponent();

            try
            {
                bsSuppliers.DataSource     = Data_Supplier.GetSuppliers();
                bsSupplierTypes.DataSource = Data_SupplierType.GetSupplierTypes();
                bsUsers.DataSource         = Data_User.GetUsers();
                bsBankAccounts.DataSource  = Data_BankAccount.GetBankAccounts();

                luSuppliers.SelectedIndex     = -1;
                luSupplierTypes.SelectedIndex = -1;
                luUsers.SelectedIndex         = -1;
                luBankAccount.SelectedIndex   = -1;

                dtDateFrom.Value = DateTime.Parse(String.Format("01/01/{0}", DateTime.Now.Year));
                dtDateTo.Value   = DateTime.Now.Date;
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                List <Data_PaymentStaging> staging = new List <Data_PaymentStaging>();

                foreach (DataGridViewRow i in grdSuppliers.Rows)
                {
                    DataGridViewCheckBoxCell cell = i.Cells["Selected"] as DataGridViewCheckBoxCell;

                    bool isSelected = Convert.ToBoolean(cell.Value);

                    if (isSelected)
                    {
                        Data_Supplier supplier = i.DataBoundItem as Data_Supplier;

                        if (supplier != null)
                        {
                            staging.Add(new Data_PaymentStaging()
                            {
                                Username    = Global.Username,
                                SuppplierId = supplier.SupplierID,
                                Amount      = amount
                            });
                        }
                    }
                }

                Data_PaymentStaging.SavePaymentStaging(Global.Username, staging);
                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                Utils.ShowException(ex);
            }
        }
Beispiel #11
0
        private void SaveSupplier()
        {
            try {
                if (String.IsNullOrWhiteSpace(txtFirstName.Text))
                {
                    Utils.ShowInformation("You must enter a First Name!");
                    txtFirstName.Focus();
                }
                else if (String.IsNullOrWhiteSpace(luSupplierType.Text))
                {
                    Utils.ShowInformation("You must select a Supplier Type!");
                    luSupplierType.Focus();
                }
                else if (String.IsNullOrWhiteSpace(Address))
                {
                    Utils.ShowInformation("You must enter an Address!");
                    txtAddress1.Focus();
                }
                else if (String.IsNullOrWhiteSpace(txtBankName.Text))
                {
                    Utils.ShowInformation("You must enter a Bank Name!");
                    txtBankName.Focus();
                }
                else if (String.IsNullOrWhiteSpace(txtSortCode.Text))
                {
                    Utils.ShowInformation("You must enter a Sort Code!");
                    txtSortCode.Focus();
                }
                else if (String.IsNullOrWhiteSpace(txtBIC.Text))
                {
                    Utils.ShowInformation("You must enter a BIC!");
                    txtBIC.Focus();
                }
                else if (String.IsNullOrWhiteSpace(txtIBAN.Text))
                {
                    Utils.ShowInformation("You must enter an IBAN!");
                    txtIBAN.Focus();
                }
                else
                {
                    if (!Data_BankIdentifierCode.ValidateCode(txtBIC.Text.Trim()))
                    {
                        Utils.ShowWarning("WARNING: BIC is not valid!");
                    }

                    // Perform some validation on IBAN
                    String bic      = txtIBAN.Text.Trim().Substring(4, 4);
                    String sortCode = txtIBAN.Text.Trim().Substring(8, 6);

                    if (!txtBIC.Text.Trim().Contains(bic))
                    {
                        Utils.ShowWarning("WARNING: IBAN does not contain BIC entered!");
                    }
                    else if (!txtSortCode.Text.Trim().Contains(sortCode))
                    {
                        Utils.ShowWarning("WARNING: IBAN does not contain Sort Code entered!");
                    }
                    else if (!Utils.ValidIBAN(txtIBAN.Text.Trim()))
                    {
                        Utils.ShowWarning("WARNING: IBAN is not valid!");
                    }

                    Data_Supplier.SaveSupplier(new Data_Supplier()
                    {
                        SupplierID       = supplierID,
                        SupplierTypeCode = luSupplierType.SelectedValue.ToString(),
                        FirstName        = txtFirstName.Text.Trim(),
                        Surname          = txtSurname.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(),
                        Mobile           = txtMobile.Text.Trim(),
                        PPSVat           = txtPPSVat.Text.Trim(),
                        BankName         = txtBankName.Text.Trim(),
                        BankAddress1     = txtBankAddress1.Text.Trim(),
                        BankAddress2     = txtBankAddress2.Text.Trim(),
                        BankAddress3     = txtBankAddress3.Text.Trim(),
                        BankAddress4     = txtBankAddress4.Text.Trim(),
                        BankAddress5     = txtBankAddress5.Text.Trim(),
                        BankAccNumber    = txtBankAccNumber.Text.Trim(),
                        SortCode         = txtSortCode.Text.Trim(),
                        BIC  = txtBIC.Text.Trim(),
                        IBAN = txtIBAN.Text.Trim()
                    });

                    DialogResult = DialogResult.OK;
                }
            } catch (Exception ex) {
                Utils.ShowException(ex);
            }
        }
 private void btnFilter_Click(object sender, EventArgs e)
 {
     bsRecords.DataSource = Data_Supplier.SearchSuppliers(Global.Username, txtSearchTerm.Text.Trim(), String.Empty, true);
 }