Example #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();
             string   orderno = wbi.GetOrderNoCode();
             for (int i = 0; i < dt.Rows.Count; i++)
             {
                 if (!string.IsNullOrEmpty(dt.Rows[i][0].ToString()))
                 {
                     OrderDetail bb = new OrderDetail();
                     bb.OrderNo          = orderno;// dt.Rows[i][0].ToString();
                     bb.CustName         = dt.Rows[i][0].ToString();
                     bb.CONTRACT         = dt.Rows[i][1].ToString();
                     bb.ProductName      = dt.Rows[i][2].ToString();
                     bb.PartsdrawingCode = dt.Rows[i][3].ToString();
                     bb.BatchNumber      = dt.Rows[i][4].ToString();
                     bb.OrderQuantity    = Convert.ToDecimal(dt.Rows[i][5].ToString());
                     bb.OutDate          = Convert.ToDateTime(dt.Rows[i][6].ToString());
                     bb.CheckTime        = Convert.ToDateTime(dt.Rows[i][7].ToString());
                     string res = wbi.SaveOrderInfo(bb);
                     if (res != "OK")
                     {
                         Label1.Text = res;
                         return(false);
                     }
                 }
             }
             return(true);
         }
         else
         {
             Label1.Text = "上传完毕,但数据为空,保存失败";
         }
         return(true);
     }
     catch (Exception ex)
     {
         Label1.Text = ex.ToString();
         return(false);
     }
 }