예제 #1
0
 public ActionResult RegisterUser()
 {
     var flag = false;
     try
     {
         var model = new UserInfoModel()
         {
             Account = Normal.ListStr(Request["Account"]),
             Password = Normal.CheckPoint(PwdUtil.MD5Encrypt(Request["Password"])),
             Email = Normal.ListStr(Request["Email"]),
             Name = Normal.ListStr(Request["Name"]),
             Sex = Normal.ListStr(Request["Sex"]),
             BirthDay = Normal.ListStr(Request["BirthDay"]),
             HomeTown = Normal.ListStr(Request["HomeTown"]),
             Marriage = Normal.ListStr(Request["Marriage"]),
             TheLatter = Normal.ListStr(Request["TheLatter"]),
             Position = Normal.ListStr(Request["Position"]),
             Company = Normal.ListStr(Request["Company"]),
             WorkingConditions = Normal.ParseInt(Request["WorkingConditions"]),
             InterestIn = Normal.ListStr(Request["InterestIn"]),
             QQ = Normal.ListStr(Request["QQ"]),
             IntroduceMyself = Normal.ListStr(Request["IntroduceMyself"])
         };
         var personService = new PersonService();
         flag = personService.AddUserInfo(model);
         return flag ? Content("修改成功!") : Content("修改失败!");
     }
     catch (Exception)
     {
         return Content("修改失败!");
     }
 }
예제 #2
0
 public ActionResult DoUpdateUserInfo()
 {
     var flag = false;
     try
     {
         var model = new UserInfoModel()
         {
             Email = Normal.ListStr(Request["Email"]),
             Name = Normal.ListStr(Request["Name"]),
             Sex = Normal.ListStr(Request["Sex"]),
             BirthDay = Normal.ListStr(Request["BirthDay"]),
             HomeTown = Normal.ListStr(Request["HomeTown"]),
             Marriage = Normal.ListStr(Request["Marriage"]),
             TheLatter = Normal.ListStr(Request["TheLatter"]),
             Position = Normal.ListStr(Request["Position"]),
             Company = Normal.ListStr(Request["Company"]),
             WorkingConditions = Normal.ParseInt(Request["WorkingConditions"]),
             InterestIn = Normal.ListStr(Request["InterestIn"]),
             QQ = Normal.ListStr(Request["QQ"]),
             IntroduceMyself = Normal.ListStr(Request["IntroduceMyself"])
         };
         var personService = new PersonService();
         flag = personService.UpdateUserInfo(model);
         return flag ? Content("注册成功!") : Content("注册失败!");
     }
     catch (Exception)
     {
         return Content("注册失败!");
     }
 }
예제 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string type = Request.QueryString["type"];
            UserInfoModel user = new UserInfoModel
            {
                UserID = txtUserID.Value,
                UserName = txtName.Value,
                DeptID = Convert.ToInt32(ddlDept.SelectedValue),
                Cellphone = txtCellphone.Value,
                UserType = Convert.ToByte(ddlType.Value)
            };

            UserInfoBLL bll = new UserInfoBLL();
            try
            {
                if (type == "add")
                {
                    bll.AppendUser(user);
                }
                else
                {
                    if (txtPwd.Value != "")
                    {
                        user.Password = txtPwd.Value;
                    }
                    bll.EditUser(user);
                }
                ClientScript.RegisterStartupScript(this.GetType(), "optuser", "alert('保存成功!');parent.dialog.close();window.parent.location.reload();", true);
            }
            catch
            {
                ClientScript.RegisterStartupScript(this.GetType(), "optuser", "alert('保存失败!');", true);
            }
        }
예제 #4
0
 public int AppendUser(UserInfoModel user)
 {
     string sql = "insert into UserInfo values(@UserID,@UserName,@DeptID,@Password,@Cellphone,@UserType)";
     SqlParameter[] pars = {
         new SqlParameter("@UserID",user.UserID),
         new SqlParameter("@UserName",user.UserName),
         new SqlParameter("@DeptID",user.DeptID),
         new SqlParameter("@Password",MD5Maker.GetMD5("1")),
         new SqlParameter("@Cellphone",user.Cellphone),
         new SqlParameter("@UserType",user.UserType)
     };
     return SqlHelper.ExecuteNonQuery(sql, pars);
 }
예제 #5
0
        //添加用户
        public bool AddUserInfo(UserInfoModel model)
        {
            string sql = string.Format(@"insert into UserInfo(Account,[Password],[Email],Name,Sex,
            TheLatter,HomeTown,Marriage,Position,Company,InterestIn,IntroduceMyself,QQ,WorkingConditions,BirthDay)
            values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}',
                '{9}','{10}','{11}','{12}',{13},'{14}')",
                    model.Account, model.Password, model.Email, model.Name, model.Sex,
                    model.TheLatter, model.HomeTown, model.Marriage,
                    model.Position, model.Company, model.InterestIn, model.IntroduceMyself,
                    model.QQ, model.WorkingConditions, model.BirthDay);

            return SqlAccess.Execute(sql) > 0;
        }
예제 #6
0
 public int EditPrivate(UserInfoModel user)
 {
     string sql = "update UserInfo set {0}Cellphone=@Cellphone where UserID=@UserID";
     List<SqlParameter> list = new List<SqlParameter>();
     list.Add(new SqlParameter("@UserID", user.UserID));
     list.Add(new SqlParameter("@Cellphone", user.Cellphone));
     if (user.Password != null)
     {
         sql = string.Format(sql, "Password=@Password,");
         list.Add(new SqlParameter("@Password", user.Password));
     }
     else sql = string.Format(sql, "");
     return SqlHelper.ExecuteNonQuery(sql, list.ToArray());
 }
예제 #7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        UserStore<IdentityUser> userStore = new UserStore<IdentityUser>();

        userStore.Context.Database.Connection.ConnectionString =
            System.Configuration.ConfigurationManager.ConnectionStrings["CANDZOILPDBConnectionString"].ConnectionString;
        
        UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);

        IdentityUser user = new IdentityUser();
        user.UserName = txtUserName.Text;

        if (txtPassword.Text.Equals(txtConfirmPassword.Text))
        {
            try {
                IdentityResult result = manager.Create(user, txtPassword.Text);
                if (result.Succeeded)
                {
                    UserInformation info = new UserInformation
                    {

                        Address = txtAddress.Text,
                        FirstName = txtFirstName.Text,
                        LastName = txtLastName.Text,
                        PostalCode = Convert.ToInt32(txtPostalCode.Text),
                        GUID = user.Id
                    };

                    UserInfoModel model = new UserInfoModel();
                    model.InsertUserInformation(info);

                    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;

                    var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

                    authenticationManager.SignIn(new AuthenticationProperties(), userIdentity);
                    Response.Redirect("~/Index.aspx");
                }else{
                    litStatusMessage.Text = result.Errors.FirstOrDefault();
                }
            }
            catch (Exception er)
            {
                litStatusMessage.Text = er.ToString();
            }
        }
        else {
            litStatusMessage.Text = "Passwords must match!";
        }
    }
예제 #8
0
 public int EditUser(UserInfoModel user)
 {
     string sql = "update UserInfo set UserName=@UserName,DeptID=@DeptID,{0}Cellphone=@Cellphone,UserType=@UserType where UserID=@UserID";
     List<SqlParameter> list = new List<SqlParameter>();
     list.Add(new SqlParameter("@UserID", user.UserID));
     list.Add(new SqlParameter("@UserName", user.UserName));
     list.Add(new SqlParameter("@DeptID", user.DeptID));
     list.Add(new SqlParameter("@Cellphone", user.Cellphone));
     list.Add(new SqlParameter("@UserType", user.UserType));
     if (user.Password != null)
     {
         sql = string.Format(sql, "Password=@Password,");
         list.Add(new SqlParameter("@Password", MD5Maker.GetMD5(user.Password)));
     }
     else sql = string.Format(sql, "");
     return SqlHelper.ExecuteNonQuery(sql, list.ToArray());
 }
예제 #9
0
 public UserInfoModel GetUserById(string userID)
 {
     string sql = "select * from UserInfo where UserID=@UserID";
     SqlParameter par = new SqlParameter("@UserID", userID);
     UserInfoModel user = new UserInfoModel();
     using (SqlDataReader reader = SqlHelper.ExecuteReader(sql, par))
     {
         while (reader.Read())
         {
             user.UserID = reader["UserID"] as string;
             user.UserName = reader["UserName"] as string;
             user.DeptID = (int)reader["DeptID"];
             user.Password = reader["Password"] as string;
             user.Cellphone = reader["Cellphone"] as string;
             user.UserType = (byte)reader["UserType"];
         }
     }
     return user;
 }
예제 #10
0
        public static ObjectData saveCloud(MetaObject metaObj, UserInfoModel info)
        {
            ObjectData data = new ObjectData(metaObj);

            data.CreatedBy        = userId;
            data.CreatedTime      = DateTime.Now;
            data.ModifiedBy       = userId;
            data.ModifiedTime     = DateTime.Now;
            data["StdIsDeleted"]  = false;
            data["SuiteKey"]      = SystemInfo.SuiteKey; //配置文件
            data["ISVTenantId"]   = info.TenantId;
            data["UserId"]        = info.UserId;
            data["UserType"]      = info.Type;
            data["MappingUserId"] = info.OpenId;
            data["CorpId"]        = info.AppId;
            data["Status"]        = info.State;// 值需要对应一下,,值代表的含义不一致
            data["StaffId"]       = info.UserId;
            data["MappingType"]   = "21";
            data["AppId"]         = SystemInfo.AppId; //配置文件

            return(data);
        }
예제 #11
0
        public void UserInfoLogon(string Name, string Key)
        {
            url += "/Login/Login";
            UserInfoModel m = new UserInfoModel()
            {
                Uname = Name, Upwd = Key
            };

            string s    = JsonConvert.SerializeObject(m);
            string data = HttpClientHeper.Post(url, s);
            List <UserInfoModel> list = JsonConvert.DeserializeObject <List <UserInfoModel> >(data);

            if (list.Count > 0)
            {
                //Cooke事件
                HttpCookie cookie = new HttpCookie("User");
                //给Cooke赋值
                cookie.Value = list.First().Uname;
                //给Cooke设置过期时间
                cookie.Expires = DateTime.Now.AddMinutes(20);
                //添加到服务器
                Response.AppendCookie(cookie);

                HttpCookie http = new HttpCookie("Cooke");
                //Cooke传入并编码
                http.Value   = HttpUtility.UrlEncode(data, Encoding.GetEncoding("UTF-8"));
                http.Expires = DateTime.Now.AddMinutes(20);
                Response.AppendCookie(http);


                Session["ID"] = list.First().UIDa;
                int ids = Convert.ToInt32(Session["ID"]);
                Response.Write("<script>alert('登录成功!');location.href='/News/NewIndex'</script>");
            }
            else
            {
                Response.Write("<script>alert('用户名错误,或密码错误!');location.href='/UserInfo/UserInfoLogon'</script>");
            }
        }
