コード例 #1
0
        /// <summary>
        /// CreateWindow
        /// </summary>
        /// <param name="windowInfo"></param>
        /// <returns></returns>
        public object CreateWindow(WindowInfo windowInfo)
        {
            MyForm returnForm = null;

            switch (windowInfo.WindowType)
            {
            case WindowType.Maintain:
            case WindowType.Transaction:
            {
                returnForm = new GeneratedArchiveOperationForm(windowInfo);
            }
            break;

            case WindowType.Query:
            {
                // decide gridType
                IList <WindowTabInfo>  tabInfos    = ADInfoBll.Instance.GetWindowTabInfosByWindowId(windowInfo.Name);
                IList <GridColumnInfo> gridColumns = ADInfoBll.Instance.GetGridColumnInfos(tabInfos[0].GridName);
                foreach (GridColumnInfo info in gridColumns)
                {
                    if (!string.IsNullOrEmpty(info.ParentPropertyName))
                    {
                        returnForm = new GeneratedArchiveSeeForm(windowInfo, DataGridType.DataUnboundGridLoadOnce);
                    }
                }
                returnForm = new GeneratedArchiveSeeForm(windowInfo);
            }
            break;

            case WindowType.QueryBound:
            {
                returnForm = new GeneratedArchiveSeeForm(windowInfo, DataGridType.DataBoundGridLoadOnDemand);
            }
            break;

            case WindowType.TransactionBound:
            {
                returnForm = new GeneratedArchiveOperationForm(windowInfo, ArchiveGridType.ArchiveBoundGrid);
            }
            break;

            case WindowType.Select:
            {
                returnForm = new GeneratedArchiveCheckForm(windowInfo);
            }
            break;

            case WindowType.DatabaseReport:
            {
                returnForm = new GeneratedArchiveDatabaseReportForm(windowInfo);
            }
            break;

            case WindowType.DataSetReport:
            {
                returnForm = new GeneratedArchiveDataSetReportForm(windowInfo);
            }
            break;

            case WindowType.SelectWindow:
            {
                using (ArchiveSelectForm selectForm = new ArchiveSelectForm(windowInfo.Name))
                {
                    if (selectForm.ShowDialog() == DialogResult.OK)
                    {
                        returnForm = selectForm.SelectedForm;
                    }
                    else
                    {
                        returnForm = null;
                    }
                }
            }
            break;

            case WindowType.DetailTransaction:
            {
                ArchiveDetailForm form = ArchiveFormFactory.GenerateArchiveDetailForm(ADInfoBll.Instance.GetWindowInfo(windowInfo.Name), null);
                form.Load += new EventHandler(delegate(object sender, System.EventArgs e)
                    {
                        form.UpdateContent();
                        form.SetMenuState();
                    });
                form.SetAsMdiChild();
                //// 创建TaskPane
                //GridRelatedControl gridRelatedControl = null;
                //form.SetGridRelatedPanel(() =>
                //    {
                //        if (gridRelatedControl == null)
                //        {
                //            gridRelatedControl = new GridRelatedControl(form.GridName, form.DisplayManager, form);
                //        }
                //        return gridRelatedControl;
                //    });

                form.GenerateWindowMenu(ADInfoBll.Instance.GetWindowMenuInfo(windowInfo.Name));
                form.Disposed += new EventHandler(delegate(object sender, System.EventArgs e)
                    {
                        form.DisposeWindowMenu();
                    });
                returnForm = form;
            }
            break;

            case WindowType.DataControl:
            {
                returnForm = new GeneratedArchiveDataControlForm(windowInfo);
            }
            break;

            case WindowType.ExcelOperation:
            {
                returnForm = new GeneratedArchiveExcelForm(windowInfo);
            }
            break;

            default:
                throw new ArgumentException("Invalid WindowType in WindowInfo");
            }

            if (WindowCreated != null)
            {
                WindowCreated(returnForm, System.EventArgs.Empty);
            }

            return(returnForm);
        }
コード例 #2
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, "载入报关单");
            }
        }