Exemplo n.º 1
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        if (txtName.Text == "" || cbList.SelectedItem == null)
        {
            ShowNotification("用户名或权限未填写");
            return;
        }
        DJ_User_Gov mgrUser = new DJ_User_Gov();

        //修改用户
        if (Request.QueryString["userid"] != null)
        {
            mgrUser = blldj_user.GetGov_UserById(Guid.Parse(Request.QueryString["userid"]));
        }
        //新增用户
        else
        {
            if (blldj_user.GetGov_UserByName(txtName.Text) != null)
            {
                ShowNotification("对不起,该用户名已被注册!");
                return;
            }
            mgrUser.Password = FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5");
        }
        //整理用户数据
        DJ_GovManageDepartment mgrDpt = bllDpt.GetMgrDpt(Guid.Parse(Master.dptid));
        mgrUser.GovDpt = mgrDpt;
        mgrUser.Name = txtName.Text;
        Model.PermissionType sat = 0;
        foreach (ListItem item in cbList.Items)
        {
            if (item.Selected)
            {
                Model.PermissionType permisson = (Model.PermissionType)Enum.Parse(typeof(Model.PermissionType), item.Text.Substring(0, item.Text.IndexOf('(')));
                sat = sat | permisson;
            }
        }
        int result, result2;
        int.TryParse(mgrUser.PermissionType.ToString(), out result);
        int.TryParse(sat.ToString(), out result2);
        if (result == 7 && result2 != 7)
        {
            IList<DJ_User_Gov> Listuser = blldj_user.GetGov_UserBygovId(CurrentDpt.Id, 7);
            if (Listuser != null && Listuser.Count <= 1)
            {
                ShowNotification("目前仅有这一个超级管理员,无法更改权限");
                return;
            }
        }
        mgrUser.PermissionType = sat;
        string message;
        blldj_user.SaveOrUpdate(mgrUser,out message);
        if (message != "")
        {
            ShowNotification(message);
        }
        else
            ShowNotification("提示", "保存成功", "/TourManagerDpt/UserManager.aspx");
    }
Exemplo n.º 2
0
 public void CreateUpdateDptAdmin(DJ_GovManageDepartment mgrDpt)
 {
     TourMembership admin = GetMgrDptAdmin(mgrDpt.Id, 7);
     DJ_User_Gov mgrUser = new DJ_User_Gov();
     if (admin != null)
     {
         mgrUser = (DJ_User_Gov)admin;
     }
     else
     {
         TourMembership member = GetMember(mgrDpt.seoname);
         if (member != null)
         {
             mgrUser = (DJ_User_Gov)member;
         }
     }
     string loginname = mgrDpt.seoname;
     mgrUser.GovDpt = mgrDpt;
     mgrUser.Name = loginname;
     mgrUser.PermissionType = PermissionType.报表查看员 | PermissionType.信息编辑员 | PermissionType.用户管理员;
     mgrUser.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5");
     CreateUpdateMember(mgrUser);
 }
