//lo vamos a llamar con una funcion //metodo mostrar mes y año de las polizas y que tengan estado 0 //este va a llamar al metodo que esta en capa datos dcierres public static DataTable BuscarPoliza(string textobuscarmes, string textobuscaranio) { DCierres Obj = new DCierres(); Obj.TextoBuscarmes = textobuscarmes; Obj.TextoBuscaranio = textobuscaranio; return Obj.BuscarPoliza(Obj); }
//lo vamos a llamar con una funcion public static string Editar(string codigocuenta, string anio, string mes, string saldoinicial, string saldoactual) { DCierres Obj = new DCierres(); Obj.Textocodigocuenta = codigocuenta; Obj.Textoanio = anio; Obj.Textomes = mes; Obj.Textosaldoini = saldoinicial; Obj.Textosalact = saldoactual; return Obj.Editar(Obj); }
//metodos //metodo insertar public string Insertar(DCierres Cierres) { string respuesta = ""; SqlConnection SqlCon = new SqlConnection(); try { //codigo SqlCon.ConnectionString = Conexion.Cn; SqlCon.Open(); //establecer el comando para ejecutar sentencias en sql SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.CommandText = "spinsertar_cierre_contable"; SqlCmd.CommandType = CommandType.StoredProcedure; //mandar a llamar a primer campo de la tabla SqlParameter ParTextocodigoempresa = new SqlParameter(); ParTextocodigoempresa.ParameterName = "@textocodigoempresa"; ParTextocodigoempresa.SqlDbType = SqlDbType.VarChar; //ParTextocodigoempresa.Size = 10; ParTextocodigoempresa.Value = Cierres.Textocodigoempresa; SqlCmd.Parameters.Add(ParTextocodigoempresa); SqlParameter ParTextocodigocuenta = new SqlParameter(); ParTextocodigocuenta.ParameterName = "@textocodigocuenta"; ParTextocodigocuenta.SqlDbType = SqlDbType.VarChar; ParTextocodigocuenta.Size = 10; ParTextocodigocuenta.Value = Cierres.Textocodigocuenta; SqlCmd.Parameters.Add(ParTextocodigocuenta); SqlParameter ParTextoanio = new SqlParameter(); ParTextoanio.ParameterName = "@textoanio"; ParTextoanio.SqlDbType = SqlDbType.VarChar; ParTextoanio.Size = 10; ParTextoanio.Value = Cierres.Textoanio; SqlCmd.Parameters.Add(ParTextoanio); SqlParameter ParTextomes = new SqlParameter(); ParTextomes.ParameterName = "@textomes"; ParTextomes.SqlDbType = SqlDbType.VarChar; ParTextomes.Size = 10; ParTextomes.Value = Cierres.Textomes; SqlCmd.Parameters.Add(ParTextomes); SqlParameter ParTextosaldoini = new SqlParameter(); ParTextosaldoini.ParameterName = "@textosaldoini"; ParTextosaldoini.SqlDbType = SqlDbType.VarChar; ParTextosaldoini.Size = 10; ParTextosaldoini.Value = Cierres.Textosaldoini; SqlCmd.Parameters.Add(ParTextosaldoini); SqlParameter ParTextosalact = new SqlParameter(); ParTextosalact.ParameterName = "@textosalact"; ParTextosalact.SqlDbType = SqlDbType.VarChar; ParTextosalact.Size = 10; ParTextosalact.Value = Cierres.Textosalact; SqlCmd.Parameters.Add(ParTextosalact); //ejecutamos nuestro comando respuesta = SqlCmd.ExecuteNonQuery() == 1 ? "OK" : "No se ingreso el registro."; } catch (Exception ex) { respuesta = ex.Message; } finally { if (SqlCon.State == ConnectionState.Open) SqlCon.Close(); } return respuesta; }
//metodo para buscar la fecha y el mes de las polizas y que tengan estado 1 public DataTable BuscarPoliza(DCierres Cierres) { DataTable DtResultado = new DataTable("TBM_ASIENTOS_CONTABLES_ENCA"); SqlConnection SqlCon = new SqlConnection(); try { SqlCon.ConnectionString = Conexion.Cn; SqlCommand SqlCmd = new SqlCommand(); SqlCmd.Connection = SqlCon; SqlCmd.CommandText = "spbuscar_poliza_pendiente"; //"spbuscar_empresa"; SqlCmd.CommandType = CommandType.StoredProcedure; SqlParameter ParTextobuscarmes = new SqlParameter(); ParTextobuscarmes.ParameterName = "@textomes"; ParTextobuscarmes.SqlDbType = SqlDbType.VarChar; ParTextobuscarmes.Size = (50); ParTextobuscarmes.Value = Cierres.TextoBuscarmes; SqlCmd.Parameters.Add(ParTextobuscarmes); SqlParameter ParTextobuscaranio = new SqlParameter(); ParTextobuscaranio.ParameterName = "@textoanio"; ParTextobuscaranio.SqlDbType = SqlDbType.VarChar; ParTextobuscaranio.Size = (5); ParTextobuscaranio.Value = Cierres.TextoBuscaranio; SqlCmd.Parameters.Add(ParTextobuscaranio); SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd); SqlDat.Fill(DtResultado); } catch (Exception ex) { DtResultado = null; } return (DtResultado); }