public int ActualizarEquipo(CEEquipo equipo) { Config.openConnection(connection); SqlCommand command = new SqlCommand("INV.EQUIPOS", connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@OPERACION", "UE"); command.Parameters.AddWithValue("@EQ_CODIGO", equipo.equipoCodigo); command.Parameters.AddWithValue("@EQ_DESCRIPCION", equipo.equipoDescripcion); command.Parameters.AddWithValue("@EQ_MODELO", equipo.modelo.id); command.Parameters.AddWithValue("@EQ_SERIAL", equipo.equipoSerial); command.Parameters.AddWithValue("@PROV_NIT", equipo.proveedorDocumento); command.Parameters.AddWithValue("@EQ_FECHAINGRESO", equipo.fechaIngreso); command.Parameters.AddWithValue("@EQ_OBSERVACION", equipo.observacion); command.Parameters.AddWithValue("@EQ_ESTADO", equipo.equipoEstado); command.Parameters.AddWithValue("@EQ_PROYECTO", equipo.proyecto.id); command.Parameters.AddWithValue("@EQ_SEDE", equipo.sede.id); command.Parameters.AddWithValue("@EQ_UBICACION", equipo.ubicacion.id); command.Parameters.AddWithValue("@EQ_PUESTO", equipo.numeroPuesto); int Resultado = command.ExecuteNonQuery(); Config.closeConnection(connection); return(Resultado); }
public void AgregarEquipoPrestar(CEEquipo equipo) { try { if (equipos == null) { equipos = new List <CEEquipo>(); source.DataSource = equipos; } foreach (CEEquipo equi in equipos) { if (equi.equipoCodigo == equipo.equipoCodigo) { Exception exception = new Exception("No puede prestar el mismo equipo a la persona"); throw exception; } } equipos.Add(equipo); tblPrestar.AutoGenerateColumns = false; tblPrestar.DataSource = source; source.ResetBindings(false); } catch (Exception ex) { MessageBox.Show("" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnSave_Click(object sender, EventArgs e) { try { CEEquipo equipoAgregar = new CEEquipo { equipoCodigo = txtCodigo.Text.ToString().Trim().ToUpper(), equipoDescripcion = txtDescripcion.Text.ToString().Trim().ToUpper(), proveedorDocumento = cmbProveedor.SelectedValue.ToString(), modelo = new CEModelo { id = Convert.ToInt32(cmbModelo.SelectedValue) }, observacion = txtObservacion.Text.ToString().ToUpper(), equipoSerial = txtSerial.Text.ToUpper(), equipoEstado = chkInactivo.Checked ? "I" : "D", proyecto = new CEProyecto { id = Convert.ToInt32(cmbProyecto.SelectedValue) }, sede = new CESede { id = Convert.ToInt32(cmbSede.SelectedValue) }, ubicacion = new CEUbicacion { id = Convert.ToInt32(cmbUbicacion.SelectedValue) }, numeroPuesto = txtPuesto.Text, documento = "9999999999", fechaIngreso = DateSelect.Text.ToString(), fechaSalida = "", }; if (equipo == null) { if (equipos.AgregarEquipo(equipoAgregar) > 0) { Close(); } } else { if (equipos.ActualizarEquipo(equipoAgregar) > 0) { Close(); } } } catch (Exception ex) { MessageBox.Show("Se presento el siguiente error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Agregar(CEEquipo equipo) { InitializeComponent(); equipos = new CNEquipos(); personas = new CNPersonas(); this.equipo = equipo; }
private void tblEquiposFilter_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex >= 0) { CEEquipo equipo = new CEEquipo { equipoCodigo = tblEquiposFilter.Rows[e.RowIndex].Cells["CODIGO"].Value.ToString(), equipoDescripcion = tblEquiposFilter.Rows[e.RowIndex].Cells["DESCRIPCION"].Value.ToString(), proveedorDocumento = tblEquiposFilter.Rows[e.RowIndex].Cells["PROVEEDOR_NIT"].Value.ToString(), proveedorNombreCorto = tblEquiposFilter.Rows[e.RowIndex].Cells["PROVEEDOR"].Value.ToString(), marca = new CEMarca { id = Convert.ToInt32(tblEquiposFilter.Rows[e.RowIndex].Cells["MARCA_ID"].Value), descripcion = tblEquiposFilter.Rows[e.RowIndex].Cells["MARCA_DESC"].Value.ToString() }, modelo = new CEModelo { id = Convert.ToInt32(tblEquiposFilter.Rows[e.RowIndex].Cells["MODELO_ID"].Value), descripcion = tblEquiposFilter.Rows[e.RowIndex].Cells["MODELO_DESC"].Value.ToString() }, equipoSerial = tblEquiposFilter.Rows[e.RowIndex].Cells["SERIAL"].Value.ToString(), fechaIngreso = tblEquiposFilter.Rows[e.RowIndex].Cells["INGRESO"].Value.ToString(), fechaSalida = tblEquiposFilter.Rows[e.RowIndex].Cells["SALIDA"].Value.ToString(), equipoEstado = tblEquiposFilter.Rows[e.RowIndex].Cells["ESTADO"].Value.ToString(), proyecto = new CEProyecto { id = Convert.ToInt32(tblEquiposFilter.Rows[e.RowIndex].Cells["PROYECTO_ID"].Value) }, sede = new CESede { id = Convert.ToInt32(tblEquiposFilter.Rows[e.RowIndex].Cells["SEDE_ID"].Value) }, ubicacion = new CEUbicacion { id = Convert.ToInt32(tblEquiposFilter.Rows[e.RowIndex].Cells["UBICACION_ID"].Value) }, numeroPuesto = tblEquiposFilter.Rows[e.RowIndex].Cells["PUESTO"].Value.ToString(), observacion = tblEquiposFilter.Rows[e.RowIndex].Cells["OBSERVACION"].Value.ToString(), fechaModifi = tblEquiposFilter.Rows[e.RowIndex].Cells["FECHAMODIFI"].Value.ToString(), usuarioModifi = tblEquiposFilter.Rows[e.RowIndex].Cells["USUMODIFI"].Value.ToString(), }; if (EquipoMovimiento == null) { Agregar AE = new Agregar(equipo); AE.TopLevel = false; AE.Dock = DockStyle.None; Controls.Add(AE); AE.Location = new Point(50, 50); AE.BringToFront(); AE.FormClosed += new FormClosedEventHandler(AE_FormClosed); AE.Show(); } else { switch (EquipoMovimiento) { case "ASIGNAR": IEquipoAsignar parent = this.Owner as IEquipoAsignar; parent.AgregarEquipoAsignar(equipo); break; case "RECOGER": IAgregarEqRec parent2 = this.Owner as IAgregarEqRec; parent2.AgregarEquipoRecogida(equipo); break; case "PRESTAR": IEquipoPrestar parent3 = this.Owner as IEquipoPrestar; parent3.AgregarEquipoPrestar(equipo); break; } Close(); } } } catch (Exception ex) { MessageBox.Show("Se presento el siguiente error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int ActualizarEquipo(CEEquipo equipo) { return(equipos.ActualizarEquipo(equipo)); }
public int AgregarEquipo(CEEquipo equipo) { return(equipos.AgregarEquipo(equipo)); }