Example #1
0
 public DataSet INSERT_UPDATE_tbl_contest_Doc_Upload(mContest _obj, string Docs)
 {
     try
     {
         _cn.Open();
         SqlCommand _cmd = new SqlCommand("INSERT_UPDATE_tbl_contest_Doc_Upload", _cn);
         _cmd.Parameters.AddWithValue("@Name", _obj.Name);
         _cmd.Parameters.AddWithValue("@Institute", _obj.Institute);
         _cmd.Parameters.AddWithValue("@Email", _obj.Email);
         _cmd.Parameters.AddWithValue("@Mobile", _obj.Mobile);
         _cmd.Parameters.AddWithValue("@Country", _obj.Country);
         _cmd.Parameters.AddWithValue("@ProgramLevels", _obj.ProgramLevels);
         _cmd.Parameters.AddWithValue("@mCourseOfStudy", _obj.mCourseOfStudy);
         _cmd.Parameters.AddWithValue("@CourseOther", _obj.CourseOther);
         _cmd.Parameters.AddWithValue("@Docs", Docs);
         _cmd.Parameters.AddWithValue("@CreatedIP", _obj.CreatedIP);
         _cmd.CommandType = CommandType.StoredProcedure;
         SqlDataAdapter _adp = new SqlDataAdapter(_cmd);
         DataSet        _ds  = new DataSet();
         _adp.Fill(_ds);
         _adp.Dispose();
         _cmd.Dispose();
         return(_ds);
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _cn.Close();
     }
 }
Example #2
0
 public DataSet SELECT_tbl_contest_details(mContest _obj)
 {
     try
     {
         _cn.Open();
         SqlCommand _cmd = new SqlCommand("SELECT_tbl_contest_details", _cn);
         _cmd.Parameters.AddWithValue("@Email", _obj.Email);
         _cmd.Parameters.AddWithValue("@Mobile", _obj.Mobile);
         _cmd.Parameters.AddWithValue("@CreatedIP", _obj.CreatedIP);
         _cmd.CommandType = CommandType.StoredProcedure;
         SqlDataAdapter _adp = new SqlDataAdapter(_cmd);
         DataSet        _ds  = new DataSet();
         _adp.Fill(_ds);
         _adp.Dispose();
         _cmd.Dispose();
         return(_ds);
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _cn.Close();
     }
 }
