public void CargarDatos(string clase, string linea, string tipofor) { FormatoDataSource formatoedit = new FormatoDataSource(); try { formatoedit = this.negocioFormato.DevolverFormato(tipofor, clase, linea); txt_encabezado.Text = this.negocioFormato.DevolverEncabezado(int.Parse(tipofor)); } catch (Exception ex) { MessageBox.Show("SE PRESENTO UN ERROR." + ex.Message, "ERROR"); } cbx_tipo.SelectedIndex = tipofor.Equals("1") ? 0 : 1; txt_clase.Text = formatoedit.ClaseCuenta; txt_linea.Text = formatoedit.Linea; txt_nombre.Text = formatoedit.Nombre; txt_cuentaini.Text = formatoedit.CuentaInicial; txt_cuentafin.Text = formatoedit.CuentaFinal; btn_guardar.Enabled = true; this.CamposActivos(); txt_encabezado.Focus(); cbx_tipo.Enabled = false; this.BotonesInhab(); this.btn_cancelar.Enabled = true; }
public FormatoDataSource DevolverFormato(string tipo, string clase, string linea) { FormatoDataSource formato = new FormatoDataSource(); try { var items = this.persistencia.DevolverFormato(tipo, clase, linea); if (items != null) { formato.TipoFormato = items.tipoformato; formato.ClaseCuenta = items.clasemayor; formato.Linea = items.linea; formato.Nombre = items.nombref; formato.CuentaInicial = this.persistenciaCuenta.DevolverCuenta(items.cuentaini); formato.CuentaFinal = this.persistenciaCuenta.DevolverCuenta(items.cuentafin); } else { formato = null; } } catch (Exception ex) { throw ex; } return(formato); }
private FormatoDataSource GuardarDatos() { FormatoDataSource format = new FormatoDataSource(); format.TipoFormato = cbx_tipo.SelectedItem.ToString() == "BALANCE GENERAL" ? "1" : "2"; format.ClaseCuenta = txt_clase.Text; format.Linea = txt_linea.Text; format.Nombre = txt_nombre.Text; format.CuentaInicial = txt_cuentaini.Text; format.CuentaFinal = txt_cuentafin.Text; return(format); }
private void Btn_guardar_Click(object sender, EventArgs e) { bool validar = this.ValidarGuardar(); if (validar) { FormatoDataSource formato = new FormatoDataSource(); formato = this.GuardarDatos(); if (cbx_tipo.Enabled == true) { try { bool guardar = this.negocioFormato.GuardarFormato(formato, txt_encabezado.Text); if (guardar) { MessageBox.Show("EL FORMATO HA SIDO GUARDADO", "GUARDAR", MessageBoxButtons.OK); } } catch (Exception ex) { MessageBox.Show("SE PRESENTO UN ERROR. " + ex.Message, "ERROR"); } } else { try { bool guardar = this.negocioFormato.ActualizarFormato(formato, txt_encabezado.Text); if (guardar) { MessageBox.Show("EL FROMATO HA SIDO ACTUALIZADO", "GUARDAR", MessageBoxButtons.OK); } } catch (Exception ex) { MessageBox.Show("SE PRESENTO UN ERROR. " + ex.Message, "ERROR"); } } this.CamposVacios(); this.CamposInactivos(); this.BotonesHabit(); btn_cancelar.Enabled = false; } }
private bool ValidarGuardar() { bool result = false; if (!txt_encabezado.Text.Equals(string.Empty) && !txt_clase.Text.Equals(string.Empty) && !txt_linea.Text.Equals(string.Empty) && !txt_nombre.Text.Equals(string.Empty) && !txt_cuentaini.Text.Equals(string.Empty) && !txt_cuentafin.Text.Equals(string.Empty)) { bool existe = false; FormatoDataSource format = new FormatoDataSource(); format = this.GuardarDatos(); try { existe = this.negocioFormato.ExisteFormato(format); } catch (Exception ex) { MessageBox.Show("SE PRESENTO UN ERROR." + ex.Message, "ERROR"); } if (!existe) { result = true; } else { if (cbx_tipo.Enabled == true) { result = false; MessageBox.Show("EL FORMATO QUE DESEA INGRESAR YA EXISTE", "ERROR", MessageBoxButtons.OK); } else { result = true; } } } else { result = false; MessageBox.Show("POR FAVOR INGRESE TODOS LOS CAMPOS", "ERROR", MessageBoxButtons.OK); } return(result); }
public bool ExisteFormato(FormatoDataSource formato) { formatosbpyg forma = new formatosbpyg(); forma.tipoformato = formato.TipoFormato; forma.nombref = formato.Nombre; forma.clasemayor = formato.ClaseCuenta; forma.linea = formato.Linea; forma.cuentaini = this.persistenciaCuenta.DevolverId(formato.CuentaInicial); forma.cuentafin = this.persistenciaCuenta.DevolverId(formato.CuentaFinal); try { return(this.persistencia.ExisteFormato(forma)); } catch (Exception ex) { throw ex; } }