private void btn_guardar_Click(Object sender, EventArgs e) //Handles btn_guardar.Click { //validar información ingresada if (Tfecha_compra.Value.ToString() == string.Empty) { P.Mensaje.Advert("Debe indicar la fecha de ingreso por Obra en Construcción"); Tfecha_compra.Focus(); return; } if (Tfecha_conta.Value.ToString() == string.Empty) { P.Mensaje.Advert("Debe indicar la fecha de contabilizacion de Obra en Construcción"); Tfecha_conta.Focus(); return; } if (cboZona.SelectedIndex == -1) { P.Mensaje.Advert("Debe indicar la zona de la Obra en Construcción"); cboZona.Focus(); return; } if (Tcredito.Text == string.Empty) { P.Mensaje.Advert("Debe indicar el monto de Obra en Construcción"); Tcredito.Focus(); return; } if (Tdoc.Text == string.Empty) { DialogResult eleccion; eleccion = P.Mensaje.Confirmar("Desea continuar sin indicar el Nº de documento de Obra en Construcción"); if (eleccion != DialogResult.Yes) //no marco SI { Tdoc.Focus(); return; } } if (Tdescrip.Text == string.Empty) { P.Mensaje.Advert("Debe indicar la descripción o referencia de la Obra en Construcción"); Tdescrip.Focus(); return; } //fin validación //inicio preparar datos para ingresar string documento, proveedor, descp; decimal credit_amo; DateTime fechaC, fechaGL; PD.GENERIC_VALUE zona; fechaC = Tfecha_compra.Value; fechaGL = Tfecha_conta.Value; zona = (PD.GENERIC_VALUE)cboZona.SelectedItem; descp = Tdescrip.Text; if (!decimal.TryParse(Tcredito.Text, out credit_amo)) { P.Mensaje.Advert("Monto ingresado no es valido"); Tcredito.Focus(); return; } if (Tdoc.Text == string.Empty) { documento = P.Consultas.documentos.defaultDocument; } else { documento = Tdoc.Text; } if (cboProveedor.SelectedIndex == -1) { proveedor = P.Consultas.documentos.defaultProveed; } else { proveedor = ((PD.SV_PROVEEDOR)cboProveedor.SelectedItem).COD; } //Valido que no se haya ingresado duplicado comprobando el documento, proveedor y zona int contar; contar = P.Consultas.documentos.buscar_entrada_obc(documento, proveedor, zona.id); if (contar > 0) { P.Mensaje.Error("La entrada indicada ya existe en el sistema"); return; } //ingreso en obra_cons PD.RespuestaAccion mRS; mRS = P.Consultas.obc.INGRESO_OBC(fechaC, zona.id, proveedor, documento, descp, credit_amo, fechaGL); if (mRS.codigo < 0) { P.Mensaje.Error(mRS.descripcion); } else { //fin ingreso en obra_cons P.Mensaje.Info("Registro de Obra en Construccion ingresado correctamente"); btn_guardar.BackColor = Color.OrangeRed; } }
private bool validar_campos() { //validar información ingresada if (Tdescrip.Text.Trim() == string.Empty) { P.Mensaje.Advert("Debe indicar la descripción del Activo Fijo"); //, MessageBoxButtons.OK Tdescrip.Focus(); return(false); } if (cboZona.SelectedIndex == -1) { P.Mensaje.Advert("Debe indicar la zona del Activo Fijo"); cboZona.Focus(); return(false); } if (cboSubzona.SelectedIndex == -1) { P.Mensaje.Advert("Debe indicar una subzona para el Activo Fijo"); cboSubzona.Focus(); return(false); } if (cboClase.SelectedIndex == -1) { P.Mensaje.Advert("Debe indicar la clase del Activo Fijo"); cboClase.Focus(); return(false); } if (cboSubclase.SelectedIndex == -1) { P.Mensaje.Advert("Debe indicar una subclase para el Activo Fijo"); cboSubclase.Focus(); return(false); } if (cboCateg.SelectedIndex == -1) { P.Mensaje.Advert("Debe indicar el proveedor del Activo Fijo"); cboCateg.Focus(); return(false); } if (cboGestion.SelectedIndex == -1) { P.Mensaje.Advert("Debe indicar la gestion del Activo Fijo"); cboGestion.Focus(); return(false); } if (Tcantidad.Text == string.Empty) { P.Mensaje.Advert("Debe indicar la cantidad de artículos"); Tcantidad.Focus(); return(false); } if (Tprecio_compra.Text == string.Empty) { P.Mensaje.Advert("Debe indicar el precio de adquisición del Activo Fijo"); Tprecio_compra.Focus(); return(false); } if (TvuF.Text == string.Empty) { P.Mensaje.Advert("Debe indicar la vida útil del artículo"); TvuF.Focus(); return(false); } if (Tdoc.Text == string.Empty) { DialogResult eleccion = P.Mensaje.Confirmar("Desea continuar sin indicar el Nº de documento del Activo Fijo"); if (eleccion != DialogResult.Yes) { //no marco SI Tdoc.Focus(); return(false); } } if (cbFecha_ing.SelectedIndex == -1) { P.Mensaje.Advert("Debe indicar el periodo contable del Activo Fijo"); cbFecha_ing.Focus(); return(false); } //fin validación return(true); }