Exemple #1
0
 private void PopulateGrid()
 {
     _dsAsiento           = AsientoDAC.GetDataByCriterio(_FechaInicial, _FechaFinal, _TipoAsiento, _Mayorizado, _Anulado, _ModuloFuente, _CuadreTemporal, _sUsuario);
     _dtAsiento           = _dsAsiento.Tables[0];
     this.grid.DataSource = null;
     this.grid.DataSource = _dtAsiento;
 }
Exemple #2
0
        private void btnMayorizar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //Validar que al menos un elemento se encuentre seleccionado
            ArrayList rows = new ArrayList();

            for (int i = 0; i < this.gridView.SelectedRowsCount; i++)
            {
                if (gridView.GetSelectedRows()[i] >= 0)
                {
                    rows.Add(gridView.GetDataRow(gridView.GetSelectedRows()[i]));
                }
            }

            if (rows.Count == 0)
            {
                MessageBox.Show("Por favor chequee los elementos que desea mayorizar");
                return;
            }

            try
            {
                for (int i = 0; i < rows.Count; i++)
                {
                    DataRow row = rows[i] as DataRow;
                    // Change the field value.


                    DateTime Fecha = Convert.ToDateTime(row["Fecha"]);
                    try
                    {
                        //if (Fecha == null || PeriodoContableDAC.ValidaFechaInPeriodoContable(Fecha))
                        PeriodoContableDAC.ValidaFechaInPeriodoContable(Fecha);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Han ocurrido los siguientes errores: \r\n" + ex.Message);
                        return;
                    }

                    if (Convert.ToBoolean(row["Mayorizado"]) == false)
                    {
                        //Validar situaciones comunes al momento de mayorizar
                        String NumAsiento  = row["Asiento"].ToString();
                        int    IdEjercicio = (int)row["IDEjercicio"];// (int)_dsEjercicioPeriodo.Tables[0].Rows[0]["IDEjercicio"];
                        String Periodo     = row["Periodo"].ToString();
                        bool   bExito      = false;
                        bExito = AsientoDAC.Mayorizar(IdEjercicio, Periodo, NumAsiento, sUsuario);

                        if (!bExito)
                        {
                            MessageBox.Show("Ha ocurrido un error tratando de mayorizar el asiento..");
                            return;
                        }
                    }
                }
                MessageBox.Show("El asiento contable, se ha mayorizado con exito");

                PopulateGrid();
            }
            finally
            {
            }
        }
Exemple #3
0
        private void BtnEliminar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (_currentRow != null)
            {
                string msg = _currentRow["Asiento"] + " eliminado..";
                if (Convert.ToBoolean(_currentRow["Mayorizado"]) == true)
                {
                    lblStatus.Caption = "No puede eliminar asientos que se encuentran mayorizados";
                    return;
                }

                if (MessageBox.Show("Esta seguro que desea eliminar el elemento: " + _currentRow["Asiento"].ToString(), _tituloVentana, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    DataSet   _dsAsientotmp = new DataSet();
                    DataSet   _dsDetalle    = new DataSet();
                    DataTable _dtAsientotmp = new DataTable();
                    DataTable _dtDetalle    = new DataTable();

                    String sAsiento = _currentRow["Asiento"].ToString();

                    _dsAsientotmp = AsientoDAC.GetDataByAsiento(sAsiento);
                    _dtAsiento    = _dsAsiento.Tables[0];

                    _dsDetalle = AsientoDetalleDAC.GetData(sAsiento, -1, -1);
                    _dtDetalle = _dsDetalle.Tables[0];


                    try
                    {
                        String xml = "";

                        _dsAsientotmp.Tables[0].TableName = "Asiento";

                        DataTable dt = new DataTable();
                        dt           = _dtDetalle.Clone();
                        dt.TableName = "Detalle";
                        if (_dsAsientotmp.Tables["Detalle"] != null)
                        {
                            _dsAsientotmp.Tables.Remove(_dsAsientotmp.Tables["Detalle"]);
                        }
                        foreach (DataRow dr in _dsDetalle.Tables[0].Rows)
                        {
                            dt.Rows.Add(dr.ItemArray);
                        }
                        _dsAsientotmp.Tables.Add(dt);

                        DataRelation rel = new DataRelation("CabeceraDetalle", _dsAsientotmp.Tables[0].Columns["Asiento"], _dsAsientotmp.Tables[1].Columns["Asiento"], true);
                        _dsAsientotmp.DataSetName = "Root";
                        xml = _dsAsientotmp.GetXml(); //ToStringAsXml(_dsAsiento);


                        AsientoDAC.InsertUpdateAsiento("D", xml, _currentRow["Asiento"].ToString(), _currentRow["Tipo"].ToString());

                        MessageBox.Show("El asiento se ha eliminado correctamente.");
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        //_dsAsiento.RejectChanges();
                        //_dsDetalle.RejectChanges();
                        MessageBox.Show("Han ocurrido errores al momento de eliminar el asiento por favor verifique" + ex.Message);
                    }

                    PopulateGrid();
                }
            }
        }