/// <summary> /// 读取预分装列表 /// </summary> /// <returns></returns> public List <AddvanceSubInfo> ReadSubInfo() { List <AddvanceSubInfo> returnVal = new List <AddvanceSubInfo>(); string ConnString = ConfigurationManager.AppSettings["Sngoo"]; //string inputPs, readPS; string ConnQuery = " select * from AddvanceSub "; SqlConnection connection = new SqlConnection(ConnString); connection.Open(); SqlCommand lo_cmd = new SqlCommand(ConnQuery, connection); SqlDataReader reader = lo_cmd.ExecuteReader(); while (reader.Read()) { AddvanceSubInfo item = new AddvanceSubInfo(); item.AddvanceSubState = Convert.ToInt32(reader["AddvanceSubState"]); item.CountTime = Convert.ToDateTime(reader["CountTime"]); item.Details = reader["Details"].ToString(); item.id = Convert.ToInt32(reader["id"]); item.OrderNum = Convert.ToInt32(reader["OrderNum"]); item.AddvanceId = reader["AddvanceId"].ToString(); returnVal.Add(item); } reader.Close(); connection.Close(); connection.Dispose(); //ConnString = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=sngoo712;Data Source=(local)"; return(returnVal); }
/// <summary> /// 写入预分装列表 /// </summary> /// <param name="info">与分装信息</param> public void WriteIntoSub(AddvanceSubInfo info) { string ConnString = ConfigurationManager.AppSettings["Sngoo"]; string ConnQuery = " insert into AddvanceSub (CountTime,OrderNum,Details,AddvanceSubState,AddvanceId) values('" + info.CountTime + "'," + info.OrderNum + ",'" + info.Details + "'," + info.AddvanceSubState + ",'" + info.AddvanceId + "')"; SqlConnection connection = new SqlConnection(ConnString); connection.Open(); SqlCommand lo_cmd = new SqlCommand(ConnQuery, connection); lo_cmd.ExecuteNonQuery(); connection.Close(); connection.Dispose(); }