private void uibtnagregar_Click(object sender, EventArgs e) { try { if (UICD_TIPO_SALDO.EditValue == null) { MetodosForm.mensajeErrorDefault("Seleccione el tipo de saldo", _datasistema); return; } if (UICD_CUENTA.Text.Length == manejadorNivelCuenta.consultarPorIdNivel(_datasistema.empresa.ID, 1).NM_CANT_CARACTERES) { if (manejadorCuenta.consultarPorIdEmpresaPorRubro(_datasistema.empresa.ID, int.Parse(UIID_RUBRO.EditValue.ToString())).Count() > 0) { MetodosForm.mensajeErrorDefault("Rubro ya registrado", _datasistema); return; } //int idnivel = (from u in _datasistema.ContextoContabilidad.CONT_NIVEL_CUENTA where u.ID_EMPRESA == _datasistema.empresa.ID select u.ID).First(); int idnivel = 1; CONT_CUENTA c = new CONT_CUENTA { ID_EMPRESA = _datasistema.empresa.ID, CD_CUENTA = UICD_CUENTA.Text, DS_CUENTA = UIDS_CUENTA.Text, CD_TIPO_SALDO = char.Parse(UICD_TIPO_SALDO.EditValue.ToString()), ID_CUENTA_PADRE = 0, FLG_DETALLE = 'N', ID_RUBRO = int.Parse(UIID_RUBRO.EditValue.ToString()), ID_NIVEL = idnivel }; manejadorCuenta.insertar(c); this.Close(); } else { MetodosForm.mensajeErrorDefault("Numero de caracteres invalido para la cuenta", _datasistema); } } catch (Exception ex) { MetodosForm.mensajeErrorDefault(ex.Message, _datasistema); } }
public void guardar() { try { if (UICD_TIPO_SALDO.EditValue == null) { MetodosForm.mensajeErrorDefault("Seleccione el tipo de saldo", _datasistema); return; } CONT_CUENTA c = new CONT_CUENTA { ID_EMPRESA = _datasistema.empresa.ID, CD_CUENTA = UICD_CUENTA.Text, DS_CUENTA = UIDS_CUENTA.Text, CD_TIPO_SALDO = char.Parse(UICD_TIPO_SALDO.EditValue.ToString()), ID_CUENTA_PADRE = Cuentapadre.ID, FLG_DETALLE = char.Parse(UIFLG_DETALLE.EditValue.ToString()), ID_RUBRO = int.Parse(UIID_RUBRO.EditValue.ToString()), ID_NIVEL = int.Parse(UIID_NIVEL.EditValue.ToString()) }; if (UIID.Text == "") { c = manejadorData.insertar(c); } else { c.ID = int.Parse(UIID.Text); manejadorData.modificar(c); } consultar(); UITREE_CATALOGOCUENTAS.FocusedNode = UITREE_CATALOGOCUENTAS.FindNodeByKeyID(c.ID); } catch (Exception ex) { MetodosForm.mensajeErrorDefault(ex.Message, _datasistema); } }
/// <summary> /// Evento del botón "Guardar" para la creación de una nueva cuenta /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnGuardar_Click(object sender, EventArgs e) { if (comboBoxRol.SelectedItem != null) { if (!string.IsNullOrEmpty(txtId.Text) && !string.IsNullOrEmpty(txtContra.Text) && !string.IsNullOrEmpty(txtNombre.Text)) { BLCuenta cuenta = new BLCuenta(); cuenta.idUsuario = txtId.Text.Trim(); cuenta.contrasenna = txtContra.Text.Trim(); cuenta.nombreEmpleado = txtNombre.Text.Trim(); cuenta.estado = checkEstado.Checked; cuenta.privilegio = comboBoxRol.SelectedItem.ToString(); ManejadorCuenta manej = new ManejadorCuenta(); BLCuenta cuent = manej.existeIdentificador(txtId.Text.Trim()); if (string.IsNullOrEmpty(cuent.idUsuario)) { manej.insertar(cuenta); this.Owner.Dispose(); this.Dispose(); MessageBox.Show("El usuario se ha creado con éxito"); new Administrador().Show(); } else { txtId.Clear(); MessageBox.Show("El nombre de usuario ya existe"); } } else { MessageBox.Show("Debe de ingresar todos los datos"); } } else { MessageBox.Show("Seleccione un rol para el empleado"); } }