示例#1
0
 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()))
                 {
                     BasBase bb = new BasBase();
                     bb.CODE    = dt.Rows[i][0].ToString();
                     bb.NAME    = dt.Rows[i][1].ToString();
                     bb.SubCode = dt.Rows[i][2].ToString();
                     bb.SubName = dt.Rows[i][3].ToString();
                     bb.MEMO    = dt.Rows[i][4].ToString();
                     wbi.SaveBaseInfo(bb);
                 }
             }
             return(true);
         }
         else
         {
             Label1.Text = "上传完毕,但数据为空,保存失败";
         }
         return(true);
     }
     catch (Exception ex)
     {
         Label1.Text = ex.ToString();
         return(false);
     }
 }