Beispiel #1
0
 public static Rc.Model.Resources.Model_F_User IsPageFlag(Page page)
 {
     Rc.Model.Resources.Model_F_User user = null;
     if (page.Session["FLoginUser"] != null)
     {
         user = (Rc.Model.Resources.Model_F_User)page.Session["FLoginUser"];
         page.Session["FLoginUser"] = user;
         return(user);
     }
     ErrorDispose(page, 1, true);
     page.Response.End();
     return(user);
 }
 public static string RenewCustom(string Two_NewWayChecklist_Id)
 {
     try
     {
         string Two_WayChecklistToTeacher_Id       = string.Empty;
         string Two_WayChecklist_Id                = string.Empty;
         Rc.Model.Resources.Model_F_User loginUser = (Rc.Model.Resources.Model_F_User)HttpContext.Current.Session["FLoginUser"];
         string    sql = @"select * from [Two_WayChecklistToTeacher] where Two_NewWayChecklist_Id='" + Two_NewWayChecklist_Id.Filter() + "' and Teacher_Id='" + loginUser.UserId + "'";
         DataTable dt  = Rc.Common.DBUtility.DbHelperSQL.Query(sql).Tables[0];
         if (dt.Rows.Count > 0)
         {
             Two_WayChecklistToTeacher_Id = dt.Rows[0]["Two_WayChecklistToTeacher_Id"].ToString();
             Two_WayChecklist_Id          = dt.Rows[0]["Two_WayChecklist_Id"].ToString();
             #region  除老师自定义双向细目表数据
             string DSql = string.Format(@"update Two_WayChecklistToTeacher set status='0' where Two_WayChecklistToTeacher_Id='{0}';
                                           delete from Two_WayChecklistDetailToAttr where Two_WayChecklist_Id='{1}';
                                           delete from Two_WayChecklistDetailToTestQuestions where Two_WayChecklist_Id='{1}';
                                           delete from Two_WayChecklistDetail where Two_WayChecklist_Id='{1}';
                                           delete from Two_WayChecklist where Two_WayChecklist_Id='{1}';"
                                         , Two_WayChecklistToTeacher_Id
                                         , Two_NewWayChecklist_Id);
             #endregion
             if (Rc.Common.DBUtility.DbHelperSQL.ExecuteSql(DSql) > 0)
             {
                 return(Two_WayChecklist_Id);
             }
             else
             {
                 return("");
             }
         }
         else
         {
             return("");
         }
     }
     catch (Exception ex)
     {
         return("");
     }
 }
Beispiel #3
0
        public static string GetResourceFolderListPage(int PageIndex, int PageSize)
        {
            try
            {
                StringBuilder strHtml = new StringBuilder();
                Rc.Model.Resources.Model_F_User loginUser = Rc.Common.StrUtility.clsUtility.IsFPageFlag() as Rc.Model.Resources.Model_F_User;
                DataTable     dtRes       = new DataTable();
                List <object> listReturn  = new List <object>();
                string        strSql      = string.Empty;
                string        strSqlCount = string.Empty;

                strSqlCount = @"SELECT count(1) from ResourceFolder t 
                                left join Bookshelves t1 on t.ResourceFolder_ID=t1.ResourceFolder_ID 
                                where t.Resource_Type='" + Resource_TypeConst.testPaper类型文件 + "' and  t.ResourceFolder_ID in(SELECT book_id from UserBuyResources where userid='" + loginUser.UserId + "') ";

                strSql = @"select * from (select ROW_NUMBER() over(ORDER BY t.CreateTime DESC) row,t1.BookImg_Url,t.*,t1.bookShelvesstate,t1.BookPrice,t1.Book_Name  from ResourceFolder t 
                                left join Bookshelves t1 on t.ResourceFolder_ID=t1.ResourceFolder_ID 
                                where t.Resource_Type='" + Resource_TypeConst.testPaper类型文件 + "' and  t.ResourceFolder_ID in(SELECT book_id from UserBuyResources where userid='" + loginUser.UserId + "') "
                         + " ) z where row between " + ((PageIndex - 1) * PageSize + 1) + " and " + (PageIndex * PageSize) + "  ";

                dtRes = Rc.Common.DBUtility.DbHelperSQL.Query(strSql).Tables[0];
                int rCount = Convert.ToInt32(Rc.Common.DBUtility.DbHelperSQL.GetSingle(strSqlCount).ToString());
                int inum   = 0;
                for (int i = 0; i < dtRes.Rows.Count; i++)
                {
                    inum++;
                    listReturn.Add(new
                    {
                        inum              = (i + 1),
                        BookImg_Url       = dtRes.Rows[i]["BookImg_Url"].ToString(),
                        Book_Name         = dtRes.Rows[i]["Book_Name"].ToString(),
                        BookPrice         = dtRes.Rows[i]["BookPrice"].ToString(),
                        ResourceFolder_ID = dtRes.Rows[i]["ResourceFolder_ID"].ToString(),
                    });
                }
                if (inum > 0)
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "null",
                        PageIndex = PageIndex,
                        PageSize = PageSize,
                        TotalCount = rCount,
                        list = listReturn
                    }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "暂无数据"
                    }));
                }
            }
            catch (Exception)
            {
                return(JsonConvert.SerializeObject(new
                {
                    err = "error"//ex.Message.ToString()
                }));
            }
        }
