protected void sub_Click(object sender, EventArgs e) { pdm.Model.DealerInfo di = new pdm.Model.DealerInfo(); di.Dealer_ID = Convert.ToInt32(Session["d_id"]); di.Name = dealer_name.Text.Trim(); di.Province = Convert.ToInt32(Province.SelectedValue); di.City = Convert.ToInt32(City.SelectedValue); di.County = Convert.ToInt32(County.SelectedValue); di.Tel = Convert.ToInt32(telephone_number.Text); di.Address = addr.Text; new pdm.BLL.DealerInfo().Update(di); //添加操作日志 pdm.Model.UseLog log = new pdm.Model.UseLog(); log.Method = "edit_user_info"; 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('修改成功')</script>"); }
protected void submit_Click(object sender, EventArgs e)//提交按钮点击触发事件 { pdm.Model.DealerInfo di = new pdm.Model.DealerInfo(); pdm.Model.Users user = new pdm.Model.Users(); if ((null != username.Text.Trim()) && ((null != password.Text.Trim()) == (null != password2.Text.Trim())) && (0 != Convert.ToInt32(Province.SelectedValue)) && (0 != Convert.ToInt32(County.SelectedValue)) && (0 != Convert.ToInt32(City.SelectedValue)) && (null != addr.Text.Trim())) { if (!(new pdm.BLL.Users().Exists(username.Text.Trim()))) { user.Dealer_Name = username.Text.Trim(); user.Dealer_Psw = password.Text.Trim(); user.Parent_ID = Convert.ToInt32(Session["UserID"]); user.Dealer_Level = Convert.ToInt32(Session["UserLevel"]) + 1; try { //将数据写入Users表 new pdm.BLL.Users().Add(user); //获取插入数据的Dealer_ID,存放在dealer_id中 DataSet userDS = new DataSet(); string sql = "select * from Users where Dealer_Name = @name"; System.Data.SqlClient.SqlParameter us = new System.Data.SqlClient.SqlParameter("@name", username.Text.Trim()); userDS = Maticsoft.DBUtility.DbHelperSQL.Query(sql, us); int dealer_id = Convert.ToInt32(userDS.Tables[0].Rows[0]["Dealer_ID"].ToString()); //Response.Write("<script type='text/javascript'>alert('" + dealer_id+ "')</script>"); //将资料写入DealerInfo表中 di.Dealer_ID = dealer_id; di.Name = dealer_name.Text.Trim(); di.Province = Convert.ToInt32(Province.SelectedValue); di.City = Convert.ToInt32(City.SelectedValue); di.County = Convert.ToInt32(County.SelectedValue); di.Tel = Convert.ToInt32(telephone_number.Text); di.Address = addr.Text; new pdm.BLL.DealerInfo().Add(di); Response.Write("<script type='text/javascript'>alert('添加成功')</script>"); //重置所有输入框 username.Text = ""; password.Text = ""; password2.Text = ""; dealer_name.Text = ""; telephone_number.Text = ""; addr.Text = ""; Province.SelectedIndex = 0; City.Visible = false; County.Visible = false; //添加日志记录 pdm.Model.UseLog log = new pdm.Model.UseLog(); log.Method = "add_user"; log.Time = DateTime.Now; log.Dealer_ID = Convert.ToInt32(Session["userID"].ToString()); new pdm.BLL.UseLog().Add(log); } catch { Response.Write("<script type='text/javascript'>alert('添加失败,请重试')</script>"); } } else { Response.Write("<script type='text/javascript'>alert('用户名已存在')</script>"); } } else { Response.Write("<script type='text/javascript'>alert('请检查信息是否有错')</script>"); } }