Exemple #1
0
        public static void 打印货代报关部委托运输联系单(ArchiveOperationForm masterForm)
        {
            进口票过程转关标志 pz = masterForm.DisplayManager.CurrentItem as 进口票过程转关标志;
            进口票 entity = pz.票;

            if (entity == null)
            {
                MessageForm.ShowError("请选择要打印的票!");
                return;
            }

            using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<进口票>())
            {
                rep.Initialize(entity.箱, entity);
            }
            MyReportForm form = new MyReportForm("报表_货代报关部委托运输联系单_进口");
            form.FillDataSet(0, new List<进口票> { entity });
            form.FillDataSet(1, entity.箱);

            form.Show();
        }
Exemple #2
0
        public static void 打印凭证(ArchiveOperationForm masterForm)
        {
            凭证 pz = masterForm.DisplayManager.CurrentItem as 凭证;
            if (pz == null)
            {
                MessageForm.ShowError("请选择要打印的凭证!");
                return;
            }

            using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<凭证>())
            {
                rep.Initialize(pz.凭证费用明细, pz);
            }

            MyReportForm form = new MyReportForm("报表_凭证");

            form.FillDataSet(0, new List<凭证> { pz });
            form.FillDataSet(1, pz.凭证费用明细);

            //System.Data.DataSet ds = form.TemplateDataSet;
            //ds.Tables["凭证"].Rows[0]["大写金额"] = ChineseHelper.ConvertToChinese(pz.金额.数额.Value);
            //ds.Tables["凭证"].Rows[0]["金额.币制编号"] = NameValueMappingCollection.Instance.FindColumn2FromColumn1("财务_币制", "代码", "符号", pz.金额.币制编号);

            form.Show();

            //Hd.Report.凭证Ds ds = new Hd.Report.凭证Ds();
            //Hd.Report.凭证Ds.凭证Row row = ds.凭证.New凭证Row();
            //row["凭证号"] = pz.凭证号;
            //row["日期"] = pz.日期;
            //row["相关人编号"] = NameValueMappingCollection.Instance.FindNameFromId("人员单位_全部", pz.相关人编号);
            ////row["项目名称"] = "000";
            //row["金额.数额"] = pz.金额.数额;
            //row["大写金额"] = Feng.Utils.ChineseHelper.ConvertToChinese(pz.金额.数额.Value);
            //row["备注"] = pz.备注;
            //ds.凭证.Rows.Add(row);
            //FormRptPreView frmReport = new FormRptPreView(ds, new Hd.Report.凭证());
            //frmReport.Show();
        }
        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;
        }
Exemple #4
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);
        }