Пример #1
0
        private void btnEditar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (currentRow == null)
            {
                lblStatus.Caption = "Por favor seleccione un elemento de la Lista";
                return;
            }
            else
            {
                lblStatus.Caption = "";
            }
            isEdition = true;

            HabilitarControles(true);
            //Inactivar Controles que no se editan
            this.slkupGrupo.ReadOnly       = true;
            this.slkupCuentaMayor.ReadOnly = true;

            if (CuentaContableDAC.GetCountCuentaByNivel(currentRow["Nivel1"].ToString(), currentRow["Nivel2"].ToString(), currentRow["Nivel3"].ToString(), currentRow["Nivel4"].ToString(), currentRow["Nivel5"].ToString(), currentRow["Nivel6"].ToString()) > 1)
            {
                this.chkAceptaDatos.ReadOnly = true;
                this.chkEsMayor.ReadOnly     = true;
                this.chkActiva.ReadOnly      = true;
            }
            else
            {
                this.chkAceptaDatos.ReadOnly = false;
                this.chkEsMayor.ReadOnly     = false;
                this.chkActiva.ReadOnly      = false;
            }

            lblStatus.Caption = "Editando el registro : " + currentRow["Descr"].ToString();
        }
Пример #2
0
        private void btnEliminar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (currentRow != null)
            {
                string msg = currentRow["Descr"] + " eliminado..";

                if (MessageBox.Show("Esta seguro que desea eliminar el elemento: " + currentRow["Descr"].ToString(), _tituloVentana, MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
                {
                    //Verificar si la cuenta a eliminar es de mayor
                    if (Convert.ToBoolean(currentRow["EsMayor"]))
                    {
                        //Validar si tiene hijos
                        if (CuentaContableDAC.GetCountCuentaByNivel(currentRow["Nivel1"].ToString(), currentRow["Nivel2"].ToString(), currentRow["Nivel3"].ToString(), currentRow["Nivel4"].ToString(), currentRow["Nivel5"].ToString(), currentRow["Nivel6"].ToString()) > 1)
                        {
                            MessageBox.Show("La cuenta que desea eliminar es una cuenta de Mayor y tiene Sub Cuentas, por favor elimine las SubCuentas antes de proseguir");
                            return;
                        }
                    }

                    currentRow.Delete();

                    try
                    {
                        CuentaContableDAC.oAdaptador.Update(_dsCuenta, "Data");
                        _dsCuenta.AcceptChanges();

                        PopulateGrid();
                        lblStatus.Caption = msg;
                        Application.DoEvents();
                    }
                    catch (System.Data.SqlClient.SqlException ex)
                    {
                        _dsCuenta.RejectChanges();
                        lblStatus.Caption = "";
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }