コード例 #1
0
        public static string getInsertSubjectValidation(OptionalSubject opSubject)
        {
            string retMsg  = "";
            bool   isValid = true;

            if (!validationBLL.IsNumber(opSubject.ClassID.ToString()))
            {
                isValid = false;
                retMsg  = retMsg + "ClassID is not a Number <br/>";
            }

            if (validationBLL.IsNullOrEmpty(opSubject.ClassID.ToString()))
            {
                isValid = false;
                retMsg  = retMsg + "ClassID is Empty/Null <br/>";
            }

            if (validationBLL.IsNullOrEmpty(opSubject.OptionalSubjectName.Trim().ToString()))
            {
                isValid = false;
                retMsg  = retMsg + "SubjectName is Empty/Null <br/>";
            }

            if (validationBLL.IsNullOrEmpty(opSubject.Current_Session.ToString()))
            {
                isValid = false;
                retMsg  = retMsg + "Current_Session is Empty/Null <br/>";
            }

            if (isValid)
            {
                return("ok");
            }
            return(retMsg);
        }
コード例 #2
0
        public static String insertNewSubject(OptionalSubject opSubject)
        {
            string msg = OpSubVal.getInsertSubjectValidation(opSubject);

            if (msg.ToUpper().Equals("OK"))
            {
                if (optionalSubjectBLL.checkDuplicateSubject(opSubject))
                {
                    msg = "Subject: " + opSubject.OptionalSubjectName.ToString() + " already Exists!!";
                }
                else
                {
                    SqlParameter[] param =
                    {
                        new SqlParameter("@subname",        opSubject.OptionalSubjectName.Trim()),
                        new SqlParameter("@classid",        Convert.ToInt64(opSubject.ClassID)),
                        new SqlParameter("@sessid",         Convert.ToInt32(opSubject.SessionID.ToString() ?? "0")),
                        new SqlParameter("@currentsession", opSubject.Current_Session)
                    };
                    DataSet dss = SqlHelper.ExecuteDataset(SqlHelper.Connect, CommandType.Text, "Insert into OptionalSubjects(OptionalSubjectName,ClassID,SessionID,Current_Session) Values(@subname,@classid,@sessid,@currentsession)", param);
                    msg = "Optional Subject(s) Added Sucessfully!!";
                }
            }
            return(msg);
        }
コード例 #3
0
 public static bool checkDuplicateSubject(OptionalSubject opSubject)
 {
     SqlParameter[] subNames =
     {
         new SqlParameter("@subname", opSubject.OptionalSubjectName.Trim()),
         new SqlParameter("@classid", Convert.ToInt64(opSubject.ClassID))
     };
     if ((int)SqlHelper.ExecuteScalar(SqlHelper.Connect, CommandType.Text, "select count(*) from OptionalSubjects where ClassID=@classid and OptionalSubjectName=@subname", subNames) > 0)
     {
         return(true);
     }
     return(false);
 }
コード例 #4
0
        public static String updateSubject(OptionalSubject opSubject)
        {
            string msg = "OK";// = OpSubVal.getInsertSubjectValidation(opSubject);

            if (msg.ToUpper().Equals("OK"))
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@subid",          Convert.ToInt64(opSubject.OptionalSubjectID)),
                    new SqlParameter("@subname",        opSubject.OptionalSubjectName.Trim()),
                    new SqlParameter("@classid",        Convert.ToInt64(opSubject.ClassID)),
                    new SqlParameter("@currentsession", opSubject.Current_Session)
                };
                if ((int)SqlHelper.ExecuteNonQuery(SqlHelper.Connect, CommandType.Text, "Update OptionalSubjects set OptionalSubjectName=@subname where ClassID=@classid and Current_Session =@currentsession and Optionalsubjectid=@subid", param) > 0)
                {
                    msg = "Subject(s) Updated Sucessfully!!";
                }
                else
                {
                    msg = "Subject(s) Not Updated!!";
                }
            }
            return(msg);
        }