Ejemplo n.º 1
0
        private void ShowInfo(long RoleId)
        {
            var bll   = new BLL.CCOM.Role();
            var model = bll.GetModel("Role_id=" + RoleId);

            this.txtName.Text = model.Role_name;
        }
Ejemplo n.º 2
0
        private string DoAction()
        {
            string result = "";

            BLL.CCOM.Role   bll = new BLL.CCOM.Role();
            Model.CCOM.Role model;
            if (action == MyEnums.ActionEnum.Add.ToString())
            {
                model = new Model.CCOM.Role();
            }
            else
            {
                model = bll.GetModel("Role_id=" + roleId);
            }
            string Name = this.txtName.Text.Trim();

            if (Tools.CheckParams(Name))
            {
                return("请勿输入非法字符");
            }

            if (Name == "")
            {
                return("请填写角色名");
            }
            model.Role_name   = Name;
            model.Role_status = true;
            try
            {
                if (action == MyEnums.ActionEnum.Edit.ToString()) //修改
                {
                    bll.Update(model);
                }
                else
                {
                    bll.Add(model);
                }
            }
            catch (Exception ex)
            {
                result = action == MyEnums.ActionEnum.Edit.ToString() ? "修改失败" : "添加失败" + ex.Message.ToString();
            }

            return(result);
        }
        public void BindRole()
        {
            string sql = "Role_status = 1";

            BLL.CCOM.Role bll = new BLL.CCOM.Role();
            DataSet       ds  = bll.GetList(sql);

            this.ddlRole.DataSource     = ds.Tables[0].DefaultView;
            this.ddlRole.DataTextField  = "Role_name";
            this.ddlRole.DataValueField = "Role_id";
            this.ddlRole.DataBind();
            ListItem item = new ListItem("--请选择角色--", "#");

            this.ddlRole.Items.Insert(0, item);
            ListItem it = this.ddlRole.Items.FindByValue("1");

            this.ddlRole.Items.Remove(it);
        }
Ejemplo n.º 4
0
        protected void lbtAble_Click(object sender, EventArgs e)
        {
            var bll = new BLL.CCOM.Role();

            var lbtn = sender as LinkButton;

            if (lbtn != null)
            {
                var  id     = Int64.Parse(DESEncrypt.Decrypt(lbtn.ToolTip.ToString()));
                bool isOn   = false;
                bool result = true;
                try
                {
                    var m = bll.GetModel("Role_id=" + id);
                    isOn          = m.Role_status == true;
                    m.Role_status = isOn ^ true;
                    if (bll.Update(m) == false)
                    {
                        result = false;
                    }
                }
                catch
                {
                    result = false;
                }
                string keywords = MyRequest.GetQueryString("keywords");
                int    page     = MyRequest.GetQueryInt("page", 1);
                if (result == true)
                {
                    JscriptMsg(isOn ? "禁用成功!" : "启用成功!", Utils.CombUrlTxt("RoleList.aspx", "fun_id={0}&keywords={1}&page={2}",
                                                                          DESEncrypt.Encrypt(this.fun_id), keywords, page.ToString()), "Success");
                }
                else
                {
                    JscriptMsg(isOn ? "禁用失败!" : "启用失败!", Utils.CombUrlTxt("RoleList.aspx", "fun_id={0}&keywords={1}&page={2}",
                                                                          DESEncrypt.Encrypt(this.fun_id), keywords, page.ToString()), "Error");
                }
                RptBind(CombSqlTxt(this.keywords), " Role_id desc ");
            }
        }
Ejemplo n.º 5
0
        //tab1
        #region 数据绑定=================================

        private void RptBind(string _strWhere, string _order)
        {
            int    pageSize    = GetPageSize(15); //每页数量
            int    page        = MyRequest.GetQueryInt("page", 1);
            string keywords    = MyRequest.GetQueryString("keywords");
            int    start_index = pageSize * (page - 1) + 1;
            int    end_index   = pageSize * page;

            this.txtKeywords.Text = keywords;

            var bll = new BLL.CCOM.Role();
            //计算数量
            int totalCount = bll.GetRecordCount(_strWhere);

            //绑定当页
            this.rptList.DataSource = bll.GetListByPage(_strWhere, _order, start_index, end_index);
            this.rptList.DataBind();

            //绑定页码
            txtPageNum.Text = pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("RoleList.aspx", "fun_id={0}&keywords={1}&page={2}", DESEncrypt.Encrypt(this.fun_id), this.keywords, "__id__");

            this.PageContent.InnerHtml = Utils.OutPageList(pageSize, page, totalCount, pageUrl, 8, true);
        }
