void smMaster_DataLoading(object sender, DataLoadingEventArgs e)
        {
            e.Cancel = true;

            ISearchExpression    searchExpression = e.SearchExpression;
            IList <ISearchOrder> searchOrders     = e.SearchOrders;

            if (this.SearchManager != null)
            {
                for (int i = 0; i < m_reportDataInfos.Count; ++i)
                {
                    m_sms[i].EnablePage       = this.SearchManager.EnablePage;
                    m_sms[i].FirstResult      = this.SearchManager.FirstResult;
                    m_sms[i].MaxResult        = this.SearchManager.MaxResult;
                    m_sms[i].IsResultDistinct = this.SearchManager.IsResultDistinct;
                }
            }

            bool haveSetMasterSearchManager = false;

            for (int i = 0; i < m_reportDataInfos.Count; ++i)
            {
                object data = m_sms[i].GetData(searchExpression, searchOrders);
                System.Collections.IEnumerable dataList = data as System.Collections.IEnumerable;
                if (dataList == null)
                {
                    dataList = (data as System.Data.DataTable).DefaultView;
                }

                System.Data.DataTable dt = this.ReportViewer.TemplateDataSet.Tables[m_reportDataInfos[i].DatasetTableName];
                dt.Rows.Clear();
                GenerateReportData.Generate(dt, dataList, m_reportDataInfos[i].GridName);

                if (!haveSetMasterSearchManager)
                {
                    this.SearchManager.Count   = m_sms[i].GetCount(searchExpression);
                    haveSetMasterSearchManager = true;
                    this.SearchManager.OnDataLoaded(new DataLoadedEventArgs(m_sms[i].Result, m_sms[i].Count));
                }
            }

            // Set Parameter
            ReportGenerator.SetParameter(this.ReportViewer.CrystalHelper, searchExpression);

            if (m_reportInfo.AfterProcess != null)
            {
                ProcessInfoHelper.ExecuteProcess(ADInfoBll.Instance.GetProcessInfo(m_reportInfo.AfterProcess.Name),
                                                 new Dictionary <string, object> {
                    { "masterForm", this }
                });
            }

            this.ReportViewer.OpenReport();
        }
 internal static void InitializeWindowProcess(WindowInfo windowInfo, MyChildForm masterForm)
 {
     if (windowInfo.AutoProcess != null)
     {
         ProcessInfoHelper.ExecuteProcess(ADInfoBll.Instance.GetProcessInfo(windowInfo.AutoProcess.Name),
                                          new Dictionary <string, object> {
             { "masterForm", masterForm }
         });
     }
     if (!string.IsNullOrEmpty(windowInfo.EventInitialized))
     {
         EventProcessUtils.ExecuteEventProcess(ADInfoBll.Instance.GetEventProcessInfos(windowInfo.EventInitialized), masterForm, System.EventArgs.Empty);
     }
 }
        private void ExecuteProcess(string processId)
        {
            if (!string.IsNullOrEmpty(processId))
            {
                ProcessInfo info;
                lock (m_processExecuting)
                {
                    if (m_processExecuting.ContainsKey(processId) && m_processExecuting[processId])
                    {
                        println("process " + processId + " is still executing!");
                        return;
                    }

                    m_processExecuting[processId] = true;
                    info = ADInfoBll.Instance.GetProcessInfo(processId);
                }

                println("process " + processId + " start to execute!");

                Feng.Async.AsyncHelper asyncHelper = new Feng.Async.AsyncHelper(
                    new Feng.Async.AsyncHelper.DoWork(delegate()
                {
                    try
                    {
                        ProcessInfoHelper.ExecuteProcess(info);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        println(ex.Message);
                    }
                    return(false);
                }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                {
                    println("process " + processId + " has executed!");
                    lock (m_processExecuting)
                    {
                        m_processExecuting[processId] = false;
                    }
                }));
            }
            else
            {
                debug("there is no process property!");
            }
        }
예제 #4
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="rep"></param>
        /// <param name="entity"></param>
        public override void Submit(IRepository rep, 对账单 entity)
        {
            if (!entity.关账日期.HasValue)
            {
                throw new InvalidUserOperationException("请输入 关账日期!");
            }

            entity.Submitted = true;

            rep.Initialize(entity.费用, entity);
            decimal sum = 0;

            foreach (费用 i in entity.费用)
            {
                if (i.收付标志 == 收付标志.收)
                {
                    sum += i.金额.Value;
                }
                else
                {
                    sum -= i.金额.Value;
                }

                if (i.凭证费用明细 != null)
                {
                    throw new InvalidUserOperationException("费用已经出凭证!");
                }
            }
            if (entity.收付标志 == 收付标志.收)
            {
                entity.金额 = sum;
            }
            else
            {
                entity.金额 = -sum;
            }

            this.Update(rep, entity);

            费用Dao fyDao = new 费用Dao();

            switch (entity.对账单类型)
            {
            case (int)货代对账单类型.自动凭证应付对账单:
                Dictionary <string, object> dict = ProcessInfoHelper.ExecuteProcess("自动凭证应付对账单", new Dictionary <string, object> {
                    { "entity", entity }
                }) as Dictionary <string, object>;
                自动对账单生成凭证(rep, entity, dict);
                break;

            case (int)货代对账单类型.货代应付对账单:
            case (int)货代对账单类型.货代应收对账单:
                foreach (费用 i in entity.费用)
                {
                    fyDao.Update(rep, i);
                }

                GenerateDzdYsyf(rep, entity);
                break;

            default:
                throw new NotSupportedException("Not Supported 对账单类型 of " + entity.对账单类型 + "!");
            }
        }
