public void UpdateTruck(Truck truck)
 {
     CreateUpdateTruck(truck);
 }
        private void CreateUpdateTruck(Truck truck)
        {
            //		@pTTKey as uniqueidentifier,
            //@pID as varchar(50),
            //@pNo as varchar(50),
            //@pRef as varchar(50),
            //@pBadge as varchar(50) = null,
            //@pCard as varchar(18) = null,
            //@pSKOOnly as bit,
            //@pCapacity as int,
            //@pOwner as varchar(50)

            SqlService sql = new SqlService(_sqlConnection);
            if (truck.Id != null)
                sql.AddParameter("@pTTKey", System.Data.SqlDbType.UniqueIdentifier, truck.Id);
            sql.AddParameter("@pID", System.Data.SqlDbType.VarChar, truck.TTId);
            sql.AddParameter("@pNo", System.Data.SqlDbType.VarChar, truck.No);
            sql.AddParameter("@pRef", System.Data.SqlDbType.VarChar, truck.RefNo);
            sql.AddParameter("@pSKOOnly", System.Data.SqlDbType.Bit, truck.SKOOnly);
            sql.AddParameter("@pCapacity", System.Data.SqlDbType.Int, truck.Capacity);
            sql.AddParameter("@pOwner", System.Data.SqlDbType.VarChar, truck.OwnerName);
            sql.ExecuteSP("ICMS_spCreateUpdateTruck");
        }
        public Truck GetTruck(Guid id)
        {
            Truck t = new Truck();
            SqlService sql = new SqlService(_sqlConnection);
            sql.AddParameter("@pTTKey", System.Data.SqlDbType.UniqueIdentifier, id);
            using (SqlDataReader reader = sql.ExecuteSPReader("ICMS_spGetTruck"))
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        t.Id = id;
                        t.RefNo = reader.SafeGetString(reader.GetOrdinal("RefNo"));
                        t.TTId = reader.SafeGetString(reader.GetOrdinal("TTId"));
                        t.No = reader.SafeGetString(reader.GetOrdinal("No"));
                        //t.BadgeNo = reader.SafeGetString(reader.GetOrdinal("BadgeNo"));
                        //t.CardNo = reader.SafeGetString(reader.GetOrdinal("CardNo"));
                        t.OwnerName = reader.SafeGetString(reader.GetOrdinal("Owner"));
                        t.SKOOnly = reader.SafeGetBool(reader.GetOrdinal("SKOOnly")).Value;
                        t.Capacity = reader.SafeGetInt(reader.GetOrdinal("Capacity")).Value;
                    }
                }
            }

            return t;
        }