Ejemplo n.º 1
0
 private ISearchExpression AndIfNecessary(ISearchExpression original, ISearchExpression and)
 {
     if (original != null)
     {
         return(SearchExpression.And(original, and));
     }
     else
     {
         return(and);
     }
 }
        //private void ProcessCmd(DbCommand cmd)
        //{
        //    foreach (string s in m_funcParams)
        //    {
        //        if (!cmd.Parameters.Contains(s))
        //        {
        //            cmd.CommandText = cmd.CommandText.Replace(s, "default");
        //        }
        //        else
        //        {
        //            // remove like %
        //            string likeString = cmd.Parameters[s].Value as string;
        //            if (!string.IsNullOrEmpty(likeString))
        //            {
        //                if (likeString[0] == '%' && likeString[likeString.Length - 1] == '%')
        //                {
        //                    cmd.Parameters[s].Value = likeString.Substring(1, likeString.Length - 2);
        //                }
        //            }

        //            // remove where clause
        //            int idx = cmd.CommandText.IndexOf("WHERE");
        //            idx = cmd.CommandText.IndexOf(s, idx);

        //            int idx2 = idx;

        //            // jump to "=, >="
        //            idx2--;
        //            while (cmd.CommandText[idx2] == ' ')
        //                idx2--;

        //            // jump to space
        //            idx2--;
        //            while (cmd.CommandText[idx2] != ' ')
        //                idx2--;

        //            // jump to propertyName
        //            idx2--;
        //            while (cmd.CommandText[idx2] == ' ')
        //                idx2--;

        //            // jump to space
        //            idx2--;
        //            while (cmd.CommandText[idx2] != ' ')
        //                idx2--;

        //            cmd.CommandText = cmd.CommandText.Replace(cmd.CommandText.Substring(idx2 + 1, idx - idx2 - 1 + s.Length), "1 = 1");
        //        }
        //    }
        //}

        private ISearchExpression RemoveFunctionParamSearchExpression(ISearchExpression se, Dictionary <string, object> deletedParam)
        {
            if (se == null)
            {
                return(null);
            }
            if (se is LogicalExpression)
            {
                LogicalExpression le = se as LogicalExpression;
                ISearchExpression ls = RemoveFunctionParamSearchExpression(le.LeftHandSide, deletedParam);
                ISearchExpression rs = RemoveFunctionParamSearchExpression(le.RightHandSide, deletedParam);
                switch (le.LogicOperator)
                {
                case LogicalOperator.And:
                    return(SearchExpression.And(ls, rs));

                case LogicalOperator.Or:
                    return(SearchExpression.Or(ls, rs));

                case LogicalOperator.Not:
                    return(SearchExpression.Not(ls));

                default:
                    throw new NotSupportedException("Not Supported LogicalOperator!");
                }
            }
            else if (se is SimpleExpression)
            {
                SimpleExpression cse = se as SimpleExpression;

                string paramName = SearchManager.CreateParamName(cse, null);
                if (Array.IndexOf(m_funcParams, paramName) != -1)
                {
                    deletedParam[paramName] = cse.Values;
                    return(null);
                }
                else
                {
                    return(cse);
                }
            }
            else
            {
                return(se);
            }
        }
Ejemplo n.º 3
0
        ///// <summary>
        ///// Constructor
        ///// </summary>
        ///// <param name="cmParent"></param>
        //public SearchManagerProxyDetailInMaster(IControlManager cmParent)
        //    : base(cmParent)
        //{
        //}

        /// <summary>
        ///
        /// </summary>
        /// <param name="searchExpression"></param>
        /// <param name="searchOrders"></param>
        /// <param name="parentItem"></param>
        /// <returns></returns>
        public override System.Collections.IEnumerable GetData(ISearchExpression searchExpression, IList <ISearchOrder> searchOrders, object parentItem)
        {
            if (parentItem == null)
            {
                return(null);
            }
            string exp = EntityHelper.ReplaceEntity(m_searchExpression, parentItem);

            searchExpression = SearchExpression.And(SearchExpression.Parse(exp), searchExpression);

            if (!string.IsNullOrEmpty(m_searchOrder))
            {
                return(m_innerSearchManager.GetData(searchExpression, SearchOrder.Parse(m_searchOrder)));
            }
            else
            {
                return(m_innerSearchManager.GetData(searchExpression, null));
            }
        }
