public Get_Out GetGroupOrder(string data) { Get_Out json = new Get_Out(); try { Get_In input = Newtonsoft.Json.JsonConvert.DeserializeObject <Get_In>(data); string strTrainmanJiaoLuGUID = input.TrainmanJiaoluGUID; string strWorkShopGUID = input.WorkShopGUID; TF.Api.BLL.BanXuBLL bllBanXu = new TF.Api.BLL.BanXuBLL(); json.Content = new List <GroupItem>(); DataTable table = bllBanXu.GetBanXuByJiaoLuGUID(strWorkShopGUID, strTrainmanJiaoLuGUID); SimpleTrainman man = null; if (table != null) { for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; GroupItem record = new GroupItem(); DateTime endWorkTime; string strEndWorkTime = row["dtLastEndWorkTime1"] == null ? "" : row["dtLastEndWorkTime1"].ToString(); if (DateTime.TryParse(strEndWorkTime, out endWorkTime)) { record.EndWorkTime = endWorkTime.ToString("yyyy-MM-dd HH:mm:ss"); } else { record.EndWorkTime = ""; } record.Index = (i + 1).ToString(); record.TrainmanList = new SimpleTrainmanList(); json.Content.Add(record); for (int j = 1; j < 5; j++) { man = new SimpleTrainman(); man.TrainmanName = row["strTrainmanName" + j.ToString()].ToString(); man.TrainmanNo = row["strTrainmanNumber" + j.ToString()].ToString(); man.trianmanGUID = row["strTrainmanGUID" + j.ToString()].ToString(); record.TrainmanList.Add(man); } } } json.result = "0"; json.resultStr = "返回成功"; } catch (Exception ex) { json.result = "1"; json.resultStr = "提交失败:" + ex.Message; } return(json); }
public SimpleTrainmanList GetListFromTable(DataTable table) { SimpleTrainmanList list = new SimpleTrainmanList(); SimpleTrainman man = null; if (list != null) { foreach (DataRow row in table.Rows) { man = new SimpleTrainman(); man.DutyName = row["DutyName"].ToString(); DateTime.TryParse(row["leaveEndTime"].ToString(), out man.leaveEndTime); DateTime.TryParse(row["LeaveStartTime"].ToString(), out man.LeaveStartTime); man.LeaveTypeName = row["LeaveTypeName"].ToString(); man.TrainmanJiaoLuGUID = row["TrainmanJiaoLuGUID"].ToString(); man.TrainmanName = row["TrainmanName"].ToString(); man.TrainmanNo = row["TrainmanNo"].ToString(); man.trianmanGUID = row["trianmanGUID"].ToString(); list.Add(man); } } return(list); }