private void btnCreate_Click(object sender, EventArgs e) { if (CheckAll(txtBarcode.Text)) { string Name = txtName.Text; string Surname = txtSurname.Text; string Barcode = txtBarcode.Text; Registration registration = new Registration() { Client_Name = Name, Client_Surname = Surname, }; _context.Registrations.Add(registration); Card card = new Card() { Registration_Id = registration.Id, Code = Barcode }; _context.Cards.Add(card); _context.SaveChanges(); FillDataGridView(); ClearAll(); } else { ShowMessage("Error", "error"); } }
private void btnCreate_Click(object sender, EventArgs e) { if (CheckAll(txtPacket.Text)) { string PacketName = txtPacket.Text; int PacketPrice = (int)nmudPrice.Value; Packet packet = new Packet() { Packet_Name = PacketName, Packet_Price = PacketPrice }; _context.Packets.Add(packet); _context.SaveChanges(); ClearAllField(); FillDataGridView(); } ; }
private void btnCreate_Click(object sender, EventArgs e) { if (CheckAll(txtService.Text)) { string ServiceName = txtService.Text; int ServicePrice = (int)nmudPrice.Value; Service service = new Service() { Service_Name = ServiceName, Service_Price = ServicePrice }; _context.Services.Add(service); _context.SaveChanges(); ClearAllField(); FillDataGridView(); } ; }
private void btnCreate_Click(object sender, EventArgs e) { if (CheckAll()) { int Packetid = _context.Packets.Where(p => p.Packet_Name == cmbPacket.Text).First().Id; foreach (var item in checkedListBox.CheckedItems) { int id = _context.Services.FirstOrDefault(s => s.Service_Name == item.ToString()).Id; if (!_context.ServicetoPackets.Where(stp => stp.Packet_Id == Packetid).Any(c => c.Service_Id == id)) { _context.ServicetoPackets.Add(new ServicetoPacket() { Service_Id = id, Packet_Id = Packetid }); } } _context.SaveChanges(); FillDataGridView(); ClearAllField(); } }
private void btnCreate_Click(object sender, EventArgs e) { decimal Tool = nmudTool.Value; decimal Salary = nmudSalary.Value; Outcome outcome = new Outcome() { Cleaning_Tools = Tool, Worker_salary = Salary, OutcomeMonth = DateTime.Now }; _context.Outcomes.Add(outcome); _context.SaveChanges(); FillDataGridView(); }
private void btnCreate_Click(object sender, EventArgs e) { if (CheckAll()) { string Name = txtName.Text; string Surname = txtSurname.Text; string Barcode = txtBarcode.Text; string Packet = cmbPacket.Text; string Service = cmbService.Text; string ServicePrice = txtServicePrice.Text; string PacketPrice = txtPacketPrice.Text; Registration registration = new Registration() { Client_Name = Name, Client_Surname = Surname }; _context.Registrations.Add(registration); Card card = new Card() { Registration_Id = registration.Id, Code = Barcode }; Service service = _context.Services.Where(p => p.Service_Name == cmbService.Text).FirstOrDefault(); Packet packet = _context.Packets.Where(p => p.Packet_Name == cmbPacket.Text).FirstOrDefault(); if (packet != null) { CardtoPacketService cardtoPacketService = new CardtoPacketService() { Card_Id = _context.Cards.Where(c => c.Code == txtBarcode.Text).First().Id, //Packet_Id = packet.Id, //Service_Id = service.Id Packet_Id = packet.Id, Service_Id = null }; Income income = new Income() { Client_Id = _context.Cards.Where(c => c.Code == txtBarcode.Text).First().Registration.Id, IncomeMonth = DateTime.Now, ClientIncomes = (int)packet.Packet_Price }; _context.Incomes.Add(income); _context.CardtoPacketServices.Add(cardtoPacketService); } if (service != null) { CardtoPacketService cardtoPacketService = new CardtoPacketService() { Card_Id = _context.Cards.Where(c => c.Code == txtBarcode.Text).First().Id, //Packet_Id = packet.Id, //Service_Id = service.Id Packet_Id = null, Service_Id = service.Id }; Income income = new Income() { Client_Id = _context.Cards.Where(c => c.Code == txtBarcode.Text).First().Registration.Id, IncomeMonth = DateTime.Now, ClientIncomes = (int)service.Service_Price }; _context.Incomes.Add(income); _context.CardtoPacketServices.Add(cardtoPacketService); } _context.SaveChanges(); FillDataGridView(); ClearAllField(); } }