コード例 #1
0
        public ActionResult StartVotation(string key)
        {
            if (Session["User"] != null)
            {
                if (key != null)
                {
                    TB_Votation_Data _DATA = new TB_Votation_Data();
                    TB_Votation      v     = new TB_Votation();
                    v.id     = int.Parse(key);
                    v.status = 2;
                    _DATA.changeStatusVotation(DBConnect.open(), v);
                    TB_Votation_URL url = new TB_Votation_URL();

                    if (v.status == 2)
                    {
                        Guid keyg = Guid.NewGuid();
                        url.votationId  = v.id;
                        url.keyVotation = keyg.ToString();
                        url.urlVotation = "";
                        var _URL = _DATA.createURLVotation(url, DBConnect.open());
                        ViewBag.URL        = _URL.keyVotation;
                        ViewBag.UrlGrafico = key;
                    }
                    return(View());
                }
                else
                {
                    return(RedirectToAction("IndexVotation", "Home"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }
        }
コード例 #2
0
        public TB_Votation_URL createURLVotation(TB_Votation_URL url, OleDbConnection db)
        {
            string          result = "";
            TB_Votation_URL urltb  = new TB_Votation_URL();

            try
            {
                string          ifexist  = @"select * from TB_Votation_URL where VotationId = " + url.votationId;
                OleDbCommand    cmdexist = new OleDbCommand(ifexist, db);
                OleDbDataReader dr       = cmdexist.ExecuteReader();

                if (!dr.Read())
                {
                    string       sql = @"INSERT INTO TB_Votation_URL(VotationId,KeyVotation,URLVotation) VALUES (" + url.votationId + ",'" + url.keyVotation + "','" + url.urlVotation + "')";
                    OleDbCommand cmd = new OleDbCommand(sql, db);
                    cmd.ExecuteNonQuery();
                    result = "VOTACIÒN INICIADA";
                    urltb  = url;
                }
                else
                {
                    urltb.keyVotation = dr.GetString(2);
                }
                db.Close();
            }
            catch (Exception e)
            {
                result = e.Message;
                db.Close();
                throw;
            }
            return(urltb);
        }
コード例 #3
0
        public JsonResult SelectQuestionforVotation()
        {
            TB_Votation_URL _URL = new TB_Votation_URL();

            _URL.votationId = int.Parse(Session["votationid"].ToString());
            _URL.order      = int.Parse(Session["order"].ToString());
            _URL.questionid = int.Parse(Session["questionid"].ToString());
            _Data.changeorderVotation(DBConnect.open(), _URL);
            return(Json("Votaciòn Iniciada , pregunta Nª" + _URL.order, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
        public JsonResult StateVotationChange(TB_Votation v)
        {
            TB_vota.changeStatusVotation(DBConnect.open(), v);
            TB_Votation_URL url = new TB_Votation_URL();

            if (v.status == 2)
            {
                Guid key = Guid.NewGuid();
                url.votationId  = v.id;
                url.keyVotation = key.ToString();
                url.urlVotation = "";
                TB_vota.createURLVotation(url, DBConnect.open());
            }
            return(Json(url.keyVotation));
        }
コード例 #5
0
        public string changeorderVotation(OleDbConnection db, TB_Votation_URL u)
        {
            string result = "";

            try
            {
                String       sql = @"UPDATE TB_Votation_URL SET [Order] =" + u.order + ",QuestionId=" + u.questionid + " WHERE VotationId = " + u.votationId;
                OleDbCommand cmd = new OleDbCommand(sql, db);
                cmd.ExecuteNonQuery();
                db.Close();
                result = "VOTACIÒN URL ACTUALIZADA ";
            }
            catch (Exception e)
            {
                result = e.Message;
                db.Close();
                throw;
            }
            return(result);
        }
コード例 #6
0
 public string changeorderVotation(OleDbConnection db, TB_Votation_URL u)
 {
     return(_Votation.changeorderVotation(db, u));
 }
コード例 #7
0
 public TB_Votation_URL createURLVotation(TB_Votation_URL url, OleDbConnection db)
 {
     return(_Votation.createURLVotation(url, db));
 }