Ejemplo n.º 4
0
        private void SetTopGrid()
        {
            if (用途分类.SelectedDataValue == null)
            {
                return;
            }

            凭证用途分类 ytfl = (凭证用途分类)用途分类.SelectedDataValue;

            if (ytfl == 凭证用途分类.业务应付)
            {
                if (付款对象.SelectedDataValue == null)
                {
                    return;
                }
                ArchiveFormFactory.SetupDataUnboundGrid(grdTop, ADInfoBll.Instance.GetWindowTabInfo("资金票据_应收应付当前"));
                grdTop.DisplayManager.SearchManager.LoadData(SearchExpression.And(SearchExpression.Eq("相关人", 付款对象.SelectedDataValue),
                                                                                  SearchExpression.Eq("收付标志", Hd.Model.收付标志.付)), null);
            }
        }
Ejemplo n.º 5
0
        private void 单车后续作业计划_Load(object sender, EventArgs e)
        {
            if (m_cl != null)
            {
                using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <车辆作业>())
                {
                    var cl = rep.Get <车辆>(m_cl.ID);

                    txt车型.Text   = cl.车型;
                    txt车主.Text   = cl.车主.简称;
                    txt承运车辆.Text = cl.车牌号;
                    txt核定载重.Text = cl.核定载重;
                    txt监管车.Text  = cl.监管车 ? "是" : "否";
                    txt联系电话.Text = cl.主驾驶员.联系方式;
                }

                var rightGrid = base.AssociateBoundGrid(pnl车辆作业集合, "车队级调度_静态任务下达_单车后续作业计划");
                rightGrid.DisplayManager.SearchManager.LoadData(SearchExpression.And(
                                                                    SearchExpression.Eq("车辆作业:车辆", m_cl), SearchExpression.IsNull("车辆作业:结束时间")),
                                                                new List <ISearchOrder> {
                    SearchOrder.Asc("车辆作业:Created")
                });
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchExpression"></param>
        /// <param name="searchOrders"></param>
        /// <param name="parentItem"></param>
        /// <returns></returns>
        public override System.Collections.IEnumerable GetData(ISearchExpression searchExpression, IList <ISearchOrder> searchOrders, object parentItem)
        {
            if (parentItem == null)
            {
                return(null);
            }

            SearchHistoryInfo his = this.ParentDisplayManager.SearchManager.GetHistory(0);

            if (!string.IsNullOrEmpty(his.Expression))
            {
                ISearchExpression exp = SearchExpression.Parse(his.Expression);
                exp = RemoveParentSelectAsExpression(exp);
                searchExpression = SearchExpression.And(searchExpression, exp);
            }

            foreach (string s in m_groupByColumns)
            {
                object            r = EntityScript.GetPropertyValue(parentItem, s);
                ISearchExpression se2;

                if (r != null && r != System.DBNull.Value)
                {
                    se2 = SearchExpression.Eq(s, EntityScript.GetPropertyValue(parentItem, s));
                }
                else
                {
                    se2 = SearchExpression.IsNull(s);
                }
                searchExpression = SearchExpression.And(searchExpression, se2);
            }

            this.SetHistory(searchExpression, searchOrders);

            return(m_innerSearchManager.GetData(searchExpression, searchOrders));
        }
Ejemplo n.º 7
0
        public static void FyDoubleClick(object sender1, EventArgs e1)
        {
            Xceed.Grid.DataCell cell = sender1 as Xceed.Grid.DataCell;
            Xceed.Grid.DataRow  row  = cell.ParentRow as Xceed.Grid.DataRow;

            //if (row.ParentGrid.ReadOnly)
            //    return;

            //IBoundGrid grid = (m_masterForm.ArchiveDetailForm as IArchiveDetailFormWithDetailGrids).DetailGrids[0];

            ArchiveSeeForm masterForm = cell.GridControl.FindForm() as ArchiveSeeForm;

            if (masterForm == null)
            {
                // 通过DetailForm来的
                masterForm = (cell.GridControl.FindForm() as ArchiveDetailForm).ParentForm as ArchiveSeeForm;
            }
            ArchiveOperationForm fydjForm = masterForm.Tag as ArchiveOperationForm;

            //if (cell.FieldName == "拟付金额" || cell.FieldName == "拟收金额" || cell.FieldName == "费用项")
            {
                if (fydjForm == null)
                {
                    if (masterForm.Name == "内贸出港_票费用")
                    {
                        fydjForm = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("内贸出港_票费用项费用登记")) as ArchiveOperationForm;
                    }
                    else
                    {
                        fydjForm = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("业务财务_票费用项费用登记")) as ArchiveOperationForm;
                    }

                    masterForm.Tag = fydjForm;

                    Dictionary <string, object> setDatanew = new Dictionary <string, object>();
                    fydjForm.Tag = setDatanew;

                    (fydjForm.ControlManager.Dao as 业务费用Dao).TransactionBeginning += new EventHandler <OperateArgs <业务费用> >(delegate(object sender, OperateArgs <业务费用> e)
                    {
                        if (e.Entity.费用实体 == null)
                        {
                            业务费用 fy  = e.Entity as 业务费用;
                            fy.费用实体  = e.Repository.Get <费用实体>(setDatanew["费用实体"]);
                            fy.票     = fy.费用实体 as 普通票;
                            fy.费用项编号 = (string)setDatanew["费用项"];
                        }
                    });
                    fydjForm.DisplayManager.SearchManager.EnablePage  = false;
                    fydjForm.DisplayManager.SearchManager.DataLoaded += new EventHandler <DataLoadedEventArgs>(delegate(object sender, DataLoadedEventArgs e)
                    {
                        fydjForm.TopMost = true;
                        fydjForm.Show();
                    });

                    fydjForm.FormClosing += new FormClosingEventHandler(delegate(object sender, FormClosingEventArgs e)
                    {
                        if (e.CloseReason == CloseReason.UserClosing)
                        {
                            if (!masterForm.IsDisposed)
                            {
                                if (masterForm is ArchiveOperationForm)
                                {
                                    //(masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Items[(masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Position] = (fydjForm.DisplayManager.CurrentItem as 费用).费用实体;
                                    (masterForm as ArchiveOperationForm).ControlManager.DisplayManager.SearchManager.ReloadItem((masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Position);
                                    (masterForm as ArchiveOperationForm).ControlManager.OnCurrentItemChanged();
                                }
                                //IBoundGrid grid = (masterForm.ArchiveDetailForm as IArchiveDetailFormWithDetailGrids).DetailGrids[0];
                                //ISearchManager sm = grid.DisplayManager.SearchManager;
                                //System.Data.DataTable dt = (System.Data.DataTable)sm.FindData(new List<ISearchExpression> { }, null);
                                //foreach (System.Data.DataRow i in dt.Rows)
                                //{
                                //    if (i["费用项"].ToString() == setDatanew["费用项"].ToString())
                                //    {
                                //        object save = row.Cells["Submitted"].Value;
                                //        grid.SetDataRowsIListData(i, row);
                                //        row.Cells["Submitted"].Value = save;
                                //        break;
                                //    }
                                //}

                                e.Cancel = true;
                                fydjForm.Hide();
                            }
                        }
                    });
                }

                Dictionary <string, object> setData = fydjForm.Tag as Dictionary <string, object>;
                setData.Clear();

                //进口_额外费用_委托人   费用项双击事件
                if (masterForm.Text.Equals("进口_额外费用_委托人"))
                {
                    //明细窗体
                    if (cell.ParentColumn.Title.Equals("费用项"))
                    {
                        setData["费用实体"] = (Guid)row.Cells["费用实体"].Value;
                        setData["费用项"]  = (string)row.Cells["费用项"].Value;
                    }
                    //主窗体
                    else
                    {
                        using (var rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <费用项>())
                        {
                            IList <费用项> list = (rep as Feng.NH.INHibernateRepository).List <费用项>(NHibernate.Criterion.DetachedCriteria.For <费用项>()
                                                                                                 .Add(NHibernate.Criterion.Expression.Eq("名称", cell.ParentColumn.Title)));
                            if (list != null && list.Count > 0)
                            {
                                setData["费用实体"] = (row.Tag as 进口票).ID;
                                setData["费用项"]  = list[0].编号;
                            }
                        }
                    }
                }
                // 票费用登记窗体
                else if (row.Cells["费用实体"] != null)
                {
                    setData["费用实体"] = (Guid)row.Cells["费用实体"].Value;
                    setData["费用项"]  = (string)row.Cells["费用项"].Value;
                    if (/*cell.FieldName == "已收金额" || cell.FieldName == "应收金额" || */ cell.FieldName == "拟收金额")
                    {
                        setData["收付标志"] = 收付标志.收;
                    }
                    else if (/*cell.FieldName == "已付金额" || cell.FieldName == "应付金额" || */ cell.FieldName == "拟付金额")
                    {
                        setData["收付标志"] = 收付标志.付;
                    }
                }
                // 滞箱费
                else
                {
                    setData["费用实体"] = (row.Tag as 费用信息).票Id;
                    setData["费用项"]  = "167";
                }

                NameValueMappingCollection.Instance["信息_箱号_动态"].Params["@票"] = (Guid)setData["费用实体"];
                NameValueMappingCollection.Instance.Reload(fydjForm.DisplayManager.Name, "信息_箱号_动态");

                ISearchExpression se = SearchExpression.And(SearchExpression.Eq("费用实体.ID", (Guid)setData["费用实体"]),
                                                            SearchExpression.Eq("费用项编号", (string)setData["费用项"]));
                if (setData.ContainsKey("收付标志"))
                {
                    se = SearchExpression.And(se, SearchExpression.Eq("收付标志", setData["收付标志"]));
                }
                fydjForm.ControlManager.DisplayManager.SearchManager.LoadData(se, null);
            }

            //Dictionary<string, bool?> submitted = new Dictionary<string, bool?>();
            //foreach (Xceed.Grid.DataRow i in grid.DataRows)
            //{
            //    submitted[i.Cells["费用项"].Value.ToString()] = (bool?)i.Cells["Submitted"].Value;
            //}
            //(row.GridControl as IBoundGrid).ReloadData();
            //foreach (Xceed.Grid.DataRow i in grid.DataRows)
            //{
            //    i.Cells["Submitted"].Value = submitted[i.Cells["费用项"].Value.ToString()];
            //}
        }
