Exemplo n.º 1
0
 public ExpendituresView(Expenditure expenditure)
 {
     this.id   = expenditure.id;
     this.Date = String.Format("Ngay {0}/{1}",
                               expenditure.Date.Day, expenditure.Date.Month);
     this.Note  = expenditure.Note;
     this.Price = String.Format("{0:n0}", expenditure.Price);
 }
Exemplo n.º 2
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.º 3
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();
             }
         }
     }
 }