Esempio n. 1
0
 public DataSet INSERT_UPDATE_CourseOfStudy(mCourseOfStudy _obj)
 {
     try
     {
         _cn.Open();
         SqlCommand _cmd = new SqlCommand("INSERT_UPDATE_CourseOfStudy", _cn);
         _cmd.Parameters.AddWithValue("@CourseOfStudy_ID", _obj.CourseOfStudy_ID);
         _cmd.Parameters.AddWithValue("@CourseOfStudy", _obj.CourseOfStudy);
         _cmd.Parameters.AddWithValue("@IsNicheCourse", _obj.IsNicheCourse);
         _cmd.CommandTimeout = 300;
         _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();
     }
 }
        public JsonResult SaveData(mCourseOfStudy _obj)
        {
            string Code = string.Empty, Message = string.Empty;

            try
            {
                CourseOfStudy_Repository _objRepo = new CourseOfStudy_Repository();
                DataSet _ds = _objRepo.INSERT_UPDATE_CourseOfStudy(_obj);
                if (_ds != null)
                {
                    if (_ds.Tables[0].Rows.Count > 0)
                    {
                        DataRow _dr = _ds.Tables[0].Rows[0];
                        if (_dr["COUNTS"].ToString() == "1")
                        {
                            Code    = "success";
                            Message = "Data saved successfully";
                        }
                        else if (_dr["COUNTS"].ToString() == "2")
                        {
                            Code    = "success";
                            Message = "Data updated successfully";
                        }
                        else if (_dr["COUNTS"].ToString() == "-1")
                        {
                            Code    = "already";
                            Message = "Data is already exists";
                        }
                        else
                        {
                            Code    = "error";
                            Message = "No data saved. Kindly try again.";
                        }
                    }
                }
            }
            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
                        ));
        }
Esempio n. 3
0
        public void selectDropdown()
        {
            StudentRepository     _objNationality = new StudentRepository();
            DataSet               ds             = _objNationality.select_form_load_student();
            List <ProgramLevels>  _ProgramLevels = new List <ProgramLevels>();
            List <Country>        _Country       = new List <Country>();
            List <mCourseOfStudy> _Course        = new List <mCourseOfStudy>();

            if (ds != null)
            {
                if (ds.Tables[4].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[4].Rows)
                    {
                        Country _objcountry = new Country();
                        _objcountry.Country_id   = (row["Country_id"].ToString());
                        _objcountry.Country_Name = row["Country_Name"].ToString();
                        _objcountry.country_code = row["country_code"].ToString();
                        _Country.Add(_objcountry);
                    }
                }
                if (ds.Tables[5].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[5].Rows)
                    {
                        ProgramLevels _objpro = new ProgramLevels();
                        _objpro.ProgramLevel_Id = (row["ProgramLevel_Id"].ToString());
                        _objpro.ProgramLevel    = row["ProgramLevel"].ToString();
                        _ProgramLevels.Add(_objpro);
                    }
                }
                if (ds.Tables[6].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[6].Rows)
                    {
                        mCourseOfStudy _objpro = new mCourseOfStudy();
                        _objpro.CourseOfStudy_ID = (row["CourseOfStudy_ID"].ToString());
                        _objpro.CourseOfStudy    = row["CourseOfStudy"].ToString();
                        _Course.Add(_objpro);
                    }
                    _Course.Add(new mCourseOfStudy {
                        CourseOfStudy_ID = "0", CourseOfStudy = "Other"
                    });
                }
            }
            ViewBag.ProgramLevels = _ProgramLevels;
            ViewBag.Country       = _Country;
            ViewBag.Course        = _Course;
        }