protected bool SaveToDB(string path, string tablename) { try { DataTable dt = ExcelManage.InputFromExcel(path, tablename); if (dt != null && dt.Rows.Count > 0) { WsSystem wbi = new WsSystem(); for (int i = 0; i < dt.Rows.Count; i++) { if (!string.IsNullOrEmpty(dt.Rows[i][0].ToString())) { PartsdrawingCode bb = new PartsdrawingCode(); bb.ID = PubHelper.GetHelper().GetNextID("MES_MASTER.SEQ_ALL_ID").ToString(); bb.PartsCode = dt.Rows[i][0].ToString(); bb.CustName = dt.Rows[i][1].ToString(); bb.CustCode = dt.Rows[i][2].ToString(); bb.ProductName = dt.Rows[i][3].ToString(); bb.ProductCode = dt.Rows[i][4].ToString(); bb.PlanQuantity = Convert.ToDecimal(dt.Rows[i][5].ToString()); bb.QualityCode = dt.Rows[i][6].ToString(); bb.AskQuantity = Convert.ToDecimal(dt.Rows[i][7].ToString()); bb.BatchNumber = dt.Rows[i][8].ToString(); bb.AskDate = Convert.ToDateTime(dt.Rows[i][9].ToString()); bb.ACTIVE = "1"; wbi.SavePartsDrawing(bb); } } return(true); } else { Label1.Text = "上传完毕,但数据为空,保存失败"; } return(true); } catch (Exception ex) { Label1.Text = ex.ToString(); return(false); } }