Exemplo n.º 3
0
    protected void btnInitial_Click(object sender, EventArgs e)
    {
        ExcelOplib.ExcelDjsOpr djsopr = new ExcelOplib.ExcelDjsOpr();
        IList<ExcelOplib.Entity.DJSEntity> enlist = djsopr.getDJSlist();
        IList<Enter_excel> templist = new List<Enter_excel>();

        //初始化管理部门
        IList<Model.DJ_GovManageDepartment> govDic = new List<Model.DJ_GovManageDepartment>();
        foreach (var item in enlist.Where(x => x.EnterpType == 数据类型.管理部门))
        {
            govDic.Add(new Model.DJ_GovManageDepartment()
            {
                Name = item.Department1,
                Area = bllarea.GetAreaByAreaname(item.Diqu),
                seoname = item.Seoname
            });
        }
        foreach (var item in govDic)
        {
            if (bllgov.GetGovDptByName(item.Name).Count == 0)
            {
                bllgov.Save(item);
            }
            Model.DJ_User_Gov user_gov = new Model.DJ_User_Gov();
            if (blldjuser.GetGov_UserByName(item.seoname) == null)
            {
                user_gov.Name = item.seoname;
                user_gov.Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5"); ;
                user_gov.GovDpt = bllgov.GetGovDptByName(item.Name)[0];
                user_gov.PermissionType = Model.PermissionType.报表查看员
                    | Model.PermissionType.信息编辑员 | Model.PermissionType.用户管理员;
                /*此处需要修改*/
                //blldjuser.SaveOrUpdate(user_gov);
            }
        }

        //初始化地接社,景区,宾馆
        foreach (var item in enlist)
        {
            if (!string.IsNullOrEmpty(item.Department3))
            {
                string[] results = item.Department3.Split(new string[] { ",", "," }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var item2 in results)
                {
                    templist.Add(new Enter_excel()
                    {
                        name = item2,
                        area = item.Diqu,
                        type = item.EnterpType.ToString(),
                        seoname = item.Seoname
                    });
                }
            }
        }

        foreach (var item in templist)
        {
            var area = bllarea.GetAreaByAreaname(item.area);
            #region MyRegion
            switch (item.type)
            {
                case "地接社":
                    var temp_djs = blldjs.GetDJS8Muti(0, Model.EnterpriseType.旅行社.ToString(), null, item.name);
                    if (temp_djs.Count == 0)
                    {
                        blldjs.AddDjs(item.name, string.Empty, area, "", "", "", "", "", item.seoname);
                    }
                    break;
                case "景区":
                    var temp_scenic = blldjs.GetDJS8Muti(0, Model.EnterpriseType.景点.ToString(), null, item.name);
                    if (temp_scenic.Count == 0)
                    {
                        bllscenic.Save(new Model.Scenic()
                        {
                            Name = item.name,
                            Area = area,
                            SeoName = item.seoname,
                            Type = Model.EnterpriseType.景点
                        });
                    }
                    break;
                case "宾馆":
                    var temp_hotel = blldjs.GetDJS8Muti(0, Model.EnterpriseType.宾馆.ToString(), null, item.name);
                    if (temp_hotel.Count == 0)
                    {
                        blldjs.Save(new Model.DJ_TourEnterprise()
                        {
                            Name = item.name,
                            Area = area,
                            SeoName = item.seoname,
                            Type = Model.EnterpriseType.宾馆
                        });
                    }
                    break;
            }
            #endregion
            var mem = bllmem.GetMember(item.seoname);
            if (mem != null)
            {
                var memEnterp = (Model.DJ_User_TourEnterprise)mem;
                memEnterp.Enterprise = blldjs.GetDJS8name(item.name).First();
                bllmem.CreateUpdateMember(memEnterp);
            }
            else
            {
                var membership=new Model.DJ_User_TourEnterprise()
                {
                    Enterprise = blldjs.GetDJS8name(item.name).First(),
                    Name = item.seoname,
                    PermissionType = PermissionType.报表查看员 | PermissionType.团队录入员 | PermissionType.信息编辑员 | PermissionType.用户管理员,
                    Password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("123456", "MD5")
                };
                bllmem.CreateUpdateMember(membership);
                //如果是景区再添加一个scenicadmin
                if (item.type == "景区")
                {
                    bllscenicadmin.SaveOrUpdate(new ScenicAdmin() {
                        RealName=item.name,
                        Scenic=bllscenic.GetScenicByScenicName(item.name,null,0,null).FirstOrDefault(),
                        Membership=membership,
                        AdminType = Model.ScenicAdminType.检票员 | Model.ScenicAdminType.景区财务 | Model.ScenicAdminType.景区资料员,
                        IsDisabled=false
                    });
                }
            }
        }
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('初始化成功!')", true);
    }