Пример #1
0
        public void LoadCustomer(int id)
        {
            if (SystemClass.CheckConnection())
            {
                ImusCityHallEntities db = new ImusCityHallEntities();
                ImusCityGovernmentSystem.Model.Customer customer = db.Customers.Find(id);
                firstnametb.Text         = customer.FirstName;
                middlenametb.Text        = customer.MiddleName;
                lastnametb.Text          = customer.LastName;
                birthdatedp.SelectedDate = customer.Birthdate;
                completeaddresstb.Text   = customer.CompleteAddress;

                if (db.CheckReleases.Any(m => m.CustomerID == customer.CustomerID))
                {
                    CheckRelease releasedCheck = db.CheckReleases.Where(m => m.CustomerID == customer.CustomerID).OrderByDescending(m => m.CheckReleaseID).FirstOrDefault();
                    CustomerIdentificationCard customerCard = db.CustomerIdentificationCards.FirstOrDefault(m => m.IdentificationCardTypeID == releasedCheck.IdentificationCardTypeID && m.CustomerID == customer.CustomerID && m.IdentificationCardType.IsActive == true);
                    if (customerCard != null)
                    {
                        idtypecb.SelectedValue = customerCard.IdentificationCardTypeID;
                        idcardnumbertb.Text    = customerCard.IdentificationNumber;
                    }
                    else
                    {
                        idtypecb.SelectedValue = releasedCheck.IdentificationCardTypeID;
                        idcardnumbertb.Text    = releasedCheck.IdentificationCardNumber;
                    }
                }
            }
            else
            {
                MessageBox.Show(SystemClass.DBConnectionErrorMessage);
            }
        }
Пример #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);
            }
        }