예제 #12
0
        private void _Init(int deck_id, int enemy_deck_id, BattleManager bManager, BattleResultFmt fmt, List <ShipModel_BattleAll> ships_f, List <ShipModel_BattleAll> ships_e, Dictionary <int, int> exp_rates_before)
        {
            UserInfoModel userInfo = bManager.UserInfo;
            DeckModel     deck     = userInfo.GetDeck(deck_id);

            _deck_name = deck.Name;
            _user_name = userInfo.Name;
            _fmt       = fmt;
            _ships_f   = ships_f.ConvertAll((ShipModel_BattleAll ship) => (ShipModel_BattleResult)ship);
            _ships_e   = ships_e.ConvertAll((ShipModel_BattleAll ship) => (ShipModel_BattleResult)ship);
            _mvp_ship  = _ships_f.Find((ShipModel_BattleResult ship) => ship != null && ship.TmpId == _fmt.MvpShip);
            for (int i = 0; i < Ships_f.Length; i++)
            {
                ShipModel_BattleResult shipModel_BattleResult = Ships_f[i];
                if (shipModel_BattleResult != null)
                {
                    _SetShipExp(deck, shipModel_BattleResult, exp_rates_before);
                    _hp_start_f += shipModel_BattleResult.HpStart;
                    _hp_end_f   += shipModel_BattleResult.HpEnd;
                }
            }
            DeckModel deck2 = userInfo.GetDeck(enemy_deck_id);

            for (int j = 0; j < Ships_e.Length; j++)
            {
                ShipModel_BattleResult shipModel_BattleResult2 = Ships_e[j];
                if (shipModel_BattleResult2 != null)
                {
                    _SetShipExp(deck2, shipModel_BattleResult2, exp_rates_before);
                    _hp_start_e += shipModel_BattleResult2.HpStart;
                    _hp_end_e   += shipModel_BattleResult2.HpEnd;
                }
            }
            _new_opened_map_ids = fmt.NewOpenMapId.GetRange(0, fmt.NewOpenMapId.Count);
            _new_opened_map_ids.AddRange(fmt.ReOpenMapId);
            _new_opened_area_ids = _new_opened_map_ids.FindAll((int map_id) => map_id % 10 == 1);
            _new_opened_area_ids = _new_opened_area_ids.ConvertAll((int map_id) => (int)Math.Floor((double)map_id / 10.0));
            _first_area_clear    = fmt.FirstAreaComplete;
        }
예제 #13
0
        private async Task <IList <UserInfoModel> > MapUsersResultToModelAsync(IEnumerable <UserFullResult> userResults, IList <UserPhotoResult> userPhotos = null)
        {
            var users = new List <UserInfoModel>();

            foreach (var userResult in userResults)
            {
                var user = new UserInfoModel()
                {
                    Address        = userResult.Address,
                    BirthDate      = userResult.BirthDate,
                    CountryCode    = userResult.CountryCode,
                    CountryId      = userResult.CountryId,
                    CountryName    = userResult.CountryName,
                    Email          = userResult.Email,
                    CreatedDate    = userResult.CreatedDate,
                    Description    = userResult.Description,
                    DisplayName    = userResult.DisplayName,
                    Firstname      = userResult.Firstname,
                    GenderId       = userResult.GenderId,
                    GenderLabel    = userResult.GenderLabel,
                    Lastname       = userResult.Lastname,
                    PhoneNumber    = userResult.PhoneNumber,
                    StatusId       = userResult.StatusId,
                    StatusLabel    = userResult.StatusLabel,
                    UpdatedDate    = userResult.UpdatedDate,
                    UserIdentityId = await _userManager.EncryptUserIdAsync(userResult.Id)
                };

                if (userPhotos != null && userPhotos.Any())
                {
                    var userAvatar = userPhotos.FirstOrDefault(x => x.UserId == userResult.Id);
                    user.AvatarCode = userAvatar.Code;
                }

                users.Add(user);
            }

            return(users);
        }
예제 #14
0
        public bool SaveNewUser(UserInfoModel user)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(SQL_SaveNewUser, conn);
                    cmd.Parameters.AddWithValue("@firstName", user.FirstName);
                    cmd.Parameters.AddWithValue("@lastName", user.LastName);
                    cmd.Parameters.AddWithValue("@email", user.Email);
                    cmd.Parameters.AddWithValue("@password", user.Password);
                    int rowsAffectedOne = cmd.ExecuteNonQuery();
                    return(rowsAffectedOne > 0);
                }
            }
            catch (SqlException ex)
            {
                throw;
            }
        }
예제 #15
0
        private void SetSessions()
        {
            try
            {
                UserInfoModel objUserInfoModel = new UserInfoModel();
                Session["UserName"] = UserName.Text;
                Session["Role"]     = objUserInfoModel.GetRole(UserName.Text);

                Session["UserManagement"]           = objUserInfoModel.SetModuleUser(UserName.Text, "UserManagement");
                Session["RoleManagement"]           = objUserInfoModel.SetModuleUser(UserName.Text, "RoleManagement");
                Session["GroupManagement"]          = objUserInfoModel.SetModuleUser(UserName.Text, "GroupManagement");
                Session["AddEditDeleteIncidents"]   = objUserInfoModel.SetModuleUser(UserName.Text, "AddEditDeleteIncidents");
                Session["AssignmentOfIncident"]     = objUserInfoModel.SetModuleUser(UserName.Text, "AssignmentOfIncident");
                Session["InputProposedDateAndTime"] = objUserInfoModel.SetModuleUser(UserName.Text, "InputProposedDateAndTime");
                Session["UpdateIncidents"]          = objUserInfoModel.SetModuleUser(UserName.Text, "UpdateIncidents");
                Session["CancelIncidents"]          = objUserInfoModel.SetModuleUser(UserName.Text, "CancelIncidents");
                Session["ViewCharts"] = objUserInfoModel.SetModuleUser(UserName.Text, "ViewCharts");
            }
            catch (Exception Ex)
            {
            }
        }
예제 #16
0
        public IActionResult AddUser(UserInfoModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var user     = _mapper.Map <UserInfo>(model);
            var repoUser = _unitOfWork.GetRepository <UserInfo>();

            //内存数据库无自增长
            user.Id = repoUser.GetEntities().OrderByDescending(i => i.Id).FirstOrDefault().Id + 1;
            repoUser.Insert(user);

            var r = _unitOfWork.SaveChanges();

            //_userInfoService.AddUserInfo();
            return(Json(new MgResult()
            {
                Code = r > 0 ? 0 : 1,
                Msg = r > 0 ? "ok" : "SaveChanges失败!"
            }));
        }
예제 #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int           ProductID    = int.Parse(Request["ProductID"].ToString());
            string        ProductName  = Request["ProductName"].ToString();
            string        ProductPic   = Request["ProductPic"].ToString();
            decimal       ProductPrice = decimal.Parse(Request["ProductPrice"].ToString());
            string        ProductDesc  = Request["ProductDesc"].ToString();
            DateTime      AddTime      = DateTime.Parse(Request["AddTime"].ToString());
            UserInfoModel m            = new UserInfoModel();

            m.ProductID    = ProductID;
            m.ProductName  = ProductName;
            m.ProductPic   = ProductPic;
            m.ProductPrice = ProductPrice;
            m.ProductDesc  = ProductDesc;
            m.AddTime      = AddTime;
            string[] strArr = ProductListBLL.Update(m);
            Response.Write("{");
            Response.Write("\"strChk\":" + strArr[0] + ",");
            Response.Write("\"strInfo\":\"" + strArr[1] + "\"");
            Response.Write("}");
        }
예제 #18
0
        public async Task UpdateInfoAsync(string userId, UserInfoModel model)
        {
            if (userId == null)
            {
                throw new ArgumentNullException(nameof(userId));
            }
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            _log.LogInformation($"Update UserInfo: {userId}");
            var user = await _db.Set <User>().FindAsync(userId);

            if (user == null)
            {
                return;
            }
            user.Email  = model.Email;
            user.Mobile = model.Mobile;
            user.Name   = model.Name;
            await _db.SaveChangesAsync();
        }
예제 #19
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public int Add(UserInfoModel user)
        {
            string sql = string.Format(@"
insert into UserInfo(
    DevSN,PIN,UserName,Passwd,IDCard,Grp,TZ,Pri
   ) values (
    @DevSN,@PIN,@UserName,@Passwd,@IDCard,@Grp,@TZ,@Pri
);");

            SQLiteParameter[] parameters =
            {
                new SQLiteParameter("@DevSN",    user.DevSN),
                new SQLiteParameter("@PIN",      user.PIN),
                new SQLiteParameter("@UserName", user.UserName),
                new SQLiteParameter("@Pri",      user.Pri),
                new SQLiteParameter("@Passwd",   user.Passwd),
                new SQLiteParameter("@IDCard",   user.IDCard),
                new SQLiteParameter("@Grp",      user.Grp),
                new SQLiteParameter("@TZ",       user.TZ)
            };
            return(SqliteHelper.ExecuteNonQuery(sql, parameters));
        }
        string GenerateJWTToken(UserInfoModel userInfo)
        {
            string s           = this.configuration["Jwt:SecretKey"];
            var    securityKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(s));
            var    credentials = new SigningCredentials(securityKey, SecurityAlgorithms.HmacSha256);
            var    claims      = new[]
            {
                new Claim(JwtRegisteredClaimNames.Sub, userInfo.UserName),
                new Claim("username", userInfo.UserName.ToString()),
                new Claim("role", userInfo.UserRole),
                new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
            };
            var token = new JwtSecurityToken(
                issuer: this.configuration["Jwt:Issuer"],
                audience: this.configuration["Jwt:Audience"],
                claims: claims,
                expires: DateTime.Now.AddMinutes(30),
                signingCredentials: credentials
                );

            return(new JwtSecurityTokenHandler().WriteToken(token));
        }
        public ActionResult LogIn(string emailid, string password)
        {
            string userRole = "";

            UserInfoModelLogic userLogic = new UserInfoModelLogic();
            UserInfoModel      userInfo  = userLogic.getUser(emailid, password);

            if (userInfo != null)
            {
                Session["userInfo"] = userInfo;
                ConfigurationManager.AppSettings.Set("userRole", userInfo.UserRole);
                TempData["alert"] = new AlertBoxModel()
                {
                    Type = "Success", Message = "User Login Successfully!"
                };

                return(Redirect(userInfo.defaultUrl));
            }
            TempData["alert"] = new AlertBoxModel()
            {
                Type = "Error", Message = "Email Id or Password is Wrong!"
            };

            //if (Response.Cookies["User"] != null)
            //{
            //    HttpCookie userInfo = new HttpCookie("User");
            //    userRole = userInfo["userRole"].ToString();
            //    //userInfo["UserName"] = "******";
            //    //userInfo["UserColor"] = "Black";
            //    //userInfo.Expires.Add(new TimeSpan(0, 1, 0));
            //    //Response.Cookies.Add(userInfo);
            //}
            //else
            //{
            //    //@Html.Action("LogOut", "Authentication", new { @area = "User" })
            //}
            return(View());
        }
