Пример #1
0
        public static void ReadCk_报关单号(ArchiveOperationForm masterForm)
        {
            IControlManager masterCm = masterForm.ControlManager;

            if (masterCm.DisplayManager.DataControls["报关单号"].SelectedDataValue == null)
            {
                ServiceProvider.GetService<IMessageBox>().ShowWarning("请输入报关单号!");
                return;
            }

            string bgdh = masterCm.DisplayManager.DataControls["报关单号"].SelectedDataValue.ToString().Trim();

            报关单数据 bgdInfo = null;
            foreach (KeyValuePair<string, string> id in Get_nbediRead_ID())
            {
                m_nbediRead = new nbediRead();
                m_nbediRead.SetLoginInfo(id.Key, id.Value);
                bgdInfo = m_nbediRead.长短号查询报关单数据(bgdh);
                if (bgdInfo != null && !string.IsNullOrEmpty(bgdInfo.报关单号))
                {
                    break;
                }
            }

            if (bgdInfo == null)
            {
                ReadCk(masterForm);
            }
            else
            {
                AskToReplace(masterCm, "报关单号", bgdInfo.报关单长号);
                AskToReplace(masterCm, "抬头", bgdInfo.经营单位);
                AskToReplace(masterCm, "提单号", bgdInfo.提运单号);
                AskToReplace(masterCm, "核销单号", bgdInfo.批准文号);
                AskToReplace(masterCm, "通关单号", bgdInfo.通关单号);
                AskToReplace(masterCm, "箱号", bgdInfo.箱号);
                AskToReplace(masterCm, "箱量", bgdInfo.箱量);
                AskToReplace(masterCm, "委托时间", bgdInfo.申报日期);
                AskToReplace(masterCm, "船名航次", bgdInfo.船名航次);
                //AskToReplace(masterCm, "报关单快照", bgdInfo.网页快照);
                AskToReplace(masterCm, "报关员编号", bgdInfo.报关员);
                AskToReplace(masterCm, "报关公司", bgdInfo.报关公司);

                if (string.IsNullOrEmpty(bgdInfo.提运单号))
                {
                    return;
                }

                IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

                IList<集装箱数据> boxList = m_nbediRead.查询集装箱数据(bgdInfo.提运单号.Trim(), bgdInfo.船名航次.Split('/')[0], bgdInfo.船名航次.Split('/')[1]);
                //IList<集装箱数据> boxList = 查询出口集装箱数据By提单号航次(bgdInfo.提运单号.Trim(), bgdInfo.船名航次.Split('/')[1]);
                string 进港地 = null;
                //bool is查验 = true; // 海关查验是否正常,异常将不查询查验结果

                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;
                        }

                        进港地 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", data.堆场区);
                    }
                    if (!have)
                    {
                        int xx = 0;
                        if (int.TryParse(data.箱型, out xx))
                        {
                            if (xx < 40)
                            {
                                xx = 20;
                            }

                            if (xx >= 45)
                            {
                                xx = 41;
                            }
                            else
                            {
                                xx = 40;
                            }
                        }

                        int? 箱型编号 = null;
                        if (xx != 0)
                        {
                            箱型编号 = xx;
                        }

                        出口箱 newItem = new 出口箱
                        {
                            箱号 = data.集装箱号,
                            箱型编号 = 箱型编号,
                            装货地编号 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", data.堆场区),
                            进港时间 = data.Real进场时间,
                            //提箱时间 = data.Real提箱时间
                        };

                        //if (is查验)
                        //{
                        //    try
                        //    {
                        //        查询海关查验结果(newItem);
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        is查验 = false;
                        //        MessageForm.ShowError(ex.Message, "海关查验");
                        //    }
                        //}

                        detailCm.AddNew();
                        detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = newItem;
                        detailCm.EndEdit();
                    }
                }

                AskToReplace(masterCm, "进港地编号", 进港地);

                保存报关单快照(bgdInfo.报关单长号, bgdInfo.网页快照);
            }
        }
