public override bool Actualizar() { int i; bool rpta = false; try { eVENDEDOR o = new eVENDEDOR(); o.VEN_codigo = Int32.TryParse(this.txtCodigo.Text.Trim(), out i) ? Convert.ToInt32(this.txtCodigo.Text.Trim()) : -1; o.VEN_nombre_completo = this.txtNombreCompleto.Text.Trim(); o.VEN_dni = this.txtDNI.Text.Trim(); o.VEN_telefono = this.txtTelefono.Text.Trim(); o.VEN_estado = this.chkEstado.Checked ? "S" : "N"; o.VEN_comentario = this.txtComentario.Text.Trim(); if (this.picImagen.Image != null) { System.IO.MemoryStream ms = new System.IO.MemoryStream(); this.picImagen.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); o.VEN_imagen = ms.GetBuffer(); } else { o.VEN_imagen = null; } if (balVENDEDOR.actualizarRegistro(o)) { mensaje("actualizar", ""); //MessageBox.Show("El registro fue actualizado correctamente.", "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtCodigo.ReadOnly = true; rpta = true; } } catch (CustomException ex) { if (ex.tupla != null) { foreach (Control c in this.gpbInformacion.Controls) { foreach (var item in ex.tupla) { if (c.Tag != null && c.Tag.ToString() == item.name) { errValidacion.SetError(c, item.message.ToString()); } } } mensaje("subsanar", ""); } else { mensaje("corregir", ex.Message); } } catch (Exception ex) { MessageBox.Show("Ocurrió un error inesperado:\r\n" + ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(rpta); }
public override void Siguiente() { int i; eVENDEDOR o = new eVENDEDOR(); o.VEN_codigo = Int32.TryParse(this.txtCodigo.Text.Trim(), out i) ? Convert.ToInt32(this.txtCodigo.Text.Trim()) : -1; cargarDatos(balVENDEDOR.siguienteRegistro(o)); }
private void btnGoVendedor_Click(object sender, EventArgs e) { eVENDEDOR o = new eVENDEDOR(); o.VEN_codigo = this.cmbVendedor.SelectedValue != null?Convert.ToInt32(this.cmbVendedor.SelectedValue.ToString()) : -1; frmDM_Vendedor o2 = new frmDM_Vendedor(o); o2.MdiParent = this.MdiParent; o2.Show(); }
public bool eliminarRegistro(eVENDEDOR oeVENDEDOR) { using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString())) { string sp = "pa_crud_VENDEDOR_eliminarRegistro"; SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cnn.Open(); cmd.Parameters.Add(new SqlParameter("@VEN_CODIGO", oeVENDEDOR.VEN_codigo)); return(cmd.ExecuteNonQuery() > 0); } }
public override void Buscar() { int i; eVENDEDOR o = new eVENDEDOR(); balVENDEDOR b = new balVENDEDOR(); _frmBusqueda ventana = new _frmBusqueda(false, "buscarRegistro", b); DialogResult respuesta = ventana.ShowDialog(); if (respuesta == DialogResult.OK) { o.VEN_codigo = Int32.TryParse(ventana.pk, out i) ? Convert.ToInt32(ventana.pk) : -1; DataTable dt = balVENDEDOR.obtenerRegistro(o); cargarDatos(dt); } }
public DataTable obtenerRegistro(eVENDEDOR oeVENDEDOR) { using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString())) { string sp = "pa_crud_VENDEDOR_obtenerRegistro"; SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter dad = new SqlDataAdapter(cmd); dad.SelectCommand.Parameters.Add(new SqlParameter("@VEN_CODIGO", oeVENDEDOR.VEN_codigo)); DataTable dt = new DataTable(); dad.Fill(dt); return(dt); } }
public override bool Eliminar() { int i; bool rpta = false; try { eVENDEDOR o = new eVENDEDOR(); o.VEN_codigo = Int32.TryParse(this.txtCodigo.Text.Trim(), out i) ? Convert.ToInt32(this.txtCodigo.Text.Trim()) : -1; if (balVENDEDOR.eliminarRegistro(o)) { mensaje("eliminar", ""); //MessageBox.Show("El registro fue eliminado correctamente.", "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information); this.txtCodigo.ReadOnly = true; rpta = true; } } catch (CustomException ex) { if (ex.tupla != null) { foreach (Control c in this.gpbInformacion.Controls) { foreach (var item in ex.tupla) { if (c.Tag != null && c.Tag.ToString() == item.name) { errValidacion.SetError(c, item.message.ToString()); } } } mensaje("subsanar", ""); } else { mensaje("corregir", ex.Message); } } catch (Exception ex) { MessageBox.Show("Ocurrió un error inesperado:\r\n" + ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(rpta); }
public bool insertarRegistro(eVENDEDOR oeVENDEDOR) { using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString())) { string sp = "pa_crud_VENDEDOR_insertarRegistro"; SqlCommand cmd = new SqlCommand(sp, cnn); cmd.CommandType = CommandType.StoredProcedure; cnn.Open(); cmd.Parameters.Add(new SqlParameter("@VEN_NOMBRE_COMPLETO", oeVENDEDOR.VEN_nombre_completo)); //variable tipo:string cmd.Parameters.Add(new SqlParameter("@VEN_DNI", oeVENDEDOR.VEN_dni)); //variable tipo:string cmd.Parameters.Add(new SqlParameter("@VEN_TELEFONO", (object)oeVENDEDOR.VEN_telefono ?? DBNull.Value)); //variable tipo:string cmd.Parameters.Add(new SqlParameter("@VEN_ESTADO", oeVENDEDOR.VEN_estado)); //variable tipo:string cmd.Parameters.Add(new SqlParameter("@VEN_COMENTARIO", (object)oeVENDEDOR.VEN_comentario ?? DBNull.Value)); //variable tipo:string cmd.Parameters.Add("@VEN_IMAGEN", SqlDbType.Image).Value = (object)oeVENDEDOR.VEN_imagen ?? DBNull.Value; // variable tipo:byte[] return(cmd.ExecuteNonQuery() > 0); } }
public frmDM_Vendedor(eVENDEDOR o) { InitializeComponent(); tabla = "VENDEDOR"; this._o = o; }
private void validarCabecera() { try { dtCab.Columns.Clear(); dtCab.Columns.Add(); dtCab.Clear(); int n = 0; DateTime d; double u; bool resultadoFila = false; bool resultadoRegistroExiste = false; int contadorErrores = 0; for (int i = 0; i < this.dgvCabecera.RowCount; i++) { resultadoFila = true; resultadoFila &= int.TryParse(this.dgvCabecera["PED_numero1", i].Value.ToString(), out n); resultadoFila &= DateTime.TryParse(this.dgvCabecera["PED_fecha", i].Value.ToString(), out d); resultadoFila &= DateTime.TryParse(this.dgvCabecera["PED_fecha_entrega", i].Value.ToString(), out d); resultadoFila &= int.TryParse(this.dgvCabecera["VEN_codigo", i].Value.ToString(), out n); resultadoFila &= this.dgvCabecera["PED_nombre_vendedor", i].Value.ToString().Length > 0; resultadoFila &= int.TryParse(this.dgvCabecera["SOC_codigo", i].Value.ToString(), out n); resultadoFila &= this.dgvCabecera["PED_soc_nombre_razon", i].Value.ToString().Length > 0; resultadoFila &= this.dgvCabecera["PED_soc_direccion", i].Value.ToString().Length > 0; resultadoFila &= int.TryParse(this.dgvCabecera["PED_soc_zona", i].Value.ToString(), out n); resultadoFila &= double.TryParse(this.dgvCabecera["PED_subtotal", i].Value.ToString(), out u); resultadoFila &= double.TryParse(this.dgvCabecera["PED_porcentaje_igv", i].Value.ToString(), out u); //resultadoFila &= double.TryParse(this.dgvCabecera["PED_porcentaje_isc", i].Value.ToString(), out u); resultadoFila &= double.TryParse(this.dgvCabecera["PED_porcentaje_percepcion", i].Value.ToString(), out u); resultadoFila &= double.TryParse(this.dgvCabecera["PED_monto_igv", i].Value.ToString(), out u); resultadoFila &= double.TryParse(this.dgvCabecera["PED_monto_isc", i].Value.ToString(), out u); resultadoFila &= double.TryParse(this.dgvCabecera["PED_monto_percepcion", i].Value.ToString(), out u); resultadoFila &= double.TryParse(this.dgvCabecera["PED_monto_total", i].Value.ToString(), out u); //resultadoFila &= int.TryParse(this.dgvCabecera["PED_comentario", i].Value.ToString(), out n); resultadoFila &= this.dgvCabecera["PED_estado", i].Value.ToString().Length == 1 && (this.dgvCabecera["PED_estado", i].Value.ToString() == "A"); resultadoFila &= this.dgvCabecera["CPA_codigo", i].Value.ToString().Length > 0; resultadoFila &= this.dgvCabecera["PED_tdo_codigo", i].Value.ToString().Length == 3; resultadoRegistroExiste = false; if (resultadoFila) { int PED_numero = Convert.ToInt16(this.dgvCabecera["PED_numero1", i].Value.ToString()); bool bandera = false; for (int t = 0; t < dtDet.Rows.Count; t++) { if (dtDet.Rows[t][0].ToString() == PED_numero.ToString()) { bandera |= true; break; } } resultadoRegistroExiste = true; ePEDIDO oePEDIDO = new ePEDIDO(); //balPEDIDO obalPEDIDO = new balPEDIDO(); eVENDEDOR oeVENDEDOR = new eVENDEDOR(); //balVENDEDOR obalVENDEDOR = new balVENDEDOR(); eSOCIO oeSOCIO = new eSOCIO(); //balSOCIO obalSOCIO = new balSOCIO(); eCONDICION_PAGO oeCONDICIONPAGO = new eCONDICION_PAGO(); //balCONDICION_PAGO obalCONDICIONPAGO = new balCONDICION_PAGO(); oePEDIDO.PED_numero = Convert.ToInt32(this.dgvCabecera["PED_numero1", i].Value.ToString()); oeVENDEDOR.VEN_codigo = Convert.ToInt16(this.dgvCabecera["VEN_codigo", i].Value.ToString()); oeSOCIO.SOC_codigo = Convert.ToInt16(this.dgvCabecera["SOC_codigo", i].Value.ToString()); oeCONDICIONPAGO.CPA_codigo = this.dgvCabecera["CPA_codigo", i].Value.ToString(); resultadoRegistroExiste &= balPEDIDO.obtenerRegistro(oePEDIDO) == null; resultadoRegistroExiste &= balVENDEDOR.obtenerRegistro(oeVENDEDOR) != null; resultadoRegistroExiste &= balSOCIO.obtenerRegistro(oeSOCIO) != null; resultadoRegistroExiste &= balCONDICION_PAGO.obtenerRegistro(oeCONDICIONPAGO) != null; resultadoRegistroExiste &= bandera; } if (resultadoRegistroExiste) { this.dgvCabecera["Check1", i].Style.BackColor = Color.LightGreen; this.dgvCabecera["Check1", i].Value = "OK"; //Carga los PED_numero al datatable dtCab DataRow dr = dtCab.NewRow(); dr[0] = this.dgvCabecera["PED_numero1", i].Value.ToString(); dtCab.Rows.Add(dr[0]); } else { this.dgvCabecera["Check1", i].Style.BackColor = Color.Orange; this.dgvCabecera["Check1", i].Value = "Err"; } if (this.dgvCabecera["Check1", i].Value.ToString() == "Err") { contadorErrores++; } } this.txtCabeceraErrores.Text = contadorErrores.ToString(); } catch (SystemException ex) { } finally { this.Cursor = Cursors.Arrow; mostrarImagenEstado(); } }