예제 #5
0
        public static bool InternalExecuteWindowMenu(IDisplayManager dm, WindowMenuInfo info, Form parentForm)
        {
            object entity = dm.CurrentItem;
            int    pos    = dm.Position;

            //ArchiveOperationForm opForm = masterForm as ArchiveOperationForm;
            switch (info.Type)
            {
            case WindowMenuType.ReportSingle:
            {
                if (entity == null)
                {
                    MessageForm.ShowError("请选择要打印的项!");
                    break;
                }

                ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                    new Feng.Async.AsyncHelper.DoWork(delegate()
                    {
                        MyReportForm form = new MyReportForm(info.ExecuteParam);
                        form.FillDataSet(entity);
                        return(form);
                    }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                    {
                        if (result != null)
                        {
                            MyReportForm form = result as MyReportForm;
                            form.Show(parentForm);
                        }
                    }),
                    parentForm, "生成");
            }
            break;

            case WindowMenuType.ReportMulti:
            {
                if (dm.Count == 0)
                {
                    MessageForm.ShowError("请选择要打印的项!");
                    break;
                }
                object[] entities = new object[dm.Count];
                for (int i = 0; i < entities.Length; ++i)
                {
                    entities[i] = dm.Items[i];
                }
                ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                    new Feng.Async.AsyncHelper.DoWork(delegate()
                    {
                        MyReportForm form = new MyReportForm(info.ExecuteParam);
                        form.FillDataSet(entities);
                        return(form);
                    }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                    {
                        if (result != null)
                        {
                            MyReportForm form = result as MyReportForm;
                            form.Show(parentForm);
                        }
                    }),
                    parentForm, "生成");
            }
            break;

            case WindowMenuType.MsReportSingle:
            {
                if (entity == null)
                {
                    MessageForm.ShowError("请选择要打印的项!");
                    break;
                }

                ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                    new Feng.Async.AsyncHelper.DoWork(delegate()
                    {
                        MsReportForm form = new MsReportForm(info.ExecuteParam);
                        form.FillDataSet(entity);
                        return(form);
                    }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                    {
                        if (result != null)
                        {
                            MsReportForm form = result as MsReportForm;
                            form.Show(parentForm);

                            // 焦点会转变到其他程序,只能这样
                            form.FormClosed += new FormClosedEventHandler(delegate(object sender, FormClosedEventArgs e)
                            {
                                parentForm.ParentForm.Activate();
                            });
                        }
                    }),
                    parentForm, "生成");
            }
            break;

            case WindowMenuType.MsReportMulti:
            {
                if (dm.Count == 0)
                {
                    MessageForm.ShowError("请选择要打印的项!");
                    break;
                }
                object[] entities = new object[dm.Count];
                for (int i = 0; i < entities.Length; ++i)
                {
                    entities[i] = dm.Items[i];
                }

                ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                    new Feng.Async.AsyncHelper.DoWork(delegate()
                    {
                        MsReportForm form = new MsReportForm(info.ExecuteParam);
                        form.FillDataSet(entities);
                        return(form);
                    }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                    {
                        if (result != null)
                        {
                            MsReportForm form = result as MsReportForm;
                            form.Show(parentForm);

                            form.FormClosed += new FormClosedEventHandler(delegate(object sender, FormClosedEventArgs e)
                            {
                                parentForm.ParentForm.Activate();
                            });
                        }
                    }),
                    parentForm, "生成");
            }
            break;

            case WindowMenuType.DatabaseCommand:
            {
                ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                    new Feng.Async.AsyncHelper.DoWork(delegate()
                    {
                        Feng.Data.DbHelper.Instance.ExecuteNonQuery(info.ExecuteParam);
                        return(null);
                    }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                    {
                    }),
                    parentForm, "执行");
            }
            break;

            case WindowMenuType.DatabaseCommandMulti:
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < dm.Count; ++i)
                {
                    string s = EntityHelper.ReplaceEntity(info.ExecuteParam, dm.Items[i]);
                    sb.Append(s);
                    sb.Append(System.Environment.NewLine);
                }
                ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                    new Feng.Async.AsyncHelper.DoWork(delegate()
                    {
                        Feng.Data.DbHelper.Instance.ExecuteNonQuery(sb.ToString());
                        return(null);
                    }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                    {
                    }),
                    parentForm, "执行");
            }
            break;

            case WindowMenuType.DatabaseCommandMultiParam:
            {
                object[] entities = new object[dm.Count];
                for (int i = 0; i < dm.Count; ++i)
                {
                    entities[i] = dm.Items[i];
                }
                string s = EntityHelper.ReplaceEntities(info.ExecuteParam, entities, '\'');

                ProgressAsyncHelper asyncHelper = new ProgressAsyncHelper(
                    new Feng.Async.AsyncHelper.DoWork(delegate()
                    {
                        Feng.Data.DbHelper.Instance.ExecuteNonQuery(s);
                        return(null);
                    }),
                    new Feng.Async.AsyncHelper.WorkDone(delegate(object result)
                    {
                    }),
                    parentForm, "执行");
            }
            break;

            case WindowMenuType.Process:
            {
                ProcessInfoHelper.ExecuteProcess(info.ExecuteParam, new Dictionary <string, object> {
                        { "masterForm", parentForm }
                    });
            }
            break;

            case WindowMenuType.Action:
            {
                ServiceProvider.GetService <IApplication>().ExecuteAction(info.ExecuteParam);
            }
            break;

            default:
                return(false);
            }
            return(true);
        }