コード例 #1
0
        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();
               }));
        }
コード例 #2
0
        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();
            }));
        }