private void Accion(int x) { switch (x) { case 0: Categoria cat = new Categoria(); cat.nombreCategoria = txbNombreCategoria.Text; cat.descripcion = txbDescripcion.Text; cat.estado = "A"; dataContext.Categorias.InsertOnSubmit(cat); dataContext.SubmitChanges(); this.Close(); break; case 1: var actualizar = from u in dataContext.Categorias where u.id == Convert.ToInt32(IdCategoria) select u; foreach (var v in actualizar) { v.nombreCategoria = txbNombreCategoria.Text; v.descripcion = txbDescripcion.Text; //v.estado = txtEstado.Text; dataContext.SubmitChanges(); } this.Close(); break; } }
private void Accion(int x) { switch (TipoAccion) { case 0: Animal tanimal = new Animal(); tanimal.codigo = txtCodigoAnimal.Text; tanimal.especie = txtEspecie.Text; tanimal.cantidad = Convert.ToInt32(txtCantidad.Text); tanimal.estado = "A"; tanimal.precio = Convert.ToDecimal(txtPrecio.Text); dataContext.Animal.InsertOnSubmit(tanimal); dataContext.SubmitChanges(); this.Close(); break; case 1: var actualizar = from u in dataContext.Animal where u.id == Convert.ToInt32(IdAnimal) select u; foreach (var v in actualizar) { v.codigo = txtCodigoAnimal.Text; v.especie = txtEspecie.Text; v.cantidad = Convert.ToInt32(txtCantidad.Text); v.precio = Convert.ToDecimal(txtPrecio.Text); dataContext.SubmitChanges(); } this.Close(); break; } }
private void Acccion() { switch (TipoAccion) { case 0: Producto tabla = new Producto(); tabla.codigo = txtCodigoProducto.Text; tabla.descripcion = txtDescripcion.Text; tabla.estado = "A"; tabla.idCategoria = Convert.ToInt32(CbCategoria.SelectedValue); tabla.precioVenta = Convert.ToDecimal(txtPrecio.Text); tabla.stock = Convert.ToInt32(txtCantidad.Text); dataContext.Producto.InsertOnSubmit(tabla); dataContext.SubmitChanges(); this.Close(); break; case 1: var actualizar = from u in dataContext.Producto where u.id == Convert.ToInt32(IdProducto) select u; foreach (var v in actualizar) { v.codigo = txtCodigoProducto.Text; v.descripcion = txtDescripcion.Text; v.idCategoria = Convert.ToInt32(CbCategoria.SelectedValue); v.precioVenta = Convert.ToDecimal(txtPrecio.Text); v.stock = Convert.ToInt32(txtCantidad.Text); dataContext.SubmitChanges(); } this.Close(); break; } }
private void Accion(int x) { switch (x) { /* * public string Cedula { get; set; } * public string Nombre { get; set; } * public string Apellido { get; set; } * public string Genero { get; set; } * public string fechaNacimiento { get; set; } * public string Telefono { get; set; } * public string Direccion { get; set; } */ case 0: if (dtpFechaNcimeinto.SelectedDate.Value < DateTime.Now.Date && dtpFechaNcimeinto.SelectedDate != null) { Empleado empleado = new Empleado(); empleado.cedula = txbCedula.Text; empleado.nombre = txbNombre.Text; empleado.apellido = txbApellido.Text; empleado.genero = cbGenero.SelectedItem.ToString(); empleado.fechaNacimiento = dtpFechaNcimeinto.SelectedDate.Value; //Convert.ToDateTime(txbFecha.Text); empleado.telefono = txbTelefono.Text; empleado.direccion = txbDireccion.Text; empleado.estado = "A"; dataContext.Empleado.InsertOnSubmit(empleado); dataContext.SubmitChanges(); this.Close(); } break; case 1: if (dtpFechaNcimeinto.SelectedDate != null) { if (dtpFechaNcimeinto.SelectedDate.Value < DateTime.Now) { var actualizar = from u in dataContext.Empleado where u.id == Convert.ToInt32(IdEmpleado) select u; foreach (var v in actualizar) { v.cedula = txbCedula.Text; v.nombre = txbNombre.Text; v.apellido = txbApellido.Text; v.genero = cbGenero.SelectedItem.ToString(); v.fechaNacimiento = dtpFechaNcimeinto.SelectedDate.Value; //Convert.ToDateTime(txbFecha.Text); v.telefono = txbTelefono.Text; v.direccion = txbDireccion.Text; //v.estado = txtEstado.Text; dataContext.SubmitChanges(); } this.Close(); } } break; } }
private void Accion(int x) { switch (x) { case 0: if (DtPFechaNacimiento.SelectedDate != null) { if (DtPFechaNacimiento.SelectedDate.Value < DateTime.Now) { Cliente cliente = new Cliente(); cliente.nombre = txbNombre.Text; cliente.apellido = txbApellido.Text; cliente.cedula = txbCedula.Text; cliente.direccion = txbDireccion.Text; cliente.telefono = txbTelefono.Text; cliente.genero = CbSexo.SelectedItem.ToString(); cliente.estado = "A"; cliente.fechaNacimiento = DtPFechaNacimiento.SelectedDate.Value; dataContext.Cliente.InsertOnSubmit(cliente); dataContext.SubmitChanges(); this.Close(); } } break; case 1: if (DtPFechaNacimiento.SelectedDate != null) { if (DtPFechaNacimiento.SelectedDate.Value < DateTime.Now) { var actualizar = from u in dataContext.Cliente where u.id == Convert.ToInt32(IdCliente) select u; foreach (var v in actualizar) { v.nombre = txbNombre.Text; v.apellido = txbApellido.Text; v.cedula = txbCedula.Text; v.direccion = txbDireccion.Text; v.telefono = txbTelefono.Text; v.fechaNacimiento = DtPFechaNacimiento.SelectedDate.Value; v.genero = CbSexo.SelectedItem.ToString(); //v.estado = txtEstado.Text; dataContext.SubmitChanges(); } this.Close(); } } break; } }
private void BtnEliminar_Click(object sender, RoutedEventArgs e) { if (dgCategorias.SelectedItem != null) { if ((MessageBox.Show("Desea eliminar esta categoria", "Eliminar Categoria", MessageBoxButton.YesNo, MessageBoxImage.Warning)) == MessageBoxResult.Yes) { object item = dgCategorias.SelectedItem; string id = (dgCategorias.SelectedCells[2].Column.GetCellContent(item) as TextBlock).Text; /*var eliminar = from c in dataContext.Categorias * where c.id == Convert.ToInt32(id) * select c; * dataContext.Categorias.DeleteAllOnSubmit(eliminar); * dataContext.SubmitChanges();*/ var eliminar = from ee in dataContext.Categorias where ee.id == Convert.ToInt32(id) select ee; foreach (var v in eliminar) { v.estado = "I"; dataContext.SubmitChanges(); } MostrarCategorias(); } } }
private void BtGuardar_Click(object sender, RoutedEventArgs e) { if (txbCedula.Text != string.Empty && txbNombre.Text != string.Empty && txbApellido.Text != string.Empty && txbPass.Text != string.Empty && txbUsuario.Text != string.Empty) { string usert = NickUsuario; var use = (from user in dataContext.Usuario where user.nickName == txbUsuario.Text select user); if (use.Count() == 0) { var actualizar = from u in dataContext.Usuario where u.id == Convert.ToInt32(IdUsuario) select u; foreach (var v in actualizar) { v.nickName = txbUsuario.Text; v.pass = txbPass.Text; dataContext.SubmitChanges(); } this.Close(); } else if (txbUsuario.Text == usert) { var actualizar = from u in dataContext.Usuario where u.id == Convert.ToInt32(IdUsuario) select u; foreach (var v in actualizar) { v.nickName = txbUsuario.Text; v.pass = txbPass.Text; dataContext.SubmitChanges(); } this.Close(); } } else { MessageBox.Show("Faltan datos por ingresar"); } }
private void BtnGuardar_Click(object sender, RoutedEventArgs e) { if (txbCedula.Text != string.Empty || txbNombreMascota.Text != string.Empty || txbTipoMascota.Text != string.Empty) { Consulta tabla = new Consulta(); tabla.idUsuario = Convert.ToInt32(ClaseCrossUsing.IdUsuario); tabla.descripcion = txbDescripcion.Text; tabla.fechaConsulta = DateTime.Now; tabla.idBoleta = Convert.ToInt32(idBoleta); dataContext.Consulta.InsertOnSubmit(tabla); dataContext.SubmitChanges(); Limpiar(); } }
private void Accion() { switch (TipoAccion) { case 0: Proveedor tabla = new Proveedor(); tabla.codigo = txtCodigoProveedor.Text; tabla.nombre = txtProveedor.Text; tabla.direccion = TxtDireccion.Text; tabla.correo = txtCorreo.Text; tabla.telefono = txtTelefono.Text; tabla.estado = "A"; tabla.fechaIngreso = DateTime.Now; dataContext.Proveedor.InsertOnSubmit(tabla); dataContext.SubmitChanges(); this.Close(); break; case 1: var actualizar = from u in dataContext.Proveedor where u.id == Convert.ToInt32(IdProveedor) select u; foreach (var v in actualizar) { v.codigo = txtCodigoProveedor.Text; v.nombre = txtProveedor.Text; v.direccion = TxtDireccion.Text; v.correo = txtCorreo.Text; v.telefono = txtTelefono.Text; dataContext.SubmitChanges(); } this.Close(); break; } }
private void BtnGuardar_Click(object sender, RoutedEventArgs e) { if (txbCedula.Text != string.Empty && txbNombreMascota.Text != string.Empty && txbTipoMascota.Text != string.Empty) { BoletaAnimal tabla = new BoletaAnimal(); tabla.nombreAnimal = txbNombreMascota.Text; tabla.tipoAnimal = txbTipoMascota.Text; tabla.idCliente = Convert.ToInt32(idCliente); dataContext.BoletaAnimal.InsertOnSubmit(tabla); dataContext.SubmitChanges(); this.Close(); } else { MessageBox.Show("Faltan datos por ingresar"); } }
private void BtnGuardar_Click(object sender, RoutedEventArgs e) { if (txtCedula.Text != string.Empty && txtNombre.Text != string.Empty && txtApellido.Text != string.Empty && txtPassword.Text != string.Empty && txtUsuario.Text != string.Empty) { var use = (from user in dataContext.Usuario where user.nickName == txtUsuario.Text select user); var ced = from emp in dataContext.Usuario_V where emp.Cedula == txtCedula.Text select emp; if (use.Count() == 0) { if (ced.Count() == 0) { Usuario tabla = new Usuario(); tabla.idEmpleado = Convert.ToInt32(IdEmpleado); tabla.nickName = txtUsuario.Text; tabla.pass = txtPassword.Text; tabla.estado = "A"; tabla.fechaIngreso = DateTime.Now; dataContext.Usuario.InsertOnSubmit(tabla); dataContext.SubmitChanges(); this.Close(); } else { MessageBox.Show("Ese empleado ya tiene un usuario", "Usuario y empleado", MessageBoxButton.OK, MessageBoxImage.Exclamation); } } else { MessageBox.Show("Ya hay usuarios con ese NickName", "Usuario", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Faltan datos por ingresar"); } }
private void BtnEliminar_Click(object sender, RoutedEventArgs e) { if (dgProducto.SelectedItem != null) { if ((MessageBox.Show("Desea eliminar este producto", "Eliminar Producto", MessageBoxButton.YesNo, MessageBoxImage.Warning)) == MessageBoxResult.Yes) { object item = dgProducto.SelectedItem; string id = (dgProducto.SelectedCells[4].Column.GetCellContent(item) as TextBlock).Text; var eliminar = from ee in dataContext.Producto where ee.id == Convert.ToInt32(id) select ee; foreach (var v in eliminar) { v.estado = "I"; dataContext.SubmitChanges(); } MostrarProductos(); } } }