Example #3
0
        public JsonResult SaveUploadDocs(mContest _obj, string Docs = "")
        {
            string Message = string.Empty, Code = string.Empty;

            try
            {
                if (ModelState.IsValid)
                {
                    RContest _objRepository = new RContest();
                    _obj.CreatedIP = Request.ServerVariables["REMOTE_ADDR"].ToString();
                    DataSet _ds = _objRepository.INSERT_UPDATE_tbl_contest_Doc_Upload(_obj, Docs);
                    if (_ds != null)
                    {
                        if (_ds.Tables[0].Rows[0]["Counts"].ToString() == "1")
                        {
                            Message = "Documents have been uploaded!";
                            Code    = "success";
                        }
                        else if (_ds.Tables[0].Rows[0]["Counts"].ToString() == "2")
                        {
                            Message = "You have already submitted your entry.";
                            Code    = "alreadyexists";
                        }
                        else
                        {
                            Message = "Error from server side. Kindly refresh the page and try again.";
                            Code    = "servererror";
                        }
                    }
                }
            }
            catch (NullReferenceException)
            {
                Message = "Your session has been expired. Kindly login again.";
                Code    = "sessionexpired";
            }
            catch (Exception)
            {
                Message = "Error from server side. Kindly refresh the page and try again.";
                Code    = "servererror";
            }
            return(Json(new
            {
                m = Message,
                c = Code
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }
Example #4
0
        public JsonResult CheckDtl(mContest _obj)
        {
            string Code = string.Empty, Message = string.Empty;

            try
            {
                RContest _objRepository = new RContest();
                _obj.CreatedIP = Request.ServerVariables["REMOTE_ADDR"].ToString();
                DataSet _ds = _objRepository.SELECT_tbl_contest_details(_obj);
                if (_ds != null)
                {
                    if (_ds.Tables[0].Rows[0]["Counts"].ToString() == "0")
                    {
                        Code    = "success";
                        Message = "Basic Details have been saved succefully.";
                    }
                    else
                    {
                        Code    = "alreadyexists";
                        Message = "You have already submitted your entry.";
                    }
                }
            }
            catch (NullReferenceException)
            {
                Code    = "error";
                Message = "Your session has been expired. Kindly refresh and try again.";
            }
            catch (Exception)
            {
                Code    = "error";
                Message = "Error from server side. Kindly refresh and try again.";
            }
            return(Json(new
            {
                c = Code,
                m = Message
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }
Example #5
0
        public JsonResult UploadDocs(string id = "", string name = "", string Mobile = "")
        {
            mContest _obj = new mContest();
            string   Message = string.Empty, Code = string.Empty;

            try
            {
                string   path          = "";
                string   filename      = "";
                string   fname         = "";
                string   fileType      = "";
                string[] fileExtension = null;
                int      MaxContentLength;
                string   MaxContentLengthMsg = "";
                if (Request.Files.Count > 0)
                {
                    if (Request.Files[0].ContentLength > 0)
                    {
                        if (id == "TestimonialVideo")
                        {
                            fileExtension    = new[] { ".avi", ".mpeg4", ".mov", ".wmv", ".mp4", ".3gpp" };
                            MaxContentLength = 1073741824; MaxContentLengthMsg = "1 GB";
                        }
                        else
                        {
                            fileExtension    = new[] { ".pdf", ".jpeg", ".jpg" };
                            MaxContentLength = 26214400; MaxContentLengthMsg = "25 MB";
                        }
                        HttpFileCollectionBase files = Request.Files;
                        path     = AppDomain.CurrentDomain.BaseDirectory + "Uploads/Contest/" + Mobile + "/";
                        filename = Path.GetFileName(Request.Files[0].FileName);
                        HttpPostedFileBase file = files[0];
                        var checkextension      = Path.GetExtension(file.FileName).ToLower();
                        if (fileExtension.Contains(checkextension))
                        {
                            if (MaxContentLength >= file.ContentLength)
                            {
                                filename = Mobile + "_" + id + Path.GetExtension(file.FileName);
                                if (!Directory.Exists(path))
                                {
                                    Directory.CreateDirectory(path);
                                }
                                else
                                {
                                    string[] curentfiles = Directory.GetFiles(path);
                                    foreach (string curentfile in curentfiles)
                                    {
                                        if (curentfile.IndexOf(filename) >= 0)
                                        {
                                            //System.IO.File.Delete(curentfile);
                                        }
                                    }
                                }

                                fname = Path.Combine(Server.MapPath("~/Uploads/Contest/" + Mobile + "/"), filename);
                                file.SaveAs(fname);
                                _obj.Path = "Uploads/Contest/" + Mobile + "/" + filename;
                            }
                            else
                            {
                                _obj.Path = "";
                                fileType  = "INVALIDSIZE";
                            }
                        }
                        else
                        {
                            _obj.Path = "";
                            fileType  = "INVALIDEX";
                        }
                    }
                    else
                    {
                        _obj.Path = "";
                    }
                }
                else
                {
                    _obj.Path = "";
                }
                if (_obj.Path != "")
                {
                    Message = "Document uploaded successfully!";
                    Code    = "success";
                }
                else if (_obj.Path == "" && fileType == "INVALIDEX")
                {
                    Code    = "fileExtension";
                    Message = "Only formats are allowed :" + String.Join(",", fileExtension);
                }
                else if (_obj.Path == "" && fileType == "INVALIDSIZE")
                {
                    Code    = "fileExtension";
                    Message = "Maximum allowed file size : " + MaxContentLengthMsg.ToString();
                }
                else
                {
                    Message = "Error from server side. Kindly refresh the page and try again.";
                    Code    = "servererror";
                }
            }
            catch (NullReferenceException)
            {
                Message = "Your session has been expired. Kindly login again.";
                Code    = "sessionexpired";
            }
            catch (Exception)
            {
                Message = "Error from server side. Kindly refresh the page and try again.";
                Code    = "servererror";
            }

            return(Json(new
            {
                m = Message,
                c = Code,
                p = _obj.Path
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }