public void Login(WD001ViewModel model) { if (string.IsNullOrWhiteSpace(model.UserId) || string.IsNullOrWhiteSpace(model.PassWord)) { return; } using (EntityDao db = new EntityDao()) { List <MySqlParameter> para = new List <MySqlParameter>(); StringBuilder sql = new StringBuilder(); sql.AppendLine("select * from tb_user"); para.Add(new MySqlParameter("CD", model.UserId)); sql.AppendLine("where CD = @CD"); para.Add(new MySqlParameter("Password", model.PassWord)); sql.AppendLine(" and Password = md5(@Password)"); sql.AppendLine(" and DateStart <= CURDATE()"); sql.AppendLine(" and CURDATE() <= DateEnd"); sql.AppendLine(" and DelFlg = '0'"); TB_User user = db.FindSingle <TB_User>(sql.ToString(), para); if (user != null) { App.LoginUser = user; model.UserName = user.Name; } else { } } }
public void Init(MainWindowViewModel model) { using (EntityDao db = new EntityDao()) { List <MySqlParameter> para = new List <MySqlParameter>(); StringBuilder sql = new StringBuilder(); sql.AppendLine("select * from tb_user"); para.Add(new MySqlParameter("IP", ComUtility.GetLocalIPV4().ToString())); sql.AppendLine("where IP = @IP"); sql.AppendLine(" and DateStart <= CURDATE()"); sql.AppendLine(" and CURDATE() <= DateEnd"); sql.AppendLine(" and DelFlg = '0'"); TB_User user = db.FindSingle <TB_User>(sql.ToString(), para); if (user != null) { App.LoginUser = user; } } }