コード例 #1
0
ファイル: AnimalTypeRepository.cs プロジェクト: Ricium/Wetu
        public AnimalType GetAnimalType(int AnimalTypeId)
        {
            AnimalType ReturnObject = new AnimalType();

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI = con.CreateCommand();
            cmdI.Connection = con;

            cmdI.Parameters.Clear();
            cmdI.CommandText = CommonStrings.GetAnimalType;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@AnimalTypeId", AnimalTypeId);
            cmdI.Connection.Open();

            SqlDataReader drI = cmdI.ExecuteReader();

            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ReturnObject.AnimalTypeId = Convert.ToInt32(drI["AnimalTypeId"]);
                    ReturnObject.Description = drI["Description"].ToString();
                }
            }

            cmdI.Connection.Close();
            con.Dispose();

            return ReturnObject;
        }
コード例 #2
0
ファイル: AnimalTypeRepository.cs プロジェクト: Ricium/Wetu
        public AnimalType GetAnimalType(int AnimalTypeId)
        {
            AnimalType ReturnObject = new AnimalType();

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();
            SqlCommand         cmdI   = con.CreateCommand();

            cmdI.Connection = con;

            cmdI.Parameters.Clear();
            cmdI.CommandText = CommonStrings.GetAnimalType;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@AnimalTypeId", AnimalTypeId);
            cmdI.Connection.Open();

            SqlDataReader drI = cmdI.ExecuteReader();

            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ReturnObject.AnimalTypeId = Convert.ToInt32(drI["AnimalTypeId"]);
                    ReturnObject.Description  = drI["Description"].ToString();
                }
            }

            cmdI.Connection.Close();
            con.Dispose();

            return(ReturnObject);
        }
コード例 #3
0
ファイル: CommonRepository.cs プロジェクト: Ricium/Wetu
        public List <AnimalType> GetAnimalTypes()
        {
            List <AnimalType> ReturnObject = new List <AnimalType>();
            AnimalType        ins;

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();
            SqlCommand         cmdI   = con.CreateCommand();

            cmdI.Connection = con;

            cmdI.Parameters.Clear();
            cmdI.CommandText = CommonStrings.GetAnimalTypes;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Connection.Open();

            SqlDataReader drI = cmdI.ExecuteReader();

            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new AnimalType();
                    ins.AnimalTypeId = Convert.ToInt32(drI["AnimalTypeId"]);
                    ins.Description  = drI["Description"].ToString();
                    ReturnObject.Add(ins);
                }
            }

            cmdI.Connection.Close();
            con.Dispose();

            return(ReturnObject);
        }
コード例 #4
0
ファイル: AnimalTypeRepository.cs プロジェクト: Ricium/Wetu
        public AnimalType InsertAnimalType(AnimalType ins)
        {
            AnimalType ReturnObject = new AnimalType();

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();

            con.Open();

            SqlCommand     cmdI = con.CreateCommand();
            SqlTransaction trx  = con.BeginTransaction(CommonStrings.InsertTransaction);

            cmdI.Connection  = con;
            cmdI.Transaction = trx;

            try
            {
                cmdI.Parameters.Clear();
                cmdI.CommandText = CommonStrings.InsertAnimalType;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@Description", ins.Description);
                ins.AnimalTypeId = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null)
                {
                    trx.Rollback();
                }
            }
            finally
            {
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }

                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }

            return(ins);
        }
コード例 #5
0
ファイル: AnimalTypeRepository.cs プロジェクト: Ricium/Wetu
        public AnimalType InsertAnimalType(AnimalType ins)
        {
            AnimalType ReturnObject = new AnimalType();

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();

            SqlCommand cmdI = con.CreateCommand();
            SqlTransaction trx = con.BeginTransaction(CommonStrings.InsertTransaction);

            cmdI.Connection = con;
            cmdI.Transaction = trx;

            try
            {
                cmdI.Parameters.Clear();
                cmdI.CommandText = CommonStrings.InsertAnimalType;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@Description", ins.Description);
                ins.AnimalTypeId = (int)cmdI.ExecuteScalar();

                trx.Commit();
                cmdI.Connection.Close();
            }
            catch(SqlException ex)
            {
                if (trx != null) trx.Rollback();
            }
            finally
            {
                if(con.State != ConnectionState.Closed)
                {
                    con.Close();
                }

                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }

            return ins;
        }
コード例 #6
0
ファイル: AnimalTypeRepository.cs プロジェクト: Ricium/Wetu
        public AnimalType UpdateAnimalType(AnimalType ins)
        {
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();

            con.Open();
            SqlCommand cmdI = con.CreateCommand();

            cmdI.Connection = con;

            cmdI.Parameters.Clear();
            cmdI.CommandText = CommonStrings.UpdateAnimalType;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@AnimalTypeId", ins.AnimalTypeId);
            cmdI.Parameters.AddWithValue("@Description", ins.Description);

            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();
            con.Dispose();

            return(ins);
        }
コード例 #7
0
ファイル: AnimalTypeRepository.cs プロジェクト: Ricium/Wetu
        public AnimalType UpdateAnimalType(AnimalType ins)
        {
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();
            SqlCommand cmdI = con.CreateCommand();
            cmdI.Connection = con;

            cmdI.Parameters.Clear();
            cmdI.CommandText = CommonStrings.UpdateAnimalType;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@AnimalTypeId", ins.AnimalTypeId);
            cmdI.Parameters.AddWithValue("@Description", ins.Description);

            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();
            con.Dispose();

            return ins;
        }
コード例 #8
0
ファイル: CommonRepository.cs プロジェクト: Ricium/Wetu
        public List<AnimalType> GetAnimalTypes()
        {
            List<AnimalType> ReturnObject = new List<AnimalType>();
            AnimalType ins;

            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            SqlCommand cmdI = con.CreateCommand();
            cmdI.Connection = con;

            cmdI.Parameters.Clear();
            cmdI.CommandText = CommonStrings.GetAnimalTypes;
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Connection.Open();

            SqlDataReader drI = cmdI.ExecuteReader();

            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new AnimalType();
                    ins.AnimalTypeId = Convert.ToInt32(drI["AnimalTypeId"]);
                    ins.Description = drI["Description"].ToString();
                    ReturnObject.Add(ins);
                }
            }

            cmdI.Connection.Close();
            con.Dispose();

            return ReturnObject;
        }
コード例 #9
0
ファイル: MaintenanceController.cs プロジェクト: Ricium/Wetu
 public JsonResult _UpdateAnimalType(AnimalType ins)
 {
     ins = animaltypeRep.UpdateAnimalType(ins);
     return Json(new GridModel(commonRep.GetAnimalTypes()));
 }