Exemplo n.º 1
0
        public MyStatusDTO GetMyStatus(string user_id, string class_id)
        {
            MyStatusDTO dto = new MyStatusDTO();
            try
            {
                string query = string.Empty;
                query = string.Format("execute UP_MY_STATUS N'{0}', {1}", user_id, class_id);

                DataSet ds = null;
                SqlParameter[] param = null;
                ds = db.GetDataSet(query, CommandType.Text, param);
                if (ds != null)
                {
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow dr in ds.Tables[0].Rows)
                        {
                            dto.ClassID = int.Parse(dr["ClassID"].ToString());
                            dto.UserID = dr["UserID"].ToString();
                            dto.UserName = dr["UserName"].ToString();
                            dto.NickName = dr["NickName"].ToString();
                            dto.SkypeID = dr["SkypeID"].ToString();
                            dto.TeacherID = dr["TeacherID"].ToString();
                            dto.TeacherName = dr["TeacherName"].ToString();
                            dto.StartDate = int.Parse(dr["StartDate"].ToString());
                            dto.EndDate = int.Parse(dr["EndDate"].ToString());
                            dto.ClassTime = dr["ClassTime"].ToString();
                            dto.Minutes = int.Parse(dr["Minutes"].ToString());
                            dto.BookCode = dr["BookCode"].ToString();
                            dto.BookName = dr["BookName"].ToString();
                            dto.Complete = int.Parse(dr["Complete"].ToString());
                            dto.Present = int.Parse(dr["Present"].ToString());
                            dto.Absent = int.Parse(dr["Absent"].ToString());
                            dto.Postpone = int.Parse(dr["Postpone"].ToString());
                            dto.Vacation = int.Parse(dr["Vacation"].ToString());
                            dto.Cancel = int.Parse(dr["Cancel"].ToString());
                            dto.TotalDays = int.Parse(dr["TotalDays"].ToString());
                            dto.RemainingDays = int.Parse(dr["RemainingDays"].ToString());
                            dto.Progress = int.Parse(dr["Progress"].ToString());
                        }
                    }
                    else
                    {
                        dto = null;
                    }
                }
            }
            catch (Exception ex)
            {
                dto = null;
            }
            return dto;
        }
Exemplo n.º 2
0
        public Dictionary<string, List<MyStatusDTO>> GetAllMyStatus(string user_id)
        {
            Dictionary<string, List<MyStatusDTO>> dic = new Dictionary<string, List<MyStatusDTO>>();
            try
            {
                string query = string.Empty;
                query = string.Format("execute UP_MY_LECTURE_HISTORY N'{0}'", user_id);

                DataSet ds = null;
                SqlParameter[] param = null;
                ds = db.GetDataSet(query, CommandType.Text, param);
                if (ds != null)
                {
                    if (ds.Tables.Count < 2)
                    {
                        dic = null;
                    }
                    else
                    {
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            dic.Add("current", null);
                        }
                        else
                        {
                            List<MyStatusDTO> lstDto = new List<MyStatusDTO>();
                            foreach (DataRow dr in ds.Tables[0].Rows)
                            {
                                MyStatusDTO dto = new MyStatusDTO();
                                dto.ClassID = int.Parse(dr["ClassID"].ToString());
                                dto.UserID = dr["UserID"].ToString();
                                dto.UserName = dr["UserName"].ToString();
                                dto.NickName = dr["NickName"].ToString();
                                dto.SkypeID = dr["SkypeID"].ToString();
                                dto.TeacherID = dr["TeacherID"].ToString();
                                dto.TeacherName = dr["TeacherName"].ToString();
                                dto.StartDate = int.Parse(dr["StartDate"].ToString());
                                dto.EndDate = int.Parse(dr["EndDate"].ToString());
                                dto.ClassTime = dr["ClassTime"].ToString();
                                dto.Minutes = int.Parse(dr["Minutes"].ToString());
                                dto.BookCode = dr["BookCode"].ToString();
                                dto.BookName = dr["BookName"].ToString();
                                dto.Complete = int.Parse(dr["Complete"].ToString());
                                dto.Present = int.Parse(dr["Present"].ToString());
                                dto.Absent = int.Parse(dr["Absent"].ToString());
                                dto.Postpone = int.Parse(dr["Postpone"].ToString());
                                dto.Vacation = int.Parse(dr["Vacation"].ToString());
                                dto.Cancel = int.Parse(dr["Cancel"].ToString());
                                dto.TotalDays = int.Parse(dr["TotalDays"].ToString());
                                dto.RemainingDays = int.Parse(dr["RemainingDays"].ToString());
                                dto.Progress = int.Parse(dr["Progress"].ToString());
                                lstDto.Add(dto);
                            }
                            dic.Add("current", lstDto);
                        }

                        if (ds.Tables[1].Rows.Count == 0)
                        {
                            dic.Add("history", null);
                        }
                        else
                        {
                            List<MyStatusDTO> lstDto = new List<MyStatusDTO>();
                            foreach (DataRow dr in ds.Tables[1].Rows)
                            {
                                MyStatusDTO dto = new MyStatusDTO();
                                dto.ClassID = int.Parse(dr["ClassID"].ToString());
                                dto.UserID = dr["UserID"].ToString();
                                dto.UserName = dr["UserName"].ToString();
                                dto.NickName = dr["NickName"].ToString();
                                dto.SkypeID = dr["SkypeID"].ToString();
                                dto.TeacherID = dr["TeacherID"].ToString();
                                dto.TeacherName = dr["TeacherName"].ToString();
                                dto.StartDate = int.Parse(dr["StartDate"].ToString());
                                dto.EndDate = int.Parse(dr["EndDate"].ToString());
                                dto.ClassTime = dr["ClassTime"].ToString();
                                dto.Minutes = int.Parse(dr["Minutes"].ToString());
                                dto.BookCode = dr["BookCode"].ToString();
                                dto.BookName = dr["BookName"].ToString();
                                dto.Complete = int.Parse(dr["Complete"].ToString());
                                dto.Present = int.Parse(dr["Present"].ToString());
                                dto.Absent = int.Parse(dr["Absent"].ToString());
                                dto.Postpone = int.Parse(dr["Postpone"].ToString());
                                dto.Vacation = int.Parse(dr["Vacation"].ToString());
                                dto.Cancel = int.Parse(dr["Cancel"].ToString());
                                dto.TotalDays = int.Parse(dr["TotalDays"].ToString());
                                dto.RemainingDays = int.Parse(dr["RemainingDays"].ToString());
                                dto.Progress = int.Parse(dr["Progress"].ToString());
                                lstDto.Add(dto);
                            }
                            dic.Add("history", lstDto);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dic = null;
            }
            return dic;
        }