예제 #22
0
    private string getAlertMessage(DeckModel deck)
    {
        UserInfoModel userInfo       = StrategyTopTaskManager.GetLogicManager().UserInfo;
        MemberMaxInfo memberMaxInfo  = userInfo.ShipCountData();
        MemberMaxInfo memberMaxInfo2 = userInfo.SlotitemCountData();

        if (deck.GetShips().Any((ShipModel x) => x.IsTaiha()))
        {
            AlertMessage.color = AlertColor;
            return("※大破している艦娘がいます。(被弾により喪失の危険があります)");
        }
        if (memberMaxInfo.MaxCount <= memberMaxInfo.NowCount)
        {
            AlertMessage.color = AlertColor;
            return("※艦娘保有数が上限に達しているため、新しい艦娘との邂逅はできません。");
        }
        if (memberMaxInfo.MaxCount - 6 <= memberMaxInfo.NowCount)
        {
            AlertMessage.color = WarningColor;
            return("※艦娘保有数が上限に近いため、新しい艦娘と邂逅できない可能性があります。");
        }
        if (memberMaxInfo2.MaxCount <= memberMaxInfo2.NowCount)
        {
            AlertMessage.color = AlertColor;
            return("※装備保有数が上限に達しているため、新しい艦娘との邂逅はできません。");
        }
        if (memberMaxInfo2.MaxCount - 24 <= memberMaxInfo2.NowCount)
        {
            AlertMessage.color = WarningColor;
            return("※装備保有数が上限に近いため、新しい艦娘と邂逅できない可能性があります。");
        }
        if (deck.GetShips().Any((ShipModel x) => x.FuelRate < 100.0 || x.AmmoRate < 100.0))
        {
            AlertMessage.color = WarningColor;
            return("※十分な補給を受けていない艦娘がいます。(本来の戦闘力を発揮できません)");
        }
        return(string.Empty);
    }
예제 #23
0
        public async Task <UserInfoModel> DetailsAsync(Guid userId)
        {
            var user = await userManager.FindByIdAsync(userId.ToString());

            if (user == null)
            {
                throw new Exception("Нет такого пользователя");
            }
            var matches = from u in userManager.Users
                          join match in unitOfWork.Match.All() on u.Id equals match.UserId
                          join word in unitOfWork.Word.All() on match.WordId equals word.Id
                          where u.Id == userId
                          group match by match.Result
                          into grp
                          select grp;

            var userInfoModel = new UserInfoModel {
                FullName = user.FullName
            };

            foreach (var match in matches)
            {
                if (match.Key)
                {
                    userInfoModel.CountOfWin = match.Count();
                }
                else
                {
                    userInfoModel.CountOfLose = match.Count();
                }
            }

            await unitOfWork.SaveChangesAsync();

            userInfoModel.GameCount = userInfoModel.CountOfWin + userInfoModel.CountOfLose;

            return(userInfoModel);
        }
예제 #24
0
        public async Task <UserInfoModel> UserInfo(string?userId = null)
        {
            var signedIn    = signInManager.IsSignedIn(User);
            var userInfoRet = new UserInfoModel
            {
                SignedIn = string.IsNullOrEmpty(userId) && signedIn
            };

            if (string.IsNullOrEmpty(userId))
            {
                userId = userManager.GetUserId(User);
            }
            var user = await userManager.FindByIdAsync(userId);

            var currentUser = string.IsNullOrEmpty(userId) ? user : await userManager.GetUserAsync(User);

            if (userId == null || user == null)
            {
                return(new UserInfoModel());
            }
            userInfoRet.UserId     = user.Id;
            userInfoRet.UserName   = user.UserName;
            userInfoRet.Privilege  = user.Privilege;
            userInfoRet.Coins      = user.Coins;
            userInfoRet.Experience = user.Experience;
            userInfoRet.OtherInfo  = IdentityHelper.GetOtherUserInfo(string.IsNullOrEmpty(user.OtherInfo) ? "{}" : user.OtherInfo);

            if (userInfoRet.SignedIn || PrivilegeHelper.IsTeacher(currentUser?.Privilege))
            {
                userInfoRet.Name                 = user.Name;
                userInfoRet.EmailConfirmed       = user.EmailConfirmed;
                userInfoRet.PhoneNumberConfirmed = user.PhoneNumberConfirmed;
                userInfoRet.Email                = user.Email;
                userInfoRet.PhoneNumber          = user.PhoneNumber;
            }

            return(userInfoRet);
        }
예제 #25
0
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <param name="uid">ID</param>
        /// <returns>用户模型实例 获取不到返回null</returns>
        public static UserInfoModel getUserInfo(String uid)
        {
            if (!exist(uid))
            {
                return(null);
            }
            Object[]  parameter = getParameterList(new SqlParameter[] { new SqlParameter("@uid", uid) });
            ArrayList arr       = SQLUtil.rawQuery("Select * From UserInfo Where Uid = @uid", parameter);

            if (arr.Count > 0)
            {
                Hashtable table = (Hashtable)arr[0];
                //密码
                String pwd = table["Pwd"].ToString().Trim();
                //注册时间
                String regtime = table["RegTime"].ToString().Trim();
                //别名
                String alias = table["Alias"].ToString().Trim();
                //Token
                String token = table["Token"].ToString().Trim();
                //Token注册时间
                String generatestr = table["TokenGenerateTime"].ToString().Trim();
                //生日
                String birthday = table["BirthDay"].ToString().Trim();
                //头像ID
                String faceid = table["FaceID"].ToString().Trim();
                //性别
                String sexstr = table["Sex"].ToString().Trim();
                bool   sex    = Convert.ToBoolean(sexstr == "" ? "True" : sexstr);
                //UserInfo对象
                UserInfoModel user = new UserInfoModel(uid.Trim(), pwd.Trim(), regtime.Trim(), alias.Trim(), faceid.Trim(), token.Trim(), generatestr.Trim(), birthday.Trim(), sex);
                return(user);
            }
            else
            {
                return(null);
            }
        }
예제 #26
0
        public JsonResult DoUpdateUserInfoStatus()
        {
            string message    = "操作失败,请与管理员联系";
            string userId     = GetFormData("userId");
            string roleType   = GetFormData("roleId");
            string workType   = GetFormData("workType");
            string statusType = GetFormData("statusType");

            List <string> userIdList = userId.Split(',').ToList();

            if (userIdList == null && userIdList.Count == 0)
            {
                return(FailedJson(message));
            }
            else
            {
                UserInfoModel model = new UserInfoModel();
                if (roleType == "roseId")
                {
                    model.RoleId = GetFormData("rolseid");
                }
                if (workType == "work")
                {
                    model.WorkStatus = GetFormData("work_status");
                }
                if (statusType == "status")
                {
                    model.Status = Convert.ToInt32(GetFormData("status"));
                }
                foreach (string userInfoId in userIdList)
                {
                    model.UserId = userInfoId;

                    UserInfoService.Instance.UpdateUserInfoStatus(model, out message);
                }
            }
            return(SuccessedJson(message, "UserMgr_UserList", "UserMgr_UserList", "closeCurrent", "/UserMgr/UserList"));
        }
예제 #27
0
        public HttpResponseMessage Login(string username, string password)
        {
            if (User.Identity.IsAuthenticated)
            {
                return(new HttpResponseMessage()
                {
                    Content = new StringContent("authenticated")
                });
            }
            else
            {
                IUserRepository repository = new UserRepository(new eyeDropsDbDataContext());
                LoginModel      model      = new LoginModel();
                model.Username = username;
                model.Password = password;
                HttpResponseMessage res = new HttpResponseMessage();
                UserInfoModel       lin = repository.login(model);
                if (lin.userData.UserId > 0)
                {
                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
                                                                                     model.Username,
                                                                                     DateTime.Now,
                                                                                     DateTime.Now.AddDays(30),
                                                                                     true,
                                                                                     null,
                                                                                     FormsAuthentication.FormsCookiePath);

                    // Encrypt the ticket.
                    FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);

                    return(Request.CreateResponse(HttpStatusCode.OK, "loggedin"));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, "failedlogin"));
                }
            }
        }
        //PROCEDURE FOR PICKING HOME PAGE OF DIFFERENT USERS: USED FOR PROFILE BUTTON IN NAVBAR
        public ActionResult PickProfile()
        {
            UserInfoModel u = new UserInfoModel();

            if (TempData["currentSession"] != null)
            {
                u = TempData["currentSession"] as UserInfoModel;
            }
            string email = u.Email;

            //OBTAINING USER'S STATUS
            var user = new DataTable();

            using (var sqlCon = new SqlConnection(connectString))
            {
                sqlCon.Open();
                var query = "Select * from UserDetails where Email='" + email + "';";
                var sqlDa = new SqlDataAdapter(query, sqlCon);
                sqlDa.Fill(user);
            }
            byte bloggerStat = (byte)user.Rows[0][4];

            //FOR NORMAL USER
            if (bloggerStat == 0)
            {
                return(RedirectToAction("Index", "User", new { email = email }));
            }
            //USER APPLIED TO BE BLOGGER
            else if (bloggerStat == 1)
            {
                return(RedirectToAction("Index1", "User", new { email = email }));
            }
            //BLOGGER
            else
            {
                return(RedirectToAction("Index", "Blogger", new { email = email }));
            }
        }
