Example #1
0
        public List <TB_Vote> ListVote(string type, int id, int qid, OleDbConnection db)
        {
            List <TB_Vote> votes = new List <TB_Vote>();
            DataSet        ds    = new DataSet();

            try
            {
                OleDbDataAdapter da = new OleDbDataAdapter("select * from tb_vote t1 where FHVote=(select " + type + "(FHVote) from tb_vote t2 where t1.userVoteid=t2.userVoteid and t2.Votationid  =" + id + " and t2.QuestionId=" + qid + ")", db);
                da.Fill(ds);
                db.Close();
                DataTable dt = ds.Tables[0];
                foreach (DataRow rows in dt.Rows)
                {
                    TB_Vote vote = new TB_Vote();
                    vote.id         = int.Parse(rows["Id"].ToString());
                    vote.votationid = int.Parse(rows["votationid"].ToString());
                    vote.mac        = rows["MAC"].ToString();
                    vote.userVoteid = int.Parse(rows["userVoteid"].ToString());
                    vote.result     = rows["Result"].ToString();
                    vote.userVoteid = int.Parse(rows["userVoteid"].ToString());
                    vote.datevote   = rows["FHVote"].ToString();
                    votes.Add(vote);
                }
            }
            catch (Exception)
            {
                throw;
            }

            return(votes);
        }
Example #2
0
        public JsonResult CreateVote(TB_Vote v)
        {
            var user = (TB_UserVote)Session["UserVote"];

            int order = lv.getOrderQuestion(DBConnect.open(), user.votationid);

            TB_Votation_Questions _Questions = new TB_Votation_Questions();

            _Questions.votationId = user.votationid;
            _Questions.order      = order;


            TB_Votation_Questions qRequest = lv.getquestions(DBConnect.open(), _Questions);

            Utils u = new Utils();

            v.userVoteid = user.id;
            v.votationid = user.votationid;
            v.mac        = getipUser();
            v.questionid = qRequest.id;
            TB_Vote_Data vdata  = new TB_Vote_Data();
            string       result = vdata.addVote(v, DBConnect.open());

            return(Json(result));
        }
Example #3
0
        public JsonResult DeleteAllQuestion()
        {
            TB_Vote vote = new TB_Vote();

            vote.votationid = int.Parse(Session["votationid"].ToString());
            var request = _Vote.deleteVote(vote, DBConnect.open());

            return(Json(request, JsonRequestBehavior.AllowGet));
        }
Example #4
0
        public string deleteVoteforQuestion(TB_Vote vote, OleDbConnection db)
        {
            string result = "";

            try
            {
                string       sql = @"DELETE FROM TB_Vote WHERE VotationId =" + vote.votationid + " AND QuestionId=" + vote.questionid;
                OleDbCommand cmd = new OleDbCommand(sql, db);
                cmd.ExecuteNonQuery();
                db.Close();
                result = "PREGUNTA REINICIADA";
            }
            catch (Exception)
            {
                throw;
            }


            return(result);
        }
Example #5
0
        public string insertVote(TB_Vote vote, OleDbConnection db)
        {
            string result = "";

            try
            {
                string       sql = @"INSERT INTO TB_Vote(VotationId,MAC,UserVoteId,Result,QuestionId,FHVote) VALUES (" + vote.votationid + ",'" + vote.mac + "'," + vote.userVoteid + ",'" + vote.result + "'," + vote.questionid + ",'" + vote.datevote + "')";
                OleDbCommand cmd = new OleDbCommand(sql, db);
                cmd.ExecuteNonQuery();
                db.Close();
                result = "VOTACIÒN INICIADA";
            }
            catch (Exception)
            {
                throw;
            }


            return(result);
        }
Example #6
0
        public string deleteVote(TB_Vote vote, OleDbConnection db)
        {
            string result = "";

            try
            {
                string       sql = @"DELETE FROM TB_Vote WHERE VotationId =" + vote.votationid;
                OleDbCommand cmd = new OleDbCommand(sql, db);
                cmd.ExecuteNonQuery();

                String       sql2 = @"UPDATE TB_VOTATION_URL SET [Order] = 0 WHERE VotationId = " + vote.votationid;
                OleDbCommand cmd2 = new OleDbCommand(sql2, db);
                cmd2.ExecuteNonQuery();

                db.Close();
                result = "VOTACIÒN REINICIADA";
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
            return(result);
        }
Example #7
0
 public string deleteVote(TB_Vote vote, OleDbConnection db)
 {
     return(_VOTE.deleteVote(vote, db));
 }
Example #8
0
 public string addVote(TB_Vote vote, OleDbConnection db)
 {
     return(_VOTE.insertVote(vote, db));
 }