//******************************************************************************************** public void 原料导入(string oleconn) { try { OleDbConnection conn = new OleDbConnection(oleconn); conn.Open(); string str_sql = "select * from [原材料$]"; OleDbDataAdapter oda = new OleDbDataAdapter(str_sql, conn); DataSet ds = new DataSet(); oda.Fill(ds); conn.Close(); //ds为数据 Material mt = new Material(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { try { mt.Name = ds.Tables[0].Rows[i][0].ToString(); mt.Supplier = ds.Tables[0].Rows[i][1].ToString(); mt.Unit = ds.Tables[0].Rows[i][2].ToString(); mt.StockCount = int.Parse(ds.Tables[0].Rows[i][3].ToString()); if (mtMgr.AddNewMaterial(mt) != 0) { richTextBox1.Text += "原料信息[" + mt.Name + "]生成成功!\r\n"; } else { richTextBox1.Text += "原料信息[" + mt.Name + "]生成失败,请仔细核准数据!\r\n"; } } catch (Exception ex) { richTextBox1.Text += "原料信息[" + mt.Name + "]生成失败,请仔细核准数据!\r\n"; }; } } catch (Exception ex) { }; }