예제 #29
0
        public ActionResult Register(UserInfoModel model)
        {
            if (model.UserName.Trim().Contains(" "))
            {
                ModelState.AddModelError("UserName", "帐号中间不可以有空格.");
            }
            if (ModelState.IsValid)
            {
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName.Trim(), model.Password.Trim(), model.Email.Trim(), null, null, true, null, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    ProfileBase objProfile = ProfileBase.Create(model.UserName.Trim());

                    objProfile.SetPropertyValue("RoleLevelID", 0);
                    objProfile.SetPropertyValue("IsActivated", false);
                    //FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);

                    var emprole = new EmployeeRole()
                    {
                        AccountName = model.UserName,
                        Email       = model.Email
                    };
                    CH.Create <EmployeeRole>(emprole);

                    return(RedirectToAction("Index", "Account"));
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
예제 #30
0
        public JsonResult Manage(MGroupUserMenuModel item)
        {
            UserInfoModel     userInfo = (UserInfoModel)GeneralFunctions.GetSession(Configs.session);
            ResultStatusModel result   = new ResultStatusModel();

            item.UserCreated  = userInfo.UserName;
            item.UserModified = userInfo.UserName;

            if (ModelState.IsValid)
            {
                try
                {
                    string id_out = "";
                    if (item.GroupUserMenuID == 0)
                    {
                        result = uow.GroupUserMenuRepository.CUD_GroupUserMenu(item, "c", out id_out);
                    }
                    else
                    {
                        result = uow.GroupUserMenuRepository.CUD_GroupUserMenu(item, "u", out id_out);
                    }

                    if (!result.issuccess)
                    {
                        ModelState.AddModelError("Failed", result.err_msg);
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("Failed", e.Message);
                }
            }
            List <string> Error = (from m in ModelState
                                   where m.Value.Errors.Any()
                                   select m.Value.Errors[0].ErrorMessage).ToList();

            return(Json(new { Error = Error, data = item }, JsonRequestBehavior.DenyGet));
        }
예제 #31
0
        /// <summary>
        /// 修改多用户状态
        /// </summary>
        /// <param name="type"></param>
        private void UpdateUsersState(int type)
        {
            string actMsg = type == 1 ? "启用" : "停用";

            if (dgvUsers.SelectedRows.Count == 0)
            {
                MsgBoxHelper.MsgErrorShow($"请选择要{actMsg}的用户!");
                return;
            }
            if (MsgBoxHelper.MsgBoxConfirm($"用户{actMsg}", $"您确定要{actMsg}这些选择的用户吗?") == DialogResult.Yes)
            {
                List <int> userIds = new List <int>();
                foreach (DataGridViewRow row in dgvUsers.SelectedRows)
                {
                    UserInfoModel userInfo = row.DataBoundItem as UserInfoModel;
                    userIds.Add(userInfo.UserId);
                }
                bool bl = false;
                if (type == 1)
                {
                    bl = RequestStar.EnableUsers(userIds);
                }
                else
                {
                    bl = RequestStar.StopUsers(userIds);
                }
                if (bl)
                {
                    MsgBoxHelper.MsgBoxShow($"用户{actMsg}", $"该用户{actMsg}成功!");
                    LoadUserList();
                }
                else
                {
                    MsgBoxHelper.MsgErrorShow($"该用户{actMsg}失败!");
                    return;
                }
            }
        }
예제 #32
0
        /// <summary>
        /// This method will remove (delete) the user, if exists.
        /// </summary>
        /// <param name="s">User information</param>
        /// <param name="login">Login information to Active Directory.</param>
        /// <returns>Deleted user's email address.</returns>
        public BaseResponse <string> RemoveUser(UserInfoModel s)
        {
            ADResponseType rt;
            string         rResult    = string.Empty;
            string         rMessage   = string.Empty;
            Exception      rException = null;
            ADLoginModel   login      = GetAdminActiveDirectoryLogin();

            try
            {
                PrincipalContext pc   = new PrincipalContext(ContextType.Domain, login.Domain, login.Username, login.Password);
                UserPrincipal    user = UserPrincipal.FindByIdentity(pc, s.DomainEmailAddress);
                if (user != null)
                {
                    user.Delete();
                    rt      = ADResponseType.OK;
                    rResult = s.DomainEmailAddress;
                }
                else
                {
                    rMessage = "User does not exist.";
                    rt       = ADResponseType.Undefined;
                }
            }
            catch (System.DirectoryServices.ActiveDirectory.ActiveDirectoryOperationException E)
            {
                rMessage   = "Unable to perform operation.";
                rt         = ADResponseType.Exception;
                rException = E;
            }
            catch (System.DirectoryServices.ActiveDirectory.ActiveDirectoryObjectNotFoundException E)
            {
                rMessage   = "User was not found.";
                rt         = ADResponseType.Exception;
                rException = E;
            }
            return(new BaseResponse <string>(rResult, rt, rMessage, rException));
        }
예제 #33
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["uid"] == null)
            {
                Response.Redirect("/login.aspx");
            }
            int userid = 0;

            try
            {
                userid             = (int)Session["uid"];
                UserOnThisPage     = UserInfoBLL.GetUserInfoByID(userid);
                txtUserName.Text   = UserOnThisPage.username + "的个人中心";
                txtRegDate.Text    = UserOnThisPage.reg_date.ToShortDateString();
                txtMail.Text       = UserOnThisPage.mail;
                txtLatestDate.Text = "昨天";

                if (!IsPostBack)
                {
                    ReloadInfo();
                }
                List <AddressModel> addresses = AddressBLL.GetAddressesByUserID(userid);
                foreach (AddressModel address in addresses)
                {
                    AddressRow row = (AddressRow)LoadControl("~/Controls/AddressRow.ascx");
                    row.SetAddress(address);
                    row.Click += Row_Click;
                    addresscontent.Controls.Add(row);
                }
                txtAddressNum.Text = AddressBLL.GetAddressNumByUserID(UserOnThisPage.id).ToString();
            }
            catch (Exception err)
            {
                string x = err.Message;

                Response.Redirect("/index.aspx");
            }
        }
 public BothWayBindViewModel()
 {
     UserInfo    = new UserInfoModel();
     CombboxList = new List <ComplexInfoModel>()
     {
         new ComplexInfoModel()
         {
             Key = "0", Text = "西瓜"
         },
         new ComplexInfoModel()
         {
             Key = "1", Text = "草莓"
         },
         new ComplexInfoModel()
         {
             Key = "2", Text = "香梨"
         },
     };
     RadioButtons = new List <RadioChoose>()
     {
         new RadioChoose()
         {
             Content = "天空", IsCheck = false
         },
         new RadioChoose()
         {
             Content = "海洋", IsCheck = false
         },
         new RadioChoose()
         {
             Content = "大地", IsCheck = false
         },
         new RadioChoose()
         {
             Content = "宇宙", IsCheck = true
         },
     };
 }
예제 #35
0
        private void SetAllShipsLevel(int LV)
        {
            if (LV == 0)
            {
                return;
            }
            UserInfo = StrategyTopTaskManager.GetLogicManager().UserInfo;
            Dictionary <int, int> dictionary = Mst_DataManager.Instance.Get_MstLevel(shipTable: true);
            int num = 1;

            while (true)
            {
                int           num2          = num;
                MemberMaxInfo memberMaxInfo = UserInfo.ShipCountData();
                if (num2 < memberMaxInfo.NowCount + 1)
                {
                    UserInfo.GetShip(num).AddExp(dictionary[LV] - UserInfo.GetShip(num).Exp);
                    num++;
                    continue;
                }
                break;
            }
        }
예제 #36
0
        //查询
        public List <UserInfoModel> Search(UserInfoModel m)
        {
            string sql = "select * from UserInfo where 1=1 ";

            if (!string.IsNullOrEmpty(m.UserName))
            {
                sql += $" and UserName = @UserName ";
            }
            if (m.Department != 0)
            {
                sql += $" and Department = @Department ";
            }
            if (m.role != 0)
            {
                sql += $" and role = @role ";
            }
            if (!string.IsNullOrEmpty(m.UserNumber))
            {
                sql += $" and UserNumber = @UserNumber ";
            }

            return(dal.Search <UserInfoModel, UserInfoModel>(sql, m));
        }
예제 #37
0
        public ApiResult <List <UserInfoModel> > QueryAllUser(string groupId)
        {
            var list = new List <UserInfoModel>();
            var data = _userGroupService.QueryAllUser(groupId.ToGuid());

            if (data != null)
            {
                foreach (var item in data)
                {
                    var entity = new UserInfoModel();
                    entity.ImUserId    = item.ImUserId;
                    entity.ImUserName  = item.ImUserName;
                    entity.UserHeadimg = item.UserHeadimg;
                    entity.UserId      = item.UserId;
                    entity.UserType    = item.UserType;
                    entity.Remark      = item.Remark;
                    entity.Online      = (CacheManager.RedisChat.Get(item.ImUserId.ToString().ToLower().AddCachePrefix("Online")).IsNullOrEmpty() ? 0 : 1);
                    list.Add(entity);
                }
            }

            return(Success(list));
        }
예제 #38
0
        protected string CreateDirPath(string parentDir, string subDir = null, bool hasUserDir = true)
        {
            UserInfoModel m      = (UserInfoModel)Session[SessionVar.SHARED_USER_INFO];
            var           userid = "";

            if (hasUserDir)
            {
                userid = m.ユーザーID;
            }
            var dir = HttpContext.Server.MapPath(ConfigurationManager.AppSettings[parentDir]);

            if (hasUserDir)
            {
                dir += "\\" + userid;
            }

            if (subDir != null)
            {
                dir += "\\" + subDir;
            }

            return(dir);
        }
예제 #39
0
        /// <summary>
        /// 获取登录信息
        /// </summary>
        /// <returns></returns>
        public static UserInfoModel GetSession()
        {
            UserInfoModel userInfo = null;
            string        user     = string.Empty;

            if (HttpContext.Current != null)
            {
                if (HttpContext.Current.Request.Cookies[SessionName] != null)
                {
                    user = HttpContext.Current.Request.Cookies[SessionName].Value.DBColToString();
                }
                else
                {
                    user = HttpContext.Current.Session[SessionName].DBColToString();
                }
                if (!string.IsNullOrEmpty(user))
                {
                    user     = user.Contains("[Encrypt]") ? DesCodeHelper.DecryptDes(user.Substring(9, user.Length - 9)) : user;
                    userInfo = JsonConvert.DeserializeObject <UserInfoModel>(user);
                }
            }
            return(userInfo);
        }
예제 #40
0
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        // Default UserStore constructor uses the default connection string named: DefaultConnection
        var userStore = new UserStore<IdentityUser>();

        //Set ConnectionString to GarageConnectionString
        userStore.Context.Database.Connection.ConnectionString =
            System.Configuration.ConfigurationManager.ConnectionStrings["GarageDBConnectionString"].ConnectionString;
        var manager = new UserManager<IdentityUser>(userStore);

        //Create new user and try to store in DB.
        var user = new IdentityUser { UserName = txtUserName.Text };

        if (txtPassword.Text == txtConfirmPassword.Text)
        {
            try
            {
                //Create user object
                //Database will be created / expanded automatically
                IdentityResult result = manager.Create(user, txtPassword.Text);

                if (result.Succeeded)
                {
                    UserInformation info = new UserInformation()
                    {
                        Address = txtAddress.Text,
                        FirstName = txtFirstName.Text,
                        LastName = txtLastName.Text,
                        PostalCode = Convert.ToInt32(txtPostalCode.Text),
                        //retreive the dynamically generateed key from the current logged in user
                        GUID = user.Id
                    };

                    //send the user information object to the database
                    UserInfoModel model = new UserInfoModel();
                    model.InsertUserDetail(info);

                     //Store user in DB
                    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;

                    //set to login new user by Cookie
                    var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

                    //If succeedeed, log in the new user and set a cookie and redirect to homepage
                    authenticationManager.SignIn(new AuthenticationProperties(), userIdentity);
                    Response.Redirect("~/Index.aspx");
                }
                else
                {
                    litStatusMessage.Text = result.Errors.FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                litStatusMessage.Text = ex.ToString();
            }
        }
        else
        {
            litStatusMessage.Text = "Passwords must match!";
        }
    }
예제 #41
0
        //通过主键ID得到用户信息
        public UserInfoModel GetUserInfo(int id)
        {
            string sql = string.Format("select * from UserInfo where id={0}", id);
            DataTable dt = new DataTable();
            SqlAccess.QueryDt(dt, sql);
            var model = new UserInfoModel()
            {
                ID = id,
                Name = Normal.ListStr(dt.Rows[0]["Name"]),
                Account = Normal.ListStr(dt.Rows[0]["Account"]),
                BirthDay = Normal.ParseDateTime(dt.Rows[0]["BirthDay"]).ToString("yyyy年MM月dd日"),
                Sex = Normal.ListStr(dt.Rows[0]["Sex"]),
                Company = Normal.ListStr(dt.Rows[0]["Company"]),
                HomeTown = Normal.ListStr(dt.Rows[0]["HomeTown"]),
                TheLatter = Normal.ListStr(dt.Rows[0]["TheLatter"]),
                InterestIn = Normal.ListStr(dt.Rows[0]["InterestIn"]),
                IntroduceMyself = Normal.ListStr(dt.Rows[0]["IntroduceMyself"]),
                Marriage = Normal.ListStr(dt.Rows[0]["Marriage"]),
                Position = Normal.ListStr(dt.Rows[0]["Position"]),
                Email = Normal.ListStr(dt.Rows[0]["Email"]),
                QQ = Normal.ListStr(dt.Rows[0]["QQ"]),
                WorkingConditions = Normal.ParseInt(dt.Rows[0]["WorkingConditions"]),
                EntryDate = Normal.ListStr(dt.Rows[0]["EntryDate"])
            };

            return model;
        }
예제 #42
0
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request.QueryString["type"] != null)
            {
                if (context.Request.QueryString["type"] == "bind")
                {
                    #region 绑定用户列表
                    if (context.Request.QueryString["opera"] == "users")
                    {
                        Dictionary<string, string> userDic = new Dictionary<string, string>();
                        if (context.Request.QueryString["userID"] != null)
                        {
                            userDic["userID"] = context.Request.QueryString["userID"];
                        }
                        if (context.Request.QueryString["userName"] != null)
                        {
                            userDic["userName"] = context.Request.QueryString["userName"];
                        }
                        if (context.Request.QueryString["deptID"] != null)
                        {
                            userDic["deptID"] = context.Request.QueryString["deptID"];
                        }

                        int pageCurrent = Convert.ToInt32(context.Request.QueryString["pageCurrent"]);
                        string order = string.IsNullOrEmpty(context.Request.QueryString["orderField"]) ? "UserID" : context.Request.QueryString["orderField"];
                        int rowCount; UserInfoBLL bll = new UserInfoBLL();
                        DataTable dt = bll.GetUserList(userDic, pageCurrent, order, out rowCount);

                        StringBuilder sb = new StringBuilder();
                        List<string> list = new List<string>();
                        list.Add("<tr><th scope='col'>序号</th><th scope='col'><input id='chkAll' type='checkbox' onclick='selectAll();' /></th><th scope='col'><a href='javascript:void(0);' onclick='order(\"UserID\");'>用户ID</a></th><th scope='col'><a href='javascript:void(0);' onclick='order(\"UserName\");'>用户姓名</a></th><th scope='col'><a href='javascript:void(0);' onclick='order(\"DeptID\");'>所属部门</a></th><th scope='col'>&nbsp;</th></tr>");
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sb.Append("<tr>");
                            sb.AppendFormat("<td style='width: 10%;'><span>{0}</span></td>", dt.Rows[i][0]);
                            sb.AppendFormat("<td style='width: 10%;'><input type='checkbox' value='{0}' /></td>", dt.Rows[i]["UserID"]);
                            sb.AppendFormat("<td style='width: 15%;'>{0}</td>", dt.Rows[i]["UserID"]);
                            sb.AppendFormat("<td style='width: 20%;'>{0}</td>", dt.Rows[i]["UserName"]);
                            sb.AppendFormat("<td style='width: 15%;'>{0}</td>", dt.Rows[i]["DeptName"]);
                            sb.AppendFormat("<td style='width: 10%;'><img alt='编辑' title='编辑' src='/Image/common/edit.png' class='imgBtn' onclick='editUser(\"{0}\");' /></td>", dt.Rows[i]["UserID"]);
                            sb.Append("</tr>");
                        }
                        if (string.IsNullOrEmpty(sb.ToString()))
                        {
                            list.Clear();
                            list.Add("<td colspan='6' style='text-align:center;line-height:26px;'>没有数据</td>");
                        }
                        else
                        {
                            list.Add(sb.ToString());
                        }
                        list.Add("☭" + rowCount);
                        context.Response.Write(string.Concat(list));
                    }
                    #endregion

                    #region 绑定部门列表
                    else if (context.Request.QueryString["opera"] == "depart")
                    {
                        DepartmentModel dept = new DepartmentModel();
                        if (context.Request.QueryString["deptName"] != null)
                        {
                            dept.DeptName = context.Request.QueryString["deptName"];
                        }
                        if (context.Request.QueryString["manager"] != null)
                        {
                            dept.ManagerID = context.Request.QueryString["manager"];
                        }

                        int pageCurrent = Convert.ToInt32(context.Request.QueryString["pageCurrent"]);
                        int rowCount; DepartmentBLL bll = new DepartmentBLL();
                        DataTable dt = bll.GetDepartList(dept, pageCurrent, out rowCount);

                        StringBuilder sb = new StringBuilder();
                        List<string> list = new List<string>();
                        list.Add("<tr><th scope='col'>序号</th><th scope='col'>部门名称</th><th scope='col'>主管</th><th scope='col'>&nbsp;</th></tr>");
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            string DeptID = dt.Rows[i]["DeptID"].ToString();
                            sb.Append("<tr>");
                            sb.AppendFormat("<td style='width: 10%;'><span>{0}</span></td>", dt.Rows[i][0]);
                            sb.AppendFormat("<td style='width: 30%;'>{0}</td>", dt.Rows[i]["DeptName"]);
                            sb.AppendFormat("<td style='width: 20%;'>{0}</td>", dt.Rows[i]["UserName"]);

                            // 如果部门下没有员工即可删除
                            if (bll.IsEmptyDepart(DeptID))
                                sb.AppendFormat("<td style='width: 20%;'><img alt='编辑' title='编辑' src='/Image/common/edit.png' class='imgBtn' onclick='editDept(\"{0}\");' /> <input type='image' id='btnDelete' title='删除' class='imgBtn' src='/Image/common/delete.png' onclick='return deleteDept(\"{1}\");' style='border-width:0px;'></td>", DeptID, DeptID);
                            else
                                sb.AppendFormat("<td style='width: 20%;'><img alt='编辑' title='编辑' src='/Image/common/edit.png' class='imgBtn' onclick='editDept(\"{0}\");' /></td>", DeptID);
                            sb.Append("</tr>");
                        }
                        if (string.IsNullOrEmpty(sb.ToString()))
                        {
                            list.Clear();
                            list.Add("<td colspan='4' style='text-align:center;line-height:26px;'>没有数据</td>");
                        }
                        else
                        {
                            list.Add(sb.ToString());
                        }
                        list.Add("☭" + rowCount);
                        context.Response.Write(string.Concat(list));
                    }
                    #endregion

                    #region 显示考勤列表
                    else if (context.Request.QueryString["opera"] == "setting")
                    {
                        int year = Convert.ToInt32(context.Request.QueryString["year"]);
                        int month = Convert.ToInt32(context.Request.QueryString["month"]);
                        int days = DateTime.DaysInMonth(year, month);// 获取当前月份的天数

                        StringBuilder sb = new StringBuilder();
                        sb.Append("<tr><th scope='col'>日期</th><th scope='col'>星期</th><th scope='col'>状态</th></tr>");
                        //string[] chsWeek = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
                        AttendanceSettingBLL bll = new AttendanceSettingBLL();
                        DataTable dt = bll.GetAttendanceSetting();
                        for (int i = 1; i <= days; i++)
                        {
                            sb.Append("<tr>");
                            DateTime time = Convert.ToDateTime(year + "-" + month + "-" + i);
                            string date = time.ToString("yyyy-MM-dd");
                            sb.AppendFormat("<td style='width:30%;'>{0}</td>", date);

                            // 判断当前日期是星期几
                            //string week = chsWeek[Convert.ToInt32(time.DayOfWeek)];
                            string week = time.ToString("dddd");
                            sb.AppendFormat("<td style='width:30%;'>{0}</td>", week);

                            // 获取当前的考勤设置
                            DataRow[] rows = dt.Select("Date = '" + date + "'");
                            if (rows.Length > 0)
                            {
                                if (rows[0]["Status"].ToString().Equals("1"))
                                {
                                    sb.AppendFormat("<td style='width:20%;'><select id='ddlStatus' date='{0}'><option value='0' style='color:Black;'>默认</option><option selected='selected' value='1' style='color:Green;'>上班</option><option value='2' style='color:Red;'>休假</option></select></td>", date);
                                }
                                else
                                {
                                    sb.AppendFormat("<td style='width:20%;'><select id='ddlStatus' date='{0}'><option value='0' style='color:Black;'>默认</option><option value='1' style='color:Green;'>上班</option><option selected='selected' value='2' style='color:Red;'>休假</option></select></td>", date);
                                }
                            }
                            else
                            {
                                sb.AppendFormat("<td style='width:20%;'><select id='ddlStatus' date='{0}'><option selected='selected' value='0' style='color:Black;'>默认</option><option value='1' style='color:Green;'>上班</option><option value='2' style='color:Red;'>休假</option></select></td>", date);
                            }
                            sb.Append("</tr>");
                        }
                        context.Response.Write(sb.ToString());
                    }
                    #endregion

                    #region 显示部门员工
                    else if (context.Request.QueryString["opera"] == "deptuser")
                    {
                        if (context.Session["user"] == null)
                        {
                            context.Response.Write("<script>top.location='/View/Default.aspx'</script>");
                            context.Response.End();
                        }
                        string userID = ((UserInfoModel)context.Session["user"]).UserID;
                        int pageCurrent = Convert.ToInt32(context.Request.QueryString["pageCurrent"]);
                        string order = string.IsNullOrEmpty(context.Request.QueryString["orderField"]) ? "UserID" : context.Request.QueryString["orderField"];
                        int rowCount; AttendanceInfoBLL bll = new AttendanceInfoBLL();
                        DataTable dt = bll.GetDeptUser(userID, pageCurrent, order, out rowCount);

                        StringBuilder sb = new StringBuilder();
                        List<string> list = new List<string>();
                        list.Add("<tr><th scope='col'>序号</th><th scope='col'><a href='javascript:void(0);' onclick='order(\"UserID\");'>用户ID</a></th><th scope='col'><a href='javascript:void(0);' onclick='order(\"UserName\");'>用户名</a></th><th scope='col'><a href='javascript:void(0);' onclick='order(\"DeptName\");'>部门</a></th><th scope='col'>考勤信息</th></tr>");
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sb.Append("<tr>");
                            sb.AppendFormat("<td style='width: 10%;'><span>{0}</span></td>", dt.Rows[i][0]);
                            sb.AppendFormat("<td style='width: 20%;'>{0}</td>", dt.Rows[i]["UserID"]);
                            sb.AppendFormat("<td style='width: 20%;'>{0}</td>", dt.Rows[i]["UserName"]);
                            sb.AppendFormat("<td style='width: 20%;'>{0}</td>", dt.Rows[i]["DeptName"]);
                            sb.AppendFormat("<td style='width: 10%;'><a href='javascript:showAttendance(\"{0}\");'>查看</a></td>", dt.Rows[i]["UserID"]);
                            sb.Append("</tr>");
                        }
                        if (string.IsNullOrEmpty(sb.ToString()))
                        {
                            list.Clear();
                            list.Add("<td colspan='5' style='text-align:center;line-height:26px;'>没有数据</td>");
                        }
                        else
                        {
                            list.Add(sb.ToString());
                        }
                        list.Add("☭" + rowCount);
                        context.Response.Write(string.Concat(list));
                    }
                    #endregion

                    #region 显示请假列表
                    else if (context.Request.QueryString["opera"] == "leave")
                    {
                        if (context.Session["user"] == null)
                        {
                            context.Response.Write("<script>top.location='/View/Default.aspx'</script>");
                            context.Response.End();
                        }

                        string userID = ((UserInfoModel)context.Session["user"]).UserID;
                        string title = null, beginDate = null, endDate = null, statu = null, name = null;
                        if (context.Request.QueryString["title"] != null)
                        {
                            title = context.Request.QueryString["title"];
                        }
                        if (context.Request.QueryString["begin"] != null)
                        {
                            beginDate = context.Request.QueryString["begin"];
                        }
                        if (context.Request.QueryString["end"] != null)
                        {
                            endDate = context.Request.QueryString["end"];
                        }
                        if (context.Request.QueryString["statu"] != null)
                        {
                            statu = context.Request.QueryString["statu"];
                        }
                        if (context.Request.QueryString["name"] != null)
                        {
                            name = context.Request.QueryString["name"];
                        }
                        int pageCurrent = Convert.ToInt32(context.Request.QueryString["pageCurrent"]);
                        string order = string.IsNullOrEmpty(context.Request.QueryString["orderField"]) ? "UserName" : context.Request.QueryString["orderField"];
                        int rowCount; ApproveBLL bll = new ApproveBLL();
                        DataTable dt = bll.GetLeave(userID, title, beginDate, endDate, statu, name, pageCurrent, order, out rowCount);

                        StringBuilder sb = new StringBuilder();
                        List<string> list = new List<string>();
                        list.Add("<tr><th scope='col'>请假单ID</th><th scope='col'><a href='javascript:void(0);' onclick='order(\"UserName\");'>申请人</a></th><th scope='col'>标题</th><th scope='col'><a href='javascript:void(0);' onclick='order(\"BeginDate\");'>起始时间</a></th><th scope='col'><a href='javascript:void(0);' onclick='order(\"EndDate\");'>结束时间</a></th><th scope='col'><a href='javascript:void(0);' onclick='order(\"ApplyDate\");'>申请时间</a></th><th scope='col'>请假单状态</th><th scope='col'>&nbsp;</th></tr>");
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            sb.Append("<tr>");
                            sb.AppendFormat("<td style='width:8%;'>{0}</td>", dt.Rows[i]["ApproveID"]);
                            sb.AppendFormat("<td style='width:10%;'>{0}</td>", dt.Rows[i]["UserName"]);
                            sb.AppendFormat("<td style='width:15%;'>{0}</td>", dt.Rows[i]["Title"]);
                            sb.AppendFormat("<td style='width:10%;'>{0}</td>", dt.Rows[i]["BeginDate"]);
                            sb.AppendFormat("<td style='width:10%;'>{0}</td>", dt.Rows[i]["EndDate"]);
                            sb.AppendFormat("<td style='width:10%;'>{0}</td>", dt.Rows[i]["ApplyDate"]);
                            string status = dt.Rows[i]["Status"].ToString();
                            sb.AppendFormat("<td style='width:7%;'><span id='lblStatus'>{0}</span></td>", status == "0" ? "待审批" : "归档");
                            string opt = HttpUtility.UrlDecode(context.Request.QueryString["opt"], Encoding.UTF8);
                            if (opt == "请假审批")
                            {
                                string type = status == "0" ? "apprv(\"{0}\")" : "show(\"{0}\")";
                                sb.AppendFormat("<td style='width:10%;'><a href='javascript:{0};'>查看</a></td>", string.Format(type, dt.Rows[i]["ApproveID"]));
                            }
                            else
                            {
                                if (status == "0")
                                {
                                    sb.AppendFormat("<td style='width:10%;'><img alt='编辑' title='编辑' src='/Image/common/edit.png' class='imgBtn' onclick='editLeave(\"{0}\");'><input type='image' id='btnDelete' title='删除' class='imgBtn' src='/Image/common/delete.png' onclick='return deleteApp(\"{1}\");' style='border-width:0px;'></td>'", dt.Rows[i]["ApproveID"], dt.Rows[i]["ApproveID"]);
                                }
                                else
                                {
                                    sb.AppendFormat("<td style='width:10%;'><a href='javascript:show(\"{0}\");'>查看</a></td>", dt.Rows[i]["ApproveID"]);
                                }
                            }
                            sb.Append("</tr>");
                        }
                        if (string.IsNullOrEmpty(sb.ToString()))
                        {
                            list.Clear();
                            list.Add("<td colspan='4' style='text-align:center;line-height:26px;'>没有数据</td>");
                        }
                        else
                        {
                            list.Add(sb.ToString());
                        }
                        list.Add("☭" + rowCount);
                        context.Response.Write(string.Concat(list));
                    }
                    #endregion

                    #region 列表显示员工考勤
                    else if (context.Request.QueryString["opera"] == "userattc")
                    {
                        string userID = string.Empty;
                        if (!string.IsNullOrEmpty(context.Request.QueryString["userID"]))
                        {
                            userID = context.Request.QueryString["userID"];
                        }
                        else if (context.Session["user"] != null)
                        {
                            userID = ((UserInfoModel)context.Session["user"]).UserID;
                        }
                        else
                        {
                            context.Response.Write("<script>top.location='/View/Default.aspx'</script>");
                            context.Response.End();
                        }

                        int year = Convert.ToInt32(context.Request.QueryString["year"]);
                        int month = Convert.ToInt32(context.Request.QueryString["month"]);
                        int days = DateTime.DaysInMonth(year, month); // 获取当前月份的天数
                        StringBuilder sb = new StringBuilder();
                        sb.Append("<table class='grid' cellspacing='0' rules='all' border='1' style='border-collapse: collapse;'>");
                        sb.Append("<tr><th scope='col'>日期</th><th scope='col'>星期</th><th scope='col'>首次打卡时间</th><th scope='col'>最后打卡时间</th><th scope='col'>考勤状态</th></tr>");
                        string[] chsWeek = { "周日", "周一", "周二", "周三", "周四", "周五", "周六" };
                        AttendanceInfoBLL bll = new AttendanceInfoBLL();
                        DataTable dt = bll.GetAskForLeaveTime(userID);
                        for (int i = 1; i <= days; i++)
                        {
                            sb.Append("<tr>");
                            DateTime time = Convert.ToDateTime(year + "-" + month + "-" + i);
                            string date = time.ToString("yyyy-MM-dd");
                            sb.AppendFormat("<td style='width:12%;'>{0}</td>", date);

                            // 判断当前日期是周几
                            string week = chsWeek[Convert.ToInt32(time.DayOfWeek)];
                            sb.AppendFormat("<td style='width:8%;'>{0}</td>", week);

                            // 获取当天的打卡时间
                            string min = bll.GetMinFaceTime(userID, date).ToString();
                            sb.AppendFormat("<td style='width:20%;'>{0}</td>", min);
                            string max = bll.GetMaxFaceTime(userID, date).ToString();
                            sb.AppendFormat("<td style='width:20%;'>{0}</td>", max);

                            DateTime? minTime = null;
                            if (!string.IsNullOrEmpty(min))
                            {
                                minTime = Convert.ToDateTime(min);
                            }
                            DateTime? maxTime = null;
                            if (!string.IsNullOrEmpty(max))
                            {
                                maxTime = Convert.ToDateTime(max);
                            }

                            // 正常的上下班时间
                            DateTime morInTime = Convert.ToDateTime(date + " 08:30:00");
                            DateTime morOutTime = Convert.ToDateTime(date + " 11:50:00");
                            DateTime aftInTime = Convert.ToDateTime(date + " 13:50:00");
                            DateTime aftOutTime = Convert.ToDateTime(date + " 17:00:00");

                            byte statu;
                            try
                            {
                                statu = Convert.ToByte(bll.GetStatus(date));
                            }
                            catch
                            {
                                statu = 0;
                            }

                            if (statu.Equals(0) || statu.Equals(2))
                            {
                                sb.Append("<td style='width:20%;'><span style='color:gray'>休假</span></td>");
                            }
                            else if (statu.Equals(1))
                            {
                                // 如果当天存在请假信息,进行考勤状态的逻辑判断
                                if (bll.IsAskForLeaveTime(userID, date))
                                {
                                    DataRow[] row1 = dt.Select("BeginDate<='" + morInTime + "' and EndDate>='" + morOutTime + "'");
                                    DataRow[] row2 = dt.Select("BeginDate<='" + aftInTime + "' and EndDate>='" + aftOutTime + "'");
                                    if (minTime == null && maxTime == null)
                                    {
                                        if (row1.Length > 0 && row2.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#436EEE'>请假</span></td>");
                                        }
                                        else if (row2.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:red;margin-right:10px;'>缺勤</span><span style='color:#436EEE;margin-left:10px;'>请假</span></td>");
                                        }
                                        else if (row1.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#436EEE;margin-right:10px;'>请假</span><span style='color:red;margin-left:10px;'>缺勤</span></td>");
                                        }
                                        else
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:red'>缺勤</span></td>");
                                        }
                                    }
                                    else
                                    {
                                        // 对比上下班时间判定考勤状态
                                        int r1 = DateTime.Compare((DateTime)minTime, morInTime);
                                        int r2 = DateTime.Compare((DateTime)maxTime, aftOutTime);
                                        int r3 = DateTime.Compare((DateTime)maxTime, morOutTime);
                                        int r4 = DateTime.Compare((DateTime)minTime, aftInTime);
                                        if (row1.Length > 0 && row2.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#436EEE'>请假</span></td>");
                                        }
                                        else if (DateTime.Compare((DateTime)minTime, (DateTime)maxTime) == 0 && row1.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#436EEE;margin-right:10px;'>请假</span><span style='color:pink;margin-left:10px;'>未打卡</span></td>");
                                        }
                                        else if (DateTime.Compare((DateTime)minTime, (DateTime)maxTime) == 0 && row2.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:pink;margin-right:10px;'>未打卡</span><span style='color:#436EEE;margin-left:10px;'>请假</span></td>");
                                        }
                                        else if ((r4 > 0 && r2 < 0) && row1.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#436EEE;margin-right:10px;'>请假</span><span style='color:Aqua;margin-left:10px;'>迟到且早退</span></td>");
                                        }
                                        else if ((r1 > 0 && r3 < 0) && row2.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:Aqua;margin-right:10px;'>迟到且早退</span><span style='color:#436EEE;margin-left:10px;'>请假</span></td>");
                                        }
                                        else if ((r4 <= 0 && r2 >= 0) && row1.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#436EEE;margin-right:10px;'>请假</span><span style='color:#3CB371;margin-left:10px;'>正常</span></td>");
                                        }
                                        else if ((r1 <= 0 && r3 >= 0) && row2.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#3CB371;margin-right:10px;'>正常</span><span style='color:#436EEE;margin-left:10px;'>请假</span></td>");
                                        }
                                        else if (r2 < 0 && row1.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#436EEE;margin-right:10px;'>请假</span><span style='color:Orange;margin-left:10px;'>早退</span></td>");
                                        }
                                        else if (r4 > 0 && row1.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#436EEE;margin-right:10px;'>请假</span><span style='color:#CAFF70;margin-left:10px;'>迟到</span></td>");
                                        }
                                        else if (r1 > 0 && row2.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#CAFF70;margin-right:10px;'>迟到</span><span style='color:#436EEE;margin-left:10px;'>请假</span></td>");
                                        }
                                        else if (r3 < 0 && row2.Length > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:Orange;margin-right:10px;'>早退</span><span style='color:#436EEE;margin-left:10px;'>请假</span></td>");
                                        }
                                        else if (r1 > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#CAFF70;margin-right:10px;'>迟到</span><span style='color:red;margin-left:10px;'>缺勤</span></td>");
                                        }
                                        else if (r2 < 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:red;margin-right:10px;'>缺勤</span><span style='color:Orange;margin-left:10px;'>早退</span></td>");
                                        }
                                        else
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:red'>缺勤</span></td>");
                                        }
                                    }
                                }
                                else
                                {
                                    if (minTime == null && maxTime == null)
                                    {
                                        sb.Append("<td style='width:20%;'><span style='color:red'>缺勤</span></td>");
                                    }
                                    else
                                    {
                                        // 对比上下班时间判定考勤状态
                                        int r1 = DateTime.Compare((DateTime)minTime, morInTime);
                                        int r2 = DateTime.Compare((DateTime)maxTime, aftOutTime);
                                        if (DateTime.Compare((DateTime)minTime, (DateTime)maxTime) == 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:pink'>未打卡</span></td>");
                                        }
                                        else if (r1 <= 0 && r2 >= 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#3CB371'>正常</span></td>");
                                        }
                                        else if (r1 > 0 && r2 < 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:Aqua'>迟到且早退</span></td>");
                                        }
                                        else if (r1 > 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#CAFF70'>迟到</span></td>");
                                        }
                                        else if (r2 < 0)
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:Orange'>早退</span></td>");
                                        }
                                        else
                                        {
                                            sb.Append("<td style='width:20%;'><span style='color:#8B008B'>异常</span></td>");
                                        }
                                    }
                                }
                            }
                            sb.Append("</tr>");
                        }
                        sb.Append("</table>");
                        context.Response.Write(sb.ToString());
                    }
                    #endregion

                    #region 日历显示员工考勤
                    else if (context.Request.QueryString["opera"] == "calendar")
                    {
                        if (context.Session["user"] == null)
                        {
                            context.Response.Write("<script>top.location='/View/Default.aspx'</script>");
                            context.Response.End();
                        }
                        string userID = ((UserInfoModel)context.Session["user"]).UserID;
                        int year = Convert.ToInt32(context.Request.QueryString["year"]);
                        int month = Convert.ToInt32(context.Request.QueryString["month"]);
                        int days = DateTime.DaysInMonth(year, month); // 获取当前月份的天数

                        StringBuilder sb = new StringBuilder();
                        sb.Append("<table class='calendar' cellspacing='0' rules='all' border='1' id='calendar' style='border-collapse:collapse;'>");
                        sb.Append("<tr><th scope='col'>一</th><th scope='col'>二</th><th scope='col'>三</th><th scope='col'>四</th><th scope='col'>五</th><th scope='col'>六</th><th scope='col'>日</th></tr>");
                        int day = 1;
                        DateTime time = Convert.ToDateTime(year + "-" + month + "-" + day);
                        AttendanceInfoBLL bll = new AttendanceInfoBLL();
                        DataTable dt = bll.GetAskForLeaveTime(userID);
                        for (int i = 0; i < 6; i++)
                        {
                            sb.Append("<tr>");
                            // 遍历每个星期的考勤状态
                            for (int j = 0; j < 7; j++)
                            {
                                int week = (Convert.ToInt32(time.DayOfWeek) + 6) % 7;
                                if (j == week && day <= days)
                                {
                                    string date = time.ToString("yyyy-MM-dd");
                                    // 获取当天的打卡时间
                                    string min = bll.GetMinFaceTime(userID, date).ToString();
                                    string max = bll.GetMaxFaceTime(userID, date).ToString();

                                    sb.AppendFormat("<td Day='{0}' FirstTime='{1}' LastTime='{2}'>", time.ToString("yyyy年MM月dd日") + "\t" + time.ToString("dddd"), min, max);
                                    sb.AppendFormat("<div class='left'>{0}</div>", day);

                                    DateTime? minTime = null;
                                    if (!string.IsNullOrEmpty(min))
                                    {
                                        minTime = Convert.ToDateTime(min);
                                    }
                                    DateTime? maxTime = null;
                                    if (!string.IsNullOrEmpty(max))
                                    {
                                        maxTime = Convert.ToDateTime(max);
                                    }

                                    // 正常的上下班时间
                                    DateTime morInTime = Convert.ToDateTime(date + " 08:30:00");
                                    DateTime morOutTime = Convert.ToDateTime(date + " 11:50:00");
                                    DateTime aftInTime = Convert.ToDateTime(date + " 13:50:00");
                                    DateTime aftOutTime = Convert.ToDateTime(date + " 17:00:00");

                                    byte statu;
                                    try
                                    {
                                        statu = Convert.ToByte(bll.GetStatus(date));
                                    }
                                    catch
                                    {
                                        statu = 0;
                                    }

                                    if (statu.Equals(0) || statu.Equals(2))
                                    {
                                        sb.Append("<div class='right'><div class='div1' style='background-color:gray;'>休假</div></div>");
                                    }
                                    else if (statu.Equals(1))
                                    {
                                        // 如果当天存在请假信息,进行考勤状态的逻辑判断
                                        if (bll.IsAskForLeaveTime(userID, date))
                                        {
                                            DataRow[] row1 = dt.Select("BeginDate<='" + morInTime + "' and EndDate>='" + morOutTime + "'");
                                            DataRow[] row2 = dt.Select("BeginDate<='" + aftInTime + "' and EndDate>='" + aftOutTime + "'");
                                            if (minTime == null && maxTime == null)
                                            {
                                                if (row1.Length > 0 && row2.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:#436EEE;'>请假</div></div>");
                                                }
                                                else if (row2.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:red;'>缺勤</div><div class='div2' style='background-color:#436EEE;'>请假</div></div>");
                                                }
                                                else if (row1.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:#436EEE;'>请假</div><div class='div2' style='background-color:red;'>缺勤</div></div>");
                                                }
                                                else
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:red;'>缺勤</div></div>");
                                                }
                                            }
                                            else
                                            {
                                                // 对比上下班时间判定考勤状态
                                                int r1 = DateTime.Compare((DateTime)minTime, morInTime);
                                                int r2 = DateTime.Compare((DateTime)maxTime, aftOutTime);
                                                int r3 = DateTime.Compare((DateTime)maxTime, morOutTime);
                                                int r4 = DateTime.Compare((DateTime)minTime, aftInTime);
                                                if (row1.Length > 0 && row2.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:#436EEE;'>请假</div></div>");
                                                }
                                                else if (DateTime.Compare((DateTime)minTime, (DateTime)maxTime) == 0 && row1.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:#436EEE;'>请假</div><div class='div2' style='background-color:pink;'>未打卡</div></div>");
                                                }
                                                else if (DateTime.Compare((DateTime)minTime, (DateTime)maxTime) == 0 && row2.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:pink;'>未打卡</div><div class='div2' style='background-color:#436EEE;'>请假</div></div>");
                                                }
                                                else if ((r4 > 0 && r2 < 0) && row1.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:#436EEE;'>请假</div><div class='div2' style='background-color:Aqua;'>迟到且早退</div></div>");
                                                }
                                                else if ((r1 > 0 && r3 < 0) && row2.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:Aqua;'>迟到且早退</div><div class='div2' style='background-color:#436EEE;'>请假</div></div>");
                                                }
                                                else if ((r4 <= 0 && r2 >= 0) && row1.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:#436EEE;'>请假</div><div class='div2' style='background-color:#3CB371;'>正常</div></div>");
                                                }
                                                else if ((r1 <= 0 && r3 >= 0) && row2.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:#3CB371;'>正常</div><div class='div2' style='background-color:#436EEE;'>请假</div></div>");
                                                }
                                                else if (r2 < 0 && row1.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:#436EEE;'>请假</div><div class='div2' style='background-color:Orange;'>早退</div></div>");
                                                }
                                                else if (r4 > 0 && row1.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:#436EEE;'>请假</div><div class='div2' style='background-color:#CAFF70;'>迟到</div></div>");
                                                }
                                                else if (r1 > 0 && row2.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:#CAFF70;'>迟到</div><div class='div2' style='background-color:#436EEE;'>请假</div></div>");
                                                }
                                                else if (r3 < 0 && row2.Length > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:Orange;'>早退</div><div class='div2' style='background-color:#436EEE;'>请假</div></div>");
                                                }
                                                else if (r1 > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:#CAFF70;'>迟到</div><div class='div2' style='background-color:red;'>缺勤</div></div>");
                                                }
                                                else if (r2 < 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div2' style='background-color:red;'>缺勤</div><div class='div2' style='background-color:Orange;'>早退</div></div>");
                                                }
                                                else
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:red;'>缺勤</div></div>");
                                                }
                                            }
                                        }
                                        else
                                        {
                                            if (minTime == null && maxTime == null)
                                            {
                                                sb.Append("<div class='right'><div class='div1' style='background-color:red;'>缺勤</div></div>");
                                            }
                                            else
                                            {
                                                // 对比上下班时间判定考勤状态
                                                int r1 = DateTime.Compare((DateTime)minTime, morInTime);
                                                int r2 = DateTime.Compare((DateTime)maxTime, aftOutTime);
                                                if (DateTime.Compare((DateTime)minTime, (DateTime)maxTime) == 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:pink;'>未打卡</div></div>");
                                                }
                                                else if (r1 <= 0 && r2 >= 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:#3CB371;'>正常</div></div>");
                                                }
                                                else if (r1 > 0 && r2 < 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:Aqua;'>迟到且早退</div></div>");
                                                }
                                                else if (r1 > 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:#CAFF70;'>迟到</div></div>");
                                                }
                                                else if (r2 < 0)
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:Orange;'>早退</div></div>");
                                                }
                                                else
                                                {
                                                    sb.Append("<div class='right'><div class='div1' style='background-color:#8B008B;'>异常</div></div>");
                                                }
                                            }
                                        }
                                    }
                                    sb.Append("</td>");
                                    time = time.AddDays(1);
                                    day++;
                                }
                                else
                                {
                                    sb.Append("<td><div class='left'></div><div class='right'></div></td>");
                                }
                            }
                            sb.Append("</tr>");
                            if (day > days) break;
                        }
                        sb.Append("</table>");
                        context.Response.Write(sb.ToString());
                    }

                    #endregion
                }
                else if (context.Request.QueryString["type"] == "delete")
                {
                    #region 删除指定用户
                    if (context.Request.QueryString["opera"] == "users")
                    {
                        if (context.Request.QueryString["userID"] != null)
                        {
                            UserInfoBLL bll = new UserInfoBLL();
                            int res = bll.DeleteUsers(context.Request.QueryString["userID"]);
                            int total = Convert.ToInt32(context.Request.QueryString["total"]);

                            string msg = res > 0 ? "删除成功:" + res + "条,删除失败:" + (res - total) + "条。" : "删除失败!";
                            context.Response.Write(msg);
                        }
                    }
                    #endregion

                    #region 删除指定部门
                    else if (context.Request.QueryString["opera"] == "depart")
                    {
                        if (context.Request.QueryString["deptID"] != null)
                        {
                            DepartmentBLL bll = new DepartmentBLL();
                            try
                            {
                                bll.DeleteDepart(context.Request.QueryString["deptID"]);
                                context.Response.Write("{'Result':'OK','Message':'删除成功!'}");
                            }
                            catch
                            {
                                context.Response.Write("{'Result':'NO','Message':'删除失败!'}");
                            }
                        }
                    }
                    #endregion

                    #region 删除请假单
                    else if (context.Request.QueryString["opera"] == "leave")
                    {
                        if (context.Request.QueryString["appID"] != null)
                        {
                            ApproveBLL bll = new ApproveBLL();
                            try
                            {
                                bll.DeleteLeave(context.Request.QueryString["appID"]);
                                context.Response.Write("{'Result':'OK','Message':'删除成功!'}");
                            }
                            catch
                            {
                                context.Response.Write("{'Result':'NO','Message':'删除失败!'}");
                            }
                        }
                    }
                    #endregion
                }
                else if (context.Request.QueryString["type"] == "append")
                {
                    #region 添加请假单
                    if (context.Request.QueryString["opera"] == "leave")
                    {
                        if (context.Session["user"] == null)
                        {
                            context.Response.Write("<script>top.location='/View/Default.aspx'</script>");
                            context.Response.End();
                        }

                        ApproveModel apprv = new ApproveModel
                        {
                            ApplyUser = ((UserInfoModel)context.Session["user"]).UserID,
                            Title = context.Request.QueryString["title"],
                            BeginDate = Convert.ToDateTime(context.Request.QueryString["beginDate"]),
                            EndDate = Convert.ToDateTime(context.Request.QueryString["endDate"]),
                            Reason = context.Request.QueryString["reason"]
                        };

                        ApproveBLL bll = new ApproveBLL();
                        try
                        {
                            bll.AppendLeave(apprv);
                            context.Response.Write("{'Result':'OK','Message':'保存成功!'}");
                        }
                        catch
                        {
                            context.Response.Write("{'Result':'NO','Message':'保存失败!'}");
                        }
                    }
                    #endregion
                }
                else if (context.Request.QueryString["type"] == "edit")
                {
                    #region 编辑个人资料
                    if (context.Request.QueryString["opera"] == "private")
                    {
                        if (context.Session["user"] == null)
                        {
                            context.Response.Write("<script>top.location='/View/Default.aspx'</script>");
                            context.Response.End();
                        }

                        UserInfoModel user = new UserInfoModel
                        {
                            UserID = ((UserInfoModel)context.Session["user"]).UserID,
                            Cellphone = context.Request.QueryString["phone"]
                        };
                        // 检验用户是否修改密码
                        if (context.Request.QueryString["pwd"] != null)
                        {
                            user.Password = MD5Maker.GetMD5(context.Request.QueryString["pwd"]);
                        }

                        UserInfoBLL bll = new UserInfoBLL();
                        try
                        {
                            bll.EditPrivate(user);
                            context.Response.Write("{'Result':'OK','Message':'保存成功!'}");
                        }
                        catch
                        {
                            context.Response.Write("{'Result':'NO','Message':'保存失败!'}");
                        }
                    }
                    #endregion

                    #region 设置日常考勤
                    else if (context.Request.QueryString["opera"] == "setting")
                    {
                        string date = context.Request.QueryString["date"];
                        string statu = context.Request.QueryString["statu"];

                        AttendanceSettingBLL bll = new AttendanceSettingBLL();
                        try
                        {
                            bll.SetAttendanceSetting(date, statu);
                            context.Response.Write("{'Result':'OK','Message':'保存成功!'}");
                        }
                        catch
                        {
                            context.Response.Write("{'Result':'NO','Message':'保存失败!'}");
                        }
                    }
                    #endregion

                    #region 编辑请假单
                    else if (context.Request.QueryString["opera"] == "leave")
                    {
                        ApproveModel apprv = new ApproveModel
                        {
                            ApproveID = Convert.ToInt32(context.Request.QueryString["appID"]),
                            Title = context.Request.QueryString["title"],
                            BeginDate = Convert.ToDateTime(context.Request.QueryString["beginDate"]),
                            EndDate = Convert.ToDateTime(context.Request.QueryString["endDate"]),
                            Reason = context.Request.QueryString["reason"]
                        };

                        ApproveBLL bll = new ApproveBLL();
                        try
                        {
                            bll.EditLeave(apprv);
                            context.Response.Write("{'Result':'OK','Message':'保存成功!'}");
                        }
                        catch
                        {
                            context.Response.Write("{'Result':'NO','Message':'保存失败!'}");
                        }
                    }
                    #endregion

                    #region 审批请假单
                    else if (context.Request.QueryString["opera"] == "apprv")
                    {
                        if (context.Session["user"] == null)
                        {
                            context.Response.Write("<script>top.location='/View/Default.aspx'</script>");
                            context.Response.End();
                        }

                        ApproveModel apprv = new ApproveModel
                        {
                            ApproveID = Convert.ToInt32(context.Request.QueryString["appID"]),
                            ApproveUser = ((UserInfoModel)context.Session["user"]).UserID,
                            Result = Convert.ToByte(context.Request.QueryString["result"]),
                            Remark = context.Request.QueryString["remark"]
                        };
                        ApproveBLL bll = new ApproveBLL();
                        try
                        {
                            bll.ApprvLeave(apprv);
                            context.Response.Write("{'Result':'OK','Message':'保存成功!'}");
                        }
                        catch
                        {
                            context.Response.Write("{'Result':'NO','Message':'保存失败!'}");
                        }
                    }
                    #endregion
                }
                else if (context.Request.QueryString["type"] == "validate")
                {
                    #region 验证用户ID
                    if (context.Request.QueryString["opera"] == "users")
                    {
                        string userID = context.Request.QueryString["userID"];
                        UserInfoBLL bll = new UserInfoBLL();
                        if (bll.IsExistsID(userID)) context.Response.Write("{'Result':'NO'}");
                        else context.Response.Write("{'Result':'OK'}");
                    }
                    #endregion

                    #region 验证部门名称
                    else if (context.Request.QueryString["opera"] == "depart")
                    {
                        string dept = context.Request.QueryString["dept"];
                        DepartmentBLL bll = new DepartmentBLL();
                        if (bll.IsExistsDept(dept)) context.Response.Write("{'Result':'NO'}");
                        else context.Response.Write("{'Result':'OK'}");
                    }
                    #endregion
                }
                else if (context.Request.QueryString["type"] == "logout")
                {
                    #region 清除Session
                    context.Session["user"] = null;
                    context.Response.Write("<script>location='/View/Default.aspx'</script>");
                    #endregion
                }
            }
        }
