public DataSet Opr_ProgrammeLevel_Ch_CloseDT(mSCFDatesSave _obj)
 {
     try
     {
         _cn.Open();
         SqlCommand _cmd = new SqlCommand("Opr_ProgrammeLevel_Ch_CloseDT", _cn);
         _cmd.Parameters.AddWithValue("@Type", _obj.Type);
         if (_obj.UG_ClosingDate == null || _obj.UG_ClosingDate.Equals(""))
         {
             _cmd.Parameters.AddWithValue("@UG_ClosingDate", DBNull.Value);
         }
         else
         {
             _cmd.Parameters.AddWithValue("@UG_ClosingDate", DateTime.ParseExact(_obj.UG_ClosingDate.ToString(), "yyyy-MM-dd HH-mm-ss", null));
         }
         if (_obj.UG_ApproveReject_StartDate == null || _obj.UG_ApproveReject_StartDate.Equals(""))
         {
             _cmd.Parameters.AddWithValue("@UG_ApproveReject_StartDate", DBNull.Value);
         }
         else
         {
             _cmd.Parameters.AddWithValue("@UG_ApproveReject_StartDate", DateTime.ParseExact(_obj.UG_ApproveReject_StartDate.ToString(), "yyyy-MM-dd HH-mm-ss", null));
         }
         if (_obj.UG_ApproveReject_EndDate == null || _obj.UG_ApproveReject_EndDate.Equals(""))
         {
             _cmd.Parameters.AddWithValue("@UG_ApproveReject_EndDate", DBNull.Value);
         }
         else
         {
             _cmd.Parameters.AddWithValue("@UG_ApproveReject_EndDate", DateTime.ParseExact(_obj.UG_ApproveReject_EndDate.ToString(), "yyyy-MM-dd HH-mm-ss", null));
         }
         if (_obj.PG_ClosingDate == null || _obj.PG_ClosingDate.Equals(""))
         {
             _cmd.Parameters.AddWithValue("@PG_ClosingDate", DBNull.Value);
         }
         else
         {
             _cmd.Parameters.AddWithValue("@PG_ClosingDate", DateTime.ParseExact(_obj.PG_ClosingDate.ToString(), "yyyy-MM-dd HH-mm-ss", null));
         }
         if (_obj.PG_ApproveReject_StartDate == null || _obj.PG_ApproveReject_StartDate.Equals(""))
         {
             _cmd.Parameters.AddWithValue("@PG_ApproveReject_StartDate", DBNull.Value);
         }
         else
         {
             _cmd.Parameters.AddWithValue("@PG_ApproveReject_StartDate", DateTime.ParseExact(_obj.PG_ApproveReject_StartDate.ToString(), "yyyy-MM-dd HH-mm-ss", null));
         }
         if (_obj.PG_ApproveReject_EndDate == null || _obj.PG_ApproveReject_EndDate.Equals(""))
         {
             _cmd.Parameters.AddWithValue("@PG_ApproveReject_EndDate", DBNull.Value);
         }
         else
         {
             _cmd.Parameters.AddWithValue("@PG_ApproveReject_EndDate", DateTime.ParseExact(_obj.PG_ApproveReject_EndDate.ToString(), "yyyy-MM-dd HH-mm-ss", null));
         }
         if (_obj.PhD_ClosingDate == null || _obj.PhD_ClosingDate.Equals(""))
         {
             _cmd.Parameters.AddWithValue("@PhD_ClosingDate", DBNull.Value);
         }
         else
         {
             _cmd.Parameters.AddWithValue("@PhD_ClosingDate", DateTime.ParseExact(_obj.PhD_ClosingDate.ToString(), "yyyy-MM-dd HH-mm-ss", null));
         }
         if (_obj.PhD_ApproveReject_StartDate == null || _obj.PhD_ApproveReject_StartDate.Equals(""))
         {
             _cmd.Parameters.AddWithValue("@PhD_ApproveReject_StartDate", DBNull.Value);
         }
         else
         {
             _cmd.Parameters.AddWithValue("@PhD_ApproveReject_StartDate", DateTime.ParseExact(_obj.PhD_ApproveReject_StartDate.ToString(), "yyyy-MM-dd HH-mm-ss", null));
         }
         if (_obj.PhD_ApproveReject_EndDate == null || _obj.PhD_ApproveReject_EndDate.Equals(""))
         {
             _cmd.Parameters.AddWithValue("@PhD_ApproveReject_EndDate", DBNull.Value);
         }
         else
         {
             _cmd.Parameters.AddWithValue("@PhD_ApproveReject_EndDate", DateTime.ParseExact(_obj.PhD_ApproveReject_EndDate.ToString(), "yyyy-MM-dd HH-mm-ss", null));
         }
         _cmd.CommandType    = CommandType.StoredProcedure;
         _cmd.CommandTimeout = 300;
         SqlDataAdapter _adp = new SqlDataAdapter(_cmd);
         DataSet        _ds  = new DataSet();
         _adp.Fill(_ds);
         _adp.Dispose();
         _cmd.Dispose();
         return(_ds);
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         _cn.Close();
     }
 }
Beispiel #2
0
        public JsonResult SaveData(mSCFDatesSave _obj)
        {
            string Code = string.Empty, Message = string.Empty, Error = string.Empty;

            try
            {
                SCFRepository _objRepo = new SCFRepository();
                _obj.Type = "Update";

                #region Change Config File Data
                Configuration configFile = null;
                if (System.Web.HttpContext.Current != null)
                {
                    configFile = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
                }
                else
                {
                    configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                }
                var settings = configFile.AppSettings.Settings;
                if (settings["StudentChoiceFillingDateTime"] == null)
                {
                    settings.Add("StudentChoiceFillingDateTime", _obj.StudentChoiceFillingDateTime);
                }
                else
                {
                    settings["StudentChoiceFillingDateTime"].Value = _obj.StudentChoiceFillingDateTime;
                }
                configFile.Save(ConfigurationSaveMode.Modified);
                ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name);
                #endregion
                DataSet _ds = _objRepo.Opr_ProgrammeLevel_Ch_CloseDT(_obj);
                if (_ds != null)
                {
                    if (_ds.Tables[0].Rows.Count > 0)
                    {
                        Code    = "success";
                        Message = "Dates have been updated.";
                    }
                }
            }
            catch (NullReferenceException ex)
            {
                Code    = "error";
                Message = "Your session has been expired. Kindly refresh and try again.";
                Error   = ex.Message;
            }
            catch (Exception ex)
            {
                Code    = "error";
                Message = "Error from server side. Kindly refresh and try again.";
                Error   = ex.Message;
            }
            return(Json(new
            {
                c = Code,
                m = Message,
                e = Error
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }