Exemplo n.º 1
0
        private void ViewAllMembers()
        {
            var db         = new OOPCSEntities();
            var members    = db.Members.ToArray();
            var memberView = new MemberView[members.Length];

            for (int i = 0; i < members.Length; i++)
            {
                memberView[i] = new MemberView(members[i]);
            }
            this.grdMembers.DataSource = memberView;
        }
Exemplo n.º 2
0
        private void ViewAllExpenditure()
        {
            var db               = new OOPCSEntities();
            var expenditures     = db.Expenditures.ToArray();
            var expenditureViews = new ExpenditureView[expenditures.Length];

            for (int i = 0; i < expenditureViews.Length; i++)
            {
                expenditureViews[i] = new ExpenditureView(expenditures[i]);
            }
            this.grdExpenditures.DataSource = expenditureViews;
        }
Exemplo n.º 3
0
        void btnsave_Click(object sender, EventArgs e)
        {
            DateTime date        = this.dtpDate.Value;
            string   note        = this.textBox1.Text;
            int      price       = Decimal.ToInt32(this.nudPrice.Value);
            var      expenditure = new Expenditure();

            expenditure.Date  = date;
            expenditure.Note  = note;
            expenditure.Price = price;
            var db = new OOPCSEntities();

            db.Expenditures.Add(expenditure);
            db.SaveChanges();
            this.Close();
        }
Exemplo n.º 4
0
 void grdExpenditures_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyValue == 46)
     {
         if (this.grdExpenditures.SelectedRows.Count == 1)
         {
             if (MessageBox.Show("do you want to delete this?") == System.Windows.Forms.DialogResult.OK)
             {
                 ExpenditureView selected = (ExpenditureView)
                                            this.grdExpenditures.SelectedRows[0].DataBoundItem;
                 var         db      = new OOPCSEntities();
                 Expenditure deleted = db.Expenditures.Find(selected.id);
                 db.Expenditures.Remove(deleted);
                 db.SaveChanges();
                 this.ViewAllExpenditure();
             }
         }
     }
 }
Exemplo n.º 5
0
        public MemberView(Member member)
        {
            this.id       = member.id;
            this.Fullname = member.Fullname;
            this.Gender   = member.Gender == true ? "Nam" : "Nu";
            if (member.Birthday != null)
            {
                this.Birthday = string.Format("{0}/{1}/{2}",
                                              member.Birthday.Value.Day,
                                              member.Birthday.Value.Month,
                                              member.Birthday.Value.Year
                                              );
            }
            if (member.Status.HasValue)
            {
                this.Status = member.Status.Value == true ? "Living" : "Deceased";
            }
            var db = new OOPCSEntities();

            if (member.Father_id.HasValue)
            {
                var father = db.Members.Find(member.Father_id.Value);
                this.Father = father.Fullname;
            }

            if (member.Mother_id.HasValue)
            {
                var mother = db.Members.Find(member.Mother_id.Value);
                this.Mother = mother.Fullname;
            }

            if (member.Spouse_id.HasValue)
            {
                var spouse = db.Members.Find(member.Spouse_id.Value);
                this.Spouse = spouse.Fullname;
            }
            this.Hometowm      = member.Hometowm;
            this.Currentliving = member.Currentliving;
            this.Occupation    = member.Occupation;
        }