/*LLENAR COMBO TRAER VOTACIONES CREADAS*/ public List <TB_Votation> getVotesCreated(OleDbConnection db) { DataSet ds = new DataSet(); try { OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM TB_Votation WHERE Status = 1", db); da.Fill(ds); db.Close(); DataTable dt = ds.Tables[0]; foreach (DataRow rows in dt.Rows) { TB_Votation _votation = new TB_Votation( int.Parse(rows["Id"].ToString()), rows["Users"].ToString(), rows["Title"].ToString(), int.Parse(rows["Status"].ToString()), rows["Type"].ToString(), Boolean.Parse(rows["Diapositive"].ToString()), int.Parse(rows["NDiapositive"].ToString()), int.Parse(rows["UserId"].ToString())); lstVotation.Add(_votation); } } catch (Exception) { throw; } return(lstVotation); }
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")); } }
public JsonResult OpenVotation(TB_Votation votation) { //TB_User user = (TB_User) Session["User"]; votation.userId = 1 /*user.id*/; tb_Votation = TB_vota.openVotation(votation, DBConnect.open()); Session["Votation"] = tb_Votation; return(Json(tb_Votation)); }
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)); }
public string changeStatusVotation(OleDbConnection db, TB_Votation v) { string result = ""; try { String sql = @"UPDATE TB_Votation SET Status =" + v.status + " WHERE Id = " + v.id; OleDbCommand cmd = new OleDbCommand(sql, db); cmd.ExecuteNonQuery(); db.Close(); result = "VOTACIÒN ACTUALIZADA "; } catch (Exception e) { result = e.Message; db.Close(); throw; } return(result); }
public TB_Votation openVotation(TB_Votation v, OleDbConnection db) { string result = ""; TB_Votation _Votation; try { string sql = @"INSERT INTO TB_Votation(Users,Title,Status,Type,Diapositive,NDiapositive,UserId) VALUES (" + v.users + ",'" + v.title + "'," + v.status + ",'" + v.type + "'," + v.diapositive + "," + v.ndiapositive + "," + v.userId + ")"; OleDbCommand cmd = new OleDbCommand(sql, db); cmd.ExecuteNonQuery(); db.Close(); result = "VOTACIÒN INICIADA"; _Votation = new TB_Votation(v.id, v.users, v.title, v.status, v.type, v.diapositive, v.ndiapositive, v.userId); } catch (Exception e) { result = e.Message; db.Close(); throw; } return(_Votation); }
public int setVotationUserId() { TB_Votation _Votation = new TB_Votation(); return(_Votation.setUserId(this.id)); }
public string changeStatusVotation(OleDbConnection db, TB_Votation v) { return(_Votation.changeStatusVotation(db, v)); }
public TB_Votation openVotation(TB_Votation votation, OleDbConnection db) { return(_Votation.openVotation(votation, db)); }