public AddWindow(Requests request, Service.Service service) { this.InitializeComponent(); this.InitializeMembers(service); this.InitializeComboBoxes(); // Fill TextBoxes this.textBoxClient.Text = request.Clients.FullName; this.textBoxAdress.Text = request.Address; this.textBoxComment.Text = request.Comment; // Fill ComboBoxes this.comboBoxServices.SelectedIndex = this.comboBoxServices.FindStringExact(request.Services.Name); this.comboBoxOperators.SelectedIndex = this.comboBoxOperators.FindStringExact(request.Operators.FullName); this.comboBoxMasters.SelectedIndex = this.comboBoxMasters.FindStringExact(request.Masters.FullName); // Fill DateTimePickers this.dateTimePickerRequest.Value = request.RequestDate; this.dateTimePickerCloseRequest.Value = request.CloseDate ?? DateTime.Now; this.dateTimePickerDepature.Value = request.DateOfDeparture ?? DateTime.Now; this.buttonAdd.Text = "Изменить"; this.isEditMode = true; this.requestToEdit = request; }
public string CreateRequest(string clientName, int masterId, int operatorId, int serviceId, string comment, string adress, DateTime requestDate, DateTime closeDate, DateTime dateOfDeparture) { Clients client = new Clients(); client.FullName = clientName; string message; this.secondaryRepo.CreateClient(client); message = "Заявка добавлена успешно"; Requests request = new Requests(); request.ClientId = client.Id; request.MasterId = masterId; request.OperatorId = operatorId; request.ServiceId = serviceId; request.Comment = comment; request.Address = adress; request.RequestDate = requestDate; request.CloseDate = closeDate; request.DateOfDeparture = dateOfDeparture; requestRepo.CreateRequest(request); return message; }
// TODO: FIX OR DELETE IT public void UpdateRequest(Requests request) { Requests req = db.Requests.Single(x => x.Id == request.Id); req.Address = request.Address; req.ClientId = request.ClientId; req.CloseDate = request.CloseDate; req.Comment = request.Comment; req.DateOfDeparture = request.DateOfDeparture; req.OperatorId = request.OperatorId; req.MasterId = request.MasterId; req.ServiceId = request.ServiceId; db.SubmitChanges(); }
private void InitializeMembers(Service.Service service) { this.isEditMode = false; this.requestToEdit = null; this.service = service; }
public string UpdateRequest(Requests request, string clientName, int masterId, int operatorId, int serviceId, string comment, string adress, DateTime requestDate, DateTime closeDate, DateTime dateOfDeparture) { Clients client = new Clients(); client.FullName = clientName; request.Clients = secondaryRepo.CreateClient(client); request.Masters = GetMasterExact(masterId); request.Operators = GetOperatorExact(operatorId); request.Services = GetServiceExact(serviceId); request.Address = adress; request.Comment = comment; request.RequestDate = requestDate; request.CloseDate = closeDate; request.DateOfDeparture = dateOfDeparture; requestDBContext.SubmitChanges(); requestRepo.UpdateRequest(request); return "Заявка успешно изменена"; }
private void detach_Requests(Requests entity) { this.SendPropertyChanging(); entity.Masters = null; }
private void attach_Requests(Requests entity) { this.SendPropertyChanging(); entity.Masters = this; }
partial void DeleteRequests(Requests instance);
partial void UpdateRequests(Requests instance);
partial void InsertRequests(Requests instance);
public void DeleteRequest(Requests request) { db.Requests.DeleteOnSubmit(request); db.SubmitChanges(); }
public void CreateRequest(Requests request) { db.Requests.InsertOnSubmit(request); db.SubmitChanges(); }