Ejemplo n.º 8
0
        private void tsbAttachment_Click(object sender, EventArgs e)
        {
            if (this.AttachmentForm == null)
            {
                return;
            }

            object entity = this.DisplayManager.CurrentItem;

            if (entity == null)
            {
                MessageForm.ShowWarning("请选择当前行!");
                return;
            }

            Type entityType = entity.GetType();
            var  sm         = ServiceProvider.GetService <Feng.NH.ISessionFactoryManager>();

            if (sm == null)
            {
                return;
            }
            NHibernate.ISessionFactory sessionFactory = sm.GetSessionFactory(Feng.Utils.RepositoryHelper.GetConfigNameFromType(entityType));
            if (sessionFactory == null)
            {
                return;
            }

            bool hasCollection;

            int idx = m_attachmentEntityIdExp.LastIndexOf('.');

            if (idx != -1)
            {
                string navi = m_attachmentEntityIdExp.Substring(0, idx);
                entityType = Feng.NH.NHibernateHelper.GetPropertyType(sessionFactory, entityType, navi, out hasCollection);
            }

            NHibernate.Metadata.IClassMetadata metaData = sessionFactory.GetClassMetadata(entityType);
            string entityName = metaData.EntityName;
            object id         = EntityScript.GetPropertyValue(entity, m_attachmentEntityIdExp);
            string entityId;

            //object id = EntityHelper.GetPropertyValue(entity, metaData.IdentifierPropertyName);
            if (id != null)
            {
                entityId = id.ToString();
            }
            else
            {
                MessageForm.ShowWarning("当前行无Id!");
                return;
            }

            string formText = entityName + ":" + entityId;
            IArhiveOperationMasterForm form = this.AttachmentForm;
            var form2 = form as ArchiveSeeForm;

            form2.tsbSearch.Visible = false;
            form.Text = formText + " 的附件";
            form.Show();
            form.DoView();

            form.DisplayManager.SearchManager.LoadData(SearchExpression.And(
                                                           SearchExpression.Eq("EntityName", entityName), SearchExpression.Eq("EntityId", entityId)), null);

            m_attachmentEntityName = entityName;
            m_attachmentEntityId   = entityId;
            //(form.ControlManager.Dao as BaseDao<AttachmentInfo>).EntityOperating += new EventHandler<OperateArgs<AttachmentInfo>>(delegate(object sender1, OperateArgs<AttachmentInfo> e1)
            //{
            //    e1.Entity.EntityName = entityName;
            //    e1.Entity.EntityId = entityId;
            //});

            (form.ControlManager.Dao as BaseDao <AttachmentInfo>).EntityOperating -= new EventHandler <OperateArgs <AttachmentInfo> >(AttachmentForm_EntityOperating);
            (form.ControlManager.Dao as BaseDao <AttachmentInfo>).EntityOperating += new EventHandler <OperateArgs <AttachmentInfo> >(AttachmentForm_EntityOperating);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="searchConditions"></param>
        /// <param name="searchOrders"></param>
        public virtual void FillSearchConditions(IList <ISearchExpression> searchConditions, IList <ISearchOrder> searchOrders)
        {
            if (Order.HasValue)
            {
                if (Order.Value)
                {
                    searchOrders.Add(SearchOrder.Asc(PropertyNameToSearch));
                }
                else
                {
                    searchOrders.Add(SearchOrder.Desc(PropertyNameToSearch));
                }
            }

            if (IsNull)
            {
                if (!IsNot)
                {
                    if (SearchNullUseFull)
                    {
                        searchConditions.Add(SearchExpression.IsNull(PropertyNameToSearch));
                    }
                    else
                    {
                        string[] ss = this.Navigator.Split(new char[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries);
                        searchConditions.Add(SearchExpression.IsNull(ss[0]));
                    }
                }
                else
                {
                    searchConditions.Add(SearchExpression.IsNotNull(PropertyNameToSearch));
                }
            }
            else
            {
                if (SelectedDataValue1 == null && SelectedDataValue2 == null)
                {
                    return;
                }

                if (SelectedDataValue1 != null && SelectedDataValue2 == null)
                {
                    if (!IsNot)
                    {
                        searchConditions.Add(SearchExpression.Ge(PropertyNameToSearch, this.SelectedDataValue1));
                    }
                    else
                    {
                        searchConditions.Add(SearchExpression.Lt(PropertyNameToSearch, this.SelectedDataValue1));
                    }
                }
                else if (SelectedDataValue1 == null && SelectedDataValue2 != null)
                {
                    if (!IsNot)
                    {
                        searchConditions.Add(SearchExpression.Le(PropertyNameToSearch, this.SelectedDataValue2));
                    }
                    else
                    {
                        searchConditions.Add(SearchExpression.Gt(PropertyNameToSearch, this.SelectedDataValue2));
                    }
                }
                else
                {
                    if (!IsNot)
                    {
                        searchConditions.Add(SearchExpression.And(SearchExpression.Ge(PropertyNameToSearch, this.SelectedDataValue1),
                                                                  SearchExpression.Le(PropertyNameToSearch, this.SelectedDataValue2)));
                    }
                    else
                    {
                        searchConditions.Add(SearchExpression.Or(SearchExpression.Lt(PropertyNameToSearch, this.SelectedDataValue1),
                                                                 SearchExpression.Gt(PropertyNameToSearch, this.SelectedDataValue2)));
                    }
                }
            }

            if (!string.IsNullOrEmpty(this.AdditionalSearchExpression))
            {
                searchConditions.Add(SearchExpression.Parse(this.AdditionalSearchExpression));
            }
        }
        /// <summary>
        /// 生成报表
        /// </summary>
        /// <param name="reportInfoName"></param>
        /// <param name="dateStart"></param>
        /// <param name="dateEnd"></param>
        /// <returns></returns>
        public static byte[] GenerateReport(string reportInfoName, DateTime dateStart, DateTime dateEnd)
        {
            CrystalHelper crystalHelper = new CrystalHelper();

            ReportInfo reportInfo = ADInfoBll.Instance.GetReportInfo(reportInfoName);

            if (reportInfo == null)
            {
                throw new ArgumentException("不存在名为" + reportInfoName + "的ReportInfo!");
            }
            ReportDocument reportDocument = ReportHelper.CreateReportDocument(reportInfo.ReportDocument);

            crystalHelper.ReportSource = reportDocument;
            System.Data.DataSet templateDataSet = ReportHelper.CreateDataset(reportInfo.DatasetName);

            IList <ISearchManager> sms             = new List <ISearchManager>();
            IList <ReportDataInfo> reportDataInfos = ADInfoBll.Instance.GetReportDataInfo(reportInfo.Name);

            foreach (ReportDataInfo reportDataInfo in reportDataInfos)
            {
                if (string.IsNullOrEmpty(reportDataInfo.SearchManagerClassName))
                {
                    throw new ArgumentException("ReportDataInfo of " + reportDataInfo.Name + " 's SearchManagerClassName must not be null!");
                }

                ISearchManager sm = ServiceProvider.GetService <IManagerFactory>().GenerateSearchManager(reportDataInfo.SearchManagerClassName, reportDataInfo.SearchManagerClassParams);

                sm.EnablePage = false;

                sms.Add(sm);
            }

            ISearchExpression se = SearchExpression.And(SearchExpression.Ge("日期", dateStart),
                                                        SearchExpression.Le("日期", dateEnd));

            for (int i = 0; i < reportDataInfos.Count; ++i)
            {
                System.Collections.IEnumerable dataList = sms[i].GetData(se, null);

                string s = reportDataInfos[i].DatasetTableName;
                if (!templateDataSet.Tables.Contains(s))
                {
                    throw new ArgumentException("报表DataSet中未包含名为" + s + "的DataTable!");
                }
                System.Data.DataTable dt = templateDataSet.Tables[s];
                dt.Rows.Clear();
                GenerateReportData.Generate(dt, dataList, reportDataInfos[i].GridName);
            }

            // Set Parameter
            SetParameter(crystalHelper, se);

            crystalHelper.DataSource = templateDataSet;

            string fileName = System.IO.Path.GetTempFileName();

            crystalHelper.Export(fileName, CrystalExportFormat.PortableDocFormat);

            System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
            byte[] fileData         = new byte[fs.Length];

            using (System.IO.BinaryReader sr = new System.IO.BinaryReader(fs))
            {
                sr.Read(fileData, 0, fileData.Length);
            }
            fs.Close();
            System.IO.File.Delete(fileName);

            return(fileData);
        }
Ejemplo n.º 11
0
        public static void FyDoubleClick(object sender1, EventArgs e1)
        {
            Xceed.Grid.DataCell cell = sender1 as Xceed.Grid.DataCell;
            Xceed.Grid.DataRow  row  = cell.ParentRow as Xceed.Grid.DataRow;

            ArchiveSeeForm masterForm = cell.GridControl.FindForm() as ArchiveSeeForm;

            if (masterForm == null)
            {
                // 通过DetailForm来的
                masterForm = (cell.GridControl.FindForm() as ArchiveDetailForm).ParentForm as ArchiveSeeForm;
            }
            ArchiveOperationForm fydjForm = masterForm.Tag as ArchiveOperationForm;

            //if (cell.FieldName == "拟付金额" || cell.FieldName == "拟收金额" || cell.FieldName == "费用项")
            {
                if (fydjForm == null)
                {
                    fydjForm       = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("业务备案_车辆产值费用_双击")) as ArchiveOperationForm;
                    masterForm.Tag = fydjForm;

                    Dictionary <string, object> setDatanew = new Dictionary <string, object>();
                    fydjForm.Tag = setDatanew;

                    (fydjForm.ControlManager.Dao as 业务费用Dao).TransactionBeginning += new EventHandler <OperateArgs <费用> >(delegate(object sender, OperateArgs <费用> e)
                    {
                        if (e.Entity.费用实体 == null)
                        {
                            业务费用 fy  = e.Entity as 业务费用;
                            fy.费用实体  = e.Repository.Get <费用实体>(setDatanew["费用实体"]);
                            fy.费用项编号 = (string)setDatanew["费用项"];
                            fy.车辆产值  = fy.费用实体 as 车辆产值;
                        }
                    });
                    fydjForm.DisplayManager.SearchManager.EnablePage  = false;
                    fydjForm.DisplayManager.SearchManager.DataLoaded += new EventHandler <DataLoadedEventArgs>(delegate(object sender, DataLoadedEventArgs e)
                    {
                        fydjForm.TopMost = true;
                        fydjForm.Show();
                    });

                    fydjForm.FormClosing += new FormClosingEventHandler(delegate(object sender, FormClosingEventArgs e)
                    {
                        if (e.CloseReason == CloseReason.UserClosing)
                        {
                            if (!masterForm.IsDisposed)
                            {
                                if (masterForm is ArchiveOperationForm)
                                {
                                    (masterForm as ArchiveOperationForm).ControlManager.DisplayManager.SearchManager.ReloadItem((masterForm as ArchiveOperationForm).ControlManager.DisplayManager.Position);
                                    (masterForm as ArchiveOperationForm).ControlManager.OnCurrentItemChanged();
                                }

                                e.Cancel = true;
                                fydjForm.Hide();
                            }
                            else
                            {
                            }
                        }
                    });
                }

                Dictionary <string, object> setData = fydjForm.Tag as Dictionary <string, object>;
                setData.Clear();

                // 票费用登记窗体
                if (row.Cells["费用实体"] != null)
                {
                    setData["费用实体"] = (Guid)row.Cells["费用实体"].Value;
                    setData["费用项"]  = (string)row.Cells["费用项"].Value;
                    if (/*cell.FieldName == "已收金额" || cell.FieldName == "应收金额" || */ cell.FieldName == "拟收金额")
                    {
                        setData["收付标志"] = 收付标志.收;
                    }
                    else if (/*cell.FieldName == "已付金额" || cell.FieldName == "应付金额" || */ cell.FieldName == "拟付金额")
                    {
                        setData["收付标志"] = 收付标志.付;
                    }
                }
                else
                {
                    throw new ArgumentException("There must be a column named 费用实体!");
                }
                //NameValueMappingCollection.Instance["信息_箱号_动态"].Params["@票"] = (Guid)setData["费用实体"];
                //NameValueMappingCollection.Instance.Reload("信息_箱号_动态");

                //Feng.Windows.Forms.MyObjectPicker op = (fydjForm.MasterGrid.GetInsertionRow().Cells["任务"].CellEditorManager as Feng.Grid.Editors.MyObjectPickerEditor).TemplateControl;
                //string exp = "车辆产值.ID = " + ((Guid)setData["费用实体"]).ToString();
                //op.SearchExpressionParam = exp;

                Feng.Windows.Forms.MyObjectPicker op = (fydjForm.MasterGrid.Columns["任务"].CellEditorManager as Feng.Grid.Editors.MyObjectPickerEditor).TemplateControl;
                string exp = "车辆产值.ID = " + ((Guid)setData["费用实体"]).ToString();
                op.SearchExpressionParam = exp;

                ISearchExpression se = SearchExpression.And(SearchExpression.Eq("费用实体.ID", (Guid)setData["费用实体"]),
                                                            SearchExpression.Eq("费用项编号", (string)setData["费用项"]));

                if (setData.ContainsKey("收付标志"))
                {
                    se = SearchExpression.And(se, SearchExpression.Eq("收付标志", setData["收付标志"]));
                }
                fydjForm.ControlManager.DisplayManager.SearchManager.LoadData(se, new List <ISearchOrder>());
            }
        }