Beispiel #4
0
        public static string GetResourceFolderListPage(string ParticularYear, string GradeTerm, string Subject, string Resource_Version, string Province, string City, string Name, int PageIndex, int PageSize)
        {
            try
            {
                StringBuilder strHtml = new StringBuilder();
                Rc.Model.Resources.Model_F_User loginUser = Rc.Common.StrUtility.clsUtility.IsFPageFlag() as Rc.Model.Resources.Model_F_User;
                DataTable     dtRes       = new DataTable();
                List <object> listReturn  = new List <object>();
                string        strSql      = string.Empty;
                string        strSqlCount = string.Empty;
                string        strWhere    = string.Empty;
                if (ParticularYear != "")
                {
                    strWhere += " and ParticularYear = '" + ParticularYear.Filter() + "' ";                      //年份
                }
                if (GradeTerm != "")
                {
                    strWhere += " and GradeTerm = '" + GradeTerm.Filter() + "' ";                 //年级学期
                }
                if (Subject != "")
                {
                    strWhere += " and Subject = '" + Subject.Filter() + "' ";               //学科
                }
                if (Resource_Version != "")
                {
                    strWhere += " and Resource_Version = '" + Resource_Version.Filter() + "' ";                         //教材版本
                }
                if (Name != "")
                {
                    strWhere += " and ResourceFolder_Name like '%" + Name.Filter() + "%' ";             //名称
                }
                string strWhereCount = strWhere;
                if (Province != "-1" && City != "-1")//选择省市
                {
                    strWhereCount = string.Format(" and t.ResourceFolder_Id in(select ResourceFolder_Id from BookArea where City_ID='{0}') ", City);
                    strWhere     += string.Format(" and ResourceFolder_Id in(select ResourceFolder_Id from BookArea where City_ID='{0}') ", City);
                }
                else if (Province != "-1" && City == "-1")//只选择省
                {
                    strWhereCount = string.Format(" and t.ResourceFolder_Id in(select ResourceFolder_Id from BookArea where Province_ID='{0}') ", Province);
                    strWhere     += string.Format(" and ResourceFolder_Id in(select ResourceFolder_Id from BookArea where Province_ID='{0}') ", Province);
                }

                strSqlCount = @"select count(1) from(SELECT DISTINCT t1.BookImg_Url ,t.*,t1.bookShelvesstate from ResourceFolder t 
                                left join Bookshelves t1 on t.ResourceFolder_ID=t1.ResourceFolder_ID 
                                left join UserBuyResources t2 on t.ResourceFolder_ID=t2.book_id
                                where t.Resource_Type='" + Resource_TypeConst.testPaper类型文件 + "' and  t1.BookShelvesState=1 " + strWhereCount + " ) a ";

                strSql = @"select * from (select  ROW_NUMBER() over(ORDER BY CreateTime DESC) row,* from (
                            SELECT DISTINCT t1.BookImg_Url ,t.*,t1.bookShelvesstate,t1.BookPrice,t2.userid,t1.Book_Name from ResourceFolder t 
                            left join Bookshelves t1 on t.ResourceFolder_ID=t1.ResourceFolder_ID 
                            left join UserBuyResources t2 on t.ResourceFolder_ID=t2.book_id and t2.userid='" + loginUser.UserId + "' where t.Resource_Type='" + Resource_TypeConst.testPaper类型文件 + "' and  t1.BookShelvesState=1 ) a  where 1=1 " + strWhere
                         + " ) z where row between " + ((PageIndex - 1) * PageSize + 1) + " and " + (PageIndex * PageSize) + "  ";

                dtRes = Rc.Common.DBUtility.DbHelperSQL.Query(strSql).Tables[0];
                int rCount = Convert.ToInt32(Rc.Common.DBUtility.DbHelperSQL.GetSingle(strSqlCount).ToString());
                int inum   = 0;
                for (int i = 0; i < dtRes.Rows.Count; i++)
                {
                    #region 处理图片显示宽高
                    int    imgHeight   = 0;
                    int    imgWidth    = 0;
                    string imgFilePath = HttpContext.Current.Server.MapPath(dtRes.Rows[i]["BookImg_Url"].ToString());
                    if (System.IO.File.Exists(imgFilePath))
                    {
                        System.Drawing.Image img = System.Drawing.Image.FromFile(imgFilePath);
                        imgHeight = img.Height;
                        imgWidth  = img.Width;
                        if (imgHeight / 218.0 > imgWidth / 160.0)
                        {
                            imgWidth = 0;
                            if (imgHeight > 218)
                            {
                                imgHeight = 218;
                            }
                        }
                        else
                        {
                            imgHeight = 0;
                            if (imgWidth > 160)
                            {
                                imgWidth = 160;
                            }
                        }
                        img.Dispose();
                    }
                    #endregion
                    inum++;
                    listReturn.Add(new
                    {
                        inum              = (i + 1),
                        Book_Name         = dtRes.Rows[i]["Book_Name"].ToString(),
                        BookImg_Url       = dtRes.Rows[i]["BookImg_Url"].ToString(),
                        BookPrice         = dtRes.Rows[i]["BookPrice"].ToString(),
                        ResourceFolder_ID = dtRes.Rows[i]["ResourceFolder_ID"].ToString(),
                        isGouMai          = (dtRes.Rows[i]["userid"].ToString() != "" ? "1" : "0"),
                        imgHeight         = imgHeight,
                        imgWidth          = imgWidth
                    });
                }
                if (inum > 0)
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "null",
                        PageIndex = PageIndex,
                        PageSize = PageSize,
                        TotalCount = rCount,
                        list = listReturn
                    }));
                }
                else
                {
                    return(JsonConvert.SerializeObject(new
                    {
                        err = "暂无数据"
                    }));
                }
            }
            catch (Exception)
            {
                return(JsonConvert.SerializeObject(new
                {
                    err = "error"//ex.Message.ToString()
                }));
            }
        }