Example #1
0
        //METODO BUSCAR
        public DataTable Buscar(DAcfMVMt_MotivoMovimiento acfMVMt_MotivoMovimiento)
        {
            DataTable     DtResultado = new DataTable("acfMVMt_MotivoMovimiento");
            SqlConnection SqlCon      = new SqlConnection();

            try
            {
                SqlCon.ConnectionString = DConexion.CnBDActivo;
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "usp_B_acfMVMt_MotivoMovimiento";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParMVMmovimiento = new SqlParameter();
                ParMVMmovimiento.ParameterName = "@sMVMid";
                ParMVMmovimiento.SqlDbType     = SqlDbType.Char;
                ParMVMmovimiento.Size          = 50;
                ParMVMmovimiento.Value         = acfMVMt_MotivoMovimiento.MVMid;
                SqlCmd.Parameters.Add(ParMVMmovimiento);

                SqlDataAdapter SqlDat = new SqlDataAdapter(SqlCmd);
                SqlDat.Fill(DtResultado);
            }
            catch (Exception ex)
            {
                DtResultado = null;
            }
            return(DtResultado);
        }
Example #2
0
        //METODO INSERTAR
        public string Insertar(DAcfMVMt_MotivoMovimiento acfMVMt_MotivoMovimiento)
        {
            string        rpta   = "";
            SqlConnection SqlCon = new SqlConnection();

            try
            {
                //Código
                SqlCon.ConnectionString = DConexion.CnBDActivo;
                SqlCon.Open();
                //Establecer el Comando
                SqlCommand SqlCmd = new SqlCommand();
                SqlCmd.Connection  = SqlCon;
                SqlCmd.CommandText = "usp_I_acfMVMt_MotivoMovimiento";
                SqlCmd.CommandType = CommandType.StoredProcedure;

                SqlParameter ParTMVid = new SqlParameter();
                ParTMVid.ParameterName = "@sTMVid";
                ParTMVid.SqlDbType     = SqlDbType.Char;
                ParTMVid.Value         = acfMVMt_MotivoMovimiento.TMVid;
                SqlCmd.Parameters.Add(ParTMVid);
                //
                SqlParameter PariMVMid = new SqlParameter();
                PariMVMid.ParameterName = "@sMVMid";
                PariMVMid.SqlDbType     = SqlDbType.Char;
                PariMVMid.Value         = acfMVMt_MotivoMovimiento.MVMid;
                SqlCmd.Parameters.Add(PariMVMid);
                //
                SqlParameter ParsMVMmotivomovimiento = new SqlParameter();
                ParsMVMmotivomovimiento.ParameterName = "@sMVMmotivomovimiento";
                ParsMVMmotivomovimiento.SqlDbType     = SqlDbType.Char;
                ParsMVMmotivomovimiento.Value         = acfMVMt_MotivoMovimiento.MVMmotivomovimiento;
                SqlCmd.Parameters.Add(ParsMVMmotivomovimiento);
                //
                SqlParameter ParsMVMjustificacion = new SqlParameter();
                ParsMVMjustificacion.ParameterName = "@iMVMjustificacion";
                ParsMVMjustificacion.SqlDbType     = SqlDbType.SmallInt;
                ParsMVMjustificacion.Value         = acfMVMt_MotivoMovimiento.MVMjustificacion;
                SqlCmd.Parameters.Add(ParsMVMjustificacion);
                //

                //Ejecutamos nuestro comando

                rpta = SqlCmd.ExecuteNonQuery() != 0 ? "OK" : "NO se Elimino el Registro";
            }
            catch (Exception ex)
            {
                rpta = ex.Message;
            }
            finally
            {
                if (SqlCon.State == ConnectionState.Open)
                {
                    SqlCon.Close();
                }
            }
            return(rpta);
        }