private void btnAceptar_Click(object sender, EventArgs e) { ContablePr proveedor = new ContablePr(); int numero = 0; int.TryParse(this.txtNumeroSN.Text, out numero); this.spvValidador.Validate(); if (this.spvValidador.LastFailedValidationResults.Count == 0) { this.Cursor = Cursors.WaitCursor; this.lblBuscando.Visible = true; objeto = proveedor.RegistroPorId((short)this.cboPeriodo.SelectedValue, (tipocontable)this.cboTipo.SelectedValue, int.Parse(this.txtNumeroSN.Text)); if (objeto == null) { this.lblMensaje.Visible = true; this.txtNumeroSN.Focus(); } else { this.DialogResult = System.Windows.Forms.DialogResult.Yes; this.Close(); } this.lblBuscando.Visible = false; this.Cursor = Cursors.Default; } }
public object ConstruirObjeto(object unObjetoLocal, bool limpiar = false) { contable registro = null; if (unObjetoLocal != null) { registro = (contable)unObjetoLocal; if (!limpiar) { registro.fktiposcontable = (tipocontable)((ComboBox)this.controles["_cboTipo"]).SelectedValue; registro.fecha = ((DateTimeInput)this.controles["_dtpFecha"]).Value; registro.observacion = this.controles["_txtDetalle"].Text; } else { registro = new contable() { fecha = General.usuarioActivo.fechasesion, eseditable = true }; } } else { registro = new contable() { fecha = General.usuarioActivo.fechasesion, eseditable = true }; } return(registro); }
public int Borrar(object unItem) { contable item = (contable)unItem; int i = 0; //VERIFICAMOS PERIODO if (PeriodoPr.PeriodoCerrado((short)item.fecha.Year, (short)item.fecha.Month)) { throw new Exception("Periodo cerrado no se puede continuar"); } //CONTRA ASIENTO PARA ANULAR CONTABLE using (ispDB db = new ispDB()) { try { db.BeginTransaction(); item.esanulado = true; i = db.InsertOrReplace(item); db.CommitTransaction(); } catch (Exception) { db.RollbackTransaction(); throw; } } return(i); }
public void RaiseCargaVista(object unObjetoLocal) { if (unObjetoLocal != null) { contable registro = (contable)unObjetoLocal; //TipoContablePr tipoContablePr = new TipoContablePr(); try { List <object> listaValores = new List <object>(); ViewLoadEventArgs argumentos = new ViewLoadEventArgs(); //ASIGNACION DE VALORES A CONTROLES this.controles["_lblAnulado"].Visible = registro.esanulado ? true : false; this.controles["_txtNumero"].Text = registro.numero.ToString("0000000"); ((ComboBox)this.controles["_cboTipo"]).DataSource = proveedor.ListaTipoContable; ((ComboBox)this.controles["_cboTipo"]).SelectedValue = registro.fktiposcontable; ((DateTimeInput)this.controles["_dtpFecha"]).Value = registro.fecha; this.controles["_txtBeneficiario"].Text = registro.fkpersona.ToString(); this.controles["_txtDetalle"].Text = registro.observacion; //ASIGNACION DE DATOS AL DETALLE ((DataGridView)this.controles["_dgrDetalle"]).DataSource = null; ((DataGridView)this.controles["_dgrDetalle"]).DataSource = SoporteList <detallecontable> .ToBindingList(registro.fkdetallescontables); //if (((DataGridView)this.controles[5]).DataSource == null) // ((DataGridView)this.controles[5]).DataSource = SoporteList<DetalleContable>.ToBindingList(registro.DetalleContable); //else //{ // System.ComponentModel.BindingList<DetalleContable> listaDetalle = (System.ComponentModel.BindingList<DetalleContable>)((DataGridView)this.controles[5]).DataSource; // listaDetalle.Clear(); // registro.DetalleContable.ForEach(delegate(DetalleContable x) { listaDetalle.Add(x); }); //} //PASO DE VALORES AL FORMULARIO PARA ASIGNACION DE VARIABLES LOCALES listaValores.Add(registro.eseditable); listaValores.Add(registro); argumentos.ListaObjetos = listaValores; GestionMaestrasCr.Instancia.OnListaCargada(null, argumentos); } catch (Exception ex) { if (ex.InnerException == null) { General.Mensaje(ex.Message.ToString()); } else { General.Mensaje(ex.InnerException.Message.ToString()); } } finally { } } }
public int Grabar(object unItem) { contable item = (contable)unItem; int i = 0; fraccionperiodo periodo = PeriodoPr.Instancia.RegistroPorId((short)item.fecha.Year, (short)item.fecha.Month); if (periodo == null) { throw new Exception("Periodo no registrado"); } if (!periodo.cerrado) { using (ispDB db = new ispDB()) { try { item.fkfraccionperiodo = periodo; item.IntegrarAsociados(); db.BeginTransaction(); if (item.numero == 0) { item.numero = db.contables.Where(x => x.idperiodo == item.idperiodo && x.idtipocontable == item.idtipocontable) .GroupBy(x => Sql.GroupBy.None, (idx, g) => g.Max(y => y.numero)).Single(); item.numero++; } i = db.InsertOrReplace(item); db.detallescontables.Where(x => x.idperiodo == item.idperiodo && x.idtipocontable == item.idtipocontable && x.numerocontable == item.numero).Delete(); for (int ix = 0; ix < item.fkdetallescontables.Count(); ix++) { detallecontable detalle = item.fkdetallescontables.ElementAt(ix); detalle.idperiodo = item.idperiodo; detalle.idtipocontable = item.idtipocontable; detalle.numerocontable = item.numero; detalle.registro = (short)ix; db.InsertOrReplace(detalle); } db.CommitTransaction(); } catch (Exception) { db.RollbackTransaction(); throw; } } } return(i); }
public string BuscarBeneficiario(ref object unObjetoLocal) { contable registro = (contable)unObjetoLocal; persona objeto = (persona)BuscarListaPr.BuscarBeneficiarios(); if (objeto != null) { registro.fkpersona = objeto; } return(registro.fkpersona.ToString()); }
public void BuscarBeneficiario(object unObjeto) { contable objeto = (contable)unObjeto; persona item = (persona)BuscarListaPr.BuscarObjeto(TipoConsulta.Personas); if (item != null) { objeto.fkpersona = item; objeto.idpersona = item.id; } }
public void Buscar(object unObjeto, bool buscar = true) { contable objeto = unObjeto as contable; try { DialogResult respuesta = DialogResult.Yes; if (objeto == null) { objeto = new contable(); } BusquedaContables f = new BusquedaContables(); if (buscar == true) { this.proveedor = new ContablePr(); this.proveedor.ListaTipoContable = null; f.listaTipos = this.proveedor.ListaTipoContable; f.objeto = objeto; f.ShowDialog(); respuesta = f.DialogResult; if (respuesta == DialogResult.Yes) { objeto = f.objeto; } } if (buscar == false) { objeto = this.proveedor.RegistroPorId(objeto.idperiodo, objeto.fktiposcontable, objeto.numero); } if (respuesta == DialogResult.Yes) { this.RaiseCargaVista(objeto); } f = null; } catch (Exception ex) { if (ex.InnerException == null) { General.Mensaje(ex.Message); } else { General.Mensaje(ex.InnerException.Message); } } }
public void ImprimirObjeto(object unContable) { try { contable objeto = (contable)unContable; Proveedores.Colecciones.DetalleContableCl coleccion = new Proveedores.Colecciones.DetalleContableCl(); coleccion.AddRange(objeto.fkdetallescontables.ToList()); Reportes reporte = new Reportes() { Reporte = "ContablesRp", FuenteDatos = "DetalleContableCl", Lista = coleccion.ObtenerItems() }; reporte.ShowDialog(); } catch (Exception ex) { General.Mensaje(ex.Message); } }
private void OrdenesPedido_FormClosing(object sender, FormClosingEventArgs e) { DialogResult resultado = VerificaCambios(); switch (resultado) { case DialogResult.Cancel: e.Cancel = true; break; case DialogResult.Yes: this.Guardar(); break; } if (!e.Cancel) { this.objetoLocal = null; } }