예제 #43
0
 /// <summary>
 /// 添加用户
 /// </summary>
 public int AppendUser(UserInfoModel user)
 {
     return dal.AppendUser(user);
 }
예제 #44
0
 /// <summary>
 /// 编辑用户资料
 /// </summary>
 public int EditUser(UserInfoModel user)
 {
     return dal.EditUser(user);
 }
예제 #45
0
 public List<UserInfoModel> GetManager()
 {
     string sql = "select UserID,UserName,Department.DeptID,Password,Cellphone,UserType from UserInfo join Department on UserInfo.DeptID=Department.DeptID where UserType=1";
     List<UserInfoModel> userList = new List<UserInfoModel>();
     using (SqlDataReader reader = SqlHelper.ExecuteReader(sql))
     {
         while (reader.Read())
         {
             UserInfoModel user = new UserInfoModel();
             user.UserID = reader["UserID"] as string;
             user.UserName = reader["UserName"] as string;
             user.DeptID = (int)reader["DeptID"];
             user.Password = reader["Password"] as string;
             user.Cellphone = reader["Cellphone"] as string;
             user.UserType = (byte)reader["UserType"];
             userList.Add(user);
         }
     }
     return userList;
 }
예제 #46
0
 /// <summary>
 /// 编辑个人资料
 /// </summary>
 public int EditPrivate(UserInfoModel user)
 {
     return dal.EditPrivate(user);
 }
예제 #47
0
        //修改个人资料
        public bool UpdateUserInfo(UserInfoModel model)
        {
            string sql = string.Format(@"upadte UserInfo set [Email]='{0}',Name='{1}',Sex='{2}',
            TheLatter='{3}',HomeTown='{4}',Marriage='{5}',Position='{6}',
            Company='{7}',InterestIn='{8}',IntroduceMyself='{9}',QQ='{10}',WorkingConditions={11},BirthDay='{12}')",
                    model.Email, model.Name, model.Sex,
                    model.TheLatter, model.HomeTown, model.Marriage,
                    model.Position, model.Company, model.InterestIn, model.IntroduceMyself,
                    model.QQ, model.WorkingConditions, model.BirthDay);

            return SqlAccess.Execute(sql) > 0;
        }