protected void btnSava_Click(object sender, EventArgs e) { try { Model.CustomerInfo cust = new Model.CustomerInfo(); cust.CustomerAccount = txtCustomerAccount.Text.Trim(); cust.CustomerPwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtCustomerAccount.Text.Trim(), "MD5"); cust.CustomerName = txtCustomerName.Text.Trim(); cust.CustomerState = 0; cust.CreateDate = DateTime.Now; int result = new BLL.CustomerInfo().Add(cust); if (result > 0) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('保存成功')</script>"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('保存失败')</script>"); } } catch (Exception ec) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert(" + ec.Message + ")</script>"); throw; } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (!string.IsNullOrEmpty(Request.QueryString["id"])) { int custId = Convert.ToInt32(Request.QueryString["id"]); Model.CustomerInfo cust = new BLL.CustomerInfo().GetModel(custId); txtCustomerAccount.Text = cust.CustomerAccount; txtCustomerName.Text = cust.CustomerName; txtCustomerPwd.Text = cust.CustomerPwd; } }
protected void btnSava_Click(object sender, EventArgs e) { try { Model.CustomerInfo cust = new Model.CustomerInfo(); int custId = Convert.ToInt32(Request.QueryString["id"]); cust.CustomerAccount = txtCustomerAccount.Text; Model.CustomerInfo custs = new BLL.CustomerInfo().GetModel(custId); if (txtCustomerPwd.Text.Trim() != "") { cust.CustomerPwd = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(txtCustomerPwd.Text, "MD5"); } else { cust.CustomerPwd = custs.CustomerPwd; } cust.CustomerName = txtCustomerName.Text; cust.CustomerState = custs.CustomerState; cust.CreateDate = custs.CreateDate; cust.CustomerID = custId; bool result = new BLL.CustomerInfo().Update(cust); if (result) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('保存成功')</script>"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('保存失败')</script>"); } } catch (Exception ec) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('" + ec.Message + "')</script>"); throw; } }
protected void btnlogin_Click(object sender, EventArgs e) { Session.Clear(); string username = Request.Form["username"].ToString(); string passwd = Request.Form["password"].ToString(); string md5pass = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(passwd, "MD5"); try { if (dropModel.SelectedValue == "0") { Model.ManagerInfo manager = new BLL.ManagerInfo().GetModel(username); if (manager == null || string.IsNullOrEmpty(manager.AdminAccount)) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('帐号不存在,请重新输入')</script>"); } else if (md5pass != manager.AdminPasswd) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('密码不正确,请重新输入')</script>"); } else { Session["manager"] = manager; AddLog(manager.AdminID, 1, DateTime.Now, "在Ip为:" + Request.UserHostAddress + " 的PC端登录"); Response.Redirect("Manage\\Management.aspx"); } } else if (dropModel.SelectedValue == "1") { Model.AgentInfo agent = new BLL.AgentInfo().GetModel(username); if (agent == null || string.IsNullOrEmpty(agent.AgentAccount)) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('帐号不存在,请重新输入')</script>"); } else if (md5pass != agent.AgentPasswd) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('密码不正确,请重新输入')</script>"); } else { Session["Agent"] = agent; Model.AgentInfo agents = new Model.AgentInfo(); agents.AgentID = agent.AgentID; agents.LoginIP = Request.UserHostAddress; agents.LoginTime = DateTime.Now; agents.OnlineState = 1; new BLL.AgentInfo().UpdateIPonTime(agents); AddLog(agent.AgentID, 2, DateTime.Now, "在IP为:" + Request.UserHostAddress + " 的PC端登录"); Response.Redirect("Manage\\AgentInfo.aspx"); } } else if (dropModel.SelectedValue == "2") { Model.CustomerInfo cust = new BLL.CustomerInfo().GetModel(username); if (cust == null || string.IsNullOrEmpty(cust.CustomerAccount)) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('帐号不存在,请重新输入')</script>"); } else if (md5pass != cust.CustomerPwd) { Page.ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('密码不正确,请重新输入')</script>"); } else { Session["Cust"] = cust; Model.CustomerInfo Customer = new Model.CustomerInfo(); Customer.CustomerState = 1; Customer.CustomerAccount = cust.CustomerAccount; new BLL.CustomerInfo().UpdateState(Customer); Response.Redirect("Manage\\OnlineProblem.aspx"); } } } catch (Exception) { throw; } }