Esempio n. 1
0
        public BirthType GetBirthType(int BirthTypeId)
        {
            BirthType ReturnObject = new BirthType();

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

            cmdI.Connection = con;

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

            SqlDataReader drI = cmdI.ExecuteReader();

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

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

            return(ReturnObject);
        }
Esempio n. 2
0
        public List <BirthType> GetBirthTypes()
        {
            List <BirthType> ReturnObject = new List <BirthType>();
            BirthType        ins;

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

            cmdI.Connection = con;

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

            SqlDataReader drI = cmdI.ExecuteReader();

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

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

            return(ReturnObject);
        }
Esempio n. 3
0
        public BirthType InsertBirthType(BirthType ins)
        {
            BirthType ReturnObject = new BirthType();

            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.InsertBirthType;
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@Description", ins.Description);
                ins.BirthTypeId = (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);
        }
Esempio n. 4
0
        public BirthType UpdateBirthType(BirthType ins)
        {
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection      con    = dbConn.SqlConn();

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

            cmdI.Connection = con;

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

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

            return(ins);
        }
Esempio n. 5
0
        public List<BirthType> GetBirthTypes()
        {
            List<BirthType> ReturnObject = new List<BirthType>();
            BirthType ins;

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

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

            SqlDataReader drI = cmdI.ExecuteReader();

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

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

            return ReturnObject;
        }
Esempio n. 6
0
 public JsonResult _UpdateBirthType(BirthType ins)
 {
     ins = birthtypeRep.UpdateBirthType(ins);
     return Json(new GridModel(commonRep.GetBirthTypes()));
 }