public UserMst GetUser(int id) { UserMst model = new UserMst(); model = _db.UserMst.Where(c => c.UserId == id).FirstOrDefault(); return(model); }
public void UserIdTest() { UserMst userMst = new UserMst(); userMst.UserId = 1; userMst.ComId = 2; }
private void btnLogin_Click(object sender, EventArgs e) { try { if (txtOldPwd.Text.Length == 0) { MessageBox.Show("Enter Old Password."); txtOldPwd.Focus(); return; } if (txtNewPwd.Text.Length == 0) { MessageBox.Show("Enter new Password."); txtNewPwd.Focus(); return; } UserMst lqry = dbx.UserMsts.Where(u => u.UserId == AppInit.UserInfo.UserId && u.Password == txtOldPwd.Text).FirstOrDefault(); if (lqry == null) { MessageBox.Show("Old password dose not match."); txtOldPwd.Focus(); return; } lqry.Password = txtNewPwd.Text; dbx.SaveChanges(); this.Close(); } catch (Exception) { throw; } }
private void sqliteTestConnectBtn_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); sb.Append("Data Source=" + this.sqliteDbFilePath.Text); sb.Append(";foreign keys=true;"); CommonFunction common = new CommonFunction(); string dbConnectionString = common.getDbConnectionString(); string dbProviderName = common.getDbProviderName(); try { using (SQLiteConnection cn = new SQLiteConnection(sb.ToString())) { cn.Open(); SQLiteCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT * FROM WORD_DIC"; cmd.ExecuteReader(); common.setSqliteDbContextPath(sb.ToString()); MyRepository rep = new MyRepository(); UserMst fromUser = rep.FindUserMstByUserId(999); MessageBox.Show("DB接続に成功しました!!"); this.sqliteConnectableDbPath.Text = sb.ToString(); this.sqliteSaveBtn.Visible = true; this.sqliteDbFilePath.Enabled = false; } } catch (Exception ex) { MessageBox.Show("DB接続失敗"); common.resetDbContextPath(dbConnectionString, dbProviderName); } }
public IHttpActionResult Register([FromBody] JObject json) { UserMst model = JsonConvert.DeserializeObject <UserMst>(json.ToString()); BodyInOut ack = api.AddModel(model); return(Json <BodyInOut>(ack)); }
public MailServiceOutBo execute() { MailServiceOutBo outBo = new MailServiceOutBo(); MyRepository rep = new MyRepository(); UserMst fromUser = rep.FindUserMstByUserId(BaseForm.UserInfo.userId); UserMst toUser = rep.FindMailingListUser(); string body = "承認者:" + fromUser.user_name + System.Environment.NewLine + this.inBo.messageBody; System.Net.Mail.MailMessage msg = new MailMessage(); System.Net.Mail.SmtpClient sc = new System.Net.Mail.SmtpClient(); try { msg = new System.Net.Mail.MailMessage(fromUser.mail_address, toUser.mail_address, this.inBo.messageSubject, body); sc.Host = "localhost"; sc.Port = 25; sc.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; sc.Credentials = new System.Net.NetworkCredential(fromUser.mail_address, fromUser.password); sc.Send(msg); } catch (Exception ex) { StringBuilder sb = new StringBuilder(); sb.AppendLine(ex.Message); sb.AppendLine("TO・・・" + "ユーザー名:" + toUser.user_name + "、メールアドレス:" + toUser.mail_address); sb.AppendLine("FROM・・・" + "ユーザー名:" + fromUser.user_name + "、メールアドレス:" + fromUser.mail_address); outBo.errorMessage = sb.ToString(); } finally { msg.Dispose(); sc.Dispose(); } return(outBo); }
/// <summary> /// 注册 /// </summary> /// <param name="user"></param> /// <returns></returns> public bool Regist(UserMst model) { string sSql = "INSERT INTO UserMst "; sSql += "(UserID, NickName, Phone, UserPwd, Sex, Photo, MailAddr, UserRole, ActiveFlg, TotalPoints, TotalConsume, TotalRecharge, Province, City, District, Address, OpenID, CompanyID, RegisterTime, UpdDateTime) "; sSql += "VALUES("; sSql += "'" + model.user_id + "',"; sSql += "'" + model.nick_name + "',"; sSql += "'" + model.phone + "',"; sSql += "'" + model.user_pwd + "',"; sSql += "'" + model.sex + "',"; sSql += "'" + model.photo + "',"; sSql += "'" + model.mail_addr + "',"; sSql += "'" + model.user_role + "',"; sSql += "'" + model.active_flg + "',"; sSql += model.total_points + ","; sSql += model.total_consume + ","; sSql += model.total_recharge + ","; sSql += "'" + model.province + "',"; sSql += "'" + model.city + "',"; sSql += "'" + model.district + "',"; sSql += "'" + model.address + "',"; sSql += "'" + model.open_id + "',"; sSql += "'" + model.company_id + "',"; sSql += "'" + DateTime.Now.ToString() + "',"; sSql += "'" + DateTime.Now.ToString() + "'"; sSql += ")"; int rowCount = DbHelperMySQL.ExecuteSql(sSql); if (rowCount > 0) { return(true); } return(false); }
/// <summary> /// 修改密码 /// </summary> /// <param name="user_id">用户ID</param> /// <param name="pwd">原密码</param> /// <param name="new_pwd">新密码</param> /// <returns></returns> public BodyInOut UpdatePwd(string user_id, string pwd, string new_pwd) { BodyInOut ack = new BodyInOut(); try { UserMst model = GetBaseModel(user_id); if (model.user_pwd.Equals(BruceClass.Sha256(pwd))) { if (dal.UpdatePwd(user_id, BruceClass.Sha256(new_pwd))) { ack.return_flag = ApiConst.RETURN_SUCCESS; ack.return_msg = ""; } else { ack.return_flag = ApiConst.RETURN_FAIL; ack.return_msg = ErrConst.ErrCode_0007; } } else { ack.return_flag = ApiConst.RETURN_FAIL; ack.return_msg = ErrConst.ErrCode_0017; } } catch (Exception ex) { LogManager.ErrorLog(ex.ToString()); ack.return_flag = ApiConst.RETURN_FAIL; ack.return_msg = ex.ToString(); } return(ack); }
public IActionResult AddEdit(UserMst userMst) { if (ModelState.IsValid) { BaseResponseModel response = _Userservice.SaveUserMst(userMst); } return(RedirectToAction(nameof(Index))); }
public long DeleteUser(UserMasterDto model) { Mapper.CreateMap <UserMasterDto, UserMst>(); UserMst tbluser = Mapper.Map <UserMasterDto, UserMst>(model); _userMasterRepository.DeleteUserDetails(tbluser, _dbContext); return(_dbContext.SaveChanges()); }
public long UpdateUserActiveStatus(UserMasterDto model) { Mapper.CreateMap <UserMasterDto, UserMst>(); UserMst tbluser = Mapper.Map <UserMasterDto, UserMst>(model); var existingUserData = _userMasterRepository.GetAllUserDetails(_dbContext) .Where(x => x.UserId == model.UserId) .FirstOrDefault(); return(_userMasterRepository.UpdateUserActiveStatus(tbluser, _dbContext)); }
public UserKanriRegistServiceOutBo execute() { UserKanriRegistServiceOutBo outBo = new UserKanriRegistServiceOutBo(); if (this.inputCheck(this.inBo, ref outBo)) { return(outBo); } for (int i = 0; i < this.inBo.userKanriDataGridView1.Rows.Count; i++) { if (this.inBo.userKanriDataGridView1.Rows[i].Cells[0].Value == null || (bool)this.inBo.userKanriDataGridView1.Rows[i].Cells[0].Value == false) { continue; } using (var context = new MyContext()) { long condtion = Convert.ToInt64(this.inBo.userKanriDataGridView1.Rows[i].Cells["user_id"].Value.ToString()); var upUser = context.UserMst.Where(x => x.user_id == condtion); if (upUser.Count() == 1) { var u = context.UserMst.Single(x => x.user_id == condtion); int empId = this.inBo.userKanriDataGridView1.Rows[i].Cells["emp_id"].Value.ToString().ToIntType(); u.emp_id = empId; u.user_name = Convert.ToString(this.inBo.userKanriDataGridView1.Rows[i].Cells["user_name"].Value); u.kengen = this.inBo.userKanriDataGridView1.Rows[i].Cells["kengen"].Value.ToString().ToIntType(); u.sanka_kahi = (bool)this.inBo.userKanriDataGridView1.Rows[i].Cells["sanka_kahi"].Value ? 0 : 1; u.mail_id = this.inBo.userKanriDataGridView1.Rows[i].Cells["mail_id"].Value.ToString(); u.mail_address = this.inBo.userKanriDataGridView1.Rows[i].Cells["mail_address"].Value.ToString(); u.password = this.inBo.userKanriDataGridView1.Rows[i].Cells["password"].Value.ToString(); u.cre_date = System.DateTime.Now.ToString(); context.SaveChanges(); if (BaseForm.UserInfo.empId == empId) { outBo.empId = empId; } continue; } UserMst user = new UserMst(); user.emp_id = this.inBo.userKanriDataGridView1.Rows[i].Cells["emp_id"].Value.ToString().ToIntType(); user.user_name = this.inBo.userKanriDataGridView1.Rows[i].Cells["user_name"].Value.ToString(); user.kengen = this.inBo.userKanriDataGridView1.Rows[i].Cells["kengen"].Value.ToString().ToIntType(); user.sanka_kahi = (bool)this.inBo.userKanriDataGridView1.Rows[i].Cells["sanka_kahi"].Value ? 0 : 1; user.mail_id = this.inBo.userKanriDataGridView1.Rows[i].Cells["mail_id"].Value.ToString(); user.mail_address = this.inBo.userKanriDataGridView1.Rows[i].Cells["mail_address"].Value.ToString(); user.password = this.inBo.userKanriDataGridView1.Rows[i].Cells["password"].Value.ToString(); user.cre_date = System.DateTime.Now.ToString(); context.UserMst.Add(user); context.SaveChanges(); } } return(outBo); }
public IActionResult AddEdit(int id) { UserMst userMst = new UserMst(); if (id != 0) { userMst = _Userservice.GetUser(id); } userMst.LstUserType = _Userservice.GetUserTypeMst(); return(View(userMst)); }
public static UserMst GetUserInfo(int id) { UserMst ret = new UserMst(); // DB接続 using (var con = new AccDbConnection(Conf._settings)) { ret = getUser(con, id); } return(ret); }
public BaseResponseModel SaveUserMst(UserMst model) { BaseResponseModel baseResponseModel = new BaseResponseModel(); UserMst UserMst = new UserMst(); using (var transaction = _db.Database.BeginTransaction()) { try { var oldData = _db.UserMst.Where(c => c.UserId == model.UserId).FirstOrDefault(); UserMst data = oldData == null ? new UserMst() : oldData; data.UserName = model.UserName; data.UserTypeId = model.UserTypeId; data.Password = model.Password; data.EmailId = model.EmailId; data.IsActive = true; if (oldData == null) { data.CreatedDate = DateTime.Now; _db.UserMst.Add(data); } else { data.UpdateDate = DateTime.Now; _db.UserMst.Update(data); } int j = _db.SaveChanges(); if (j >= 1) { baseResponseModel.IsSuccess = true; } else { baseResponseModel.IsSuccess = true; } transaction.Commit(); } catch (Exception ex) { throw ex; } } return(baseResponseModel); }
public ActionResult Login() { UserMst user = new UserMst(); try { Session["LoginUserId"] = null; Session.Abandon(); ViewBag.ErrorMessage = null; } catch (Exception ex) { throw ex; } return(View(user)); }
private static UserMst[] getUserList(AccDbConnection con) { List <UserMst> ret = new List <UserMst>(); // コマンドオブジェクト生成 using (var cmd = con.CreateCommand()) { // SQL生成 // ---------------------------- // SELECT id,login_id,name,permission // FROM M_User // ---------------------------- StringBuilder selSQL = new StringBuilder(); selSQL.Append("SELECT"); selSQL.Append(" id"); selSQL.Append(",name"); selSQL.Append(",cd"); selSQL.Append(",seq"); selSQL.Append(",permission"); selSQL.Append(" FROM"); selSQL.Append(" M_User"); selSQL.Append(" ORDER BY"); selSQL.Append(" seq"); cmd.CommandText = selSQL.ToString(); // SQL実行 using (var dr = cmd.ExecuteReader()) // 該当データがある場合、返却値を設定 while (dr.Read()) { UserMst tmpUser = new UserMst(); tmpUser.UserID = Convert.ToInt32(dr["id"]); tmpUser.CD = dr["cd"].ToString(); if (dr["name"] != DBNull.Value) { tmpUser.Name = dr["name"].ToString(); } tmpUser.Seq = Convert.ToInt32(dr["seq"]); tmpUser.Permission = Convert.ToInt32(dr["permission"]); ret.Add(tmpUser); } } return(ret.ToArray()); }
private static UserMst getUser(AccDbConnection con, int id) { UserMst ret = new UserMst(); // コマンドオブジェクト生成 using (var cmd = con.CreateCommand()) { // SQL生成 // ---------------------------- // SELECT id,name,permission // FROM M_User // WHERE login_id=id // AND id=id // ---------------------------- StringBuilder selSQL = new StringBuilder(); selSQL.Append("SELECT"); selSQL.Append(" id"); selSQL.Append(",name"); selSQL.Append(",cd"); selSQL.Append(",seq"); selSQL.Append(",permission"); selSQL.Append(" FROM"); selSQL.Append(" M_User"); selSQL.Append(" WHERE"); selSQL.Append(" id="); selSQL.Append(cmd.Add(id).ParameterName); cmd.CommandText = selSQL.ToString(); // SQL実行 using (var dr = cmd.ExecuteReader()) // 該当データがある場合、返却値を設定 if (dr.Read()) { ret.UserID = id; ret.CD = dr["cd"].ToString(); if (dr["name"] != DBNull.Value) { ret.Name = dr["name"].ToString(); } ret.Seq = Convert.ToInt32(dr["seq"]); ret.Permission = Convert.ToInt32(dr["permission"]); } } return(ret); }
/// <summary> /// 追加前チェック /// </summary> /// <param name="form"></param> /// <returns></returns> private bool addPreCheck(UserKanri form) { bool isNgRequired = false; if (String.IsNullOrEmpty(form.empId.Text)) { errorProvider1.SetError(form.empId, MessageConst.ERR_001); isNgRequired = true; } if (String.IsNullOrEmpty(form.userName.Text)) { errorProvider1.SetError(form.userName, MessageConst.ERR_001); isNgRequired = true; } if (String.IsNullOrEmpty(form.kengen.Text) || form.kengen.Text.ToIntType() == 2) { errorProvider1.SetError(form.kengen, MessageConst.ERR_001); isNgRequired = true; } if (isNgRequired) { return(false); } MyRepository rep = new MyRepository(); UserMst mailUser = rep.FindMailingListUser(); if (!String.IsNullOrEmpty(mailUser.user_name) && form.kengen.SelectedIndex == (int)KengenKbn.メーリングリスト) { errorProvider1.SetError(form.kengen, MessageConst.ERR_008); return(false); } checkValList = new List <bool>(); for (int i = 0; i < form.userKanriDataGridView1.Rows.Count; i++) { if (form.userKanriDataGridView1.Rows[i].Cells[0].Value != null && (bool)form.userKanriDataGridView1.Rows[i].Cells[0].Value != false) { checkValList.Add((bool)form.userKanriDataGridView1.Rows[i].Cells[0].Value); continue; } checkValList.Add(false); } return(true); }
/// <summary> /// 注册 /// </summary> /// <param name="user"></param> /// <returns></returns> public BodyInOut AddModel(UserMst user) { BodyInOut ack = new BodyInOut(); UserLogin model = new UserLogin(); if (Exists(user.phone)) { ack.return_flag = ApiConst.RETURN_FAIL; ack.return_msg = ErrConst.ErrCode_0001; } else { user.user_id = seqNoDal.GetSeqNo(MemoConst.USER_KEY); //采番 if (string.IsNullOrEmpty(user.user_pwd)) { user.user_pwd = "111111"; //默认密码为111111 } user.user_pwd = BruceClass.Sha256(user.user_pwd); //加密 //user.user_type = MemoConst.USER_TYPE_DEFAULT; //默认用户类型 user.active_flg = MemoConst.ACTIVEFLG_1; //默认用户是否有效 user.total_points = MemoConst.POINTS; //默认注册积分 if (dal.Regist(user)) { model.user_id = user.user_id; model.nick_name = user.nick_name; model.phone = user.phone; model.photo = user.photo; model.sex = user.sex; model.mail_addr = user.mail_addr; model.active_flg = user.active_flg; model.total_points = user.total_points; model.register_time = user.register_time.ToString("yyyy-MM-dd hh:mm:ss"); model.open_id = user.open_id; ack.data = model; ack.return_flag = ApiConst.RETURN_SUCCESS; ack.return_msg = ""; } else { ack.return_flag = ApiConst.RETURN_FAIL; ack.return_msg = ErrConst.ErrCode_0002; } } return(ack); }
public long UpdateUserActiveStatus(UserMst user, DbContext dbContext) { try { using (var db = new IOTLoggerEntities1()) { db.UserMsts.Attach(user); db.Entry(user).Property(x => x.UpdatedBy).IsModified = true; db.Entry(user).Property(x => x.UpdatedDate).IsModified = true; db.Entry(user).Property(x => x.IsActive).IsModified = true; user.UpdatedBy = "testing"; user.UpdatedDate = DateTime.Now; return(db.SaveChanges()); } } catch (Exception ex) { throw ex; } }
/// <summary> /// ユーザ情報取得 /// </summary> /// <param name="id">ユーザID</param> /// <param name="usrMst">o:ユーザ情報クラス</param> /// <returns>処理結果クラス</returns> public ResultData GetUser_Serv(int id, out UserMst usrMst) { var ret = new ResultData(); usrMst = new UserMst(); try { // ユーザ情報取得メソッド呼び出し(内部関数) usrMst = User.GetUserInfo(id); ret.Result = true; } catch (Exception e) { LogControl.WriteLog(LogType.ERR, "GetUser_Serv", e.Message); ret.Message = e.Message; } return(ret); }
/// <summary> /// 根据会员ID——查询会员信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public UserMst GetBaseModel(string id) { UserMst model = new UserMst(); DataTable dt = dal.GetModel(id); if (dt.Rows.Count > 0) { model.user_id = BruceClass.DBNULLStr(dt.Rows[0]["UserID"]); model.phone = BruceClass.DBNULLStr(dt.Rows[0]["Phone"]); model.nick_name = BruceClass.DBNULLStr(dt.Rows[0]["NickName"]); model.user_role = BruceClass.DBNULLStr(dt.Rows[0]["UserRole"]); model.user_pwd = BruceClass.DBNULLStr(dt.Rows[0]["UserPwd"]); model.photo = BruceClass.DBNULLStr(dt.Rows[0]["Photo"]); model.sex = BruceClass.DBNULLStr(dt.Rows[0]["Sex"]); model.mail_addr = BruceClass.DBNULLStr(dt.Rows[0]["MailAddr"]); model.active_flg = BruceClass.DBNULLStr(dt.Rows[0]["ActiveFlg"]); model.register_time = BruceClass.DBNULLDateTime(dt.Rows[0]["RegisterTime"]); model.open_id = BruceClass.DBNULLStr(dt.Rows[0]["OpenID"]); } return(model); }
public void CreateUser(UserMst user, DbContext dbContext) { dbContext.Set <UserMst>().Add(user); }
public void UpdateUser(UserMst userExisting, UserMst user, DbContext dbContext) { dbContext.Entry(userExisting).CurrentValues.SetValues(user); }
//public IQueryable<sp_GetUserDtls_Result> GetAllUserDetailsBySp(DbContext dbContext) //{ // return dbContext.Set<sp_GetUserDtls_Result>(); //} public void DeleteUserDetails(UserMst user, DbContext dbContext) { dbContext.Entry(user).State = EntityState.Deleted; }
public ActionResult Login(UserMst model, string returnUrl) { List <UserMst> courseModelList = null; try { courseModelList = BCBSDataAccess.GetUserInfoById(model); if (courseModelList != null && courseModelList.Count > 0) { foreach (var item in courseModelList) { if (item.LoginIsActive == true) { UserMst TempLocation = new UserMst(); Session["LoginUserId"] = item.LoginUserId; TempLocation.LoginUserId = item.LoginUserId; TempLocation.LoginUserName = item.LoginUserName; TempLocation.LoginPassword = item.LoginPassword; TempLocation.LoginEmail = item.LoginEmail; TempLocation.LoginFirstName = item.LoginFirstName; TempLocation.LoginLastName = item.LoginLastName; TempLocation.LoginIsActive = item.LoginIsActive; courseModelList.Add(TempLocation); Util.LogInfo("Login", "Successfully Login : "******"Index", "U65Report"); return(RedirectToAction("Index", "SalesReport")); } else { Session["LoginUserId"] = null; Session.Abandon(); Util.LogInfo("Login", "User is In-Active. Please contact Administrator : " + item.LoginUserName); ViewBag.ErrorMessage = "User is In-Active. Please contact Administrator"; } } } else { Session["LoginUserId"] = null; Session.Abandon(); ViewBag.ErrorMessage = "Incorrect user name/password."; return(View()); } } catch (Exception ex) { string DetailsMessageError = null; if (ex.InnerException != null) { DetailsMessageError = ex.InnerException.Message + " " + ex.StackTrace; } else { DetailsMessageError = ex.StackTrace; } Util.LoggError(new System.Diagnostics.StackFrame(0).GetMethod().Name, ex.Message, DetailsMessageError); } return(View()); }