Ejemplo n.º 1
0
 private void BindInfo()
 {
     BLL.user_info   bll   = new BLL.user_info();
     Model.user_info model = bll.GetModel(this.id);
     if (model == null)
     {
         JscriptMsg("信息不存在或已被删除!", "back");
         return;
     }
     txtgroup_id.Text    = model.group_id + "";
     txtuser_name.Text   = model.user_name + "";
     txtphone.Text       = model.phone + "";
     txtsalt.Text        = model.salt + "";
     txtuser_pwd.Text    = model.user_pwd + "";
     txtnick_name.Text   = model.nick_name + "";
     txtavatar.Text      = model.avatar + "";
     txtintegral.Text    = model.integral + "";
     txtschool_id.Text   = model.school_id + "";
     txtschool_name.Text = model.school_name + "";
     txtcollege.Text     = model.college + "";
     txtjob.Text         = model.job + "";
     txtcourse.Text      = model.course + "";
     txtline_way.Text    = model.line_way + "";
     txtarea.Text        = model.area + "";
     txtaddress.Text     = model.address + "";
     txtreg_ip.Text      = model.reg_ip + "";
     txtadd_time.Text    = model.add_time + "";
 }
Ejemplo n.º 2
0
        private void BindSelect()
        {
            string where = "";
            if (adminInfo.role_type == 2)
            {
                Model.user_info user = new BLL.user_info().GetModel(" phone = '" + adminInfo.user_name + "' ");
                where += " user_id = " + user.id;
            }

            this.ddlClassroom.DataSource     = new BLL.classroom_info().GetList(where);
            this.ddlClassroom.DataTextField  = "name";
            this.ddlClassroom.DataValueField = "id";
            this.ddlClassroom.DataBind();

            this.ddlClassroom.SelectedValue = this.class_id + "";
            //Model.classroom_info model = new BLL.classroom_info().GetModel(class_id);
            //if (model != null)
            //{
            //    this.lblClass.Text = model.name;
            //    this.lblCreator.Text = model.user_name;
            //}
            //else
            //{
            //    this.lblClass.Text = "";
            //}
        }
Ejemplo n.º 3
0
        private void BindData()
        {
            #region 组装查询条件
            string whereStr  = " group_id = " + (int)EnumCollection.user_group.普通用户;
            string _keywords = keywords.Replace("'", "");

            if (!string.IsNullOrEmpty(_keywords))
            {
                if (Utils.IsSafeSqlString(_keywords))
                {
                    whereStr += " and (phone like  '%" + _keywords + "%')";
                }
                else
                {
                    JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("user_list.aspx", "keywords={0}", ""));
                    return;
                }
            }
            #endregion

            this.page        = RequestHelper.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.user_info bll = new BLL.user_info();
            this.rptList.DataSource = bll.GetListByPage(whereStr, "ID DESC", this.page, this.pageSize);
            this.rptList.DataBind();

            this.totalCount = bll.GetRecordCount(whereStr);
            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("user_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__");
            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Ejemplo n.º 4
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_user_info", EnumCollection.ActionEnum.Modify.ToString()); //检查权限
            BLL.user_info   bll   = new BLL.user_info();
            Model.user_info model = bll.GetModel(this.id);

            model.group_id    = Convert.ToInt32(txtgroup_id.Text);
            model.user_name   = Convert.ToString(txtuser_name.Text);
            model.phone       = Convert.ToString(txtphone.Text);
            model.salt        = Convert.ToString(txtsalt.Text);
            model.user_pwd    = Convert.ToString(txtuser_pwd.Text);
            model.nick_name   = Convert.ToString(txtnick_name.Text);
            model.avatar      = Convert.ToString(txtavatar.Text);
            model.integral    = Convert.ToInt32(txtintegral.Text);
            model.school_id   = Convert.ToInt32(txtschool_id.Text);
            model.school_name = Convert.ToString(txtschool_name.Text);
            model.college     = Convert.ToString(txtcollege.Text);
            model.job         = Convert.ToString(txtjob.Text);
            model.course      = Convert.ToString(txtcourse.Text);
            model.line_way    = Convert.ToString(txtline_way.Text);
            model.area        = Convert.ToString(txtarea.Text);
            model.address     = Convert.ToString(txtaddress.Text);
            model.reg_ip      = Convert.ToString(txtreg_ip.Text);
            model.add_time    = Convert.ToDateTime(txtadd_time.Text);

            if (bll.Update(model))
            {
                AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改用户信息信息,主键:" + id); //记录日志
                JscriptMsg("修改用户信息信息成功!", "Manage.aspx");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
Ejemplo n.º 5
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_user_info", EnumCollection.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.user_info bll = new BLL.user_info();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int      id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除用户信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("Manage.aspx", "keywords={0}", this.keywords));
        }
        private void BindSelect()
        {
            DataTable dt = EnumCollection.EnumToDataTable(typeof(EnumCollection.resource_group), "key", "val");

            if (dt.Rows.Count > 0)
            {
                this.rbtnGroup.Items.Clear();
                foreach (DataRow item in dt.Rows)
                {
                    this.rbtnGroup.Items.Add(new ListItem(item["key"].ToString(), item["val"].ToString()));
                }
                this.rbtnGroup.SelectedIndex = 0;
            }

            dt = new BLL.user_info().GetList(" group_id = " + (int)EnumCollection.user_group.资源分享用户);
            this.ckbUser.DataSource     = dt;
            this.ckbUser.DataTextField  = "phone";
            this.ckbUser.DataValueField = "id";
            this.ckbUser.DataBind();
            this.ckbUser.SelectedIndex = 0;

            dt = new BLL.common_school().GetList(" 1=1 order by sort ");
            this.ddlSchool.DataSource     = dt;
            this.ddlSchool.DataTextField  = "name";
            this.ddlSchool.DataValueField = "id";
            this.ddlSchool.DataBind();
            this.ckbUser.SelectedIndex = 0;
        }
