private void btnAceptar_Click(object sender, EventArgs e) { int respuesta = 0; Producto nProducto = new Producto(); nProducto.Codigo = int.Parse(txtCodProducto.Text); nProducto.Descripcion = txtDescripcion.Text; nProducto.TipoProducto = (TipoProducto)cboTipo.SelectedItem; nProducto.Marca = (Marca)cboMarca.SelectedItem; nProducto.Precio = decimal.Parse(txtPrecio.Text); nProducto.Cantidad = int.Parse(txtCantidad.Text); nProducto.Talle = txtTalle.Text; nProducto.Estado = cboEstado.SelectedIndex; if (Accion.Equals("A")) { respuesta = nProducto.Agregar(); } else if (Accion.Equals("M")) { respuesta = nProducto.Modificar(); } if (respuesta.Equals(1)) { MessageBox.Show("Producto agregado correctamente"); Limpiar(); } else { MessageBox.Show("Error al Ingresar el Producto"); } }
/// <summary> /// Actualiza los controles con los valores del registro. /// </summary> public void ColocarValoresEnControles() { //Combo box Proveedores var proveedores = db.Suppliers.Select(p => new { p.SupplierID, p.CompanyName }); cboProveedor.DataSource = proveedores.ToList(); cboProveedor.DisplayMember = "CompanyName"; cboProveedor.ValueMember = "SupplierID"; //Combo box Categorías var categorias = db.Categories.Select(c => new { c.CategoryID, c.CategoryName }); cboCategoría.DataSource = categorias.ToList(); cboCategoría.DisplayMember = "CategoryName"; cboCategoría.ValueMember = "CategoryID"; //Elegir valor actual en controles. if (Accion.Equals(AccionPopup.Nuevo)) { this.Text = "Agregar Producto"; } else { this.Text = "Modificar Producto"; txtID.Enabled = false; producto = db.Products.First(p => p.ProductID.Equals(Id)); txtID.Text = producto.ProductID.ToString(); txtNombre.Text = producto.ProductName; cboProveedor.SelectedValue = producto.SupplierID; cboCategoría.SelectedValue = (int)producto.CategoryID; } }
private void btnAceptar_Click(object sender, EventArgs e) { int resEmpleado = 0; int resUsuario = 0; Empleado nEmpleado = new Empleado(); Usuario nUsers = new Usuario(); TipoUsuario nTipoUser = new TipoUsuario(); nEmpleado.IdEmpleado = (Accion.Equals("A") ? nEmpleado.ObtenerId() : Empl.IdEmpleado); nEmpleado.Legajo = txtLegajo.Text; nEmpleado.Nombre = txtNombre.Text; nEmpleado.Apellido = txtApellido.Text; nEmpleado.DNI = int.Parse(txtDNI.Text); nEmpleado.FechaNacimiento = dtpFechaNac.Value; nEmpleado.Direccion = txtDireccion.Text; nEmpleado.Telefono = int.Parse(txtTelefono.Text); nEmpleado.Estado = cboEstado.SelectedIndex; nEmpleado.Sueldo = decimal.Parse(txtSueldo.Text); nUsers.IdUsuario = (Accion.Equals("A") ? nUsers.ObtenerId() : Empl.Usuario.IdUsuario); nUsers.User = txtUsuario.Text; nUsers.Password = (Accion.Equals("A") ? txtPass.Text: Empl.Usuario.Password); nTipoUser.IdTipoUsuario = cboTipoUsuario.SelectedIndex; nUsers.TipoUsuario = nTipoUser; nEmpleado.Usuario = nUsers; try { if (Accion.Equals("A")) { resUsuario = nEmpleado.Usuario.Agregar(); resEmpleado = nEmpleado.Agregar(); } else if (Accion.Equals("M")) { resUsuario = nEmpleado.Usuario.Modificar(); resEmpleado = nEmpleado.Modificar(); } else if (Accion.Equals("P")) { Salir(); } if (resEmpleado.Equals(1) && resUsuario.Equals(1)) { MessageBox.Show("Accion finalizado correctamente"); Limpiar(); } else { MessageBox.Show("Error al realizar la accion"); } } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } }
void Interfaz() { cmbRegion.SelectedIndex = -1; txtID.Focus(); if (Accion.Equals("Nuevo")) { this.Text = "Ingrese Territorio"; } else { this.Text = "Actualizar Territorio"; using (var db = new NorthwindDataContext()) { db.Territories.Where(x => x.TerritoryID.Equals(IdTerritory)) .ToList().ForEach(x => { txtID.Text = x.TerritoryID; txtNombre.Text = x.TerritoryDescription; cmbRegion.SelectedValue = x.RegionID; }); } txtID.ReadOnly = true; } }
public TransDetailViewModel(ref Trans transaccion, Detalle_Transaccion _detalle = null) { transaccion = this.Trans; detalle = _detalle; if (Accion.Equals(Acciones.Modificar)) { MostrarDetalle(); } }
private void btnGuardar_Click(object sender, EventArgs e) { if (Accion.Equals(Constantes.accionInsertar)) { NuevaPelicula(); } else { EditarPelicula(); } }
private void inicializarformulario(VistaPelicula_Admin vistaPelicula_Admin, string titulo) { VistaPelicula_Admin = vistaPelicula_Admin; Text = titulo; InitializeComponent(); DisenoTabla(); this.CenterToParent(); if (Accion.Equals(Constantes.accionEditar)) { cargarDatos(); } }
public void ComprobarEstadoBatalla() { if (!accionActual.Equals(Accion.VACIO) && !SceneManager.GetActiveScene().name.Equals("Hoguera") && !SceneManager.GetActiveScene().name.Equals("Tesoro")) { if (enemigosCombate.Count == 0) { if (!accionActual.Equals(Accion.VACIO)) { accionActual = Accion.VICTORIA; sistemaMenus.DesactivarMenu(); } } if (heroesCombate[0].CompareTag("Muerto") && heroesCombate[1].CompareTag("Muerto") && heroesCombate[2].CompareTag("Muerto") && heroesCombate[3].CompareTag("Muerto")) { accionActual = Accion.DERROTA; } if (GameObject.FindGameObjectsWithTag("Enemigo").Length != cantEnemigosCombate) { enemigosCombate.RemoveRange(0, enemigosCombate.Count); enemigosCombate.AddRange(GameObject.FindGameObjectsWithTag("Enemigo")); } if ((turnosPersonajes[0] == null) || (turnosPersonajes[0].CompareTag("Enemigo") && turnosPersonajes[0].GetComponent <EnemigoStateMachine>().estadoTurno.Equals(EnemigoStateMachine.EstadoTurno.MUERTO))) { turnosPersonajes.RemoveAt(0); } for (int i = 0; i < enemigosCombate.Count; i++) { if (enemigosCombate[i].GetComponent <EnemigoStateMachine>().estadoTurno.Equals(EnemigoStateMachine.EstadoTurno.MUERTO)) { enemigosCombate.RemoveAt(i); } } } }
public RegistroViewModel(int IDRg) { this._id = IDRg; TipoItems = GetTiposUsuarios(); TipoReg = GetTipoRegistros(); if (Accion.Equals(Acciones.Modificar)) { MostrarRegistro(); MostrarControlesOpcionales(true); } else { MostrarControlesOpcionales(false); } }
/// <summary> /// Realiza la operación de inserción o actualización segun la acción del formulario. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAceptar_Click(object sender, EventArgs e) { //Limpiar errores pasados. errorProvider.InitializeError(); //Condicional de Id vacío. errorProvider.HasError(String.IsNullOrWhiteSpace(txtID.Text), txtID, "Rellenar campo de Id"); //Condicional de Producto vacío. errorProvider.HasError(String.IsNullOrWhiteSpace(txtNombre.Text), txtNombre, "Rellenar campo de Nombre del producto"); if (errorProvider.GetError(this)) { return; } //Condicional de Id númerico. errorProvider.HasError(!int.TryParse(txtID.Text, out var id), txtID, "Ingrese código númerico de maximo 10 dígitos."); if (Accion.Equals(AccionPopup.Nuevo)) { if (errorProvider.GetError(this)) { return; } //Condicional de Id repetido. var existeID = db.Products.Any(p => p.ProductID.Equals(txtID.Text)); errorProvider.HasError(existeID, txtID, "El Id ya está registrado."); //Condicional de Producto repetido. var existeProducto = db.Products.Any(p => p.ProductName.Equals(txtNombre.Text)); errorProvider.HasError(existeProducto, txtNombre, "El producto ya está registrado."); if (errorProvider.GetError(this)) { return; } //Agregar Recurso. AgregarRecurso(); } else { //Condicional de Producto repetido. var existeProducto = db.Products.Any(p => p.ProductName == txtNombre.Text && p.ProductID != id); errorProvider.HasError(existeProducto, txtNombre, "El producto ya está registrado."); if (errorProvider.GetError(this)) { return; } //Editar el recurso. EditarRecurso(); } }
private void btnAceptar_Click(object sender, EventArgs e) { if (txtID.Text.Equals("")) { errValidator.SetError(txtID, "Campo Obligatorio"); this.DialogResult = DialogResult.None; return; } else { errValidator.SetError(txtID, null); } if (txtNombre.Text.Equals("")) { errValidator.SetError(txtNombre, "Campo Obligatorio"); this.DialogResult = DialogResult.None; return; } else { errValidator.SetError(txtNombre, null); } if (cmbRegion.Text.Equals("")) { errValidator.SetError(cmbRegion, "Campo Obligatorio"); this.DialogResult = DialogResult.None; return; } else { errValidator.SetError(cmbRegion, null); } if (Accion.Equals("Nuevo")) { Agregar(); } else { Actualizar(); } }
private void btnRegresar_Click(object sender, EventArgs e) { if (Accion.Equals(1)) { this.Hide(); /*encabezado factura*/ Factura fac = new Factura(); fac.Id = this.id; fac.Nombre = this.nombre; fac.Rol = this.rol; /*encabezado*/ fac.IdCliente = this.idCliente; fac.NombreCliente = this.nombreCliente; fac.Documento = this.documento; fac.Direccion1 = this.Direccion; fac.Telefono1 = this.Telefono; fac.Tipo = this.tipo; fac.NumeroFact = this.numeroFact; fac.Codigo1 = this.Codigo; /*detalle*/ fac.Idproducto = this.idproductoVenta; fac.NombreProducto = this.nombreProducto; fac.Cantidad = this.cantidadVendidad; fac.Descuento = this.descuento; fac.PrecioVenta = this.precioVenta; fac.Totalproducto = this.totalproducto; fac.SubTotal = this.subTotal; fac.Show(); } else { if (this.accion.Equals(4)) { this.Hide(); ActuFactu actu = new ActuFactu(); actu.Id = this.id; actu.Nombre = this.nombre; actu.Rol = this.rol; actu.IdFact = this.idfact; actu.Accion = this.accion; actu.Show(); } else { if (this.accion.Equals(5)) { this.Hide(); ActuFactu actu = new ActuFactu(); actu.Id = this.id; actu.Nombre = this.nombre; actu.Rol = this.rol; actu.IdFact = this.idfact; actu.Accion = this.accion; actu.Show(); } else { this.Hide(); /*encabezado factura*/ Factura fac = new Factura(); fac.Id = this.id; fac.Nombre = this.nombre; fac.Rol = this.rol; /*encabezado*/ fac.IdCliente = this.idCliente; fac.NombreCliente = this.nombreCliente; fac.Documento = this.documento; fac.Direccion1 = this.Direccion; fac.Telefono1 = this.Telefono; fac.Tipo = this.tipo; fac.NumeroFact = this.numeroFact; fac.Codigo1 = this.Codigo; /*detalle*/ fac.Idproducto = this.idproductoVenta; fac.NombreProducto = this.nombreProducto; fac.Cantidad = this.cantidadVendidad; fac.Descuento = this.descuento; fac.PrecioVenta = this.precioVenta; fac.Totalproducto = this.totalproducto; fac.SubTotal = this.subTotal; fac.Show(); } } } }
private void btnAgregar_Click(object sender, EventArgs e) { if (Accion.Equals(1)) { this.Hide(); /*encabezado factura*/ Factura fac = new Factura(); fac.Id = this.id; fac.Nombre = this.nombre; fac.Rol = this.rol; /*encabezado*/ fac.IdCliente = Convert.ToInt32(txtCodigo.Text); fac.NombreCliente = txtNombre.Text; fac.Documento = txtCantidad.Text; fac.Direccion1 = txtPrecio.Text; fac.Telefono1 = txtDecuento.Text; fac.Tipo = txtTipo.Text; fac.NumeroFact = this.numeroFact; /*detalle*/ fac.Idproducto = this.idproductoVenta; fac.NombreProducto = this.nombreProducto; fac.Cantidad = this.cantidadVendidad; fac.Descuento = this.descuento; fac.PrecioVenta = this.precioVenta; fac.Totalproducto = this.totalproducto; fac.SubTotal = this.subTotal; fac.Codigo1 = this.Codigo; fac.Show(); } else { if (this.accion.Equals(4)) {/*cambio de cliente */ if (txtCodigo.Text.Equals("")) { MessageBox.Show("Seleccione el cliente nuevo"); } else { try { DialogResult dialogo = MessageBox.Show("Decea Cambiar de Cliente", "Cambio", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogo == DialogResult.Yes) { modelo.CambioCliente cc = new modelo.CambioCliente(); cc.Idfactura = this.idfact; cc.CodCliente1 = Convert.ToInt32(txtCodigo.Text); cc.facCamClien(); if (cc.Msg.Equals("Se cambio el cliente")) { MessageBox.Show(cc.Msg); } else { MessageBox.Show(cc.Msg); } } else { return; } } catch (Exception ex) { Console.WriteLine(ex); } this.Hide(); ActuFactu ff = new ActuFactu(); ff.IdFact = this.idfact; ff.Accion = this.accion; ff.Show(); } } else { if (txtDecuento.Text.Equals("") || txtCantidad.Text.Equals("")) { MessageBox.Show("Dijite la cantidad y el Descuento"); } else { int p = Convert.ToInt32(txtCantidad.Text); if (p > cantidad) { MessageBox.Show("La cantidad ingresada es mayor a la que ay en el Inventario"); } else { if (this.accion.Equals(5)) { try { DialogResult dialogo = MessageBox.Show("Decea Agregar el Producto", "Agregar", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogo == DialogResult.Yes) { /*para actualizar la factura */ modelo.CambioCliente ccc = new modelo.CambioCliente(); ccc.Idfactura = this.idfact; ccc.Idproducto = Convert.ToInt32(txtCodigo.Text); ccc.PrecioVenta = Convert.ToDouble(txtPrecio.Text); ccc.Cantidad = Convert.ToInt32(txtCantidad.Text); ccc.Descuento = Convert.ToDouble(txtDecuento.Text); Double s, d, dd; d = Convert.ToDouble(txtDecuento.Text) / 100; s = Convert.ToInt32(txtCantidad.Text) * Convert.ToDouble(txtPrecio.Text); dd = s * d; s = s - dd; ccc.Totalproducto = s; this.sub = this.sub + s; this.iva = this.sub * 0.13; this.total = this.sub + this.iva; ccc.Sub1 = this.sub; ccc.Iva = this.iva; ccc.Total = this.total; ccc.cambioTotal(); if (ccc.Msg.Equals("Producto agregado ")) { MessageBox.Show(ccc.Msg); } else { MessageBox.Show(ccc.Msg); } } else { return; } } catch (Exception ex) { Console.WriteLine(ex); } this.Hide(); ActuFactu ff = new ActuFactu(); ff.IdFact = this.idfact; ff.Accion = this.accion; ff.Show(); } else { int con = idproductoVenta.Count; if (con.Equals(0)) { idproductoVenta.Add(Convert.ToInt32(txtCodigo.Text)); nombreProducto.Add(txtNombre.Text); CantidadVendidad.Add(Convert.ToInt32(txtCantidad.Text)); Double desc = Convert.ToDouble(txtDecuento.Text) / 100; descuento.Add(Convert.ToDouble(txtDecuento.Text)); PrecioVenta.Add(Convert.ToDouble(txtPrecio.Text)); Double tott = Convert.ToDouble(txtPrecio.Text) * Convert.ToInt32(txtCantidad.Text); Double dessprod = tott * desc; tott = tott - dessprod; this.subTotal = subTotal + tott; totalproducto.Add(tott); Codigo.Add(cod); this.Hide(); Factura factu = new Factura(); factu.Id = this.id; factu.Nombre = this.nombre; factu.Rol = this.rol; factu.Idproducto = this.idproductoVenta; factu.NombreProducto = this.nombreProducto; factu.Cantidad = this.cantidadVendidad; factu.Descuento = this.descuento; factu.PrecioVenta = this.precioVenta; factu.Totalproducto = this.totalproducto; factu.SubTotal = this.subTotal; factu.Codigo1 = this.Codigo; /*par el cliente*/ factu.IdCliente = this.idCliente; factu.NombreCliente = this.nombreCliente; factu.Documento = this.documento; factu.Direccion1 = this.Direccion; factu.Telefono1 = this.Telefono; factu.Tipo = this.tipo; /*la factura*/ factu.NumeroFact = this.numeroFact; factu.Show(); } else { Codigo.Add(cod); idproductoVenta.Add(Convert.ToInt32(txtCodigo.Text)); nombreProducto.Add(txtNombre.Text); CantidadVendidad.Add(Convert.ToInt32(txtCantidad.Text)); Double desc = Convert.ToDouble(txtDecuento.Text) / 100; descuento.Add(Convert.ToDouble(txtDecuento.Text)); PrecioVenta.Add(Convert.ToDouble(txtPrecio.Text)); Double tott = Convert.ToDouble(txtPrecio.Text) * Convert.ToInt32(txtCantidad.Text); this.subTotal = subTotal + tott; Totalproducto.Add(tott); this.Hide(); Factura factu = new Factura(); factu.Id = this.id; factu.Nombre = this.nombre; factu.Rol = this.rol; factu.Idproducto = this.idproductoVenta; factu.NombreProducto = this.nombreProducto; factu.Cantidad = this.cantidadVendidad; factu.Descuento = this.descuento; factu.PrecioVenta = this.precioVenta; factu.Totalproducto = this.totalproducto; factu.SubTotal = this.subTotal; factu.Codigo1 = this.Codigo; /*par el cliente*/ factu.IdCliente = this.idCliente; factu.NombreCliente = this.nombreCliente; factu.Documento = this.documento; factu.Direccion1 = this.Direccion; factu.Telefono1 = this.Telefono; factu.Tipo = this.tipo; factu.NumeroFact = this.numeroFact; factu.Show(); } } } } } } }