public int InsertAgentsInfo(AgentsModel model) { SqlConnection con = new SqlConnection(); con.ConnectionString = "server=127.0.0.1;database=Rent;uid=Rent;pwd=Rent"; try { con.Open(); string sql = "insert into agent (agentID,agentPwd,agentTel,agentName,agentAge) values('" + model.agentID + "','" + model.agentPwd + "','" + model.agentTel + "','" + model.agentName + "'," + model.agentAge + ")"; SqlCommand cmd = new SqlCommand(sql, con); return(cmd.ExecuteNonQuery()); } catch (Exception e) { return(-1); } finally { if (con.State == ConnectionState.Open) { con.Close(); } } }
public DataTable GetAgentsInfoById(AgentsModel model) { AgentsDAL dal = new AgentsDAL(); DataTable dt = dal.GetAgentsInfoById(model); return(dt); }
protected virtual void PrepareAgentstoEntity(Agents to, AgentsModel from) { to.NickName = from.NickName; to.AvartaId = from.AvartaId; to.CustomerId = from.CustomerId; to.NgayTao = from.NgayTao; }
public AgentsControllerUnitTests() { var agentsModel = new AgentsModel(); var loggerMock = new Mock <ILogger <AgentsController> >(); _controller = new AgentsController(agentsModel, loggerMock.Object); }
public ActionResult EditAgents(AgentsModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.CVChat)) { return(AccessDeniedView()); } var _agents = _chatService.GetAgentsById(model.Id); if (_agents == null) { //No manufacturer found with the specified id return(RedirectToAction("ListAgents")); } if (ModelState.IsValid) { _agents = new Agents(); PrepareAgentstoEntity(_agents, model); _chatService.UpdateAgents(_agents); if (continueEditing) { //selected tab SaveSelectedTabIndex(); return(RedirectToAction("EditAgents", _agents.Id)); } return(RedirectToAction("ListAgents")); } return(View(model)); }
protected virtual void PrepareAgentstoModel(Agents from, AgentsModel to) { to.NickName = from.NickName; to.AvartaId = from.AvartaId; to.CustomerId = from.CustomerId; to.NgayTao = from.NgayTao; }
public DataTable GetAgentsInfoById(AgentsModel model) { SqlConnection con = new SqlConnection(); con.ConnectionString = "server=127.0.0.1;database=Rent;uid=Rent;pwd=Rent"; try { con.Open(); SqlCommand cmd = new SqlCommand("select * from agent where agentID = " + "'" + model.agentID + "'", con); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); // 使用数据适配器填充数据集的时候,需要进行分页数据的处理 sda.Fill(ds, "agents"); return(ds.Tables["agents"]); } catch (Exception e) { return(null); } finally { if (con.State == ConnectionState.Open) { con.Close(); } } }
public ActionResult CreateAgents() { if (!_permissionService.Authorize(StandardPermissionProvider.CVChat)) { return(AccessDeniedView()); } var model = new AgentsModel(); preparecustomer(model); return(View(model)); }
protected virtual void preparecustomer(AgentsModel model) { model.Customer = new AgentsModel.KhachHangModel(); if (model.CustomerId > 0) { var custommer = _customerService.GetCustomerById(model.CustomerId); if (custommer != null) { model.Customer.Id = custommer.Id; model.Customer.Email = custommer.Email; model.Customer.Fullname = custommer.GetFullName(); } } }
public ActionResult CreateAgents(AgentsModel model, bool continueEditing) { if (!_permissionService.Authorize(StandardPermissionProvider.CVChat)) { return(AccessDeniedView()); } var agents = new Agents(); PrepareAgentstoEntity(agents, model); var _nhanvien = _customerService.GetCustomerByEmail(model.Customer.Email); agents.CustomerId = _nhanvien.Id; _chatService.InsertAgents(agents); return(continueEditing ? RedirectToAction("EditAgents", new { id = agents.Id }) : RedirectToAction("ListAgents")); //return View(model); }
public ActionResult EditAgents(int id) { if (!_permissionService.Authorize(StandardPermissionProvider.CVChat)) { return(AccessDeniedView()); } var _agents = _chatService.GetAgentsById(id); if (_agents == null) { //No manufacturer found with the specified id return(RedirectToAction("ListAgents")); } var model = new AgentsModel(); PrepareAgentstoModel(_agents, model); preparecustomer(model); //default values return(View(model)); }
public ActionResult ListAgents(DataSourceRequest command, ListAgentsModel model) { if (!_permissionService.Authorize(StandardPermissionProvider.CVChat)) { return(AccessDeniedView()); } var arragents = _chatService.GetallAgents(model.NameAgents); var gridModel = new DataSourceResult { Data = arragents.Select(x => { var m = new AgentsModel(); m.Id = x.Id; PrepareAgentstoModel(x, m); return(m); }), Total = arragents.Count() }; return(Json(gridModel)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(AgentsModel model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(AgentsModel model) { return(dal.Update(model)); }
protected void Button1_Click1(object sender, EventArgs e) { if (TextBox1.Text == "" || TextBox2.Text == "" || TextBox3.Text == "") { Response.Write("<script>alert('请先填写账号密码及验证码')</script>"); } else { //判断验证码是否正确 if (TextBox2.Text == Label1.Text) { /*租户*/ if (this.DropDownList1.SelectedValue == "user") { UsersModel model = new UsersModel(); model.userID = TextBox1.Text; //先判断ID号是否存在 UsersBLL bll = new UsersBLL(); DataTable dt = bll.GetUsersInfoById(model); if (dt.Rows.Count != 0) { Response.Write("<script>alert('账号已存在')</script>"); } else { //再ID号不重复的情况下 对姓名和电话号码进行判断 if (TextBox4.Text == model.userName && TextBox5.Text == model.userPhone) { Response.Write("<script>alert('所填姓名与电话已存在,请重新填写')</script>"); } else { UsersModel mode1 = new UsersModel(); model.userID = TextBox1.Text; model.userPwd = TextBox3.Text; model.userName = TextBox4.Text; model.userPhone = TextBox5.Text; model.UserAge = int.Parse(TextBox6.Text); UsersBLL bll1 = new UsersBLL(); int affectRows = bll1.InsertUsersInfo(mode1); Response.Write("<script>alert('手机号已自动注册,请登录')</script>"); Response.Redirect("Login-ap.aspx"); } } } /*房东*/ if (this.DropDownList1.SelectedValue == "owner") { OwnersModel model = new OwnersModel(); model.ownerID = TextBox1.Text; //先判断ID号是否存在 OwnersBLL bll = new OwnersBLL(); DataTable dt = bll.GetUsersInfoById(model); if (dt.Rows.Count != 0) { Response.Write("<script>alert('账号已存在')</script>"); } else { if (TextBox4.Text == model.ownerName && TextBox5.Text == model.ownerPhone) { Response.Write("<script>alert('所填姓名与电话已存在,请重新填写')</script>"); } else { OwnersModel mode1 = new OwnersModel(); model.ownerID = TextBox1.Text; model.ownerPwd = TextBox3.Text; model.ownerName = TextBox4.Text; model.ownerImage = "https://image.5i5j.com/picture/8108815.jpg"; model.ownerAge = int.Parse(TextBox6.Text); OwnersBLL bll1 = new OwnersBLL(); int affectRows = bll1.InsertOwnersInfo(mode1); Response.Write("<script>alert('手机号已自动注册,请登录')</script>"); Response.Redirect("Login-ap.aspx"); } } } /*经济人*/ if (this.DropDownList1.SelectedValue == "agent") { AgentsModel model = new AgentsModel(); model.agentID = TextBox1.Text; //先判断ID号是否存在 AgentsBLL bll = new AgentsBLL(); DataTable dt = bll.GetAgentsInfoById(model); if (dt.Rows.Count != 0) { Response.Write("<script>alert('账号已存在')</script>"); } else { if (TextBox4.Text == model.agentName && TextBox5.Text == model.agentTel) { Response.Write("<script>alert('所填姓名与电话已存在,请重新填写')</script>"); } else { AgentsModel mode1 = new AgentsModel(); model.agentID = TextBox1.Text; model.agentPwd = TextBox3.Text; model.agentTel = TextBox5.Text; model.agentName = TextBox4.Text; model.agentAge = int.Parse(TextBox6.Text); AgentsBLL bll1 = new AgentsBLL(); int affectRows = bll1.InsertAentsInfo(mode1); Response.Write("<script>alert('手机号已自动注册,请登录')</script>"); Response.Redirect("Login-ap.aspx"); } } } /*管理人*/ if (this.DropDownList1.SelectedValue == "admin") { AdminsModel model = new AdminsModel(); model.adminID = TextBox1.Text; //先判断ID号是否存在 AdminsBLL bll = new AdminsBLL(); DataTable dt = bll.GetAdminsInfoById(model); if (dt.Rows.Count != 0) { Response.Write("<script>alert('账号已存在')</script>"); } else { if (TextBox4.Text == model.adminName && TextBox5.Text == model.adminTel) { Response.Write("<script>alert('所填姓名与电话已存在,请重新填写')</script>"); } else { AdminsModel mode1 = new AdminsModel(); model.adminID = TextBox1.Text; model.adminPwd = TextBox3.Text; model.adminName = TextBox4.Text; model.adminTel = TextBox5.Text; model.adminAge = int.Parse(TextBox6.Text); AdminsBLL bll1 = new AdminsBLL(); int affectRows = bll1.InsertAdminsInfo(mode1); Response.Write("<script>alert('手机号已自动注册,请登录')</script>"); Response.Redirect("Login-ap.aspx"); } } } } else { Response.Write("<script>alert('验证码错误')</script>"); } } }
public static Agents ToEntity(this AgentsModel model, Agents destination) { return(model.MapTo(destination)); }
protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "") { Response.Write("<script>alert('账号不能为空')</script>"); } else { if (TextBox2.Text == "") { Response.Write("<script>alert('密码不能为空')</script>"); } } //string role = this.DropDownList1.SelectedValue; try { if (this.DropDownList1.SelectedValue == "用户") { UsersModel model = new UsersModel(); model.userID = TextBox1.Text; UsersBLL bll = new UsersBLL(); DataTable dt = bll.GetUsersInfoById(model); //SqlDataReader sda = cmd.ExecuteReader(); if (dt.Columns["usersPwd"].ToString() == TextBox2.Text) { Rent.CommDB.ID = TextBox1.Text; Rent.Users.userID = Rent.CommDB.ID; Response.Write("<script>alert('成功登录')</script>"); Response.Redirect("houseInfo.aspx");//跳转到主页面 } else { Response.Write("<script>alert('账号,密码输入错误或请先注册新用户!!!')</script>"); } } if (this.DropDownList1.SelectedValue == "房东") { OwnersModel model = new OwnersModel(); model.ownerID = TextBox1.Text; OwnersBLL bll = new OwnersBLL(); DataTable dt = bll.GetUsersInfoById(model); if (dt.Columns["ownerPwd"].ToString() == TextBox2.Text) { Response.Write("<script>alert('成功登录')</script>"); Owner.ownerID = TextBox1.Text; //获取ownerPhone的值 Owner.ownerPhone = dt.Columns["ownerPhone"].ToString(); Response.Redirect("houseInfo.aspx");//跳转到房东信息页面 } else { Response.Write("<script>alert('账号,密码输入错误或请先注册新用户!!!')</script>"); } } if (this.DropDownList1.SelectedValue == "经纪人") { AgentsModel model = new AgentsModel(); model.agentID = TextBox1.Text; AgentsBLL bll = new AgentsBLL(); DataTable dt = bll.GetAgentsInfoById(model); if (dt.Columns["agentPwd"].ToString() == TextBox2.Text) { Agent.agentID = TextBox1.Text; //获取agentTel的值 Agent.agentTel = dt.Columns["agentTel"].ToString(); Response.Write("<script>alert('成功登录')</script>"); Response.Redirect("houseInfo.aspx");//跳转到经纪人信息页面 } else { Response.Write("<script>alert('账号,密码输入错误或请先注册新用户!!!')</script>"); } } if (this.DropDownList1.SelectedValue == "管理员") { AdminsModel model = new AdminsModel(); model.adminID = TextBox1.Text; AdminsBLL bll = new AdminsBLL(); DataTable dt = bll.GetAdminsInfoById(model); if (dt.Columns["adminPwd"].ToString() == TextBox2.Text) { Admin.adminID = TextBox1.Text; Response.Write("<script>alert('成功登录')</script>"); Response.Redirect("adminEditInfo.aspx");//跳转到管理员信息页面 } else { Response.Write("<script>alert('账号,密码输入错误或请先注册新用户!!!')</script>"); } } } catch { Response.Write("<script>alert('账号,密码输入错误或身份选择错误')</script>"); } }
public AgentsController(AgentsModel agentsModel, ILogger <AgentsController> logger) { _agentsModel = agentsModel; _logger = logger; _logger.LogDebug(1, "NLog встроен в AgentsController"); }
public int InsertAentsInfo(AgentsModel model) { AgentsDAL dal = new AgentsDAL(); return(dal.InsertAgentsInfo(model)); }