Beispiel #1
0
        private void deletebtn_Click(object sender, RoutedEventArgs e)
        {
            if (SystemClass.CheckConnection())
            {
                if (fundlb.SelectedValue != null)
                {
                    ImusCityHallEntities db = new ImusCityHallEntities();
                    int id = (int)fundlb.SelectedValue;
                    ImusCityGovernmentSystem.Model.Fund fund = db.Funds.Find(id);
                    fund.IsActive = false;
                    db.SaveChanges();
                    db = new ImusCityHallEntities();
                    fundlb.ItemsSource       = db.Funds.Where(m => m.IsActive == true).OrderByDescending(m => m.FundID).ToList();
                    fundlb.DisplayMemberPath = "FundName";
                    fundlb.SelectedValuePath = "FundID";

                    var audit = new AuditTrailModel
                    {
                        Activity   = "Deleted item in the fund list. FUND 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);
            }
        }
Beispiel #2
0
 private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
 {
     if (SystemClass.CheckConnection())
     {
         ImusCityHallEntities db = new ImusCityHallEntities();
         ImusCityGovernmentSystem.Model.Fund fund = db.Funds.Find(FundID);
         fundcodetb.Text      = fund.FundCode;
         fundnametb.Text      = fund.FundName;
         voucherprefixtb.Text = fund.FundPrefix;
     }
     else
     {
         MessageBox.Show(SystemClass.DBConnectionErrorMessage);
     }
 }
Beispiel #3
0
        private void savebtn_Click(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            if (SystemClass.CheckConnection())
            {
                if (String.IsNullOrEmpty(fundcodetb.Text) || String.IsNullOrEmpty(fundnametb.Text))
                {
                    MessageBox.Show("Please input fund code and fund name!");
                }
                else if (String.IsNullOrEmpty(voucherprefixtb.Text))
                {
                    MessageBox.Show("Please enter voucher prefix");
                }
                else
                {
                    ImusCityHallEntities db = new ImusCityHallEntities();
                    ImusCityGovernmentSystem.Model.Fund fund = db.Funds.Find(FundID);
                    fund.FundCode   = fundcodetb.Text;
                    fund.FundName   = fundnametb.Text;
                    fund.FundPrefix = voucherprefixtb.Text;
                    db.SaveChanges();
                    Mouse.OverrideCursor = null;
                    var audit = new AuditTrailModel
                    {
                        Activity   = "Updated an item in fund list. FUND ID: " + FundID.ToString(),
                        ModuleName = this.GetType().Name,
                        EmployeeID = App.EmployeeID
                    };

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

            Mouse.OverrideCursor = null;
        }