private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (SystemClass.CheckConnection())
            {
                foreach (var item in Enum.GetValues(typeof(CheckStatus)))
                {
                    if (item.ToString() == "Released" && item.ToString() == "Created")
                    {
                    }
                    else
                    {
                        checkstatuscb.Items.Add(item);
                    }
                }

                ImusCityHallEntities db = new ImusCityHallEntities();
                ImusCityGovernmentSystem.Model.Check check = db.Checks.Find(CheckID);
                checknumbertb.Text          = check.CheckNo;
                checkdatecreateddp.Text     = check.DateCreated.Value.ToShortDateString();
                checkstatuscb.SelectedIndex = check.Status.HasValue ? check.Status.Value : 0;
            }
            else
            {
                MessageBox.Show(SystemClass.DBConnectionErrorMessage);
            }
        }
Esempio n. 2
0
        public void SaveCheckReleased(int Id, int checkId)
        {
            if (SystemClass.CheckConnection())
            {
                ImusCityHallEntities db = new ImusCityHallEntities();
                ImusCityGovernmentSystem.Model.CheckRelease released = new CheckRelease();
                released.CustomerID               = Id;
                released.ReleasedDate             = DateTime.Now;
                released.CheckID                  = checkId;
                released.Photo                    = ConvertImageSourceToByte(imagecapture);
                released.DigitalSignature         = ConvertImageSourceToByte(digitalsignatureimg);
                released.ReleasedBy               = App.EmployeeID;
                released.IdentificationCardNumber = idcardnumbertb.Text;
                released.IdentificationCardTypeID = (int)idtypecb.SelectedValue;
                db.CheckReleases.Add(released);

                ImusCityGovernmentSystem.Model.Check check = db.Checks.Find(checkId);
                check.Status = (int)CheckStatus.Released;

                int cardId = (int)idtypecb.SelectedValue;
                CustomerIdentificationCard customerCard = db.CustomerIdentificationCards.FirstOrDefault(m => m.IdentificationCardTypeID == cardId && m.CustomerID == Id && m.IdentificationCardType.IsActive == true);
                if (customerCard != null)
                {
                    customerCard.IdentificationNumber = idcardnumbertb.Text;
                    db.SaveChanges();
                }
                else
                {
                    CustomerIdentificationCard custCard = new CustomerIdentificationCard();
                    custCard.CustomerID = Id;
                    custCard.IdentificationCardTypeID = (int)idtypecb.SelectedValue;
                    custCard.IdentificationNumber     = idcardnumbertb.Text;
                    db.CustomerIdentificationCards.Add(custCard);
                }

                db.SaveChanges();
                MessageBox.Show("Check has been successfully released");
                LoadIdentificationCardType();

                var audit = new AuditTrailModel
                {
                    Activity   = "Released check to CUSTOMER ID: " + released.CustomerID.ToString() + " with CHECK NUMBER: " + released.Check.CheckNo,
                    ModuleName = this.GetType().Name,
                    EmployeeID = App.EmployeeID
                };
                SystemClass.InsertLog(audit);

                ResetFields();
            }
            else
            {
                MessageBox.Show(SystemClass.DBConnectionErrorMessage);
            }
        }
Esempio n. 3
0
        public void CheckReport(int id)
        {
            if (SystemClass.CheckConnection())
            {
                ImusCityHallEntities db          = new ImusCityHallEntities();
                CDSSignatory         signatories = db.CDSSignatories.FirstOrDefault();
                CheckModel           check       = new CheckModel();
                ImusCityGovernmentSystem.Model.Check checklist = db.Checks.Find(id);
                check.CheckNo     = checklist.CheckNo;
                check.CheckDate   = checklist.DateCreated.Value;
                check.CompanyName = checklist.Disbursement.Payee == null ? checklist.Disbursement.PayeeName : checklist.Disbursement.Payee.CompanyName;
                CurrencyToWords convert = new CurrencyToWords();
                double          amount  = Convert.ToDouble(checklist.Amount.Value);
                check.AmountInWords    = convert.NumberToWords(amount).ToUpper();
                check.CheckDescription = checklist.CheckDescription;
                check.VoucherNo        = checklist.Disbursement.VoucherNo;
                check.Amount           = checklist.Amount.Value;
                check.Signatory1       = SystemClass.GetSignatory(signatories.CityMayor);
                check.Signatory2       = SystemClass.GetSignatory(signatories.CityTreasurer);
                ReportDocument report;
                switch (bankName)
                {
                case "LB":
                    report = new LBCheckReport();
                    report.SetDataSource(new[] { check });
                    reportviewer.ViewerCore.ReportSource = report;
                    break;

                case "UCPB":
                    report = new UCPBCheckReport();
                    report.SetDataSource(new[] { check });
                    reportviewer.ViewerCore.ReportSource = report;
                    break;

                case "DBP":
                    report = new DBPCheckReport();
                    report.SetDataSource(new[] { check });
                    reportviewer.ViewerCore.ReportSource = report;
                    break;
                }
            }
            else
            {
                MessageBox.Show(SystemClass.DBConnectionErrorMessage);
            }
        }