Ejemplo n.º 7
0
        private void BindSelect()
        {
            string where = "";
            if (adminInfo.role_type == 2)
            {
                Model.user_info user = new BLL.user_info().GetModel(" phone = '" + adminInfo.user_name + "' ");
                where += " user_id = " + user.id;
            }

            this.ddlClassroom.DataSource     = new BLL.classroom_info().GetList(where);
            this.ddlClassroom.DataTextField  = "name";
            this.ddlClassroom.DataValueField = "id";
            this.ddlClassroom.DataBind();
        }
        private void ShowInfo()
        {
            BLL.user_info   bll   = new BLL.user_info();
            Model.user_info model = bll.GetModel(this.id);
            if (model == null)
            {
                JscriptMsg("信息不存在或已被删除!", "back");
                return;
            }

            txtuser_name.Text = model.user_name + "";
            txtphone.Text     = model.phone + "";
            txtuser_pwd.Text  = DESEncrypt.Decrypt(model.user_pwd, model.salt.Trim());
            txtnick_name.Text = model.nick_name + "";
            txtavatar.Text    = model.avatar + "";
        }
Ejemplo n.º 9
0
        private bool DoAdd()
        {
            Model.common_article model = new Model.common_article();
            BLL.common_article   bll   = new BLL.common_article();

            model.group_id = (int)EnumCollection.article_group.课堂公告;

            if (adminInfo.role_type == 2)//教师
            {
                Model.user_info user = new BLL.user_info().GetModel(" phone = '" + adminInfo.user_name + "' ");
                model.user_id = user.id;
            }
            else if (adminInfo.role_type == 1)//超管
            {
                Model.classroom_info ciModel = new BLL.classroom_info().GetModel(this.class_id);
                if (ciModel != null)
                {
                    model.user_id = ciModel.user_id;
                }
            }

            model.category_id = Convert.ToInt32(ddlClassroom.SelectedValue);
            //model.category_id = this.class_id;
            model.title    = Convert.ToString(txttitle.Text);
            model.subtitle = "";
            model.contents = Convert.ToString(txtcontents.Text);
            model.img_src  = Convert.ToString(txtimg_src.Text);
            model.click    = 0;
            model.upvote   = 0;
            model.status   = 1;
            model.add_time = System.DateTime.Now;

            int id = bll.Add(model);

            if (id > 0)
            {
                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加课堂公告信息,主键:" + id); //记录日志
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
        private void BindData()
        {
            #region 组装查询条件
            string whereStr  = " 1 = 1 ";
            string _keywords = keywords.Replace("'", "");

            if (!string.IsNullOrEmpty(_keywords))
            {
                if (Utils.IsSafeSqlString(_keywords))
                {
                    whereStr += " and (name like  '%" + _keywords + "%')";
                }
                else
                {
                    JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("classroom_list.aspx", "keywords={0}", ""));
                    return;
                }
            }

            if (this.adminInfo.role_type == 2)
            {
                Model.user_info user = new BLL.user_info().GetModel(" phone = '" + this.adminInfo.user_name + "' ");
                if (user == null)
                {
                    JscriptMsg("此用户没有创建课堂,请确认后重新登录", "/admin/login.aspx");
                    return;
                }

                whereStr += " and user_id = " + user.id;
            }
            #endregion

            this.page        = RequestHelper.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.classroom_info bll = new BLL.classroom_info();
            this.rptList.DataSource = bll.GetListByPage(whereStr, "ID DESC", this.page, this.pageSize);
            this.rptList.DataBind();

            this.totalCount = bll.GetRecordCount(whereStr);
            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("classroom_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__");
            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
Ejemplo n.º 11
0
        //批量删除
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_user_list", EnumCollection.ActionEnum.Delete.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.user_info     bll     = new BLL.user_info();
            BLL.user_oauths   oBll    = new BLL.user_oauths();
            BLL.user_tree     tBll    = new BLL.user_tree();
            Model.user_oauths uoModel = null;
            Model.user_tree   utModel = null;
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value);
                uoModel = oBll.GetModel(" user_id = " + id);
                utModel = tBll.GetModel(" user_id = " + id);
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId");
                if (cb.Checked)
                {
                    if (bll.Delete(id))
                    {
                        if (uoModel != null)
                        {
                            oBll.Delete(uoModel.id);
                        }
                        if (utModel != null)
                        {
                            tBll.Delete(utModel.id);
                        }
                        sucCount += 1;
                    }
                    else
                    {
                        errorCount += 1;
                    }
                }
            }
            AddAdminLog(EnumCollection.ActionEnum.Delete.ToString(), "删除用户信息" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("user_list.aspx", "keywords={0}", this.keywords));
        }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string source_url = Request.QueryString["source_url"];
            string code       = Request.QueryString["code"];
            string state      = Request.QueryString["state"];

            if (!string.IsNullOrEmpty(source_url))
            {
                string location = Request.RawUrl;
                int    index    = location.IndexOf('=');
                source_url = location.Substring(index + 1, location.Length - index - 1);
                source_url = source_url.Replace('&', '*');


                Utils.StringToTxt("wxOAuth_WeChat_GetCode————source_url==" + source_url);
                Utils.WriteCookie("wxOAuth_WeChatGrant", "True");
                string url = WeChatContext.GetRedirectCode("/html/wxOAuth.aspx", source_url, true);

                Response.Redirect(url);
            }
            else if (!string.IsNullOrEmpty(code))
            {
                string temp      = Utils.UrlDecode(state);
                string decodeurl = temp.Replace('*', '&');

                Utils.StringToTxt("wxOAuth_wxLogin————code==" + code + ";wxOAuth_state==" + decodeurl);

                WeiXin_Access_token access_token = WeChatContext.GetAccessModel(code);

                if (access_token != null)
                {
                    SnsapiUserInfo userInfo = WeChatContext.GetSnsapiUserInfo(access_token.Access_token, access_token.Openid);//获取用户信息
                    if (userInfo != null)
                    {
                        user_info_entity entity = new user_info_entity();

                        //公众号openid存在
                        Model.user_oauths oaModel = new BLL.user_oauths().GetModel(" appid = '" + access_token.Openid + "'");
                        if (oaModel != null)
                        {
                            try
                            {
                                Utils.StringToTxt("wxOAuth_wxLogin————公众号openid存在,则更新openID=" + access_token.Openid + "和unionID=" + userInfo.unionid);
                                Model.user_info model = new BLL.user_info().GetModel(oaModel.user_id);

                                Utils.StringToTxt("wxOAuth_wxLogin————用户信息:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));
                                Utils.StringToTxt("wxOAuth_wxLogin————认证信息:" + Newtonsoft.Json.JsonConvert.SerializeObject(oaModel));

                                //更新unionid(多应用唯一识别码)
                                oaModel.appid   = userInfo.openid;
                                oaModel.unionid = userInfo.unionid;
                                new BLL.user_oauths().Update(oaModel);

                                if (model.school_id == 0)//没有学校,公共资源
                                {
                                    decodeurl += "&method=scan";
                                    Response.Redirect(decodeurl);
                                }
                                else//有学校,学校资源
                                {
                                    int    idindex = decodeurl.IndexOf('=');
                                    string id      = decodeurl.Substring(idindex + 1, decodeurl.Length - idindex - 1);

                                    BLL.common_resource   resBll = new BLL.common_resource();
                                    Model.common_resource res    = resBll.GetModel(Convert.ToInt32(id));
                                    if (res != null)
                                    {
                                        if (res.from_id == (int)EnumCollection.resource_from.精品微课)       //如果是精品微课的资源
                                        {
                                            if (res.group_id == (int)EnumCollection.resource_group.公共资源) //若此资源是公共资源,查询此章节下的学校资源
                                            {
                                                Model.common_resource newRes = resBll.GetModel(string.Format(" from_id = {0} and group_id = {1} and type = {2} and data_id = {3}",
                                                                                                             res.from_id, (int)EnumCollection.resource_group.学校资源, res.type, res.data_id));
                                                if (newRes != null)
                                                {
                                                    decodeurl = decodeurl.Replace("id=" + id, "id=" + newRes.id);
                                                    Utils.StringToTxt("wxOAuth_wxLogin————学校资源=" + decodeurl);
                                                }

                                                decodeurl += "&method=scan";
                                                Response.Redirect(decodeurl);
                                            }
                                            else if (res.group_id == (int)EnumCollection.resource_group.学校资源)//若此资源是学校资源,判断是否是本学校的
                                            {
                                                if (model.school_id != res.school_id)
                                                {
                                                    Response.Write("您没有权限查看此资源");
                                                }
                                                else
                                                {
                                                    decodeurl += "&method=scan";
                                                    Response.Redirect(decodeurl);
                                                }
                                            }
                                        }
                                        else if (res.from_id == (int)EnumCollection.resource_from.课堂)//如果是课堂的资源
                                        {
                                            decodeurl += "&method=scan";
                                            Response.Redirect(decodeurl);
                                        }
                                    }
                                    else
                                    {
                                        decodeurl += "&method=scan";
                                        Response.Redirect(decodeurl);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Utils.StringToTxt("wxOAuth_wxLogin————获取数据库用户信息出现异常:" + ex.Message);
                                Response.Write("获取数据库用户信息出现异常:" + ex.Message);
                                return;
                            }
                        }
                        else//不存在
                        {
                            if (Utils.GetCookie("wxOAuth_WeChatGrant") == "True")
                            {
                                Utils.WriteCookie("wxOAuth_WeChatGrant", "False");

                                Utils.StringToTxt("wxOAuth_wxLogin————公众号openid不存在,是全新用户");

                                #region 创建用户
                                Model.user_info model = new Model.user_info();
                                model.group_id    = (int)EnumCollection.user_group.普通用户;
                                model.user_name   = "";
                                model.phone       = "";
                                model.salt        = Utils.GetCheckCode(6);
                                model.user_pwd    = "";
                                model.nick_name   = userInfo.nickname;
                                model.avatar      = userInfo.headimgurl;
                                model.integral    = 0;
                                model.school_id   = 0;
                                model.school_name = "";
                                model.college     = "";
                                model.job         = "";
                                model.course      = "";
                                model.line_way    = "";
                                model.area        = userInfo.country + userInfo.province + userInfo.city;
                                model.address     = "";
                                model.reg_ip      = RequestHelper.GetIP();
                                model.add_time    = System.DateTime.Now;

                                BLL.user_info bll = new BLL.user_info();
                                int           row = bll.Add(model);
                                if (row > 0)
                                {
                                    model.id                 = row;
                                    entity.UserInfo          = model;
                                    entity.UserInfo.user_pwd = "";
                                    entity.UserInfo.salt     = "";
                                    entity.UserInfo.reg_ip   = "";

                                    BLL.user_tree tBll = new BLL.user_tree();
                                    //1 创建code
                                    string tree_code = string.Empty;
                                    do
                                    {
                                        tree_code = Utils.Number(6);
                                    } while (tBll.GetModel(" code = '" + tree_code + "'") != null);

                                    //添加关系
                                    #region 添加关系
                                    Model.user_tree tree = new Model.user_tree();
                                    tree.user_id     = row;
                                    tree.code        = tree_code;
                                    tree.parent_code = "0";
                                    tree.grand_code  = "0";

                                    int treeid = tBll.Add(tree);
                                    if (treeid > 0)
                                    {
                                        tree.id         = treeid;
                                        entity.UserTree = tree;
                                    }
                                    #endregion

                                    #region 添加认证信息
                                    Utils.StringToTxt("wxOAuth_wxLogin————用户信息:" + Newtonsoft.Json.JsonConvert.SerializeObject(model));

                                    Model.user_oauths model1 = new Model.user_oauths();
                                    model1.user_id = row;
                                    model1.type    = (int)EnumCollection.user_oauths.公众号微信登录;
                                    model1.name    = EnumCollection.user_oauths.公众号微信登录.ToString();
                                    model1.appid   = userInfo.openid;
                                    model1.unionid = userInfo.unionid;

                                    int oaid = new BLL.user_oauths().Add(model1);
                                    if (row > 0)
                                    {
                                        model1.id         = row;
                                        entity.UserOAuths = model1;

                                        Utils.StringToTxt("wxOAuth_wxLogin————新增的认证信息:" + Newtonsoft.Json.JsonConvert.SerializeObject(model1));
                                    }
                                    #endregion

                                    Response.Redirect(decodeurl);
                                    return;
                                }
                                else
                                {
                                    Utils.WriteCookie("wxOAuth_WeChatGrant", "True");
                                    string url = WeChatContext.GetRedirectCode("/html/wxOAuth.aspx", state, true);
                                    Response.Redirect(url);
                                    return;
                                }
                                #endregion
                            }
                            else
                            {
                                Utils.WriteCookie("wxOAuth_WeChatGrant", "True");
                                string url = WeChatContext.GetRedirectCode("/html/wxOAuth.aspx", state, true);
                                Response.Redirect(url);
                                return;
                            }
                        }
                    }
                    else
                    {
                        Response.Write("微信认证失败,请重试");
                        return;
                    }
                }
                else
                {
                    Response.Write("token获取失败");
                    return;
                }
            }
        }
Ejemplo n.º 13
0
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("_ybd_user_info", EnumCollection.ActionEnum.Add.ToString()); //检查权限

            #region
            string strError = string.Empty;
            if (txtgroup_id.Text.Trim() == "" || txtgroup_id.Text.Trim().Length > 4)
            {
                strError += "用户分组为空或超出长度![br]";
            }
            if (txtuser_name.Text.Trim() == "" || txtuser_name.Text.Trim().Length > 50)
            {
                strError += "用户名为空或超出长度![br]";
            }
            if (txtphone.Text.Trim() == "" || txtphone.Text.Trim().Length > 50)
            {
                strError += "手机号为空或超出长度![br]";
            }
            if (txtsalt.Text.Trim() == "" || txtsalt.Text.Trim().Length > 50)
            {
                strError += "随机加密字符串为空或超出长度![br]";
            }
            if (txtuser_pwd.Text.Trim() == "" || txtuser_pwd.Text.Trim().Length > 200)
            {
                strError += "密码为空或超出长度![br]";
            }
            if (txtnick_name.Text.Trim() == "" || txtnick_name.Text.Trim().Length > 50)
            {
                strError += "昵称为空或超出长度![br]";
            }
            if (txtavatar.Text.Trim() == "" || txtavatar.Text.Trim().Length > 255)
            {
                strError += "头像为空或超出长度![br]";
            }
            if (txtintegral.Text.Trim() == "" || txtintegral.Text.Trim().Length > 4)
            {
                strError += "积分为空或超出长度![br]";
            }
            if (txtschool_id.Text.Trim() == "" || txtschool_id.Text.Trim().Length > 4)
            {
                strError += "学校ID为空或超出长度![br]";
            }
            if (txtschool_name.Text.Trim() == "" || txtschool_name.Text.Trim().Length > 50)
            {
                strError += "学校姓名为空或超出长度![br]";
            }
            if (txtcollege.Text.Trim() == "" || txtcollege.Text.Trim().Length > 50)
            {
                strError += "院系为空或超出长度![br]";
            }
            if (txtjob.Text.Trim() == "" || txtjob.Text.Trim().Length > 50)
            {
                strError += "职位为空或超出长度![br]";
            }
            if (txtcourse.Text.Trim() == "" || txtcourse.Text.Trim().Length > 50)
            {
                strError += "所授课程为空或超出长度![br]";
            }
            if (txtline_way.Text.Trim() == "" || txtline_way.Text.Trim().Length > 50)
            {
                strError += "联系方式为空或超出长度![br]";
            }
            if (txtarea.Text.Trim() == "" || txtarea.Text.Trim().Length > 200)
            {
                strError += "区域为空或超出长度![br]";
            }
            if (txtaddress.Text.Trim() == "" || txtaddress.Text.Trim().Length > 200)
            {
                strError += "详细地址为空或超出长度![br]";
            }
            if (txtreg_ip.Text.Trim() == "" || txtreg_ip.Text.Trim().Length > 50)
            {
                strError += "注册IP为空或超出长度![br]";
            }
            if (txtadd_time.Text.Trim() == "" || txtadd_time.Text.Trim().Length > 8)
            {
                strError += "注册时间为空或超出长度![br]";
            }

            if (strError != string.Empty)
            {
                JscriptMsg(strError, "", "Error");
                return;
            }
            #endregion

            Model.user_info model = new Model.user_info();
            BLL.user_info   bll   = new BLL.user_info();

            model.group_id    = Convert.ToInt32(txtgroup_id.Text);
            model.user_name   = Convert.ToString(txtuser_name.Text);
            model.phone       = Convert.ToString(txtphone.Text);
            model.salt        = Convert.ToString(txtsalt.Text);
            model.user_pwd    = Convert.ToString(txtuser_pwd.Text);
            model.nick_name   = Convert.ToString(txtnick_name.Text);
            model.avatar      = Convert.ToString(txtavatar.Text);
            model.integral    = Convert.ToInt32(txtintegral.Text);
            model.school_id   = Convert.ToInt32(txtschool_id.Text);
            model.school_name = Convert.ToString(txtschool_name.Text);
            model.college     = Convert.ToString(txtcollege.Text);
            model.job         = Convert.ToString(txtjob.Text);
            model.course      = Convert.ToString(txtcourse.Text);
            model.line_way    = Convert.ToString(txtline_way.Text);
            model.area        = Convert.ToString(txtarea.Text);
            model.address     = Convert.ToString(txtaddress.Text);
            model.reg_ip      = Convert.ToString(txtreg_ip.Text);
            model.add_time    = Convert.ToDateTime(txtadd_time.Text);

            int id = bll.Add(model);
            if (id > 0)
            {
                AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加用户信息信息,主键:" + id); //记录日志
                JscriptMsg("添加用户信息信息成功!", "Manage.aspx", "");
            }
            else
            {
                JscriptMsg("保存过程中发生错误!", "");
            }
        }
Ejemplo n.º 14
0
        private void SumScore(int exa_id, int uid)
        {
            int truth_count = 0;
            int score       = 0;

            BLL.common_questions     qBll  = new BLL.common_questions();
            BLL.answer_record        arBll = new BLL.answer_record();
            BLL.common_answers       aBll  = new BLL.common_answers();
            Model.user_info          user  = new BLL.user_info().GetModel(uid);
            Model.common_examination exa   = new BLL.common_examination().GetModel(exa_id);
            if (exa != null)
            {
                DataTable dt = arBll.GetList(" exa_id = " + exa_id + " and user_id = " + uid);

                foreach (DataRow item in dt.Rows)
                {
                    #region 批改作业按老师选择对错为准
                    int is_truth = Convert.ToInt32(item["is_truth"]);

                    if (is_truth == 1)
                    {
                        truth_count++;
                        score += Convert.ToInt32(item["score"]);
                    }
                    #endregion

                    #region 批改作业按答题记录为准
                    //int q_id = Convert.ToInt32(item["q_id"]);
                    //string answer = item["answer"].ToString();

                    //Model.common_questions question = qBll.GetModel(q_id);
                    //if (!string.IsNullOrEmpty(answer))//没有答题
                    //{
                    //    if (question.type == (int)EnumCollection.questions_type.单选题 || question.type == (int)EnumCollection.questions_type.判断题)
                    //    {
                    //        Model.common_answers anModel = aBll.GetModel(Convert.ToInt32(answer));
                    //        if (anModel.options == question.answer)
                    //        {
                    //            truth_count++;
                    //            score += Convert.ToInt32(item["score"]);
                    //        }
                    //    }
                    //    if (question.type == (int)EnumCollection.questions_type.多选题)
                    //    {
                    //        string[] ids = answer.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                    //        string anids = string.Empty;
                    //        foreach (string id in ids)
                    //        {
                    //            Model.common_answers anModel = aBll.GetModel(Convert.ToInt32(id));
                    //            anids += anModel.options + ",";
                    //        }
                    //        if (question.answer == Utils.DelLastComma(anids))
                    //        {
                    //            truth_count++;
                    //            score += Convert.ToInt32(item["score"]);
                    //        }
                    //    }
                    //    if (question.type == (int)EnumCollection.questions_type.填空题 || question.type == (int)EnumCollection.questions_type.主观题)
                    //    {
                    //        if (answer.Contains(question.answer))
                    //        {
                    //            truth_count++;
                    //            score += Convert.ToInt32(item["score"]);
                    //        }
                    //    }
                    //}
                    #endregion
                }

                BLL.answer_result   bll   = new BLL.answer_result();
                Model.answer_result model = bll.GetModel(" group_id = " + (int)EnumCollection.examination_group.课堂作业 + " and exa_id = " + exa_id + " and user_id = " + uid);
                if (model != null)
                {
                    model.truth_num   = truth_count;
                    model.count       = exa.nums;
                    model.truth_ratio = Convert.ToDecimal((decimal)model.truth_num / (decimal)model.count) * 100;
                    model.score       = score;
                    model.status      = (int)EnumCollection.correcting_status.已批改;

                    bll.Update(model);
                }
                else
                {
                    model             = new Model.answer_result();
                    model.group_id    = (int)EnumCollection.examination_group.课堂作业;
                    model.exa_id      = exa_id;
                    model.exa_title   = exa.name;
                    model.user_id     = uid;
                    model.avatar      = user.avatar;
                    model.nick_name   = user.nick_name;
                    model.use_min     = 0;
                    model.use_sec     = 0;
                    model.truth_num   = truth_count;
                    model.count       = exa.nums;
                    model.truth_ratio = 0;
                    model.score       = score;
                    model.status      = (int)EnumCollection.correcting_status.未批改;
                    model.add_time    = System.DateTime.Now;

                    bll.Add(model);
                }
            }
        }
Ejemplo n.º 15
0
        private void BindData()
        {
            BLL.course_chapter   ccBll   = new BLL.course_chapter();
            Model.course_chapter chapter = ccBll.GetModel(this.chapter);
            if (chapter == null)
            {
                JscriptMsg("没有此节", "back");
                return;
            }

            this.chapter_name = chapter.name;
            Model.course_chapter pModel = ccBll.GetModel(chapter.parent_id);
            if (pModel == null)
            {
                JscriptMsg("没有此章", "back");
                return;
            }

            this.parent_name = pModel.name;
            Model.classroom_info ciModel = new BLL.classroom_info().GetModel(pModel.course_id);
            if (ciModel == null)
            {
                JscriptMsg("没有此课堂", "back");
                return;
            }

            this.class_name = ciModel.name;
            Model.user_info user = new BLL.user_info().GetModel(" phone = '" + adminInfo.user_name + "' ");
            if (user == null)
            {
                JscriptMsg("没有此教师", "back");
                return;
            }

            if (ciModel.user_id != user.id)
            {
                JscriptMsg("此课堂不属于你", "back");
                return;
            }

            Model.common_examination exaModel = new BLL.common_examination().GetModel(this.exa_id);
            if (exaModel == null)
            {
                JscriptMsg("没有此作业", "back");
                return;
            }

            this.examination = exaModel.name;
            #region 组装查询条件
            string whereStr = " 1 = 1 ";

            DataTable dtids = new BLL.examination_question().GetList(" exa_id = " + this.exa_id);
            string    ids   = string.Empty;
            foreach (DataRow item in dtids.Rows)
            {
                ids += Convert.ToInt32(item["q_id"]) + ",";
            }

            ids = Utils.DelLastComma(ids);

            if (!string.IsNullOrEmpty(ids))
            {
                whereStr += " and id in (" + ids + ") ";
            }


            string _keywords = keywords.Replace("'", "");

            if (!string.IsNullOrEmpty(_keywords))
            {
                if (Utils.IsSafeSqlString(_keywords))
                {
                    whereStr += " and (Title like  '%" + _keywords + "%')";
                }
                else
                {
                    JscriptMsg("搜索关键词中包含危险字符,检索终止!", Utils.CombUrlTxt("currect_question_list.aspx", "keywords={0}", ""));
                    return;
                }
            }

            if (this.type > 0)
            {
                this.ddlType.SelectedValue = this.type + "";
                whereStr += " and type = " + this.type;
            }
            #endregion

            this.page        = RequestHelper.GetQueryInt("page", 1);
            txtKeywords.Text = this.keywords;
            BLL.common_questions bll = new BLL.common_questions();
            this.rptList.DataSource = bll.GetListByPage(whereStr, "ID", this.page, this.pageSize);
            this.rptList.DataBind();

            this.totalCount = bll.GetRecordCount(whereStr);
            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("currect_question_list.aspx", "keywords={0}&page={1}&type={2}", this.keywords, "__id__", this.type + "");
            PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
        //保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            BLL.user_info bll = new BLL.user_info();

            if (action == EnumCollection.ActionEnum.Modify.ToString())                          //修改
            {
                ChkAdminLevel("_share_user_list", EnumCollection.ActionEnum.Modify.ToString()); //检查权限
                Model.user_info model = bll.GetModel(this.id);

                model.group_id    = (int)EnumCollection.user_group.资源分享用户;
                model.user_name   = Convert.ToString(txtuser_name.Text);
                model.phone       = Convert.ToString(txtphone.Text);
                model.salt        = Utils.GetCheckCode(6);
                model.user_pwd    = DESEncrypt.Encrypt(txtuser_pwd.Text.Trim().ToUpper(), model.salt.Trim());
                model.nick_name   = Convert.ToString(txtnick_name.Text);
                model.avatar      = Convert.ToString(txtavatar.Text);
                model.school_id   = 0;
                model.school_name = "";
                model.college     = "";
                model.job         = "";
                model.course      = "";
                model.line_way    = "";
                model.area        = "";
                model.address     = "";
                model.reg_ip      = RequestHelper.GetIP();

                if (bll.Update(model))
                {
                    AddAdminLog(EnumCollection.ActionEnum.Modify.ToString(), "修改用户信息,主键:" + id); //记录日志
                    JscriptMsg("修改用户信息成功!", "share_user_list.aspx?page=" + this.page);
                }
                else
                {
                    JscriptMsg("保存过程中发生错误!", "");
                }
            }
            else //添加
            {
                ChkAdminLevel("_course_adR", EnumCollection.ActionEnum.Add.ToString()); //检查权限

                Model.user_info model = bll.GetModel(" phone = '" + this.txtphone.Text.Trim() + "'");
                if (model != null)
                {
                    JscriptMsg("此手机号已被注册", "");
                    return;
                }

                model             = new Model.user_info();
                model.group_id    = (int)EnumCollection.user_group.资源分享用户;
                model.user_name   = Convert.ToString(txtuser_name.Text);
                model.phone       = Convert.ToString(txtphone.Text);
                model.salt        = Utils.GetCheckCode(6);
                model.user_pwd    = DESEncrypt.Encrypt(Utils.MD5(txtuser_pwd.Text.Trim()).ToUpper(), model.salt.Trim());
                model.nick_name   = Convert.ToString(txtnick_name.Text);
                model.avatar      = Convert.ToString(txtavatar.Text);
                model.school_id   = 0;
                model.school_name = "";
                model.college     = "";
                model.job         = "";
                model.course      = "";
                model.line_way    = "";
                model.area        = "";
                model.address     = "";
                model.reg_ip      = RequestHelper.GetIP();
                model.add_time    = System.DateTime.Now;

                int id = bll.Add(model);
                if (id > 0)
                {
                    AddAdminLog(EnumCollection.ActionEnum.Add.ToString(), "添加用户信息,主键:" + id); //记录日志
                    JscriptMsg("添加用户信息成功!", "share_user_list.aspx");
                }
                else
                {
                    JscriptMsg("保存过程中发生错误!", "");
                }
            }
        }