public List <clsUnitType> GetAllUnitTypeInfo() { List <clsUnitType> lst = new List <clsUnitType>(); using (SqlConnection conn = new SqlConnection(strConn)) { conn.Open(); using (SqlCommand cmd = new SqlCommand("TMR_USP_GetUnitType")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = conn; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { var info = new clsUnitType(); info.strUnitTypeID = reader["UnitTypeID"].ToString(); info.strDesc = reader["UnitTypeDescription"].ToString(); info.id = Convert.ToInt32(reader["ID"]); lst.Add(info); } conn.Close(); } } return(lst); }
public bool AddUnitType(clsUnitType info) { int st = 0; try { using (SqlConnection conn = new SqlConnection(strConn)) { conn.Open(); { using (SqlCommand cmd = new SqlCommand("TMR_USP_AddUnitType")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = conn; cmd.Parameters.AddWithValue("@UnitTypeID", info.strUnitTypeID); cmd.Parameters.AddWithValue("@UnitTypeDescription", info.strDesc); cmd.Parameters.AddWithValue("@ID", info.id); st = cmd.ExecuteNonQuery(); } } conn.Close(); } } catch (Exception ex) { } if (st > 0) { return(true); } else { return(false); } }