private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { if (thirdPArty_serviceCmb.IsChecked == true) { if (clientCmb.SelectedItem == null || brandCmb.SelectedItem == null || string.IsNullOrEmpty(unique_referenceTextBox.Text) || string.IsNullOrEmpty(commercial_invoiceTextBox.Text) || purchase_dateDatePicker.DisplayDate.ToString() == "" || userCmb.SelectedItem == null || string.IsNullOrEmpty(in_dateDatePicker.DisplayDate.ToString())) { MessageBox.Show("Los campos cliente, marca, imei o serie, factura, fecha de compra, tecnico encargado y fecha de entrada no deben ser nulas"); return; } } else { if (clientCmb.SelectedItem == null || string.IsNullOrEmpty(unique_referenceTextBox.Text) || userCmb.SelectedItem == null || string.IsNullOrEmpty(in_dateDatePicker.DisplayDate.ToString())) { MessageBox.Show("Los campos cliente, imei o serie, tecnico encargado y fecha de entrada no deben estar vacios"); return; } } using (context) { Models.services newService = new Models.services(); Models.customers newCustomer = (Models.customers)clientCmb.SelectedItem; Models.users newUser = (Models.users)userCmb.SelectedItem; newService.id_customer = newCustomer.id_customer; if (thirdPArty_serviceCmb.IsChecked == true) { Models.brands newBrand = (Models.brands)brandCmb.SelectedItem; newService.id_brand = newBrand.id_brand; newService.is_warranty = true; newService.purchase_date = purchase_dateDatePicker.DisplayDate; newService.commercial_invoice = commercial_invoiceTextBox.Text; } else { newService.is_warranty = false; } newService.unique_reference = unique_referenceTextBox.Text; newService.model = modelTextBox.Text; newService.technical_operator = newUser.id_user; newService.in_date = in_dateDatePicker.DisplayDate; context.services.Add(newService); context.SaveChanges(); disableAll(); mainw.Succesful("service"); lblNotification.Content = "Nuevo servicio registrado correctamente"; lblNotification.Visibility = Visibility.Visible; } }
private void CommandBinding_Executed_1(object sender, ExecutedRoutedEventArgs e) { if (thirdPArty_serviceCmb.IsChecked == true) { if (clientCmb.SelectedItem == null || brandCmb.SelectedItem == null || string.IsNullOrEmpty(unique_referenceTextBox.Text) || string.IsNullOrEmpty(commercial_invoiceTextBox.Text) || purchase_dateDatePicker.DisplayDate.ToString() == "" || userCmb.SelectedItem == null || string.IsNullOrEmpty(in_dateDatePicker.DisplayDate.ToString())) { MessageBox.Show("Los campos cliente, marca, imei o serie, factura, fecha de compra, tecnico encargado y fecha de entrada no deben ser nulas"); return; } } else { if (clientCmb.SelectedItem == null || string.IsNullOrEmpty(unique_referenceTextBox.Text) || userCmb.SelectedItem == null || string.IsNullOrEmpty(in_dateDatePicker.DisplayDate.ToString())) { MessageBox.Show("Los campos cliente, imei o serie, tecnico encargado y fecha de entrada no deben estar vacios"); return; } } var mservice = new Models.services { id_service = service.id_service }; using (var context = new Models.solutecEntities()) { Models.customers newCustomer = (Models.customers)clientCmb.SelectedItem; Models.users newUser = (Models.users)userCmb.SelectedItem; context.services.Attach(mservice); if (thirdPArty_serviceCmb.IsChecked == true) { Models.brands newBrand = (Models.brands)brandCmb.SelectedItem; mservice.id_brand = newBrand.id_brand; mservice.is_warranty = true; mservice.purchase_date = purchase_dateDatePicker.DisplayDate; mservice.commercial_invoice = commercial_invoiceTextBox.Text; } else { mservice.is_warranty = false; } mservice.unique_reference = unique_referenceTextBox.Text; mservice.model = modelTextBox.Text; mservice.technical_operator = newUser.id_user; mservice.in_date = in_dateDatePicker.DisplayDate; context.Configuration.ValidateOnSaveEnabled = false; context.SaveChanges(); } mainw.Succesful("service"); }
private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e) { if (string.IsNullOrEmpty(full_nameTextBox.Text) || string.IsNullOrEmpty(phone_numberTextBox.Text)) { MessageBox.Show("Los campos nombre y telefono no deben estar vacios"); return; } using (Models.solutecEntities context = new Models.solutecEntities()) { Models.customers newCustomer = new Models.customers(); newCustomer.full_name = full_nameTextBox.Text; newCustomer.phone_number = phone_numberTextBox.Text; newCustomer.is_active = true; newCustomer.nit = nitTextBox.Text; newCustomer.dui = duiTextBox.Text; newCustomer.address = addressTextBox.Text; if (direct_customer.IsChecked == true) { newCustomer.customer_type = 1; newCustomer.nrc = ""; } else { newCustomer.customer_type = 2; newCustomer.nrc = nrcTextBox.Text; } context.customers.Add(newCustomer); context.SaveChanges(); lblNotification.Content = "Cliente registrado correctamente"; notification.Visibility = Visibility.Visible; direct_customer.IsEnabled = false; thirdParty_customer.IsEnabled = false; full_nameTextBox.IsEnabled = false; phone_numberTextBox.IsEnabled = false; nitTextBox.IsEnabled = false; nrcTextBox.IsEnabled = false; duiTextBox.IsEnabled = false; addressTextBox.IsEnabled = false; btnSave.IsEnabled = false; mainw.Succesful("customer"); } }
public new_customer(MainWindow mainwin, Models.customers customer) { InitializeComponent(); mainw = mainwin; custom = customer; if (custom.customer_type == 1) { direct_customer.IsChecked = true; } else { thirdParty_customer.IsChecked = true; } full_nameTextBox.Text = custom.full_name; phone_numberTextBox.Text = custom.phone_number; addressTextBox.Text = custom.address; duiTextBox.Text = custom.dui; nitTextBox.Text = custom.nit; nrcTextBox.Text = custom.nrc; btnDelete.Visibility = Visibility.Visible; btnModify.Visibility = Visibility.Visible; btnSave.Visibility = Visibility.Hidden; notification.Visibility = Visibility.Hidden; }