コード例 #1
0
        public string InsertTeacherNote(TeacherNote Info)
        {
            string Result = string.Empty;

            try
            {
                using (SqlConnection con = new SqlConnection(conn))
                {
                    SqlCommand com = new SqlCommand("[teacher].[SP_InsertTeacherNote]", con);
                    com.CommandType = CommandType.StoredProcedure;
                    com.Parameters.AddWithValue("@TeacherID_FK", Info.TeacherID_FK);
                    com.Parameters.AddWithValue("@Note", Info.Note);
                    con.Open();
                    int LastRow = Convert.ToInt32(com.ExecuteScalar());
                    if (LastRow > 0)
                    {
                        Result = "Success!" + LastRow;;
                    }
                    else
                    {
                        Result = "Failed! ";
                    }
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                WriteLogFile.WriteErrorLog("Error.txt", ex.Message);
            }
            return(Result);
        }
コード例 #2
0
        public List <TeacherNote> GetTeacherNotes(long TeacherID_FK)
        {
            List <TeacherNote> Result = new List <TeacherNote>();

            try
            {
                using (SqlConnection con = new SqlConnection(conn))
                {
                    SqlCommand com = new SqlCommand("[teacher].[SP_GetTeacherNotes]", con);
                    com.CommandType = CommandType.StoredProcedure;
                    com.Parameters.AddWithValue("@TeacherID", TeacherID_FK);
                    con.Open();
                    SqlDataReader reader = com.ExecuteReader();
                    while (reader.Read())
                    {
                        TeacherNote temp = new TeacherNote();
                        temp.ID          = Convert.ToInt32(reader["ID"]);
                        temp.Note        = Convert.ToString(reader["Note"]);
                        temp.CreatedDate = Convert.ToDateTime(reader["CreatedDate"]);
                        Result.Add(temp);
                    }
                    con.Close();
                }
            }
            catch (Exception ex)
            {
                WriteLogFile.WriteErrorLog("Error.txt", ex.Message);
            }
            return(Result);
        }
コード例 #3
0
ファイル: HodController.cs プロジェクト: GMAIL123/Go2uni
        public JsonResult InsertTeacherNote(TeacherNote Info)
        {
            ResultInfo <string> ResultInfo = new ResultInfo <string>()
            {
                Status      = false,
                Description = "Failed|Login"
            };

            if (Info != null)
            {
                Hod PageObj = new Hod();
                ResultInfo.Info = PageObj.InsertTeacherNote(Info);
                if (ResultInfo.Info.Split('!')[0] == "Success")
                {
                    ResultInfo.Description = "Success| Inserted";
                    ResultInfo.Status      = true;
                }
            }
            return(Json(ResultInfo, JsonRequestBehavior.AllowGet));
        }