Пример #2
0
        public static void ReadPx_报关单号(ArchiveOperationForm masterForm)
        {
            IControlManager masterCm = masterForm.ControlManager;

            if (masterCm.DisplayManager.DataControls["报关单号"].SelectedDataValue == null)
            {
                ServiceProvider.GetService<IMessageBox>().ShowWarning("请输入报关单号!");
                return;
            }

            string bgdh = masterCm.DisplayManager.DataControls["报关单号"].SelectedDataValue.ToString().Trim();

            报关单数据 bgdInfo = null;
            foreach (KeyValuePair<string, string> id in Get_nbediRead_ID())
            {
                nbediRead m_nbediRead = new nbediRead();
                m_nbediRead.SetLoginInfo(id.Key, id.Value);
                bgdInfo = m_nbediRead.长短号查询报关单数据(bgdh);
                if (bgdInfo != null && !string.IsNullOrEmpty(bgdInfo.报关单号))
                {
                    break;
                }
            }

            if (bgdInfo == null)
            {
                return;
            }

            AskToReplace(masterCm, "报关单号", bgdInfo.报关单长号);
            AskToReplace(masterCm, "抬头", bgdInfo.经营单位);
            AskToReplace(masterCm, "提单号", bgdInfo.提运单号);
            AskToReplace(masterCm, "核销单号", bgdInfo.批准文号);
            AskToReplace(masterCm, "通关单号", bgdInfo.通关单号);
            AskToReplace(masterCm, "箱号", bgdInfo.箱号);
            AskToReplace(masterCm, "箱量", bgdInfo.箱量);
            AskToReplace(masterCm, "委托时间", bgdInfo.申报日期);
            AskToReplace(masterCm, "船名航次", bgdInfo.船名航次);
            AskToReplace(masterCm, "报关单快照", bgdInfo.网页快照);
            AskToReplace(masterCm, "报关员编号", bgdInfo.报关员);
            AskToReplace(masterCm, "报关公司", bgdInfo.报关公司);

            if (string.IsNullOrEmpty(bgdInfo.提运单号))
            {
                return;
            }

            IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

            IList<集装箱数据> boxList = 查询出口集装箱数据By提单号航次(bgdInfo.提运单号.Trim(), bgdInfo.船名航次.Split('/')[1]);
            string 进港地 = null;
            DateTime? 离港时间 = null;

            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;
                    }

                    进港地 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", data.堆场区);
                    离港时间 = data.Real进场时间;
                }
                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();
                }
            }

            AskToReplace(masterCm, "进港地编号", 进港地);
            AskToReplace(masterCm, "离港时间", 离港时间);
        }
