private void Btn_createTicket(object sender, EventArgs e)
        {
            //Ticket ticket1 = new Ticket();
            //ticket1.Title = createTicketControl.Controls.GetType().Name;
            //ticket.Description = createTicketControl.txbx_Description.Text;
            //ticket.CraetedDate = DateTime.Now;
            //ticket.CreatedBy = Session.User.Id;

            //using(TicketsDbContext db=new TicketsDbContext())
            //{
            //    db.Tickets.Add(ticket);
            //    db.SaveChanges();
            //}

            Ticket ticket = this.MapToDataModell <Ticket>();

            ticket.CreatedBy   = Session.User.Id;
            ticket.CraetedDate = DateTime.Now;

            using (TicketsDbContext td = new TicketsDbContext())
            {
                td.Tickets.Add(ticket);
                td.SaveChanges();
            }
            MessageBox.Show("Successfully added");
        }
예제 #2
0
        private void ListTickeControl_Load(object sender, EventArgs e)
        {
            List <Ticket> tickets = null;

            using (TicketsDbContext db = new TicketsDbContext())
            {
                tickets = db.Tickets.ToList();
                db.SaveChanges();
            }
            ticketListGrid.DataSource = tickets;
        }
예제 #3
0
        private void btn_UpdateTicket_Click(object sender, EventArgs e)
        {
            DataGridViewRow newDataRow = ticketListGrid.Rows[indexRow];

            newDataRow.Cells[4].Value = txbx_Title.Text;
            newDataRow.Cells[5].Value = txbx_Description.Text;
            using (TicketsDbContext db = new TicketsDbContext())
            {
                Ticket ticket = db.Tickets.Where(x => x.Id == indexRow + 1).FirstOrDefault();
                ticket.Title       = txbx_Title.Text;
                ticket.Description = txbx_Description.Text;
                db.SaveChanges();
                MessageBox.Show("Update Syccessfully");
            }
        }