public ActionResult ApplicationForm(application_form model)
        {
            var dbs = Database.Open("sqlConnection");

            ViewBag.StateName = dropdown(null);
            string newCommand = "SELECT count(*) FROM application_form WHERE userid='" + User.Identity.Name + "'";

            ViewBag.status = newCommand;
            int val = dbs.QueryValue(newCommand);

            if (val == 1)
            {
                ModelState.AddModelError("", "You have already submitted the Application Form, If You fill again previous details will be replaced.");
                return(View(model));
            }



            return(View());
        }
        public ActionResult ApplicationForm(application_form model, FormCollection form)
        {
            string value = form["States"];

            ViewBag.StateName = dropdown(value.Split(','));
            try
            {
                var      dbs = Database.Open("sqlConnection");
                string[] content;
                content     = new string[19];
                content[0]  = model.fname;
                content[1]  = model.mname;
                content[2]  = model.lname;
                content[3]  = model.fatname;
                content[4]  = model.Maaname;
                content[5]  = form["Gender"];
                content[6]  = model.calender;
                content[7]  = form["Religion"];
                content[8]  = form["MT"];
                content[9]  = model.add1;
                content[10] = model.add2;
                content[11] = model.add3;
                content[12] = value;
                content[13] = form["District"];
                content[14] = form["Taluka"];
                content[15] = model.pinCode;
                content[16] = model.mob;
                content[17] = User.Identity.Name;
                content[18] = form["Category"];
                string join = null;
                for (int i = 0; i < content.Length - 1; i++)
                {
                    join = join + "'" + content[i] + "'" + ",";
                }
                // ViewBag.status = join;
                string newCommand = "SELECT count(*) FROM application_form WHERE userid='" + content[17] + "'";
                ViewBag.status = newCommand;
                int val = dbs.QueryValue(newCommand);
                if (val == 1)
                {
                    var newmodel = new application_form
                    {
                        fname    = dbs.QueryValue("SELECT fname FROM application_form WHERE userid='" + content[17] + "'"),
                        mname    = dbs.QueryValue("SELECT mname FROM application_form WHERE userid='" + content[17] + "'"),
                        lname    = dbs.QueryValue("SELECT lname FROM application_form WHERE userid='" + content[17] + "'"),
                        fatname  = dbs.QueryValue("SELECT faname FROM application_form WHERE userid='" + content[17] + "'"),
                        Maaname  = dbs.QueryValue("SELECT moname FROM application_form WHERE userid='" + content[17] + "'"),
                        gender   = dbs.QueryValue("SELECT gender FROM application_form WHERE userid='" + content[17] + "'"),
                        calender = dbs.QueryValue("SELECT dob FROM application_form WHERE userid='" + content[17] + "'"),
                        religion = dbs.QueryValue("SELECT religion FROM application_form WHERE userid='" + content[17] + "'"),
                        mt       = dbs.QueryValue("SELECT mtounge FROM application_form WHERE userid='" + content[17] + "'"),
                        add1     = dbs.QueryValue("SELECT add1 FROM application_form WHERE userid='" + content[17] + "'"),
                        add2     = dbs.QueryValue("SELECT add2 FROM application_form WHERE userid='" + content[17] + "'"),
                        add3     = dbs.QueryValue("SELECT add3 FROM application_form WHERE userid='" + content[17] + "'"),
                        state    = dbs.QueryValue("SELECT states FROM application_form WHERE userid='" + content[17] + "'"),
                        // = dbs.QueryValue("SELECT district FROM application_form WHERE userid='" + content[17] + "'"),
                        //form["Taluka"] = dbs.QueryValue("SELECT taluka FROM application_form WHERE userid='" + content[17] + "'"),
                        pinCode = dbs.QueryValue("SELECT pincode FROM application_form WHERE userid='" + content[17] + "'"),
                        mob     = dbs.QueryValue("SELECT mobileNo FROM application_form WHERE userid='" + content[17] + "'"),
                    };
                    return(View(newmodel));
                }
                else
                {
                    string command = "insert into application_form values(" + join + "'" + content[18] + "')";//+ "'" + content[16] + "')";
                    dbs.Execute(command);
                    return(RedirectToAction("preferenceCollege"));
                }
                //return RedirectToAction("verifyCertificate");
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message.ToString());
                return(View(model));
            }
        }