Exemple #1
0
        public static System.Collections.Generic.List <KursusDag> GetAllKursusDagList(int KursusPolicyID)
        {
            System.Collections.Generic.List <KursusDag> result = new System.Collections.Generic.List <KursusDag>();
            int      ID = -1;
            DBAccess db = new DBAccess();

            db.AddInt("KursusPolicyID", KursusPolicyID);

            SqlDataReader dr = default(SqlDataReader);

            try
            {
                dr = (System.Data.SqlClient.SqlDataReader)(db.ExecuteReader(_SQLSelectAllList));
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        KursusDag kd = new KursusDag();
                        Populate(dr, kd);
                        result.Add(kd);
                    }
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(result);
        }
Exemple #2
0
        public static int Insert(KursusDag c)
        {
            DBAccess db = new DBAccess();

            if (c.Status == KursusStatusEnum.Initialize)
            {
                c.Status = KursusStatusEnum.Aktiv;
            }
            AddParms(ref db, c);

            SqlParameter objParam = new SqlParameter("@ID", 0);

            objParam.Direction = ParameterDirection.Output;
            db.Parameters.Add(objParam);
            int retval = db.ExecuteNonQuery(_SQLInsert);

            if (retval == 1)
            {
                return(int.Parse(objParam.Value.ToString()));
            }
            else
            {
                return(-1);
            }
        }
Exemple #3
0
        private static void Populate(System.Data.SqlClient.SqlDataReader dr, KursusDag c)
        {
            var with_1 = c;

            with_1.KursusPolicyID  = System.Convert.ToInt32(dr.DBtoInt("KursusPolicyID"));
            with_1.KursusDato      = System.Convert.ToDateTime(dr.DBtoDate("KursusDato"));
            with_1.Repetionskursus = System.Convert.ToBoolean(dr.DBtoBool("Repetionskursus"));
            with_1.Status          = (RescueTekniq.BOL.KursusStatusEnum)(dr.DBtoInt("Status"));
            PopulateStandard(dr, c);
        }
Exemple #4
0
        private static void AddParms(ref DBAccess db, KursusDag c)
        {
            var with_1 = c;

            db.AddInt("KursusPolicyID", with_1.KursusPolicyID);
            db.AddDateTime("KursusDato", with_1.KursusDato);
            db.AddBoolean("Repetionskursus", with_1.Repetionskursus);
            db.AddInt("Status", (System.Int32)with_1.Status);
            AddParmsStandard(db, c);
        }
Exemple #5
0
        public static int Update(int ID, int KursusPolicyID, DateTime KursusDato, bool Repetionskursus, KursusStatusEnum Status)
        {
            KursusDag c = new KursusDag(ID);

            c.KursusPolicyID  = KursusPolicyID;
            c.KursusDato      = KursusDato;
            c.Repetionskursus = Repetionskursus;
            c.Status          = Status;

            return(Update(c));
        }
Exemple #6
0
        public static int Update(KursusDag c)
        {
            DBAccess db = new DBAccess();

            db.AddInt("ID", c.ID);
            AddParms(ref db, c);

            int retval = db.ExecuteNonQuery(_SQLUpdate);

            return(retval);
        }
Exemple #7
0
        public static KursusDag GetKursusDag(int ID)
        {
            DBAccess db = new DBAccess();

            db.AddInt("ID", ID);
            KursusDag     c  = new KursusDag();
            SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectOne));

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Populate(dr, c);
                }
                dr.Close();
            }
            return(c);
        }
Exemple #8
0
        public static KursusDag GetKursusDag(int KursusPolicyID, DateTime KursusDato)
        {
            KursusDag c  = new KursusDag();
            DBAccess  db = new DBAccess();

            db.AddDateTime("KursusDato", KursusDato);
            db.AddInt("KursusPolicyID", KursusPolicyID);

            SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectByDate));

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Populate(dr, c);
                }
                dr.Close();
            }

            return(c);
        }
Exemple #9
0
 public static int Delete(KursusDag c)
 {
     return(Delete(c.ID));
 }