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()))
                 {
                     WorkOrderDetails bb = new WorkOrderDetails();
                     bb.WO          = dt.Rows[i][0].ToString();// PubHelper.GetHelper().GetNextID("MES_MASTER.SEQ_ALL_ID").ToString();
                     bb.WorkerName  = dt.Rows[i][1].ToString();
                     bb.WORKER      = wbi.FindUserCodeByUserName(bb.WorkerName);
                     bb.StationName = dt.Rows[i][2].ToString();
                     bb.RouteCode   = dt.Rows[i][3].ToString();
                     string res = wbi.SaveWorkOrderAssign(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);
     }
 }
Exemple #2
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()))
                 {
                     TechnologyWip bb = new TechnologyWip();
                     bb.PARTSDRAWINGNO  = dt.Rows[i][0].ToString();// PubHelper.GetHelper().GetNextID("MES_MASTER.SEQ_ALL_ID").ToString();
                     bb.CustName        = dt.Rows[i][1].ToString();
                     bb.ProductName     = dt.Rows[i][2].ToString();
                     bb.ProcessName     = dt.Rows[i][3].ToString();
                     bb.ProcessEngineer = wbi.FindUserCodeByUserName(bb.ProcessName);
                     bb.PlanDate        = Convert.ToDateTime(dt.Rows[i][4].ToString());
                     bb.STATUS          = 1;
                     bb.StatusMemo      = "分派工艺";
                     wbi.SaveTechnologyInfoForImport(bb);
                 }
             }
             return(true);
         }
         else
         {
             Label1.Text = "上传完毕,但数据为空,保存失败";
         }
         return(true);
     }
     catch (Exception ex)
     {
         Label1.Text = ex.ToString();
         return(false);
     }
 }