예제 #1
0
 public DataSet INSERT_UPDATE_tbl_CourseBranch(mCourseOfStudyMapping _obj)
 {
     try
     {
         _cn.Open();
         SqlCommand _cmd = new SqlCommand("INSERT_UPDATE_tbl_CourseBranch", _cn);
         _cmd.Parameters.AddWithValue("@Branch_Id", _obj.Branch_Id);
         _cmd.Parameters.AddWithValue("@Natureofcourse_Id", _obj.Natureofcourse_Id);
         _cmd.Parameters.AddWithValue("@Discipline_ID", _obj.Discipline_ID);
         _cmd.Parameters.AddWithValue("@ProgramLevel_Id", _obj.ProgramLevel_Id);
         _cmd.Parameters.AddWithValue("@Qualification_ID", _obj.Qualification_ID);
         _cmd.Parameters.AddWithValue("@CourseOfStudy_ID", _obj.CourseOfStudy_ID);
         _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 MappingSaveData(mCourseOfStudyMapping _obj)
        {
            string Code = string.Empty, Message = string.Empty;

            try
            {
                CourseOfStudy_Repository _objRepo = new CourseOfStudy_Repository();
                DataSet _ds = _objRepo.INSERT_UPDATE_tbl_CourseBranch(_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
                        ));
        }