public static void ReadCk(ArchiveOperationForm masterForm) { IControlManager masterCm = masterForm.ControlManager; if (masterCm.DisplayManager.DataControls["提单号"].SelectedDataValue == null) { ServiceProvider.GetService <IMessageBox>().ShowWarning("请输入提单号!"); return; } string tdh = masterCm.DisplayManager.DataControls["提单号"].SelectedDataValue.ToString().Trim(); m_nbeportGrab.SetLoginInfo(SystemProfileFile.DefaultUserProfile.GetValue("Hd.Options", "NetReadUserName", ""), SystemProfileFile.DefaultUserProfile.GetValue("Hd.Options", "NetReadPassword", "")); IList <集装箱数据> boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.出口集装箱, tdh); if (boxList.Count <= 0) { return; } AskToReplace(masterCm, "船名航次", boxList[0].船舶英文名称 + "/" + boxList[0].航次); AskToReplace(masterCm, "进港地编号", NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", boxList[0].堆场区)); AskToReplace(masterCm, "离港时间", boxList[0].进场时间); AskToReplace(masterCm, "提单号", boxList[0].提单号); AskToReplace(masterCm, "箱量", boxList.Count); IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager; foreach (集装箱数据 data in boxList) { bool have = false; foreach (Xceed.Grid.DataRow row in ((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0].DataRows) { if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == data.集装箱号.Trim()) { have = true; break; } } if (!have) { 出口箱 newItem = new 出口箱 { 箱号 = data.集装箱号, 箱型 = Feng.Utils.ConvertHelper.ChangeType(data.箱型, typeof(箱型)) as 箱型, 装货地编号 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", data.堆场区), 进港时间 = data.Real进场时间, 提箱时间 = data.Real提箱时间 }; detailCm.AddNew(); detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = newItem; detailCm.EndEdit(); } } }
private void btn网上导入_Click(object sender, EventArgs e) { string tdh = (string)(pnl提单号.Controls[0] as IWindowDataControl).SelectedDataValue; string hc = (string)(pnl船名.Controls[0] as IWindowDataControl).SelectedDataValue; if (string.IsNullOrEmpty(tdh)) { MessageForm.ShowWarning("请填写提单号!"); return; } if (!string.IsNullOrEmpty(hc) && hc.Contains('/')) { hc = hc.Substring(hc.LastIndexOf('/') + 1).Trim(); } IList<Hd.NetRead.集装箱数据> boxList = null; int piao_successCount = 0;//成功导入的票数量 int rw_successCount = 0;//成功导入的任务数量 ProgressForm progressForm = new ProgressForm(); progressForm.Start(this, "网上导入"); Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper( new Feng.Async.AsyncHelper.DoWork(delegate() { nbeportRead m_nbeportGrab = new nbeportRead(); m_nbeportGrab.SetLoginInfo(Feng.DBDef.Instance.TryGetValue("NetReadUserName"), Feng.DBDef.Instance.TryGetValue("NetReadPassword")); if (string.IsNullOrEmpty(hc)) { boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.进口集装箱, tdh); } else { boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.进口集装箱, tdh, hc); } if (boxList != null && boxList.Count > 0) { AskToReplace(m_cm, "任务性质", 任务性质.进口拆箱); AskToReplace(m_cm, "提单号", boxList[0].提单号); AskToReplace(m_cm, "船名航次", boxList[0].船名 + "/" + boxList[0].航次); piao_successCount++; foreach (集装箱数据 jzx in boxList) { bool have = false; foreach (Xceed.Grid.DataRow row in m_显示区Grid.DataRows) { if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == jzx.集装箱号.Trim()) { have = true; break; } } if (!have) { 任务 rw = new 任务(); rw.任务来源 = 任务来源.网上; rw.任务性质 = 任务性质.进口拆箱; rw.提箱点编号 = NameValueMappingCollection.Instance.FindIdFromName("人员单位_全部", jzx.堆场区).ToString(); rw.箱号 = jzx.集装箱号; rw.船名 = jzx.船名; rw.航次 = jzx.航次; m_cm2.AddNew(); m_cm2.DisplayManager.Items[m_cm2.DisplayManager.Position] = rw; m_cm2.EndEdit(); rw_successCount++; } } } return null; }), new Feng.Async.AsyncHelper.WorkDone(delegate(object result) { MessageForm.ShowInfo("成功导入 " + piao_successCount + " 票," + rw_successCount + " 条任务。"); progressForm.Stop(); })); }
private void btn网上导入_Click(object sender, EventArgs e) { string tdh = (string)(pnl提单号.Controls[0] as IWindowDataControl).SelectedDataValue; string hc = (string)(pnl船名.Controls[0] as IWindowDataControl).SelectedDataValue; if (string.IsNullOrEmpty(tdh)) { MessageForm.ShowWarning("请填写提单号!"); return; } if (!string.IsNullOrEmpty(hc) && hc.Contains('/')) { hc = hc.Substring(hc.LastIndexOf('/') + 1).Trim(); } IList <Hd.NetRead.集装箱数据> boxList = null; int piao_successCount = 0; //成功导入的票数量 int rw_successCount = 0; //成功导入的任务数量 ProgressForm progressForm = new ProgressForm(); progressForm.Start(this, "网上导入"); Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper( new Feng.Async.AsyncHelper.DoWork(delegate() { nbeportRead m_nbeportGrab = new nbeportRead(); m_nbeportGrab.SetLoginInfo(Feng.DBDef.Instance.TryGetValue("NetReadUserName"), Feng.DBDef.Instance.TryGetValue("NetReadPassword")); if (string.IsNullOrEmpty(hc)) { boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.进口集装箱, tdh); } else { boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.进口集装箱, tdh, hc); } if (boxList != null && boxList.Count > 0) { AskToReplace(m_cm, "任务性质", 任务性质.进口拆箱); AskToReplace(m_cm, "提单号", boxList[0].提单号); AskToReplace(m_cm, "船名航次", boxList[0].船名 + "/" + boxList[0].航次); piao_successCount++; foreach (集装箱数据 jzx in boxList) { bool have = false; foreach (Xceed.Grid.DataRow row in m_显示区Grid.DataRows) { if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == jzx.集装箱号.Trim()) { have = true; break; } } if (!have) { 任务 rw = new 任务(); rw.任务来源 = 任务来源.网上; rw.任务性质 = 任务性质.进口拆箱; rw.提箱点编号 = NameValueMappingCollection.Instance.FindIdFromName("人员单位_全部", jzx.堆场区).ToString(); rw.箱号 = jzx.集装箱号; rw.船名 = jzx.船名; rw.航次 = jzx.航次; m_cm2.AddNew(); m_cm2.DisplayManager.Items[m_cm2.DisplayManager.Position] = rw; m_cm2.EndEdit(); rw_successCount++; } } } return(null); }), new Feng.Async.AsyncHelper.WorkDone(delegate(object result) { MessageForm.ShowInfo("成功导入 " + piao_successCount + " 票," + rw_successCount + " 条任务。"); progressForm.Stop(); })); }