日期:2014-05-18 浏览次数:20946 次
private void Loadprodunt() { string strconnection = Convert.ToString(ConfigurationManager.ConnectionStrings["NEW_YJQXConnectionString"]); //将连接数据库字符串,写入STRCONNECTION 变量 SqlConnection objconnection = new SqlConnection(strconnection); //创建一个Objconnection 数据库连接 string strQuery = "select 记录顺序,作业单号,接车日期,接车人,车牌号,车型,VIN号,客户名称,联系人,联系电话,客户地址,维修类别,维修性质,送车单位,送车人,估价人,业务员 from 前台_接车登记表 where 记录顺序=(select max(记录顺序) from 前台_接车登记表)"; //将SQL查询字符串,写入STRQUERY 变量 objconnection.Open(); //打开数据库连接 SqlCommand dbcomm = new SqlCommand(strQuery, objconnection); //创建一个命令并将之连接 SqlDataReader reader = dbcomm.ExecuteReader(); reader.Read(); 作业单号TextBox.Text = reader.GetString(1); 接车日期TextBox.Text = reader.GetDateTime(2).ToString(); 接车人TextBox.Text = reader.GetString(3); 车牌号码TextBox.Text = reader.GetString(4); 车型TextBox.Text = reader.GetString(5); VIN号TextBox.Text = reader.GetString(6); 客户名称TextBox.Text = reader.GetString(7); 联系人TextBox.Text = reader.GetString(8); 联系电话TextBox.Text = reader.GetString(9); 客户地址TextBox.Text = reader.GetString(10); 维修类别DropDownList.Text = reader.GetString(11); 维修性质DropDownList.Text = reader.GetString(12); DropDownList1.Text = reader.GetString(13); 送车人TextBox.Text = reader.GetString(14); DropDownList2.Text = reader.GetString(15); DropDownList3.Text = reader.GetString(16); reader.Close(); objconnection.Close();
private void Intoproduct() { string 接车日期 = DateTime.Now.ToString("yyyy-MM-dd"); string 接车人 = Session["userName"].ToString(); string strconnection = Convert.ToString(ConfigurationManager.ConnectionStrings["NEW_YJQXConnectionString"]); //将连接数据库字符串,写入STRCONNECTION 变量 string strSQL = "SET NOCOUNT ON;insert into 前台_接车登记表 (接车日期,接车人,维修状态,结算状态) values ('" + 接车日期 + "','" + 接车人 + "','"+"登记"+"','"+"未结算"+"');Select @@IDENTITY"; SqlConnection objconnection = new SqlConnection(strconnection); //创建一个Objconnection 数据库连接 SqlCommand dbcomn = new SqlCommand(strSQL, objconnection); //执行 strSQL 字符串命令到 objconnection 连接 objconnection.Open(); //打开数据库连接 dbcomn.ExecuteNonQuery(); objconnection.Close(); //关闭数据库连接 }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Loadprodunt(); //绑定TEXTBOX GRIDproduct(); //绑定GRIDVIEW控件 RENproduct(); //绑定下拉框DORPDOWNLIST1 YEWUproduct(); //绑定下拉框DORPDOWNLIST2 SCproduct(); //绑定下拉框DORPDOWNLIST3 }