public static System.Collections.Generic.List <KursusPolicy> GetKursusPolicyList(int CompanyID)
        {
            System.Collections.Generic.List <KursusPolicy> result = new System.Collections.Generic.List <KursusPolicy>();
            int      ID = -1;
            DBAccess db = new DBAccess();

            db.AddInt("CompanyID", CompanyID);

            SqlDataReader dr = default(SqlDataReader);

            try
            {
                dr = (System.Data.SqlClient.SqlDataReader)(db.ExecuteReader(_SQLSelectIDByCompanyID));
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        ID = System.Convert.ToInt32(dr.DBtoInt("ID"));
                        result.Add(KursusPolicy.GetKursusPolicy(ID));
                    }
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(result);
        }
        public static int Insert(KursusPolicy 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)
            {
                c.ID = int.Parse(objParam.Value.ToString());
                return(int.Parse(objParam.Value.ToString()));
            }
            else
            {
                return(-1);
            }
        }
        public static int Update(KursusPolicy c)
        {
            DBAccess db = new DBAccess();

            db.AddInt("ID", c.ID);
            AddParms(ref db, c);
            int retval = db.ExecuteNonQuery("Co2Db_KursusPolicy_Update");

            return(retval);
        }
        public static int Insert(int CompanyID, KursusStatusEnum Status, string FirstAidTitle, int FirstAidAftale, int FirstAidLeverandor, int FirstAidKursusType, int FirstAidAdminAftale, int FirstAidRepetition, int FirstAidMedarbInfo)
        {
            KursusPolicy c = new KursusPolicy();

            c.CompanyID           = CompanyID;
            c.Status              = Status;
            c.FirstAidTitle       = FirstAidTitle;
            c.FirstAidAftale      = FirstAidAftale;
            c.FirstAidLeverandor  = FirstAidLeverandor;
            c.FirstAidKursusType  = FirstAidKursusType;
            c.FirstAidAdminAftale = FirstAidAdminAftale;
            c.FirstAidRepetition  = FirstAidRepetition;
            c.FirstAidMedarbInfo  = System.Convert.ToString(FirstAidMedarbInfo);

            return(Insert(c));
        }
        private static void AddParms(ref DBAccess db, KursusPolicy c)
        {
            var with_1 = c;

            db.AddInt("CompanyID", with_1.CompanyID);
            db.AddInt("Status", (System.Int32)with_1.Status);

            db.AddNVarChar("FirstAidTitle", with_1.FirstAidTitle, 250);
            db.AddInt("FirstAidAftale", with_1.FirstAidAftale);
            db.AddInt("FirstAidLeverandor", with_1.FirstAidLeverandor);
            db.AddInt("FirstAidKursusType", with_1.FirstAidKursusType);
            db.AddInt("FirstAidAdminAftale", with_1.FirstAidAdminAftale);
            db.AddInt("FirstAidRepetition", with_1.FirstAidRepetition);
            db.AddNVarChar("FirstAidMedarbInfo", with_1.FirstAidMedarbInfo, 50);

            AddParmsStandard(db, c);
        }
        public static int Update(int ID, int CompanyID, KursusStatusEnum Status, string FirstAidTitle, int FirstAidAftale, int FirstAidLeverandor, int FirstAidKursusType, int FirstAidAdminAftale, int FirstAidRepetition, int FirstAidMedarbInfo)
        {
            KursusPolicy c = new KursusPolicy(ID);

            c.CompanyID = CompanyID;
            if (Status == KursusStatusEnum.Initialize)
            {
                Status = KursusStatusEnum.Aktiv;
            }
            c.Status              = Status;
            c.FirstAidTitle       = FirstAidTitle;
            c.FirstAidAftale      = FirstAidAftale;
            c.FirstAidLeverandor  = FirstAidLeverandor;
            c.FirstAidKursusType  = FirstAidKursusType;
            c.FirstAidAdminAftale = FirstAidAdminAftale;
            c.FirstAidRepetition  = FirstAidRepetition;
            c.FirstAidMedarbInfo  = System.Convert.ToString(FirstAidMedarbInfo);

            return(Update(c));
        }
        //SELECT [ID]
        //      ,[companyID]
        //      ,[status]
        //      ,[FirstAidTitle]
        //      ,[FirstAidAftale]
        //      ,[FirstAidAftaleText]
        //      ,[FirstAidLeverandor]
        //      ,[FirstAidLeverandorText]
        //      ,[FirstAidKursusType]
        //      ,[FirstAidKursusTypeText]
        //      ,[FirstAidAdminAftale]
        //      ,[FirstAidAdminAftaleText]
        //      ,[FirstAidRepetition]
        //      ,[FirstAidRepetitionText]
        //      ,[FirstAidMedarbInfo]
        //  FROM [vicjos1_Heart2Start].[vicjos1_sysadm].[vw_Co2Db_KursusPolicy]

        private static void Populate(SqlDataReader dr, KursusPolicy c)
        {
            PopulateStandard(dr, c);
            var with_1 = c;

            with_1.CompanyID                = System.Convert.ToInt32(dr.DBtoInt("CompanyID"));
            with_1.Status                   = (RescueTekniq.BOL.KursusStatusEnum)(dr.DBtoInt("Status"));
            with_1.FirstAidTitle            = dr.DBtoString("FirstAidTitle");
            with_1.FirstAidAftale           = System.Convert.ToInt32(dr.DBtoInt("FirstAidAftale"));
            with_1._FirstAidAftaleText      = dr.DBtoString("FirstAidAftaleText");
            with_1.FirstAidLeverandor       = System.Convert.ToInt32(dr.DBtoInt("FirstAidLeverandor"));
            with_1._FirstAidLeverandorText  = dr.DBtoString("FirstAidLeverandorText");
            with_1.FirstAidKursusType       = System.Convert.ToInt32(dr.DBtoInt("FirstAidKursusType"));
            with_1._FirstAidKursusTypeText  = dr.DBtoString("FirstAidKursusTypeText");
            with_1.FirstAidAdminAftale      = System.Convert.ToInt32(dr.DBtoInt("FirstAidAdminAftale"));
            with_1._FirstAidAdminAftaleText = dr.DBtoString("FirstAidAdminAftaleText");
            with_1.FirstAidRepetition       = System.Convert.ToInt32(dr.DBtoInt("FirstAidRepetition"));
            with_1._FirstAidRepetitionText  = dr.DBtoString("FirstAidRepetitionText");
            with_1.FirstAidMedarbInfo       = dr.DBtoString("FirstAidMedarbInfo");
        }
        public static System.Collections.Generic.List <KursusPolicy> Search_KursusPolicyList(string search, KursusStatusEnum status, int CompanyID)
        {
            System.Collections.Generic.List <KursusPolicy> result = new System.Collections.Generic.List <KursusPolicy>();
            int      ID     = -1;
            DBAccess db     = new DBAccess();
            DataSet  ds     = new DataSet();
            DataSet  dsTemp = new DataSet();
            bool     flag   = false;

            db.AddInt("CompanyID", CompanyID);

            string[] arr = search.Split(' ');
            foreach (string s in arr)
            {
                db.AddNVarChar("Search", s, 250);
                db.AddInt("Status", System.Convert.ToInt32(status));
                db.AddInt("CompanyID", CompanyID);

                dsTemp = db.ExecuteDataSet(_SQLSelectIDBySearch);
                db.Parameters.Clear();
                //If dsTemp.Tables.Count > 0 Then
                ds.Merge(dsTemp);
                if (flag == false)
                {
                    DataColumn[] pk = new DataColumn[2];
                    pk[0] = ds.Tables[0].Columns["ID"];
                    ds.Tables[0].PrimaryKey = pk;
                    flag = true;
                }
                //End If
            }

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                ID = System.Convert.ToInt32(row["ID"]);
                result.Add(KursusPolicy.GetKursusPolicy(ID));
            }

            return(result);
        }
        public static KursusPolicy GetKursusPolicy(string Title)
        {
            DBAccess     db = new DBAccess();
            KursusPolicy c  = new KursusPolicy();

            db.AddInt("Title", System.Convert.ToInt32(Title));
            try
            {
                SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectByTitle));
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Populate(dr, c);
                    }
                }
                dr.Close();
            }
            catch (Exception)
            {
            }
            return(c);
        }
        public static KursusPolicy GetKursusPolicy(int ID)
        {
            DBAccess db = new DBAccess();

            db.AddInt("ID", ID);
            KursusPolicy c = new KursusPolicy();

            try
            {
                SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectOne));
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Populate(dr, c);
                    }
                    dr.Close();
                }
            }
            catch (Exception)
            {
            }
            return(c);
        }
 public static int Delete(KursusPolicy c)
 {
     return(Delete(c.ID));
 }