Example #1
0
        public static void 自动生成费用(ArchiveOperationForm masterForm)
        {
            Dictionary <string, object> setData = masterForm.Tag as Dictionary <string, object>;
            费用实体 entity;

            using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <业务费用>())
            {
                rep.BeginTransaction();
                entity = rep.Get <费用实体>(setData["费用实体"]);
                rep.CommitTransaction();
            }

            if (entity.费用实体类型编号 == 11 /*费用实体类型.进口*/)
            {
                using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <进口票>())
                {
                    进口票 piao = rep.Get <进口票>(setData["费用实体"]);
                    rep.Initialize(piao.箱, piao);
                    process_fy_yw.批量生成费用(rep, entity.费用实体类型编号, piao, piao.箱, (string)setData["费用项"], !setData.ContainsKey("收付标志") ? null : (收付标志?)setData["收付标志"]);
                }
            }
            else if (entity.费用实体类型编号 == 15 /*费用实体类型.内贸出港*/)
            {
                using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <内贸出港票>())
                {
                    内贸出港票 piao = rep.Get <内贸出港票>(setData["费用实体"]);
                    rep.Initialize(piao.箱, piao);
                    process_fy_yw.批量生成费用(rep, entity.费用实体类型编号, piao, piao.箱, (string)setData["费用项"], !setData.ContainsKey("收付标志") ? null : (收付标志?)setData["收付标志"]);
                }
            }
            else if (entity.费用实体类型编号 == 45 /*费用实体类型.进口其他业务*/)
            {
                using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <进口其他业务票>())
                {
                    进口其他业务票 piao = rep.Get <进口其他业务票>(setData["费用实体"]);
                    rep.Initialize(piao.箱, piao);
                    process_fy_yw.批量生成费用(rep, entity.费用实体类型编号, piao, piao.箱, (string)setData["费用项"], !setData.ContainsKey("收付标志") ? null : (收付标志?)setData["收付标志"]);
                }
            }
            else if (entity.费用实体类型编号 == 13 /*费用实体类型.出口*/)
            {
                using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <出口票>())
                {
                    出口票 piao = rep.Get <出口票>(setData["费用实体"]);
                    rep.Initialize(piao.箱, piao);
                    process_fy_yw.批量生成费用(rep, entity.费用实体类型编号, piao, piao.箱, (string)setData["费用项"], !setData.ContainsKey("收付标志") ? null : (收付标志?)setData["收付标志"]);
                }
            }

            (masterForm.MasterGrid as IBoundGrid).ReloadData();
        }
Example #2
0
        // 服务_读取出口海关查验结果
        public static 出口箱 查询海关查验结果(出口箱 ckx)
        {
            if (string.IsNullOrEmpty(ckx.箱号))
            {
                throw new ArgumentNullException("出口箱箱号 is null");
            }

            海关查验查询结果 hgcxjg = m_npediGrab.查询海关查验结果(ckx.箱号);


            if (hgcxjg == null)
            {
                ckx.查验标志 = false;
                //ckx.海关查验 = Hd.Model.查验标志.不查验;
            }
            else
            {
                if (ckx.票.船名航次 == hgcxjg.船名 + "/" + hgcxjg.航次)
                {
                    using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <出口票>())
                    {
                        rep.BeginTransaction();
                        出口票 ckp = rep.Get <出口票>(ckx.票.ID);
                        ckp.海关查验时间 = hgcxjg.处理时间;
                        new 出口票Dao().Update(rep, ckp);
                        rep.CommitTransaction();
                    }

                    ckx.查验标志 = true;
                    if (hgcxjg.H986 == "Y")
                    {
                        ckx.海关查验 = Hd.Model.查验标志.开箱门;
                    }
                    else if (hgcxjg.H986 == "N")
                    {
                        ckx.海关查验 = Hd.Model.查验标志.开箱门;
                    }
                }
            }
            return(ckx);
        }
Example #3
0
 public static void 生成票费用(费用实体 entity, bool service)
 {
     if (entity.费用实体类型编号 == 11)
     {
         using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <进口票>())
         {
             进口票 piao = rep.Get <进口票>(entity.ID);
             rep.Initialize(piao.箱, piao);
             process_fy_yw.批量生成费用(rep, entity.费用实体类型编号, piao, piao.箱, null, null, service);
         }
     }
     else if (entity.费用实体类型编号 == 15)
     {
         using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <内贸出港票>())
         {
             内贸出港票 piao = rep.Get <内贸出港票>(entity.ID);
             rep.Initialize(piao.箱, piao);
             process_fy_yw.批量生成费用(rep, entity.费用实体类型编号, piao, piao.箱, null, null, service);
         }
     }
     else if (entity.费用实体类型编号 == 45)
     {
         using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <进口其他业务票>())
         {
             进口其他业务票 piao = rep.Get <进口其他业务票>(entity.ID);
             rep.Initialize(piao.箱, piao);
             process_fy_yw.批量生成费用(rep, entity.费用实体类型编号, piao, piao.箱, null, null, service);
         }
     }
     else if (entity.费用实体类型编号 == 13)
     {
         using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <出口票>())
         {
             出口票 piao = rep.Get <出口票>(entity.ID);
             rep.Initialize(piao.箱, piao);
             process_fy_yw.批量生成费用(rep, entity.费用实体类型编号, piao, piao.箱, null, null, service);
         }
     }
 }
        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, "载入报关单");
            }
        }
Example #5
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, "载入报关单");
            }
        }