Ejemplo n.º 6
0
        protected string ImportDataItem(DataSet ds, ref int success, ref int error)//基础数据
        {
            string result = "";

            BLL.CCOM.User_information   bll   = new BLL.CCOM.User_information();
            Model.CCOM.User_information model = new Model.CCOM.User_information();

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                string checkmsg = null;
                //姓名
                string name = ds.Tables[0].Rows[i]["姓名"].ToString().Trim();
                if (!ValidDFValue(name, true, "", ref checkmsg))
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,姓名" + checkmsg + "<br/>";
                    error++;
                    continue;
                }
                else if (name != "")
                {
                    model.User_realname = name;
                }
                //学号/工号
                string mobile = ds.Tables[0].Rows[i]["学号/工号"].ToString().Trim();
                if (!Validator.IsMobile(mobile))
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,学号/工号要为整数<br/>";
                    error++;
                    continue;
                }
                if (!ValidDFValue(mobile, true, "", ref checkmsg))
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,学号/工号" + checkmsg + "<br/>";
                    error++;
                    continue;
                }
                else if (bll.GetRecordCount(" User_number='" + mobile + "'") > 0)
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,该学号/工号已被添加<br/>";
                    error++;
                    continue;
                }
                else if (mobile != "")
                {
                    model.User_number = mobile;
                }
                //性别
                string gender = ds.Tables[0].Rows[i]["性别"].ToString().Trim();
                if (!ValidDFValue(gender, true, "男|女", ref checkmsg))
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,性别" + checkmsg + "<br/>";
                    error++;
                    continue;
                }
                else if (gender == "男")
                {
                    model.User_gender = false;
                }
                else if (gender == "女")
                {
                    model.User_gender = true;
                }
                //机构
                string angency = ds.Tables[0].Rows[i]["机构/班号"].ToString().Trim();
                if (!ValidDFValue(angency, true, "", ref checkmsg))
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,所在机构/班号" + checkmsg + "<br/>";
                    error++;
                    continue;
                }
                BLL.CCOM.Agency   agency_bll   = new BLL.CCOM.Agency();
                Model.CCOM.Agency agency_model = new Model.CCOM.Agency();
                agency_model = agency_bll.GetModel(" Agency_name='" + angency + "'");
                if (agency_model == null)
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,所在机构/班号不存在<br/>";
                    error++;
                    continue;
                }
                model.Agency_id = agency_model.Agency_id;
                //角色
                string role = ds.Tables[0].Rows[i]["角色"].ToString().Trim();
                if (!ValidDFValue(role, true, "", ref checkmsg))
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,角色<br/>";
                    error++;
                    continue;
                }
                BLL.CCOM.Role   role_bll   = new BLL.CCOM.Role();
                Model.CCOM.Role role_model = new Model.CCOM.Role();
                role_model = role_bll.GetModel(" Role_name='" + role + "'");
                if (role_model == null)
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新失败,用户角色不存在<br/>";
                    error++;
                    continue;
                }
                model.Role_id = role_model.Role_id;

                //生日
                //string birthday = ds.Tables[0].Rows[i]["生日"].ToString().Trim();
                //if (!ValidDFValue(birthday, false, "", ref checkmsg))
                //{
                //    result += "×第" + (i + 1).ToString() + "行数据更新失败,生日" + checkmsg + "<br/>";
                //    error++;
                //    continue;
                //}
                //else if (birthday != "")
                //{
                //    if (!Validator.IsBirthday(birthday))
                //    {
                //        result += "×第" + (i + 1).ToString() + "行数据更新失败,生日格式不对<br/>";
                //        error++;
                //        continue;
                //    }
                //    model.User_birthday = Convert.ToDateTime(birthday);
                //}
                //model.User_password = mobile;

                ////教师职称
                //string title = ds.Tables[0].Rows[i]["教师职称"].ToString().Trim();

                //BLL.CCOM.Title title_bll = new BLL.CCOM.Title();
                //Model.CCOM.Title title_model = new Model.CCOM.Title();
                //title_model = title_bll.GetModel(" Title_name='" + title + "'");
                //if (title_model == null)
                //{
                //    result += "×第" + (i + 1).ToString() + "行数据更新失败,该教师职称不存在<br/>";
                //    error++;
                //    continue;
                //}
                //else if (!ValidDFValue(title, true, "", ref checkmsg))
                //{
                //    result += "×第" + (i + 1).ToString() + "行数据更新失败,教师职称<br/>";
                //    error++;
                //    continue;
                //}
                model.User_password = DESEncrypt.MD5Encrypt(mobile);
                if (bll.Add(model) == 0)
                {
                    result += "×第" + (i + 1).ToString() + "行数据更新异常<br/>";
                    error++;
                    continue;
                }
                else
                {
                    success++;
                    BLL.CCOM.User_information   user_bll   = new BLL.CCOM.User_information();
                    Model.CCOM.User_information user_model = user_bll.GetModel("User_number='" + mobile + "'");
                    if (model.Role_id == 2) //如果为指导教师,插入Tutor表
                    {
                        BLL.CCOM.Tutor   tutor_bll   = new BLL.CCOM.Tutor();
                        Model.CCOM.Tutor tutor_model = new Model.CCOM.Tutor();
                        tutor_model.User_id  = user_model.User_id;
                        tutor_model.Title_id = 1;
                        tutor_bll.Add(tutor_model);
                    }
                    if (model.Role_id == 3)//如果为学生,插入Student表
                    {
                        BLL.CCOM.Student   student_bll   = new BLL.CCOM.Student();
                        Model.CCOM.Student student_model = new Model.CCOM.Student();
                        student_model.User_id   = user_model.User_id;
                        student_model.Period_id = 4;
                        student_bll.Add(student_model);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 7
0
        private void ManagePage_Load(object sender, EventArgs e)
        {
            //return;

            //判断后台是否登录
            if (checkLogin && !IsAdminLogin())
            {
                Redirect(MyEnums.RediirectErrorEnum.SessionNull);
                return;
            }

            if (checkLogin && checkUserStaus && (Session[MyKeys.SESSION_ADMIN_INFO] == null || Session[MyKeys.SESSION_USER_STATUSID] == null))
            {
                //Response.Write("<script type=\"text/javascript\" src=\"/metro/js/ex-common-scripts.js\"></script><script>if(window.parent != window) getTopWindow().location.href='/adminmetro/index.aspx';"
                //   + " else window.location.href='" + siteConfig.webpath + siteConfig.webmanagepath + "/Login.aspx';</script>");
                Response.Write("<script type=\"text/javascript\" src=\"/metro/js/ex-common-scripts.js\"></script><script>if(window.parent != window) getTopWindow().location.href='/AdminMetro/index.aspx';"
                               + " else window.location.href='/AdminMetro/login_page.aspx';</script>");
                Response.End();
                return;
            }

            if (checkFunID)
            {
                if (MyRequest.GetQueryString("fun_id") != "")
                {
                    fun_id    = DESEncrypt.Decrypt(MyRequest.GetQueryString("fun_id"));
                    user_info = GetAdminInfo_CCOM(); //用户信息
                    String url = HttpContext.Current.Request.Url.AbsolutePath;
                    url = url.Replace("/AdminMetro/", "");

                    BLL.CCOM.Son_function   sfbll   = new BLL.CCOM.Son_function();
                    Model.CCOM.Son_function sfModel = sfbll.GetModel("Sf_id =" + fun_id);
                    if (sfModel.Sf_url != url)
                    {
                        InnerRedirect(MyEnums.RediirectErrorEnum.ParameterError);
                    }

                    //BLL.CCOM.Admin_permission bll = new BLL.CCOM.Admin_permission();
                    //Model.CCOM.Admin_permission model = bll.GetModel("Sf_id =" + fun_id + "and User_id =" + user_info.User_id);
                    //if (model == null)
                    //{
                    //    InnerRedirect(MyEnums.RediirectErrorEnum.NotAdmin);
                    //}
                    //else
                    //{
                    BLL.CCOM.Role rolebll = new BLL.CCOM.Role();
                    //Model.CCOM.Role roleModel = rolebll.GetModel("Role_id IN (SELECT Role_id FROM Role_permission WHERE User_id = " + user_info.User_id + ")");
                    Model.CCOM.Role roleModel = rolebll.GetModel("Role_id IN (SELECT Role_id FROM User_information WHERE User_id = " + user_info.User_id + ")");

                    if (!roleModel.Role_status)
                    {
                        BLL.CCOM.Role_permission          rpbll   = new BLL.CCOM.Role_permission();
                        List <Model.CCOM.Role_permission> rpmodel = rpbll.GetModelList("Sf_id =" + fun_id + "and Role_id =" + roleModel.Role_id);
                        if (rpmodel.Count > 0)
                        {
                            InnerRedirect(MyEnums.RediirectErrorEnum.NotAdmin);
                        }
                    }
                }
                else
                {
                    InnerRedirect(MyEnums.RediirectErrorEnum.FunIDNull);
                }
            }


            //标志首次登陆
            if (Session[MyKeys.SESSION_FIRST_LOGIN] != null)
            {
                isFirstLogin = true;
            }

            //只要有操作就重写session
            Session[MyKeys.SESSION_ADMIN_INFO] = GetAdminInfo_CCOM();
            Session.Timeout = 300;
            return;
        }