Пример #3
0
        public static void 载入出口报关单数据(ArchiveOperationForm masterForm)
        {
            GeneratedArchiveDataControlForm dataControlForm = ServiceProvider.GetService<IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("出口_备案_报关单导入")) as GeneratedArchiveDataControlForm;

            if (dataControlForm.ShowDialog() == DialogResult.OK)
            {
                if (dataControlForm.DataControls["委托时间"].SelectedDataValue == null)
                {
                    ServiceProvider.GetService<IMessageBox>().ShowWarning("请输入委托时间!");
                    return;
                }

                if (DateTime.Parse(dataControlForm.DataControls["委托时间"].SelectedDataValue.ToString()) > DateTime.Today)
                {
                    ServiceProvider.GetService<IMessageBox>().ShowWarning("不能载入大于今天的报关单数据!");
                    return;
                }

                DateTime wtsj = DateTime.Parse(dataControlForm.DataControls["委托时间"].SelectedDataValue.ToString());

                int count = 0;
                ProgressAsyncHelper pah = new ProgressAsyncHelper(new Feng.Async.AsyncHelper.DoWork(
                    delegate()
                    {
                        foreach (KeyValuePair<string, string> id in Get_nbediRead_ID())
                        {
                            m_nbediRead = new nbediRead();
                            m_nbediRead.SetLoginInfo(id.Key, id.Value);

                            //List<string> bgdhList = m_nbediRead.查询报关单号(wtsj);
                            Dictionary<string, string> bgdhList = m_nbediRead.查询报关单号2(wtsj);

                            if (bgdhList == null || bgdhList.Count == 0)
                            {
                                continue;
                            }

                            // 查询数据库已有提单号,避免重复数据
                            using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<出口票>())
                            {
                                try
                                {
                                    //IList<string> bgdh_List = (rep as Feng.NH.INHibernateRepository).Session.CreateCriteria(typeof(出口票))
                                    //    .SetProjection(NHibernate.Criterion.Projections.Distinct(NHibernate.Criterion.Projections.ProjectionList()
                                    //    .Add(NHibernate.Criterion.Projections.Property("报关单号")))).List<string>();

                                    //bool is查验 = true; // 海关查验是否正常,异常将不查询查验结果

                                    //foreach (string bgdh in bgdhList)   // 网上的报关单号
                                    //{
                                    foreach (KeyValuePair<string, string> bgdh in bgdhList)
                                    {
                                        if (bgdh.Key.Substring(9, 1) == "0" || bgdh.Key.Substring(9, 1) == "1")    // 0 = 进口,5 = 出口
                                        {
                                            continue;
                                        }

                                        IList<出口票> ckp_List = (rep as Feng.NH.INHibernateRepository).Session.CreateCriteria(typeof(出口票))
                                            .Add(NHibernate.Criterion.Expression.Eq("报关单号", bgdh.Key)).List<出口票>();

                                        if (ckp_List != null && ckp_List.Count > 0)
                                        {
                                            continue;
                                        }

                                        rep.BeginTransaction();

                                        报关单数据 bgdsj = m_nbediRead.查询报关单数据2(bgdh.Key, bgdh.Value);
                                        if (bgdsj != null)
                                        {
                                            出口票 ckp = new 出口票
                                            {
                                                报关单号 = bgdsj.报关单长号,
                                                抬头 = bgdsj.经营单位,
                                                提单号 = bgdsj.提运单号,
                                                核销单号 = bgdsj.批准文号,
                                                通关单号 = bgdsj.通关单号,
                                                //箱号 = bgdsj.箱号,// Formula = Distinct 出口箱.箱号
                                                箱量 = bgdsj.箱量,
                                                委托时间 = bgdsj.申报日期,
                                                船名航次 = bgdsj.船名航次,
                                                //报关单快照 = bgdsj.网页快照,
                                                报关员编号 = bgdsj.报关员,
                                                报关公司 = bgdsj.报关公司
                                            };

                                            if (!string.IsNullOrEmpty(ckp.提单号))
                                            {
                                                IList<集装箱数据> jzxList = null;
                                                try
                                                {
                                                    jzxList = m_nbediRead.查询集装箱数据(bgdsj.提运单号.Trim(), bgdsj.船名航次.Split('/')[0], bgdsj.船名航次.Split('/')[1]);
                                                    //IList<集装箱数据> jzxList = 查询出口集装箱数据By提单号航次(bgdsj.提运单号.Trim(), bgdsj.船名航次.Split('/')[1]);
                                                }
                                                catch
                                                {
                                                }

                                                if (jzxList != null && jzxList.Count > 0)
                                                {
                                                    List<string> success箱号 = new List<string>();

                                                    foreach (集装箱数据 jzx in jzxList)
                                                    {
                                                        // 避免重复箱保存
                                                        bool isSame箱号 = false;
                                                        foreach (string 箱号 in success箱号)
                                                        {
                                                            if (jzx.集装箱号 == 箱号)
                                                            {
                                                                isSame箱号 = true;
                                                                break;
                                                            }
                                                        }

                                                        if (isSame箱号)
                                                        {
                                                            continue;
                                                        }

                                                        int xx = 0;
                                                        if (int.TryParse(jzx.箱型, out xx))
                                                        {
                                                            if (xx < 40)
                                                            {
                                                                xx = 20;
                                                            }

                                                            if (xx >= 45)
                                                            {
                                                                xx = 41;
                                                            }
                                                            else
                                                            {
                                                                xx = 40;
                                                            }
                                                        }

                                                        int? 箱型编号 = null;
                                                        if (xx != 0)
                                                        {
                                                            箱型编号 = xx;
                                                        }

                                                        出口箱 newCkx = new 出口箱
                                                        {
                                                            箱号 = jzx.集装箱号,
                                                            箱型编号 = 箱型编号,
                                                            装货地编号 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", jzx.堆场区),
                                                            进港时间 = jzx.Real进场时间,
                                                            //提箱时间 = jzx.Real提箱时间
                                                        };

                                                        //if (is查验)
                                                        //{
                                                        //    try
                                                        //    {
                                                        //        查询海关查验结果(newCkx);
                                                        //    }
                                                        //    catch (Exception ex)
                                                        //    {
                                                        //        is查验 = false;
                                                        //        MessageForm.ShowError(ex.Message, "海关查验");
                                                        //    }
                                                        //}

                                                        success箱号.Add(newCkx.箱号);

                                                        if (ckp.进港地编号 == null && ckp.离港时间 == null)
                                                        {
                                                            ckp.进港地编号 = newCkx.装货地编号;
                                                            //ckp.离港时间 = newCkx.进港时间;

                                                            new 出口票Dao().Save(rep, ckp);

                                                            保存报关单快照(bgdsj.报关单长号, bgdsj.网页快照);
                                                        }

                                                        newCkx.票 = ckp;
                                                        new HdBaseDao<出口箱>().Save(rep, newCkx);
                                                    }
                                                }
                                                else
                                                {
                                                    new 出口票Dao().Save(rep, ckp);
                                                }
                                            }
                                        }
                                        rep.CommitTransaction();
                                        count++;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    rep.RollbackTransaction();
                                    throw new NullReferenceException(ex.Message, ex);
                                }
                            }
                        }
                        return null;
                    }), new Feng.Async.AsyncHelper.WorkDone(
                        delegate(object result)
                        {
                            MessageForm.ShowInfo("成功载入报关单数据" + count + "条");
                        }), masterForm, "载入报关单");
            }
        }
Пример #4
0
        /// <summary>
        /// 补填没有进港地的出口票
        /// </summary>
        public static void Helper_出口票_进港地()
        {
            using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<出口票>())
            {
                IList<出口票> list = (rep as Feng.NH.INHibernateRepository)
                    .List<出口票>(NHibernate.Criterion.DetachedCriteria.For<出口票>()
                    .Add(NHibernate.Criterion.Expression.IsNull("进港地编号")));

                if (list != null && list.Count > 0)
                {
                    nbediRead nbedi = new nbediRead();
                    string mt;
                    foreach (出口票 ckp in list)
                    {
                        try
                        {
                            mt = nbedi.查询进场码头(ckp.船名航次.Split('/')[0], ckp.船名航次.Split('/')[1], ckp.提单号);
                            if (mt == "BLCTMS") mt = "梅山码头";
                        }
                        catch
                        {
                            // 查询进场码头的网站可能会发生错误,将被忽略继续执行
                            continue;
                        }
                        ckp.进港地编号 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", mt);
                        rep.BeginTransaction();
                        rep.Update(ckp);
                        rep.CommitTransaction();
                    }
                }
            }
        }