Beispiel #1
0
        private void deletebtn_Click(object sender, RoutedEventArgs e)
        {
            if (SystemClass.CheckConnection())
            {
                if (banklb.SelectedValue != null)
                {
                    ImusCityHallEntities db = new ImusCityHallEntities();
                    int id = (int)banklb.SelectedValue;
                    ImusCityGovernmentSystem.Model.Bank bank = db.Banks.Find(id);
                    bank.IsActive = false;
                    db.SaveChanges();
                    db = new ImusCityHallEntities();
                    banklb.ItemsSource       = db.Banks.Where(m => m.IsActive == true).OrderByDescending(m => m.BankID).ToList();
                    banklb.DisplayMemberPath = "BankName";
                    banklb.SelectedValuePath = "BankID";

                    var audit = new AuditTrailModel
                    {
                        Activity   = "Deleted item in the fund list. BANK ID: " + id.ToString(),
                        ModuleName = this.GetType().Name,
                        EmployeeID = App.EmployeeID
                    };
                    SystemClass.InsertLog(audit);
                }
                else
                {
                    MessageBox.Show("Please select an item");
                }
            }
            else
            {
                MessageBox.Show(SystemClass.DBConnectionErrorMessage);
            }
        }
 private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
 {
     if (SystemClass.CheckConnection())
     {
         ImusCityHallEntities db = new ImusCityHallEntities();
         ImusCityGovernmentSystem.Model.Bank bank = db.Banks.Find(BankID);
         bankcodetb.Text = bank.BankCode;
         banknametb.Text = bank.BankName;
         branchtb.Text   = bank.Branch;
     }
     else
     {
         MessageBox.Show(SystemClass.DBConnectionErrorMessage);
     }
 }
        private void savebtn_Click(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            if (SystemClass.CheckConnection())
            {
                if (String.IsNullOrEmpty(bankcodetb.Text) || String.IsNullOrEmpty(banknametb.Text))
                {
                    MessageBox.Show("Please input bank code and bank name!");
                }
                else if (String.IsNullOrEmpty(branchtb.Text))
                {
                    MessageBox.Show("Please enter branch name");
                }
                else
                {
                    ImusCityHallEntities db = new ImusCityHallEntities();
                    ImusCityGovernmentSystem.Model.Bank bank = db.Banks.Find(BankID);
                    bank.BankCode = bankcodetb.Text;
                    bank.BankName = banknametb.Text;
                    bank.Branch   = branchtb.Text;
                    db.SaveChanges();
                    Mouse.OverrideCursor = null;
                    var audit = new AuditTrailModel
                    {
                        Activity   = "Updated an item in bank list. BANK ID: " + BankID.ToString(),
                        ModuleName = this.GetType().Name,
                        EmployeeID = App.EmployeeID
                    };

                    SystemClass.InsertLog(audit);
                    MessageBox.Show("Bank updated successfully!");
                }
            }
            else
            {
                Mouse.OverrideCursor = null;
                MessageBox.Show(SystemClass.DBConnectionErrorMessage);
            }

            Mouse.OverrideCursor = null;
        }