Esempio n. 4
0
 private void checklistcb_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (SystemClass.CheckConnection())
     {
         ImusCityHallEntities db = new ImusCityHallEntities();
         if (checklistcb.SelectedValue == null)
         {
             return;
         }
         int id = (int)checklistcb.SelectedValue;
         ImusCityGovernmentSystem.Model.Check check = db.Checks.Find(id);
         voucherNumbertb.Text    = check.Disbursement.VoucherNo;
         checknumbertb.Text      = check.CheckNo;
         checkdatetb.Text        = check.DateCreated.Value.ToShortDateString();
         companynametb.Text      = check.Disbursement.Payee == null ? check.Disbursement.PayeeName : check.Disbursement.Payee.CompanyName;
         checkdescriptiontb.Text = check.CheckDescription;
         banktb.Text             = string.Join("/", check.Disbursement.FundBank.Fund.FundName, check.Disbursement.FundBank.Bank.BankName);
         amountb.Text            = string.Format("{0:n}", check.Amount);
     }
     else
     {
         MessageBox.Show(SystemClass.DBConnectionErrorMessage);
     }
 }
        private void savebtn_Click(object sender, RoutedEventArgs e)
        {
            if (SystemClass.CheckConnection())
            {
                ImusCityHallEntities db = new ImusCityHallEntities();
                ImusCityGovernmentSystem.Model.Check check = db.Checks.Find(CheckID);
                check.Status = checkstatuscb.SelectedIndex;


                if (checkstatuscb.SelectedIndex == (int)CheckStatus.Cancelled)
                {
                    check.CancelledBy   = App.EmployeeID;
                    check.CancelledDate = DateTime.Now;

                    ImusCityGovernmentSystem.Model.BankTrail    banktrail    = new BankTrail();
                    ImusCityGovernmentSystem.Model.Disbursement disbursement = db.Disbursements.Find(check.DisbursementID);
                    banktrail.DebitCredit = "C";
                    banktrail.FundBankID  = disbursement.FundBankID;
                    banktrail.Amount      = Convert.ToDecimal(check.Amount);
                    banktrail.EntryName   = nameof(BankTrailEntry.CheckCancelled);
                    banktrail.CheckID     = check.CheckID;
                    banktrail.EntryNameID = (int)BankTrailEntry.CheckCancelled;
                    banktrail.EmployeeID  = App.EmployeeID;
                    banktrail.DateCreated = DateTime.Now;
                    db.BankTrails.Add(banktrail);

                    ImusCityGovernmentSystem.Model.FundBank account = db.FundBanks.Find(disbursement.FundBankID);
                    account.CurrentBalance += Convert.ToDecimal(check.Amount);
                }
                else if (checkstatuscb.SelectedIndex == (int)CheckStatus.Deleted)
                {
                    check.DeletedBy   = App.EmployeeID;
                    check.DeletedDate = DateTime.Now;

                    ImusCityGovernmentSystem.Model.BankTrail    banktrail    = new BankTrail();
                    ImusCityGovernmentSystem.Model.Disbursement disbursement = db.Disbursements.Find(check.DisbursementID);
                    banktrail.DebitCredit = "C";
                    banktrail.FundBankID  = disbursement.FundBankID;
                    banktrail.Amount      = Convert.ToDecimal(check.Amount);
                    banktrail.EntryName   = nameof(BankTrailEntry.CheckDeleted);
                    banktrail.CheckID     = check.CheckID;
                    banktrail.EntryNameID = (int)BankTrailEntry.CheckDeleted;
                    banktrail.EmployeeID  = App.EmployeeID;
                    banktrail.DateCreated = DateTime.Now;
                    db.BankTrails.Add(banktrail);

                    ImusCityGovernmentSystem.Model.FundBank account = db.FundBanks.Find(disbursement.FundBankID);
                    account.CurrentBalance += Convert.ToDecimal(check.Amount);
                }


                db.SaveChanges();

                var audit = new AuditTrailModel
                {
                    Activity   = "Updated check in the database. CHECK NUMBER: " + check.CheckNo,
                    ModuleName = this.GetType().Name,
                    EmployeeID = App.EmployeeID
                };

                SystemClass.InsertLog(audit);

                MessageBox.Show("Check entry updated successfully");
            }
            else
            {
                MessageBox.Show(SystemClass.DBConnectionErrorMessage);
            }
        }