public ActionResult UploadImage()
        {
            string file = Request.Files.AllKeys[0].ToString();

            if (Request.Files.Count > 0)
            {
                try
                {
                    HttpPostedFileBase fbase    = Request.Files[0];
                    string             path     = Path.Combine(HttpRuntime.AppDomainAppPath, "Resource\\");
                    string             fullpath = Path.Combine(path, file);
                    if (fbase != null && fbase.ContentLength > 0)
                    {
                        fbase.SaveAs(fullpath);
                        TB_Votation_Graphic _Graphic = new TB_Votation_Graphic();
                        _Graphic.VotationId = int.Parse(Request.Form[0].ToString());
                        _Graphic.GraphicId  = int.Parse(Request.Form[1].ToString());
                        _Graphic.ImageG     = file;
                        _Graphic.width      = int.Parse(Request.Form[2].ToString());
                        _Graphic.height     = int.Parse(Request.Form[3].ToString());
                        TB_vota.addGraphic(_Graphic, DBConnect.open());
                        return(Json("Gràfico insertado correctamente"));
                    }
                }
                catch (System.Exception)
                {
                    throw;
                }
            }

            return(Json(""));
        }
Exemple #2
0
        public string insertGraphic(TB_Votation_Graphic tvg, OleDbConnection db)
        {
            string result = "";

            try
            {
                string       sql = @"INSERT INTO TB_Votation_Graphic(VotationId,GraphicId,ImageG,Width,Heigth,Transparent) VALUES (" + tvg.VotationId + "," + tvg.GraphicId + ",'" + tvg.ImageG + "'," + tvg.width + "," + tvg.height + "," + tvg.transparent + ")";
                OleDbCommand cmd = new OleDbCommand(sql, db);
                cmd.ExecuteNonQuery();
                db.Close();
                result = "VOTACIÒN INICIADA";
            }
            catch (Exception)
            {
                throw;
            }


            return(result);
        }
Exemple #3
0
 public string addGraphic(TB_Votation_Graphic tvg, OleDbConnection db)
 {
     return(_Votation.insertGraphic(tvg, db));
 }