Пример #1
0
        public static void 批量添加费用(ArchiveOperationForm masterForm)
        {
            IControlManager cm = masterForm.ControlManager;

            ArchiveSelectForm selectForm = new ArchiveSelectForm("批量添加非业务费用");
            if (selectForm.ShowDialog() == DialogResult.OK)
            {
                ArchiveCheckForm form = selectForm.SelectedForm as ArchiveCheckForm;

                if (form != null && form.ShowDialog() == DialogResult.OK)
                {
                    foreach (object i in form.SelectedEntites)
                    {
                        非业务费用 newItem = new 非业务费用();

                        if (i is 费用实体)
                        {
                            newItem.费用实体 = i as 费用实体;
                        }
                        else
                        {
                            System.Diagnostics.Debug.Assert(false, "选中的费用实体类型不是要求类型,而是" + i.GetType().ToString());
                        }

                        cm.AddNew();
                        cm.DisplayManager.Items[cm.DisplayManager.Position] = newItem;
                        cm.EndEdit();

                        //string filter = "现有费用实体类型 LIKE '%" + (int)item.费用实体.费用实体类型 + ",%'";
                        //masterForm.ActiveGrid.CurrentDataRow.Cells["费用项编号"].CellEditorManager = ControlDataLoad.GetGridComboEditor("费用项_非业务", filter);
                    }
                }
            }
        }
Пример #2
0
        public static void 批量添加费用(ArchiveOperationForm masterForm)
        {
            IControlManager cm = masterForm.ControlManager;

            ArchiveSelectForm selectForm = new ArchiveSelectForm("批量添加业务费用");
            if (selectForm.ShowDialog() == DialogResult.OK)
            {
                ArchiveCheckForm form = selectForm.SelectedForm as ArchiveCheckForm;

                if (form != null && form.ShowDialog() == DialogResult.OK)
                {
                    foreach (object i in form.SelectedEntites)
                    {
                        业务费用 item = new 业务费用();
                        if (i is 车辆产值)
                        {
                            车辆产值 tang = i as 车辆产值;
                            item.车辆 = (i == null ? null : tang.车辆);
                            item.车辆编号 = i == null ? null : (Guid?)tang.车辆编号;
                            item.费用实体 = tang;
                            item.车辆产值 = tang;
                        }
                        else if (i is 任务)
                        {
                            任务 xiang = i as 任务;

                            // it must have piao
                            //item.车辆产值 = xiang.车辆产值;
                            item.任务 = (i == null ? null : xiang);
                            item.车辆 = (i == null ? null : xiang.车辆产值.车辆);
                            item.车辆编号 = i == null ? null : (Guid?)xiang.车辆产值.车辆编号;
                            item.费用实体 = xiang.车辆产值;// new 车辆产值 { ID = item.车辆产值.ID, Version = item.车辆产值.Version };
                            item.车辆产值 = xiang.车辆产值;
                        }
                        else
                        {
                            System.Diagnostics.Debug.Assert(false, "选中的费用实体类型不是要求类型,而是" + i.GetType().ToString());
                        }

                        object entity = cm.AddNew();
                        if (entity != null)
                        {
                            cm.DisplayManager.Items[cm.DisplayManager.Position] = item;
                            cm.EndEdit();
                        }
                        else
                        {
                            // 出现错误,不再继续。 AddNew的时候,前一个出现错误,没保存。然后提示时候保存,选不继续
                            masterForm.ControlManager.CancelEdit();
                            break;
                        }

                        //bool isPiao = (i is 普通票);
                        //string filter = "现有费用实体类型 LIKE '%" + (int)item.票.费用实体类型;
                        //if (isPiao)
                        //{
                        //    filter += ",%' AND 票 = " + isPiao;
                        //}
                        //else
                        //{
                        //    filter += ",%' AND 箱 = " + !isPiao;
                        //}
                        //masterForm.ActiveGrid.CurrentDataRow.Cells["费用项编号"].CellEditorManager = ControlDataLoad.GetGridComboEditor("费用项_业务", filter);
                    }
                }
            }
        }
Пример #3
0
        public static void 批量添加费用(ArchiveOperationForm masterForm)
        {
            IControlManager cm = masterForm.ControlManager;

            ArchiveSelectForm selectForm = new ArchiveSelectForm("批量添加业务费用");
            if (selectForm.ShowDialog() == DialogResult.OK)
            {
                ArchiveCheckForm form = selectForm.SelectedForm as ArchiveCheckForm;

                if (form != null && form.ShowDialog() == DialogResult.OK)
                {
                    foreach (object i in form.SelectedEntites)
                    {

                        业务费用 item = new 业务费用();
                        if (i is 普通票)
                        {
                            item.票 = i as 普通票;
                            item.费用实体 = new 普通票 { ID = item.票.ID, Version = item.票.Version, 费用实体类型编号 = item.票.费用实体类型编号 };
                        }
                        else if (i is 普通箱)
                        {
                            普通箱 xiang = i as 普通箱;

                            // it must have piao
                            item.票 = xiang.GetType().InvokeMember("票",
                                BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public, null, xiang, null) as 普通票;

                            item.箱 = (i == null ? null : xiang);
                            item.箱Id = i == null ? null : (Guid?)xiang.ID;
                            item.费用实体 = new 普通票 { ID = item.票.ID, Version = item.票.Version, 费用实体类型编号 = item.票.费用实体类型编号 };
                        }
                        else
                        {
                            System.Diagnostics.Debug.Assert(false, "选中的费用实体类型不是要求类型,而是" + i.GetType().ToString());
                        }

                        object entity = cm.AddNew();
                        if (entity != null)
                        {
                            cm.DisplayManager.Items[cm.DisplayManager.Position] = item;
                            cm.EndEdit();
                        }
                        else
                        {
                            // 出现错误,不再继续。 AddNew的时候,前一个出现错误,没保存。然后提示时候保存,选不继续
                            masterForm.ControlManager.CancelEdit();
                            break;
                        }

                        //bool isPiao = (i is 普通票);
                        //string filter = "现有费用实体类型 LIKE '%" + (int)item.票.费用实体类型;
                        //if (isPiao)
                        //{
                        //    filter += ",%' AND 票 = " + isPiao;
                        //}
                        //else
                        //{
                        //    filter += ",%' AND 箱 = " + !isPiao;
                        //}
                        //masterForm.ActiveGrid.CurrentDataRow.Cells["费用项编号"].CellEditorManager = ControlDataLoad.GetGridComboEditor("费用项_业务", filter);
                    }
                }
            }
        }
        /// <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;
        }