private void btnRealizarVenta_Click(object sender, EventArgs e) { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { model.InsertarVenta(null, null); var idVenta = int.Parse(model.Venta.Max(v => v.ID_Venta).ToString()); for (int i = 0; i < dgvNVenta.Rows.Count; i++) { string idPieza = dgvNVenta.Rows[i].Cells["Codigo de producto"].FormattedValue.ToString(); string codProd = model.Pieza. Where(p => p.ID_Pieza.ToString().Equals(idPieza)). Select(p => p.ID_Pieza). FirstOrDefault(); int cantidad = int.Parse(dgvNVenta.Rows[i].Cells["cantidad"].FormattedValue.ToString()); model.AgregarDetalleVenta(idVenta, codProd, cantidad); } model.SaveChanges(); } MessageBox.Show("Se ha realizado la venta con exito", "Informacion"); }
private void frmVerVentas_Load(object sender, EventArgs e) { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { dgvVerVentas.DataSource = model.InformacionDeVentas.ToList(); } }
private void btnEliminar_Click(object sender, EventArgs e) { if (indexRow < 0) { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { string codProd = model.Pieza.Where(p => p.ID_Pieza == txtIdPieza.Text.ToString()).Select(p => p.ID_Pieza).FirstOrDefault().ToString(); if (codProd != txtIdPieza.Text) { MessageBox.Show("El producto no esta registrado", "Alerta"); return; } model.Venta.Remove((Venta)model.Venta. Where(V => V.ID_Venta == int.Parse(txtIdVenta.Text)). FirstOrDefault()); model.SaveChanges(); model.EliminarDetalle_venta(int.Parse(txtIdVenta.Text), txtIdPieza.Text.ToString()); MessageBox.Show("La venta ha sido eliminada", "informacion"); } } else { MessageBox.Show("Seleccione la columna a eliminar", "Alerta"); } }
private void frmNuevaVenta_Load(object sender, EventArgs e) { dt.Columns.Add("Nombre cliente", typeof(string)); dt.Columns.Add("Apellido cliente", typeof(string)); dt.Columns.Add("Codigo de producto", typeof(string)); dt.Columns.Add("Tipo de pieza", typeof(string)); dt.Columns.Add("cantidad", typeof(int)); dt.Columns.Add("precio", typeof(decimal)); dt.Columns.Add("subtotal", typeof(decimal)); dgvNVenta.DataSource = dt; btnRealizarVenta.Enabled = false; btnEditar.Enabled = false; btnEliminar.Enabled = false; using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchValue = model.Pieza.Select(p => p.ID_Pieza); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchValue.ToArray()); this.txtPieza.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtPieza.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtPieza.AutoCompleteCustomSource = auto; } }
private void btnEditar_Click_1(object sender, EventArgs e) { if (txtRuc.Text == "" || txtPNomC.Text == "" || txtPApC.Text == "" || txtEmp.Text == "") { MessageBox.Show("Inserte la informacion pedida", "Atencion"); return; } if (!(txtTelC.Text.StartsWith("2") || txtTelC.Text.StartsWith("5") || txtTelC.Text.StartsWith("7") || txtTelC.Text.StartsWith("8")) || txtTelC.Text.Trim().Length > 8 || !isNumericValue(txtTelC)) { MessageBox.Show("Inserte un numero de telefono adecuado"); return; } using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { model.EditarCliente(txtRuc.Text, txtPNomC.Text, txtSNomC.Text, txtPApC.Text, txtSApC.Text, txtCorreo.Text, txtTelC.Text, txtTipoEmp.Text, txtTipoSer.Text, txtDir.Text, txtEmp.Text); model.SaveChanges(); dgvVerClientes.DataSource = model.ListarCliente().ToList(); } MessageBox.Show("Cliente editado con exito!!"); Clear(); }
private void btnAgregarCliente_Click(object sender, EventArgs e) { if (txtRuc.Text == "" || txtPNomC.Text == "" || txtPApC.Text == "" || txtEmpr.Text == "") { MessageBox.Show("Es necesario llenar las casillas con valores esenciales (Ruc, primer nombre representante, primer apellido representante, empresa)"); return; } if (!(isNumericValue(txtRuc) || isNumericValue(txtPNomC) || isNumericValue(txtSNomC) || isNumericValue(txtPApC) || isNumericValue(txtSApC) || isNumericValue(txtCor))) { MessageBox.Show("No inserte valores solo numericos en los campos que requieren de valores literales", "alerta"); } string sNom, sAp, Corr, Tel, TipoEmp, TipoSer, Dir; sNom = validatingEmptyValues(txtSNomC); sAp = validatingEmptyValues(txtSApC); Corr = validatingEmptyValues(txtCor); Tel = validatingEmptyValues(txtTel); TipoEmp = validatingEmptyValues(txtTipoEmp); TipoSer = validatingEmptyValues(txtTipoSer); Dir = validatingEmptyValues(txtDir); using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { model.InsertarCliente(txtRuc.Text, txtPNomC.Text, txtSNomC.Text, txtPApC.Text, txtSApC.Text, txtCor.Text, txtTel.Text, txtTipoEmp.Text, txtTipoSer.Text, txtDir.Text, txtEmpr.Text); model.SaveChanges(); clear(); } MessageBox.Show("Cliente registrado con exito", "informacion"); }
private void frmEditarDevCompra_Load(object sender, EventArgs e) { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchValue = model.Detalle_compra.Where(p => p.ID_Compra == txtID_Compra.Text).Select(p => p.ID_Pieza); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchValue.ToArray()); this.txtPieza.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtPieza.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtPieza.AutoCompleteCustomSource = auto; } btnEditar.Enabled = false; btnEliminar.Enabled = false; btnLimpiar.Enabled = false; btnDevolucion.Enabled = false; dt.Columns.Add("ID_DevolucionCompra", typeof(int)); dt.Columns.Add("Pieza", typeof(string)); dt.Columns.Add("cantidad", typeof(int)); dt.Columns.Add("precioCompra", typeof(decimal)); dt.Columns.Add("subtotal", typeof(decimal)); dgvDetDevCompra.DataSource = dt; lblDate.Text = DateTime.Now.ToString("dd/M/yy"); txtID_Dev.Enabled = false; txtID_Compra.Enabled = false; CargarDetDevCompra(); CalcularTotal(); }
private void btnModificar_Click(object sender, EventArgs e) { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { model.EditarDetalle_venta(int.Parse(txtCant.Text), txtIdPieza.Text, int.Parse(txtCant.Text)); model.EditarVenta(int.Parse(txtIdVenta.Text), null, DateTime.Parse(dtFechaEntrega.Value.ToShortDateString()), txtEstado.Text); } }
private void frmNuevaReparacion_Load(object sender, EventArgs e) { if (drReparacion != null) { btnEditar.Enabled = true; btnEliminar.Enabled = false; btnReparacion.Enabled = false; txtID_Reparacion.Enabled = false; txtCliente.Enabled = false; radTieneCliente.Enabled = false; dt.Columns.Add("ID_Reparacion", typeof(int)); dt.Columns.Add("Pieza", typeof(string)); dt.Columns.Add("Cantidad", typeof(int)); dt.Columns.Add("Precio", typeof(decimal)); dt.Columns.Add("Subtotal", typeof(float)); dgvDetReparacion.DataSource = dt; lblAccion.Text = "Editar Reparacion"; CargarDetReparaciones(); CalcularTotal(); } else { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchValue = model.Pieza.Select(p => p.ID_Pieza); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchValue.ToArray()); this.txtPieza.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtPieza.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtPieza.AutoCompleteCustomSource = auto; } using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchValue = model.Cliente.Select(p => p.PNombre_rep); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchValue.ToArray()); this.txtPieza.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtPieza.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtPieza.AutoCompleteCustomSource = auto; } btnEditar.Enabled = false; btnEliminar.Enabled = false; btnReparacion.Enabled = false; dt.Columns.Add("ID_Reparacion", typeof(int)); dt.Columns.Add("Pieza", typeof(string)); dt.Columns.Add("Cantidad", typeof(int)); dt.Columns.Add("Precio", typeof(decimal)); dt.Columns.Add("Subtotal", typeof(float)); var ultima_devVenta = bD.Reparacion.Max(v => v.ID_Reparacion).ToString(); txtID_Reparacion.Text = ultima_devVenta + 1; dgvDetReparacion.DataSource = dt; lblFecha.Text = DateTime.Now.ToString("dd/M/yy"); } }
private void frmVerProveedores_Load(object sender, EventArgs e) { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { dgvProveedores.DataSource = model.InformacionProveedores.ToList(); } btnEditar.Enabled = false; btnEliminar.Enabled = false; }
private void btnEncargo_Click(object sender, EventArgs e) { if (txtCan.Text == "" || txtIdCli.Text == "" || txtIdPi.Text == "" || panel.Text == "") { MessageBox.Show("Insertar la informacion requerida", "Alerta"); return; } using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var idPieza = model.Pieza. Where(p => p.ID_Pieza == txtIdPi.Text). Select(p => p.ID_Pieza). FirstOrDefault(); if (idPieza != txtIdPi.Text) { MessageBox.Show("El producto no esta registrado", "Alerta"); return; } int Can = model.Pieza. Where(p => p.ID_Pieza == txtIdPi.Text.ToString()). Select(p => p.cantidad). FirstOrDefault(); if (Can < int.Parse(txtCan.Text)) { MessageBox.Show("No puede vender una cantidad menor de la que esta en inventario", "Alerta"); return; } string idCli = model.Cliente. Where(c => c.RUC == txtCan.Text.ToString()). Select(c => c.RUC). FirstOrDefault(); if (idCli != txtIdCli.Text) { MessageBox.Show("Cliente no registrado", "informacion"); return; } string estado; if (cmbEstado.SelectedIndex == 0) { estado = "Entregado"; } estado = "Solicitado"; model.InsertarVenta(idCli, dtFin.Value); model.AgregarDetalleVenta(model.Venta.Select(v => v.ID_Venta).Last(), idPieza, Can); model.SaveChanges(); MessageBox.Show("Encargo insertado con exito", "informacion"); } }
private void frmPedido_Load(object sender, EventArgs e) { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { dgvPedidos.DataSource = model.InformacionDePedidos.ToList(); cmbEstado.SelectedIndex = 0; btnEditar.Enabled = false; btnEliminar.Enabled = false; } }
private void btnAgregar_Click(object sender, EventArgs e) { if (txtPieza.Text == "" || txtCantidad.Text == "") { MessageBox.Show("Inserte la informacion pedida", "Alerta"); return; } using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { int existenciaProd = model.Pieza.Where(p => p.ID_Pieza == txtPieza.Text).Select(p => p.cantidad).FirstOrDefault(); if (int.Parse(txtCantidad.Text) > existenciaProd) { MessageBox.Show("La cantidad que desea comprar es mayor a la que hay en existencia", "informacion"); return; } } if (isNumericValue(txtCantidad)) { MessageBox.Show("Insertar valores numericos en el campo de cantidad", "Alerta"); return; } string producto; decimal precio; string tipoPieza; using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { producto = model.Pieza. Where(p => p.ID_Pieza == txtPieza.Text). FirstOrDefault().ToString(); precio = decimal.Parse(model.Pieza. Where(p => p.ID_Pieza.ToString() == txtPieza.Text). Select(p => p.precio). FirstOrDefault().ToString()); tipoPieza = model.Pieza. Where(p => p.ID_Pieza == txtPieza.Text). Select(p => p.Tipo_piezas). FirstOrDefault().ToString(); } if (producto != txtPieza.Text) { MessageBox.Show("Pieza no registrada"); return; } decimal subTotalV = int.Parse(txtCantidad.Text) * precio; dt.Rows.Add(txtNombre.Text, txtApellido.Text, producto, tipoPieza, int.Parse(txtCantidad.Text), precio, subTotalV); btnRealizarVenta.Enabled = false; }
private void frmNuevaDevVenta_Load(object sender, EventArgs e) { //cargar datos de compra para que elija using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchValue = model.Compra.Select(p => p.ID_Compra); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchValue.ToArray()); this.txtID_Venta.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtID_Venta.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtID_Venta.AutoCompleteCustomSource = auto; } //una vez elija, que se rellenen con las piezas de esa compra unicamente using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchValue = model.Detalle_venta.Where(p => p.ID_Venta == int.Parse(txtID_Venta.Text)).Select(p => p.ID_Pieza); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchValue.ToArray()); this.txtPieza.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtPieza.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtPieza.AutoCompleteCustomSource = auto; } btnEditar.Enabled = false; btnEliminar.Enabled = false; btnDevolucion.Enabled = false; dt.Columns.Add("ID_DevVenta", typeof(int)); dt.Columns.Add("Pieza", typeof(string)); dt.Columns.Add("cantidad", typeof(int)); dt.Columns.Add("precioVenta", typeof(decimal)); dt.Columns.Add("subtotal", typeof(decimal)); var ultima_devVenta = bD.DevolucionVenta.Max(v => v.ID_DevVenta).ToString(); txtID_Dev.Text = ultima_devVenta + 1; dgvDetVenta.DataSource = dt; btnDevolucion.Enabled = false; lblDate.Text = DateTime.Now.ToString("dd/M/yy"); if (tiene_cliente) { string id_cliente = bD.Venta.Where(p => p.ID_Venta == int.Parse(txtID_Venta.Text)).Select(p => p.ID_Cliente).FirstOrDefault(); var nombre_cliente = bD.Cliente.Where(p => p.RUC == id_cliente).Select(p => p.PNombre_rep).FirstOrDefault(); txtCliente.Text = nombre_cliente; } else { lblCliente.Visible = false; txtCliente.Visible = true; } }
private void frmInForPieza_Load(object sender, EventArgs e) { cmbEstado.SelectedIndex = 0; cmbTipoPieza.SelectedIndex = 0; using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchProv = model.Proveedor.Select(p => p.Empresa); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchProv.ToArray()); this.txtNomProv.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtNomProv.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtNomProv.AutoCompleteCustomSource = auto; } }
private void btnEliminar_Click(object sender, EventArgs e) { if (txtIdVenta.Text == "") { MessageBox.Show("Seleccionar la celda a editar", "informacion"); return; } using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { // model.Venta.Remove((Venta)model.Venta.Where(v => v.ID_Venta == int.Parse(txtIdVenta.Text)).Select(v => v.ID_Venta).SingleOrDefault()); model.SaveChanges(); MessageBox.Show("Se elimino el pedido", "informacion"); } }
private void btnEliminar_Click_1(object sender, EventArgs e) { if (txtRuc.Text == "") { MessageBox.Show("Seleccione la celda del cliente a eliminar", "informacion"); } var codCliente = txtRuc.Text; using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { model.EliminarCliente(codCliente); model.SaveChanges(); } MessageBox.Show("Cliente borrado con exito"); }
private void btnEditar_Click(object sender, EventArgs e) { if (txtCantidad.Text == "" || txtPieza.Text == "") { MessageBox.Show("No deje los campos vacios", "Alerta"); return; } string producto; decimal precio; string tipoPieza; using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { producto = model.Pieza. Where(p => p.ID_Pieza == txtPieza.Text). FirstOrDefault().ToString(); precio = decimal.Parse(model.Pieza. Where(p => p.ID_Pieza.ToString() == txtPieza.Text). Select(p => p.precio). FirstOrDefault().ToString()); tipoPieza = model.Pieza. Where(p => p.ID_Pieza == txtPieza.Text). Select(p => p.Tipo_piezas). FirstOrDefault().ToString(); } if (producto != txtPieza.Text) { MessageBox.Show("Pieza no registrada"); return; } decimal subTotalV = int.Parse(txtCantidad.Text) * precio; DataGridViewRow newRow = new DataGridViewRow(); newRow.Cells[0].Value = txtNombre.Text; newRow.Cells[1].Value = txtApellido.Text; newRow.Cells[2].Value = producto; newRow.Cells[3].Value = tipoPieza; newRow.Cells[4].Value = int.Parse(txtCantidad.Text); newRow.Cells[5].Value = precio; newRow.Cells[6].Value = subTotalV; }
private void btnEliminar_Click(object sender, EventArgs e) { if (txtCodProd.Text == "") { MessageBox.Show("Seleccione la celda del proveedor a eliminar", "informacion"); return; } string codProd = txtCodProd.Text; using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { model.EliminarProveedor(codProd); model.SaveChanges(); MessageBox.Show("El cliente ha sido eliminado", "informacion"); } }
private void frmVerVentas_Load(object sender, EventArgs e) { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { dgvVerClientes.DataSource = model.ListarCliente().ToList(); btnEditar.Enabled = false; btnEliminar.Enabled = false; var searchValue = model.Cliente.Select(c => c.PNombre_rep); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchValue.ToArray()); this.txtSearchClientes.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtSearchClientes.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtSearchClientes.AutoCompleteCustomSource = auto; } btnEditar.Enabled = false; txtRuc.Enabled = false; }
private void btnAgregarProveedor_Click_1(object sender, EventArgs e) { if (txtCodProv.Text == "" || cmbTipoProv.SelectedIndex < 0) { MessageBox.Show("Inserte los valores requeridos"); return; } if (isNumericValue(txtCor) || isNumericValue(txtDir) || isNumericValue(txtEmp)) { MessageBox.Show("Inserte solo valores literales en los campos que los requieren", "Alerta"); return; } if (!isNumericValue(txtTel)) { MessageBox.Show("No se pueden insertar letras en el campo de telefono"); return; } txtCor.Text = validatingEmptyValues(txtCor); txtDir.Text = validatingEmptyValues(txtDir); txtEmp.Text = validatingEmptyValues(txtEmp); txtTel.Text = validatingEmptyValues(txtTel); txtNom.Text = validatingEmptyValues(txtCor); txtAp.Text = validatingEmptyValues(txtAp); int valor; if (cmbTipoProv.SelectedIndex == 0) { valor = 2; } else { valor = 1; } using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { model.InsertarProveedor(txtCodProv.Text, txtNom.Text, txtAp.Text, txtEmp.Text, txtCor.Text, txtTel.Text, txtTel.Text, (byte?)valor); model.SaveChanges(); MessageBox.Show("Proveedor insertado con exito"); } }
private void btnRegistrar_Click(object sender, EventArgs e) { if (txtPass.Text.Equals("") || txtUser.Text.Equals("")) { MessageBox.Show("No pueden haber campos vacios", "Alerta"); Cursor.Current = Cursors.Default; return; } try { bD = new ELECTROMOBILEModel("Server=CHINO-PC;Database=ELECTROMOBILEDB;UID=" + txtUser.Text + ";PWD=" + txtPass.Text); bD.Database.Connection.Open(); } catch (Exception ex) { Console.WriteLine("Error de registro");; } if (bD.Database.Connection.State == ConnectionState.Open) { this.Hide(); frm.ShowDialog(); this.Show(); txtPass.Text = ""; txtUser.Text = ""; } else { Cursor.Current = Cursors.Default; --contador; MessageBox.Show("Usuario o contraseƱa incorrecta, tiene: " + contador + " intentos restantes"); if (contador == 0) { contador = 3; btnRegistrar.Enabled = false; //pictureBox2.Enabled = false; Thread.Sleep(3000); btnRegistrar.Enabled = true; //pictureBox2.Enabled = true; } } }
private void frmNuevaDevCompra_Load(object sender, EventArgs e) { //cargar datos de compra para que elija using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchValue = model.Compra.Select(p => p.ID_Compra); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchValue.ToArray()); this.txtID_Compra.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtID_Compra.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtID_Compra.AutoCompleteCustomSource = auto; } //una vez elija, que se rellenen con las piezas de esa compra unicamente using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchValue = model.Detalle_compra.Where(p => p.ID_Compra == txtID_Compra.Text).Select(p => p.ID_Pieza); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchValue.ToArray()); this.txtPieza.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtPieza.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtPieza.AutoCompleteCustomSource = auto; } btnEditar.Enabled = false; btnEliminar.Enabled = false; btnDevolucion.Enabled = false; dt.Columns.Add("ID_DevolucionCompra", typeof(int)); dt.Columns.Add("Pieza", typeof(string)); dt.Columns.Add("cantidad", typeof(int)); dt.Columns.Add("precioCompra", typeof(decimal)); dt.Columns.Add("subtotal", typeof(decimal)); dgvDetDevCompra.DataSource = dt; lblDate.Text = DateTime.Now.ToString("dd/M/yy"); }
private void frmNuevaCompra_Load(object sender, EventArgs e) { if (drCompras != null) { btnEditar.Enabled = true; btnEliminar.Enabled = false; btnCompra.Enabled = false; btnLimpiar.Enabled = false; txtID_Compra.Enabled = false; txtProveedor.Enabled = false; dt.Columns.Add("ID_Compra", typeof(string)); dt.Columns.Add("ID_Pieza", typeof(string)); dt.Columns.Add("precio", typeof(decimal)); dt.Columns.Add("cantidad", typeof(int)); dt.Columns.Add("Subtotal", typeof(decimal)); dgvDetCompras.DataSource = dt; lblAccion.Text = "Editar Compra"; CargarDetDevCompra(); CalcularTotal(); } else { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var searchProv = model.Proveedor.Select(p => p.Nombre); AutoCompleteStringCollection auto = new AutoCompleteStringCollection(); auto.AddRange(searchProv.ToArray()); this.txtProveedor.AutoCompleteMode = AutoCompleteMode.Suggest; this.txtProveedor.AutoCompleteSource = AutoCompleteSource.CustomSource; this.txtProveedor.AutoCompleteCustomSource = auto; } lblFecha.Text = DateTime.Now.ToString("dd/M/yy"); } }
private void btnGuardarPiezas_Click(object sender, EventArgs e) { using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { var codPro = model.Pieza. Where(p => p.ID_Pieza == txtIdPi.Text). Select(p => p.ID_Pieza). FirstOrDefault(); if (codPro == txtIdPi.Text) { MessageBox.Show("El producto ya esta resgistrado", "Alerta"); return; } var idProv = model.Proveedor. Where(p => p.Empresa == txtNomProv.Text). Select(p => p.ID_Proveedor). FirstOrDefault(); if (idProv == null) { MessageBox.Show("Proveedor no registrado", "Alerta"); return; } int estado; if (cmbEstado.SelectedIndex == 0) { estado = 3; } else if (cmbEstado.SelectedIndex == 1) { estado = 2; } else { estado = 1; } int idTipoPieza; int tension = int.Parse(txtTension.Text); if (txtPrecio.Text == "") { MessageBox.Show("Inserte el precio de venta", "informacion"); return; } decimal precio = decimal.Parse(txtPrecio.Text); string circuito = txtCir.Text; string estante = txtEstante.Text; int dientes = int.Parse(txtDir.Text); int recuentoTerminales = int.Parse(txtTerminales.Text); string volt = txtVolatje.Text; string fab = txtFabricante.Text; for (int i = 0; i < 8; i++) { if (cmbTipoPieza.SelectedIndex == i) { model.InsertarPieza(codPro, idProv, (byte?)estado, (byte?)(i + 1), pbImgPrin.ImageLocation, pbImgCir.ImageLocation, pbImgCor.ImageLocation, estante, (byte?)tension, precio, circuito, (byte?)dientes, (byte?)recuentoTerminales, volt, fab); } break; } MessageBox.Show("Pieza insertada exitosamente"); model.SaveChanges(); this.Close(); } }
private void dgvProveedores_CellClick(object sender, DataGridViewCellEventArgs e) { int indexRow = e.RowIndex; if (indexRow < 0) { return; } if (dgvProveedores.Rows.Count > 0) { /* P.ID_Proveedor, * Nombre, * Apellido, * Empresa, * Correo, * Telefono, * Direccion, * Tipo*/ if ((txtNombre.Text != "" || txtApellido.Text != "") && cmbTipoProv.SelectedIndex == 0) { MessageBox.Show("Los atributos de nombre y apellido solo estan disponibles si el proveedor es de tipo natural", "informacion"); return; } DataGridViewRow row = dgvProveedores.Rows[indexRow]; txtCodProd.Text = row.Cells[0].Value.ToString(); txtNombre.Text = row.Cells[1].Value.ToString(); txtApellido.Text = row.Cells[2].Value.ToString(); txtEmpresa.Text = row.Cells[3].Value.ToString(); txtCor.Text = row.Cells[4].Value.ToString(); txtTel.Text = row.Cells[5].Value.ToString(); txtDir.Text = row.Cells[6].Value.ToString(); if (row.Cells[7].Value.ToString().Equals("Natural")) { cmbTipoProv.SelectedIndex = 1; } cmbTipoProv.SelectedIndex = 0; if (isNumericValue(txtNombre) || isNumericValue(txtApellido) || isNumericValue(txtEmpresa) || isNumericValue(txtCor) || isNumericValue(txtDir)) { MessageBox.Show("Inserte valores literales donde se le piden", "informacion"); return; } if (!isNumericValue(txtTel)) { MessageBox.Show("Inserte un numero de telefono adecuado", "informacion"); return; } txtNombre.Text = validatingEmptyValues(txtNombre); txtApellido.Text = validatingEmptyValues(txtApellido); txtEmpresa.Text = validatingEmptyValues(txtEmpresa); txtCor.Text = validatingEmptyValues(txtCor); txtDir.Text = validatingEmptyValues(txtDir); using (ELECTROMOBILEModel model = new ELECTROMOBILEModel()) { model.EditarProveedor(txtCodProd.Text, txtNombre.Text, txtApellido.Text, txtEmpresa.Text, txtCor.Text, txtTel.Text, txtDir.Text); model.SaveChanges(); MessageBox.Show("El proveedor ha sido editado con exito"); } } }