protected void SignIn_Click(object sender, EventArgs e) { if (null != username.Text.Trim() && null != password.Text.Trim()) { try { //根据输入框中的用户名来取出一个Dataset,搜索语句采用传参的方式 DataSet userDS = new DataSet(); string sql = "select * from Users where Dealer_Name = @name"; pdm.BLL.DealerInfo dealer = new pdm.BLL.DealerInfo(); System.Data.SqlClient.SqlParameter us = new System.Data.SqlClient.SqlParameter("@name", username.Text.Trim()); userDS = Maticsoft.DBUtility.DbHelperSQL.Query(sql, us); //判断是否密码是否正确 if (userDS.Tables[0].Rows.Count > 0) { if (userDS.Tables[0].Rows[0]["Dealer_Psw"].ToString() == password.Text.Trim()) { Session["UserID"] = userDS.Tables[0].Rows[0]["Dealer_ID"].ToString(); Session["UserName"] = userDS.Tables[0].Rows[0]["Dealer_Name"].ToString(); Session["UserLevel"] = userDS.Tables[0].Rows[0]["Dealer_Level"].ToString(); Session["Parent"] = userDS.Tables[0].Rows[0]["Parent_ID"].ToString(); if (int.Parse(userDS.Tables[0].Rows[0]["Parent_ID"].ToString()) == -1) { //添加操作日志 pdm.Model.UseLog log = new pdm.Model.UseLog(); log.Method = "login"; log.Time = DateTime.Now; log.Dealer_ID = Convert.ToInt32(Session["userID"].ToString()); new pdm.BLL.UseLog().Add(log); Response.Write("<script type='text/javascript'>alert('登陆成功');window.location.href='./SystemManagerForm/index.aspx';</script>"); } else { Response.Write("<script type='text/javascript'>alert('登陆成功');window.location.href='./NormalUserForm/index.aspx'</script>"); } } else { Response.Write("<script type='text/javascript'>alert('请检查用户名或密码是否正确')</script>"); } } } catch { Response.Write("<script type='text/javascript'>alert('登陆失败')</script>"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session.Count > 0 && Session["userID"].ToString() != "") { } else { Response.Redirect("/loginout.aspx?method=sb"); } } pdm.Model.DealerInfo di = new pdm.BLL.DealerInfo().GetModel(Convert.ToInt32(Request.QueryString["id"])); username.Text = Request.QueryString["uname"]; dealer_name.Text = di.Name; telephone_number.Text = di.Tel.ToString(); addr.Text = di.Address; string province = new pdm.BLL.Address_code().GetModel(Convert.ToInt32(di.Province)).A_Name; string city = new pdm.BLL.Address_code().GetModel(Convert.ToInt32(di.City)).A_Name; string county = new pdm.BLL.Address_code().GetModel(Convert.ToInt32(di.County)).A_Name; pd.Text = province + city + county; }
protected void Page_Load(object sender, EventArgs e) { username.Text = Session["UserName"].ToString(); if (!IsPostBack) { if (Session.Count > 0 && Session["userID"].ToString() != "") { } else { Response.Redirect("/loginout.aspx?method=sb"); } ListItem prov = new ListItem(); prov = new ListItem(); prov.Text = "--省份--"; prov.Value = "0"; Province.Items.Add(prov); //为文本框赋值 pdm.Model.DealerInfo temp = new pdm.BLL.DealerInfo().GetModel(Convert.ToInt32(Session["userID"].ToString())); dealer_name.Text = temp.Name; telephone_number.Text = temp.Tel.ToString(); addr.Text = temp.Address; //生成省份下拉菜单选项 DataSet ProvDS = new DataSet(); string sql = "select * from Address_code where Code < 100"; ProvDS = Maticsoft.DBUtility.DbHelperSQL.Query(sql); int num = 0; if ((num = ProvDS.Tables[0].Rows.Count) > 0) { for (int i = 0; i < num; i++) { prov = new ListItem(); prov.Value = ProvDS.Tables[0].Rows[i]["Code"].ToString(); prov.Text = ProvDS.Tables[0].Rows[i]["A_Name"].ToString(); Province.Items.Add(prov); } } string level = Session["UserLevel"].ToString(); switch (level) { case "2": //省级 Province.SelectedValue = new pdm.BLL.DealerInfo().GetModel(Convert.ToInt32(Session["userID"].ToString())).Province.ToString(); Province.Enabled = false; City.Visible = true; County.Visible = false; City.Items.Clear(); County.Items.Clear(); ListItem city = new ListItem(); city.Text = "--城市--"; city.Value = "0"; City.Items.Add(city); DataSet cityDS = new DataSet(); int citycode = Convert.ToInt32(Province.SelectedValue) * 100; // Response.Write("<script type='text/javascript'>alert('" + citycode + "')</script>"); string sqlcity = "select * from Address_code where Code > @ccode and Code < (@ccode+100)"; System.Data.SqlClient.SqlParameter ct = new System.Data.SqlClient.SqlParameter("@ccode", citycode); cityDS = Maticsoft.DBUtility.DbHelperSQL.Query(sqlcity, ct); num = 0; if ((num = cityDS.Tables[0].Rows.Count) > 0) { for (int i = 0; i < num; i++) { city = new ListItem(); city.Value = cityDS.Tables[0].Rows[i]["Code"].ToString(); city.Text = cityDS.Tables[0].Rows[i]["A_Name"].ToString(); City.Items.Add(city); } } break; case "3": //市级 //省份选择:不可更改 Province.SelectedValue = new pdm.BLL.DealerInfo().GetModel(Convert.ToInt32(Session["userID"].ToString())).Province.ToString(); Province.Enabled = false; //市区选择:不可更改 City.Visible = true; County.Visible = false; City.Items.Clear(); County.Items.Clear(); city = new ListItem(); city.Text = "--城市--"; city.Value = "0"; City.Items.Add(city); sqlcity = "select * from Address_code where Code > @ccode and Code < (@ccode+100)"; citycode = Convert.ToInt32(Province.SelectedValue) * 100; System.Data.SqlClient.SqlParameter ct1 = new System.Data.SqlClient.SqlParameter("@ccode", citycode); cityDS = Maticsoft.DBUtility.DbHelperSQL.Query(sqlcity, ct1); num = 0; if ((num = cityDS.Tables[0].Rows.Count) > 0) { for (int i = 0; i < num; i++) { city = new ListItem(); city.Value = cityDS.Tables[0].Rows[i]["Code"].ToString(); city.Text = cityDS.Tables[0].Rows[i]["A_Name"].ToString(); City.Items.Add(city); } } City.SelectedValue = new pdm.BLL.DealerInfo().GetModel(Convert.ToInt32(Session["userID"].ToString())).City.ToString(); City.Enabled = false; //县级选择:允许更改 County.Visible = true; County.Items.Clear(); ListItem county = new ListItem(); county.Text = "--县--"; county.Value = "0"; County.Items.Add(county); DataSet countyDS = new DataSet(); int countycode = Convert.ToInt32(City.SelectedValue) * 100; // Response.Write("<script type='text/javascript'>alert('" + citycode + "')</script>"); string countysql = "select * from Address_code where Code > @ccode and Code < (@ccode+100)"; System.Data.SqlClient.SqlParameter coun = new System.Data.SqlClient.SqlParameter("@ccode", countycode); countyDS = Maticsoft.DBUtility.DbHelperSQL.Query(countysql, coun); num = 0; if ((num = countyDS.Tables[0].Rows.Count) > 0) { for (int i = 0; i < num; i++) { county = new ListItem(); county.Value = countyDS.Tables[0].Rows[i]["Code"].ToString(); county.Text = countyDS.Tables[0].Rows[i]["A_Name"].ToString(); County.Items.Add(county); } } break; case "4": //县级用户 Province.SelectedValue = new pdm.BLL.DealerInfo().GetModel(Convert.ToInt32(Session["userID"].ToString())).Province.ToString(); Province.Enabled = false; //市区选择:不可更改 City.Visible = true; County.Visible = false; City.Items.Clear(); County.Items.Clear(); city = new ListItem(); city.Text = "--城市--"; city.Value = "0"; City.Items.Add(city); sqlcity = "select * from Address_code where Code > @ccode and Code < (@ccode+100)"; citycode = Convert.ToInt32(Province.SelectedValue) * 100; System.Data.SqlClient.SqlParameter ct2 = new System.Data.SqlClient.SqlParameter("@ccode", citycode); cityDS = Maticsoft.DBUtility.DbHelperSQL.Query(sqlcity, ct2); num = 0; if ((num = cityDS.Tables[0].Rows.Count) > 0) { for (int i = 0; i < num; i++) { city = new ListItem(); city.Value = cityDS.Tables[0].Rows[i]["Code"].ToString(); city.Text = cityDS.Tables[0].Rows[i]["A_Name"].ToString(); City.Items.Add(city); } } City.SelectedValue = new pdm.BLL.DealerInfo().GetModel(Convert.ToInt32(Session["userID"].ToString())).City.ToString(); City.Enabled = false; //县级选择:不允许更改 County.Visible = true; County.Items.Clear(); county = new ListItem(); county.Text = "--县--"; county.Value = "0"; County.Items.Add(county); DataSet couDS = new DataSet(); int coucode = Convert.ToInt32(City.SelectedValue) * 100; // Response.Write("<script type='text/javascript'>alert('" + citycode + "')</script>"); string cousql = "select * from Address_code where Code > @ccode and Code < (@ccode+100)"; System.Data.SqlClient.SqlParameter cou = new System.Data.SqlClient.SqlParameter("@ccode", coucode); countyDS = Maticsoft.DBUtility.DbHelperSQL.Query(cousql, cou); num = 0; if ((num = countyDS.Tables[0].Rows.Count) > 0) { for (int i = 0; i < num; i++) { county = new ListItem(); county.Value = countyDS.Tables[0].Rows[i]["Code"].ToString(); county.Text = countyDS.Tables[0].Rows[i]["A_Name"].ToString(); County.Items.Add(county); } } County.SelectedValue = new pdm.BLL.DealerInfo().GetModel(Convert.ToInt32(Session["userID"].ToString())).County.ToString(); County.Enabled = false; break; } } }