Beispiel #1
0
        public List<Schoolsc> GetListSchools()
        {
            List<Schoolsc> list = new List<Schoolsc>();
            Schoolsc ins;

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

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM Schools ", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new Schoolsc();
                    ins.SchoolId = Convert.ToInt32(drI["SchoolId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.SchoolName = drI["SchoolName"].ToString();
                    ins.Schoolabbreviation = drI["Schoolabbreviation"].ToString();
                    ins.PictureId = Convert.ToInt32(drI["PictureId"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            return list;
        }
Beispiel #2
0
        public List<Schoolsc> GetListSchools(int ClientId)
        {
            List<Schoolsc> list = new List<Schoolsc>();
            Schoolsc ins;

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

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * from Schools WHERE ClientId = " + ClientId + " ORDER BY SchoolId DESC", con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins = new Schoolsc();
                    ins.SchoolId = Convert.ToInt32(drI["SchoolId"]);
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.SchoolName = drI["SchoolName"].ToString();
                    ins.Schoolabbreviation = drI["Schoolabbreviation"].ToString();
                    ins.PictureId = Convert.ToInt32(drI["PictureId"]);
                    list.Add(ins);
                }
            }
            drI.Close();
            con.Close();

            PictureRepository picRep = new PictureRepository();

            foreach (Schoolsc item in list)
            {
                if (item.PictureId != 0)
                {
                    item.PicUrl = picRep.GetPicture(item.PictureId).PicUrl;
                    /*if (item.PicUrl.Contains("\\Images\\"))
                    {
                        string path = item.PicUrl.Substring(item.PicUrl.IndexOf("\\Images\\"));
                        path = path.Replace('\\', '/');
                        item.PicUrl = "http://www.netintercom.co.za" + path;
                    }*/
                }
            }

            return list;
        }
Beispiel #3
0
        public ActionResult _UpdateSchools(Schoolsc ins)
        {
            //...ViewData...
            ins.ClientId = Convert.ToInt32(HttpContext.Session["ClientId"]);
            Schoolsc ins2 = SchRep.UpdateSchools(ins);
            //...Notify...
            string regIds = AppRep.GetAllRegIds(ins.ClientId);
            if (!regIds.Equals(""))
            {
                comrep.NewUpdateData(regIds, "CMD_EDITSchools", ins2.SchoolId.ToString());
            }

            //...Repopulate Grid...
            List<Schoolsc> lst = new List<Schoolsc>();
            lst = SchRep.GetListSchools(Convert.ToInt32(HttpContext.Session["ClientId"]));
            return View(new GridModel(lst));
        }
Beispiel #4
0
        public ActionResult _InsertSchools(Schoolsc ins)
        {
            ins.ClientId = Convert.ToInt32(HttpContext.Session["ClientId"]);

            //...Insert into Database...
            Schoolsc ins2 = SchRep.InsertSchools(ins);
            //...Notify...
            string regIds = AppRep.GetAllRegIds(ins.ClientId);
            List<string> reg = AppRep.GetAllRegIdsList(ins.ClientId);
            if (!regIds.Equals(""))
            {
                comrep.NewsyncData(regIds, "CMD_NEWSchools", reg, ins.ClientId);
            }

            //...Facebook...
            string access_token = FacebookPost.GetAccessToken(ins.ClientId);

            if (!access_token.Equals(""))
            {
                string page_id = FacebookPost.GetPageId(ins.ClientId);
                if (!page_id.Equals(""))
                {
                    FacebookPost.Post(access_token, page_id, "Schools Update: " + ins.SchoolName);
                }
            }
            //...Repopulate Grid...
            List<Schoolsc> lst = new List<Schoolsc>();
            lst = SchRep.GetListSchools(Convert.ToInt32(HttpContext.Session["ClientId"]));
            return View(new GridModel(lst));
        }
Beispiel #5
0
        public Schoolsc UpdateSchools(Schoolsc ins)
        {
            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();
            SqlCommand cmdI = con.CreateCommand();
            cmdI.Connection = con;

            //...Update Picture...

            //...Update Record...
            cmdI.Parameters.Clear();
            cmdI.CommandText = "f_Admin_Update_Schools";
            cmdI.CommandType = System.Data.CommandType.StoredProcedure;
            cmdI.Parameters.AddWithValue("@SchoolId", ins.SchoolId);
            cmdI.Parameters.AddWithValue("@SchoolName", ins.SchoolName);
            cmdI.Parameters.AddWithValue("@Schoolabbreviation", ins.Schoolabbreviation);
            cmdI.Parameters.AddWithValue("@PictureID", ins.PictureId);
            cmdI.ExecuteNonQuery();
            cmdI.Connection.Close();

            return ins;
        }
Beispiel #6
0
        public Schoolsc InsertSchools(Schoolsc ins)
        {
            //...Get User and Date Data...
            string strTrx = "Insert_Schools";

            //...Database Connection...
            DataBaseConnection dbConn = new DataBaseConnection();
            SqlConnection con = dbConn.SqlConn();
            con.Open();

            //...Command Interface...
            SqlCommand cmdI = con.CreateCommand();
            SqlTransaction trx;
            trx = con.BeginTransaction(strTrx);
            cmdI.Connection = con;
            cmdI.Transaction = trx;

            try
            {
                //...Insert Picture...

                //...Insert Record...
                cmdI.Parameters.Clear();
                cmdI.CommandText = "f_Admin_Insert_Schools";
                //cmdI.Connection.Open();
                cmdI.CommandType = System.Data.CommandType.StoredProcedure;
                cmdI.Parameters.AddWithValue("@ClientId", ins.ClientId);
                cmdI.Parameters.AddWithValue("@SchoolName", ins.SchoolName);
                cmdI.Parameters.AddWithValue("@Schoolabbreviation", ins.Schoolabbreviation);
                cmdI.Parameters.AddWithValue("@PictureID", ins.PictureId);

                //...Return new ID...
                ins.SchoolId = (int)cmdI.ExecuteScalar();

                //...Commit Transaction...
                trx.Commit();
                cmdI.Connection.Close();
            }
            catch (SqlException ex)
            {
                if (trx != null) trx.Rollback();
                //...Save Error to Log...
                Functions func = new Functions();
                func.LogError(ex.ToString());
            }
            finally
            {
                //...Check for close and respond accordingly..
                if (con.State != ConnectionState.Closed)
                {
                    con.Close();
                }

                //...Clean up...
                con.Dispose();
                cmdI.Dispose();
                trx.Dispose();
            }

            return ins;
        }
Beispiel #7
0
        public Schoolsc GetSchools(int SchoolsId)
        {
            Schoolsc ins = new Schoolsc();

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

            //...SQL Commands...
            cmdI = new SqlCommand("SELECT * FROM Schools WHERE SchoolId =" + SchoolsId, con);
            cmdI.Connection.Open();
            SqlDataReader drI = cmdI.ExecuteReader();

            //...Retrieve Data...
            if (drI.HasRows)
            {
                while (drI.Read())
                {
                    ins.SchoolId = Convert.ToInt32(drI["SchoolId"]);
                    ins.SchoolName = drI["SchoolName"].ToString();
                    ins.Schoolabbreviation = drI["Schoolabbreviation"].ToString();
                    ins.ClientId = Convert.ToInt32(drI["ClientId"]);
                    ins.PictureId = Convert.ToInt32(drI["PictureId"]);

                }
            }
            drI.Close();
            con.Close();

            return ins;
        }