コード例 #1
0
        /* Leaves operations ends here */

        internal List <QPaper> QPapers(bool View = true, int DeptID = 0, int FacultyID = 0)
        {
            DataTable     td   = new DataTable();
            List <QPaper> list = new List <QPaper>();

            try
            {
                string sqlquery = string.Empty;
                if (View) // View All
                {
                    sqlquery = $"SELECT * FROM papers ORDER BY paperid DESC";
                }
                else // View Specific
                {
                    string FaculQuery = string.Empty;
                    if (FacultyID > 0)
                    {
                        FaculQuery = "AND facultyid = " + FacultyID;
                    }
                    sqlquery = $"SELECT * FROM papers WHERE deptid = {DeptID} {FaculQuery} ORDER BY paperid DESC";
                }

                SqlCommand     cmd = new SqlCommand(sqlquery, Conn);
                SqlDataAdapter adp = new SqlDataAdapter(cmd);
                Conn.Open();
                adp.Fill(td);
                Conn.Close();
                PrinciUtil princiUtil = new PrinciUtil();
                foreach (DataRow row in td.Rows)
                {
                    QPaper obj = new QPaper
                    {
                        ID          = Convert.ToInt32(row["paperid"]),
                        Title       = Convert.ToString(row["title"]),
                        Subject     = Convert.ToString(row["subject"]),
                        Description = Convert.ToString(row["description"]),
                        Path        = Convert.ToString(row["path"]),
                        Status      = Convert.ToInt32(row["status"]),
                        FacultyID   = Convert.ToInt32(row["facultyid"]),
                        DateTime    = Convert.ToDateTime(row["datetime"]),
                        DeptID      = Convert.ToInt32(row["deptid"])
                    };
                    obj.FacultyName = princiUtil.GetFacultyByID(obj.FacultyID).Name;
                    obj.DeptName    = princiUtil.GetDeptByID(obj.DeptID).Name;
                    list.Add(obj);
                }
            }
            catch (Exception)
            { }
            return(list);
        }
コード例 #2
0
        /* Meetings operations starts here */
        internal List <Meetings> Meetings(bool All = false, int DeptID = 0)
        {
            DataTable       td         = new DataTable();
            List <Meetings> list       = new List <Meetings>();
            PrinciUtil      princiUtil = new PrinciUtil();

            try
            {
                string Top5          = string.Empty;
                string DeptCondition = string.Empty;
                if (!All)
                {
                    Top5 = "TOP 5";
                }
                if (DeptID > 0)
                {
                    DeptCondition = "WHERE deptid = " + DeptID;
                }
                string         sqlquery = $"SELECT {Top5} * FROM meetings {DeptCondition} ORDER BY date DESC";
                SqlCommand     cmd      = new SqlCommand(sqlquery, Conn);
                SqlDataAdapter adp      = new SqlDataAdapter(cmd);
                Conn.Open();
                adp.Fill(td);
                Conn.Close();
                foreach (DataRow row in td.Rows)
                {
                    Meetings obj = new Meetings
                    {
                        ID            = Convert.ToInt32(row["meetingid"]),
                        DeptID        = Convert.ToInt32(row["deptid"]),
                        AddedBy       = Convert.ToString(row["addedby"]),
                        Title         = Convert.ToString(row["title"]),
                        DateOfMeeting = Convert.ToDateTime(row["date"]),
                        TimeOfMeeting = Convert.ToString(row["time"]),
                        Place         = Convert.ToString(row["place"]),
                        Description   = Convert.ToString(row["description"]),
                        DeptName      = princiUtil.GetDeptByID(Convert.ToInt32(row["deptid"])).Name
                    };

                    list.Add(obj);
                }
            }
            catch (Exception)
            { }
            return(list);
        }