private void button1_Click(object sender, EventArgs e) { if (MetroMessageBox.Show(this, "Are you sure you want to update this register?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { // Tratamento das Datas EntitiesContext context = new EntitiesContext(); EventDAO edao = new EventDAO(); aBeg = DateTime.Parse(mdtDateBegin.Text); bBeg = aBeg.ToString("dd/MM/yyyy"); cBeg = bBeg + " " + txtTimeBegin.Text; aEnd = DateTime.Parse(mdtDateEnd.Text); bEnd = aEnd.ToString("dd/MM/yyyy"); cEnd = bEnd + " " + txtTimeEnd.Text; //Tratamento da Combo Box Artista ArtistDAO adao = new ArtistDAO(); idart = adao.FindIdByCb(mcbArtEvent.Text); //Tratamento da Combo Box Menu MenuDAO mdao = new MenuDAO(); idmenu = mdao.FindIdByCb(mcbMenuEvent.Text); Event eve = edao.FindId(global.ideve); eve.Name = txtNameEvent.Text; eve.Desc = txtDescEvent.Text; eve.TimeBegin = DateTime.Parse(cBeg); eve.TimeEnd = DateTime.Parse(cEnd); eve.ArtistId = idart; eve.MenuId = idmenu; edao.Update(); MetroMessageBox.Show(this, "Register Successfully Updated", "Updated", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); } }
private void btnRegister_Click(object sender, EventArgs e) { if (MetroMessageBox.Show(this, Strings.ConfRegister, Strings.Register, MessageBoxButtons.YesNo, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { // Tratamento das Datas EntitiesContext context = new EntitiesContext(); EventDAO edao = new EventDAO(); aBeg = DateTime.Parse(mdtDateBegin.Text); bBeg = aBeg.ToString("dd/MM/yyyy"); cBeg = bBeg + " " + txtTimeBegin.Text; aEnd = DateTime.Parse(mdtDateEnd.Text); bEnd = aEnd.ToString("dd/MM/yyyy"); cEnd = bEnd + " " + txtTimeEnd.Text; //Tratamento da Combo Box Artista ArtistDAO adao = new ArtistDAO(); idart = adao.FindIdByCb(mcbArtEvent.Text); //Tratamento da Combo Box Menu MenuDAO mdao = new MenuDAO(); idmenu = mdao.FindIdByCb(mcbMenuEvent.Text); Event even = new Event() { Name = txtNameEvent.Text, Desc = txtDescEvent.Text, TimeBegin = DateTime.Parse(cBeg), TimeEnd = DateTime.Parse(cEnd), ArtistId = idart, MenuId = idmenu }; edao.Add(even); MetroMessageBox.Show(this, Strings.SuccessRegistered, Strings.Registered, MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); } }