예제 #1
0
        public static bool DoEditS(IControlManager cm, string gridName)
        {
            var info = ADInfoBll.Instance.GetGridRowInfo(gridName);

            if (info != null && !string.IsNullOrEmpty(info.AllowEdit) &&
                !Permission.AuthorizeByRule(info.AllowEdit, cm.DisplayManager.CurrentItem))
            {
                MessageForm.ShowError("您没有修改此记录的权限!");
                return(false);
            }

            cm.EditCurrent();

            return(true);
        }
예제 #2
0
        public static void AddFees(凭证 master, IList<费用> list, IControlManager<凭证费用明细> detailCm, bool add, 收付标志? asDzd收付标志)
        {
            if (list == null)
                return;

            List<费用> newList = new List<费用>();
            foreach (费用 i in list)
            {
                if (i.凭证费用明细 == null)
                {
                    newList.Add(i);
                }
            }

            IList<凭证费用明细> ret = new List<凭证费用明细>();
            if (!asDzd收付标志.HasValue)
            {
                // 费用实体类型. 收付标志, 费用项编号, 相关人编号
                Dictionary<Tuple<int, 收付标志, string, string>, IList<费用>> dict = Utility.GroupFyToPzYsyf(newList);

                foreach (KeyValuePair<Tuple<int, 收付标志, string, string>, IList<费用>> kvp in dict)
                {
                    凭证费用明细 pzs1 = new 凭证费用明细();

                    decimal sum = 0;
                    foreach (费用 k4 in kvp.Value)
                    {
                        sum += k4.金额.Value;
                        k4.凭证费用明细 = pzs1;
                    }

                    //string s = NameValueMappingCollection.Instance.FindNameFromId("信息_业务类型_全部", kvp.Key.Item1);
                    //if (string.IsNullOrEmpty(s))
                    //{
                    //    pzs1.业务类型编号 = null;
                    //}
                    //else
                    //{
                    //    pzs1.业务类型编号 = kvp.Key.Item1;
                    //}
                    pzs1.业务类型编号 = kvp.Key.Item1;

                    pzs1.费用 = kvp.Value;
                    pzs1.费用项编号 = kvp.Key.Item3;
                    pzs1.金额 = sum;
                    pzs1.收付标志 = kvp.Key.Item2;
                    pzs1.相关人编号 = kvp.Key.Item4;

                    // pzs1.凭证 = pz;

                    ret.Add(pzs1);
                }
            }
            else
            {
                Dictionary<Tuple<int, string>, IList<费用>> dict = Utility.GroupFyToDzdYsyf(newList);

                foreach (KeyValuePair<Tuple<int, string>, IList<费用>> kvp in dict)
                {
                    凭证费用明细 pzs1 = new 凭证费用明细();

                    decimal sum = 0;
                    foreach (费用 k4 in kvp.Value)
                    {
                        if (k4.收付标志 == asDzd收付标志.Value)
                        {
                            sum += k4.金额.Value;
                        }
                        else
                        {
                            sum -= k4.金额.Value;
                        }
                        k4.凭证费用明细 = pzs1;
                    }

                    //string s = NameValueMappingCollection.Instance.FindNameFromId("信息_业务类型_全部", kvp.Key.First);
                    //if (string.IsNullOrEmpty(s))
                    //{
                    //    pzs1.业务类型编号 = null;
                    //}
                    //else
                    //{
                    //    pzs1.业务类型编号 = kvp.Key.First;
                    //}
                    pzs1.业务类型编号 = kvp.Key.Item1;

                    pzs1.费用 = kvp.Value;
                    pzs1.费用项编号 = "000";    // 常规应收应付
                    pzs1.金额 = sum;
                    pzs1.收付标志 = asDzd收付标志.Value;
                    pzs1.相关人编号 = kvp.Key.Item2;

                    // pzs1.凭证 = pz;

                    ret.Add(pzs1);
                }
            }

            if (add)
            {
                foreach (凭证费用明细 item in ret)
                {
                    detailCm.AddNew();
                    detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item;
                    detailCm.EndEdit();

                    foreach (费用 i in item.费用)
                    {
                        i.凭证费用明细 = item;
                    }
                }
            }
            else
            {
                if (ret.Count == 0)
                    return;

                System.Diagnostics.Debug.Assert(ret.Count <= 1, "选出多个凭证费用明细,请查证!");
                System.Diagnostics.Debug.Assert(ret[0].费用项编号 == detailCm.DisplayManagerT.CurrentEntity.费用项编号, "凭证费用明细费用项和选择的费用项不同!");
                System.Diagnostics.Debug.Assert(ret[0].相关人编号 == detailCm.DisplayManagerT.CurrentEntity.相关人编号, "凭证费用明细费用项和选择的相关人不同!");
                System.Diagnostics.Debug.Assert(ret[0].收付标志 == detailCm.DisplayManagerT.CurrentEntity.收付标志, "凭证费用明细费用项和选择的相关人不同!");

                using (IRepository rep = ServiceProvider.GetService<IRepositoryFactory>().GenerateRepository<费用>())
                {
                    rep.Initialize(detailCm.DisplayManagerT.CurrentEntity.费用, detailCm.DisplayManagerT.CurrentEntity);
                }

                if (detailCm.DisplayManagerT.CurrentEntity.费用 == null)
                {
                    detailCm.DisplayManagerT.CurrentEntity.费用 = new List<费用>();
                }
                foreach (费用 i in ret[0].费用)
                {
                    i.凭证费用明细 = detailCm.DisplayManagerT.CurrentEntity;
                }

                detailCm.EditCurrent();
                detailCm.EndEdit();
            }
        }
예제 #3
0
        private void 电子作业单_Load(object sender, EventArgs e)
        {
            int[]    taskIdx             = null;
            string[] importantAreas      = null;
            string[] importantTaskStatus = null;
            string[] importantWorkStatus = null;
            using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <车辆作业>())
            {
                var clzy = rep.Get <车辆作业>(m_clzy.ID);

                m_cm.DisplayManager.SetDataBinding(new List <车辆作业> {
                    clzy
                }, string.Empty);
                m_cm.EditCurrent();

                ModelHelper.Get任务状态(clzy.专家任务, out taskIdx, out importantAreas, out importantTaskStatus, out importantWorkStatus);

                StringBuilder strZylx = new StringBuilder();
                for (int i = 0; i < taskIdx.Length; ++i)
                {
                    Xceed.Grid.DataRow row = m_作业流程.DataRows.AddNew();
                    row.Cells["次序"].Value   = i;
                    row.Cells["作业地点"].Value = importantAreas[i];
                    row.Cells["动作"].Value   = importantWorkStatus[i];

                    var rw = clzy.专家任务.任务[taskIdx[i]];
                    row.Cells["箱号"].Value = rw.箱号;
                    row.Cells["箱型"].Value = rw.箱型编号;
                    if (importantWorkStatus[i].StartsWith("港区提箱"))
                    {
                        m_cm.DisplayManager.DataControls["疏港期限"].SelectedDataValue = rw.提箱时间要求.HasValue ? rw.提箱时间要求.Value : rw.提箱时间要求;
                    }
                    else if (importantWorkStatus[i].StartsWith("还箱") || importantWorkStatus[i].StartsWith("进港"))
                    {
                        m_cm.DisplayManager.DataControls["进港还箱期限"].SelectedDataValue = rw.还箱进港时间要求.HasValue ? rw.还箱进港时间要求.Value : rw.还箱进港时间要求;
                    }
                    else if (importantWorkStatus[i].StartsWith("卸货"))
                    {
                        row.Cells["详细地址"].Value = rw.卸货地详细地址;
                        row.Cells["联系人"].Value  = rw.卸货联系人;
                        row.Cells["联系电话"].Value = rw.卸货联系手机 + "," + rw.卸货联系座机;
                    }
                    else if (importantWorkStatus[i].StartsWith("装货"))
                    {
                        row.Cells["详细地址"].Value = rw.装货地详细地址;
                        row.Cells["联系人"].Value  = rw.装货联系人;
                        row.Cells["联系电话"].Value = rw.装货联系手机 + "," + rw.装货联系座机;
                    }

                    row.EndEdit();

                    if (i != 0)
                    {
                        strZylx.Append("、");
                    }
                    strZylx.Append(row.Cells["作业地点"].GetDisplayText() + "(" + row.Cells["动作"].GetDisplayText() + ")");
                }

                m_cm.DisplayManager.DataControls["作业路线"].SelectedDataValue = strZylx.ToString();

                if (m_cm.DisplayManager.DataControls["开始时间"].SelectedDataValue == null)
                {
                    m_cm.DisplayManager.DataControls["开始时间"].SelectedDataValue = System.DateTime.Now;
                }

                if (m_cm.DisplayManager.DataControls["车载Id号"].SelectedDataValue == null)
                {
                    m_cm.DisplayManager.DataControls["车载Id号"].SelectedDataValue = clzy.车辆.车载Id号;
                }

                if (m_cm.DisplayManager.DataControls["驾驶员编号"].SelectedDataValue == null)
                {
                    m_cm.DisplayManager.DataControls["驾驶员编号"].SelectedDataValue = clzy.车辆.主驾驶员编号;
                }
            }
        }
        private static bool InternalExecuteWindowMenu2(IControlManager cm, WindowMenuInfo info, Form parentForm)
        {
            object entity = cm.DisplayManager.CurrentItem;
            int pos = cm.DisplayManager.Position;
            //ArchiveOperationForm opForm = masterForm as ArchiveOperationForm;
            switch (info.Type)
            {
                case WindowMenuType.Add:
                    {
                        ArchiveOperationForm.DoAddS(cm);
                    }
                    break;
                case WindowMenuType.Edit:
                    {
                        ArchiveOperationForm.DoEditS(cm, (parentForm as IGridNamesContainer).GridNames[0]);
                    }
                    break;
                case WindowMenuType.Delete:
                    {
                        ArchiveOperationForm.DoDeleteS(cm, (parentForm as IGridNamesContainer).GridNames[0]);
                    }
                    break;
                case WindowMenuType.Confirm:
                    {
                        parentForm.ValidateChildren();
                        ArchiveDetailForm.DoSaveS(cm);
                    }
                    break;
                case WindowMenuType.Cancel:
                    {
                        ArchiveDetailForm.DoCancelS(cm);
                    }
                    break;
                case WindowMenuType.Submit:
                    {
                        if (entity == null)
                        {
                            MessageForm.ShowError("请选择要提交的项!");
                            return true;
                        }
                        if (!MessageForm.ShowYesNo("是否确认提交?"))
                            return true;

                        ISubmittedEntity se = entity as ISubmittedEntity;
                        if (se == null)
                        {
                            throw new ArgumentException("Submit Entity should be ISubmittedEntity!");
                        }
                        if (string.IsNullOrEmpty(info.ExecuteParam))
                        {
                            cm.EditCurrent();
                            se.Submitted = true;
                            cm.EndEdit();
                        }
                        else
                        {
                            ISubmittedEntityDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(info.ExecuteParam) as ISubmittedEntityDao;
                            if (dao == null)
                            {
                                throw new ArgumentException("Submit windowMenuType's ExecuteParam should be ISubmittedEntityDao!");
                            }

                            using (IRepository rep = dao.GenerateRepository())
                            {
                                try
                                {
                                    se.Submitted = true;
                                    rep.BeginTransaction();
                                    dao.Submit(rep, entity);
                                    rep.CommitTransaction();
                                    cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                                }
                                catch (Exception ex)
                                {
                                    se.Submitted = false;
                                    rep.RollbackTransaction();
                                    ExceptionProcess.ProcessWithNotify(ex);
                                }
                            }
                        }
                    }
                    break;
                case WindowMenuType.Unsubmit:
                    {
                        if (entity == null)
                        {
                            MessageForm.ShowError("请选择要撤销提交的项!");
                            return true;
                        }
                        if (!MessageForm.ShowYesNo("是否确认撤销提交?", "确认", true))
                            return true;

                        ISubmittedEntity se = entity as ISubmittedEntity;
                        if (se == null)
                        {
                            throw new ArgumentException("Submit Entity should be ISubmittedEntity!");
                        }
                        if (string.IsNullOrEmpty(info.ExecuteParam))
                        {
                            cm.EditCurrent();
                            se.Submitted = false;
                            cm.EndEdit();
                        }
                        else
                        {
                            ISubmittedEntityDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(info.ExecuteParam) as ISubmittedEntityDao;
                            if (dao == null)
                            {
                                throw new ArgumentException("Submit windowMenuType's ExecuteParam should be ISubmittedEntityDao!");
                            }

                            using (IRepository rep = dao.GenerateRepository())
                            {
                                try
                                {
                                    se.Submitted = false;
                                    rep.BeginTransaction();
                                    dao.Unsubmit(rep, entity);
                                    rep.CommitTransaction();
                                    cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                                }
                                catch (Exception ex)
                                {
                                    se.Submitted = true;
                                    rep.RollbackTransaction();
                                    ExceptionProcess.ProcessWithNotify(ex);
                                }
                            }
                        }
                    }
                    break;
                case WindowMenuType.SubmitMulti:
                    {
                        if (cm.DisplayManager.Count == 0)
                        {
                            MessageForm.ShowError("请选择要提交的项!");
                            return true;
                        }
                        if (!MessageForm.ShowYesNo("是否确认提交(当前全部)?"))
                            return true;

                        ISubmittedEntity se = entity as ISubmittedEntity;
                        if (se == null)
                        {
                            throw new ArgumentException("Submit Entity should be ISubmittedEntity!");
                        }
                        if (string.IsNullOrEmpty(info.ExecuteParam))
                        {
                            IBatchDao batchDao = cm.Dao as IBatchDao;
                            if (batchDao != null)
                            {
                                batchDao.SuspendOperation();
                            }

                            for (int i = 0; i < cm.DisplayManager.Count; ++i)
                            {
                                cm.DisplayManager.Position = i;
                                cm.EditCurrent();
                                (cm.DisplayManager.Items[i] as ISubmittedEntity).Submitted = true;
                                cm.EndEdit();
                            }

                            if (batchDao != null)
                            {
                                batchDao.ResumeOperation();
                            }
                        }
                        else
                        {
                            ISubmittedEntityDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(info.ExecuteParam) as ISubmittedEntityDao;
                            if (dao == null)
                            {
                                throw new ArgumentException("Submit windowMenuType's ExecuteParam should be ISubmittedEntityDao!");
                            }

                            using (IRepository rep = dao.GenerateRepository())
                            {
                                try
                                {
                                    rep.BeginTransaction();
                                    for (int i = 0; i < cm.DisplayManager.Count; ++i)
                                    {
                                        (cm.DisplayManager.Items[i] as ISubmittedEntity).Submitted = true;
                                        dao.Submit(rep, cm.DisplayManager.Items[i]);
                                    }
                                    rep.CommitTransaction();
                                    cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                                }
                                catch (Exception ex)
                                {
                                    se.Submitted = false;
                                    rep.RollbackTransaction();
                                    ExceptionProcess.ProcessWithNotify(ex);
                                }
                            }
                        }
                    }
                    break;
                case WindowMenuType.Cancellate:
                    {
                        if (entity == null)
                        {
                            MessageForm.ShowError("请选择要作废的项!");
                            return true;
                        }
                        if (!MessageForm.ShowYesNo("是否确认作废?", "确认", true))
                            return true;

                        ICancellateDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(info.ExecuteParam) as ICancellateDao;
                        if (dao == null)
                        {
                            throw new ArgumentException("Submit windowMenuType's ExecuteParam should be ICancellateDao!");
                        }
                        using (IRepository rep = dao.GenerateRepository())
                        {
                            try
                            {
                                rep.BeginTransaction();
                                dao.Cancellate(rep, entity);
                                rep.CommitTransaction();
                                cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                            }
                            catch (Exception ex)
                            {
                                rep.RollbackTransaction();
                                ExceptionProcess.ProcessWithNotify(ex);
                            }
                        }
                    }
                    break;
                case WindowMenuType.DaoProcess:
                    {
                        if (entity == null)
                        {
                            MessageForm.ShowError("请选择要操作的项!");
                            return true;
                        }
                        if (!MessageForm.ShowYesNo("是否要执行" + info.Text + "?"))
                            return true;

                        string[] ss = info.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        if (ss.Length != 2)
                        {
                            throw new ArgumentException("DaoProcess windowMenuType's ExecuteParam should be IDao;MethodName!");
                        }
                        IRepositoryDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(ss[0].Trim()) as IRepositoryDao;
                        if (dao == null)
                        {
                            throw new ArgumentException("DaoProcess windowMenuType's ExecuteParam's first part should be IDao!");
                        }

                        using (IRepository rep = dao.GenerateRepository())
                        {
                            try
                            {
                                rep.BeginTransaction();
                                Feng.Utils.ReflectionHelper.RunInstanceMethod(ss[0].Trim(), ss[1].Trim(), dao, new object[] { rep, entity });
                                rep.CommitTransaction();
                                cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                            }
                            catch (Exception ex)
                            {
                                rep.RollbackTransaction();
                                ExceptionProcess.ProcessWithNotify(ex);
                            }
                        }
                    }
                    break;
                case WindowMenuType.Select:
                    {
                        string[] ss = info.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        if (ss.Length == 0)
                        {
                            throw new ArgumentException("WindowMenu's ExecuteParam is Invalid of WindowMenu " + info.Name);
                        }
                        ArchiveCheckForm form = ServiceProvider.GetService<IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo(ss[0])) as ArchiveCheckForm;
                        if (ss.Length > 1)
                        {
                            string exp = ss[1];
                            exp = EntityHelper.ReplaceEntity(exp, new EntityHelper.GetReplaceValue(delegate(string paramName)
                            {
                                Tuple<string, object> t = EventProcessUtils.GetDataControlValue(paramName, cm.DisplayManager);
                                if (t.Item2 == null)
                                {
                                    throw new InvalidUserOperationException(string.Format("请先填写{0}!", paramName));
                                }
                                cm.DisplayManager.DataControls[t.Item1].ReadOnly = true;
                                // save controlValue to entity because readonly will not save
                                EntityScript.SetPropertyValue(cm.DisplayManager.CurrentItem, t.Item1, t.Item2);

                                return t.Item2;
                            }));
                            if (string.IsNullOrEmpty(form.DisplayManager.SearchManager.AdditionalSearchExpression))
                            {
                                form.DisplayManager.SearchManager.AdditionalSearchExpression = exp;
                            }
                            else
                            {
                                form.DisplayManager.SearchManager.AdditionalSearchExpression = "(" + form.DisplayManager.SearchManager.AdditionalSearchExpression + ") and " + exp;
                            }
                        }

                        int detailGridIdx = 0;
                        if (ss.Length > 2)
                        {
                            detailGridIdx = Feng.Utils.ConvertHelper.ToInt(ss[2]).Value;
                        }
                        if (form.ShowDialog(parentForm) == System.Windows.Forms.DialogResult.OK)
                        {
                            IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)(parentForm as IArchiveMasterForm).ArchiveDetailForm).DetailGrids[detailGridIdx] as IArchiveGrid).ControlManager;

                            var nowList = detailCm.DisplayManager.Items;
                            foreach (object i in form.SelectedEntites)
                            {
                                if (nowList.Contains(i))
                                    continue;

                                detailCm.AddNew();
                                detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = i;
                                detailCm.EndEdit();
                            }
                        }
                        form.Dispose();
                    }
                    break;
                case WindowMenuType.Input:
                    throw new NotSupportedException("Not supported now!");
                case WindowMenuType.ManyToOneWindow:
                    {
                        if (cm.DisplayManager.CurrentItem == null)
                        {
                            MessageForm.ShowInfo("无当前项,不能操作!");
                            return true;
                        }
                        string[] ss = info.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                        if (ss.Length < 2)
                        {
                            throw new ArgumentException("WindowMenu's ExecuteParam is Invalid of WindowMenu " + info.Name);
                        }
                        ArchiveDetailForm selectForm = ServiceProvider.GetService<IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo(ss[0])) as ArchiveDetailForm;
                        string propertyName = ss[1];
                        object masterEntity = EntityScript.GetPropertyValue(cm.DisplayManager.CurrentItem, propertyName);
                        if (masterEntity == null)
                        {
                            ArchiveOperationForm.DoAddS(selectForm.ControlManager);
                            selectForm.UpdateContent();
                            if (selectForm.ShowDialog(parentForm) == System.Windows.Forms.DialogResult.OK)
                            {
                                cm.EditCurrent();
                                EntityScript.SetPropertyValue(cm.DisplayManager.CurrentItem, propertyName, selectForm.DisplayManager.CurrentItem);
                                cm.EndEdit();

                                cm.OnCurrentItemChanged();
                            }
                        }
                        else
                        {
                            selectForm.ControlManager.AddNew();
                            selectForm.DisplayManager.Items[selectForm.DisplayManager.Position] = masterEntity;
                            selectForm.ControlManager.EndEdit(false);
                            ArchiveOperationForm.DoEditS(selectForm.ControlManager, selectForm.GridName);
                            selectForm.UpdateContent();

                            if (selectForm.ShowDialog(parentForm) == System.Windows.Forms.DialogResult.OK)
                            {
                                ((parentForm as IArchiveMasterForm).MasterGrid as IBoundGrid).ReloadData();
                            }
                        }
                        selectForm.Dispose();
                    }
                    break;
                default:
                    return false;
            }
            return true;
        }
예제 #5
0
        public static void AddFees(凭证 master, IList <费用> list, IControlManager <凭证费用明细> detailCm, bool add, 收付标志?asDzd收付标志)
        {
            if (list == null)
            {
                return;
            }

            List <费用> newList = new List <费用>();

            foreach (费用 i in list)
            {
                if (i.凭证费用明细 == null)
                {
                    newList.Add(i);
                }
            }

            IList <凭证费用明细> ret = new List <凭证费用明细>();

            if (!asDzd收付标志.HasValue)
            {
                // 费用实体类型. 收付标志, 费用项编号, 相关人编号
                Dictionary <Tuple <int, 收付标志, string, string>, IList <费用> > dict = Cd.Model.Utility.GroupFyToPzYsyf(newList);

                foreach (KeyValuePair <Tuple <int, 收付标志, string, string>, IList <费用> > kvp in dict)
                {
                    凭证费用明细 pzs1 = new 凭证费用明细();

                    decimal sum = 0;
                    foreach (费用 k4 in kvp.Value)
                    {
                        sum      += k4.金额.Value;
                        k4.凭证费用明细 = pzs1;
                    }

                    //string s = NameValueMappingCollection.Instance.FindNameFromId("信息_业务类型_全部", kvp.Key.Item1);
                    //if (string.IsNullOrEmpty(s))
                    //{
                    //    pzs1.业务类型编号 = null;
                    //}
                    //else
                    //{
                    //    pzs1.业务类型编号 = kvp.Key.Item1;
                    //}
                    pzs1.业务类型编号 = kvp.Key.Item1;

                    pzs1.费用    = kvp.Value;
                    pzs1.费用项编号 = kvp.Key.Item3;
                    pzs1.金额    = sum;
                    pzs1.收付标志  = kvp.Key.Item2;
                    pzs1.相关人编号 = kvp.Key.Item4;

                    // pzs1.凭证 = pz;

                    ret.Add(pzs1);
                }
            }
            else
            {
                Dictionary <Tuple <int, string>, IList <费用> > dict = Cd.Model.Utility.GroupFyToDzdYsyf(newList);

                foreach (KeyValuePair <Tuple <int, string>, IList <费用> > kvp in dict)
                {
                    凭证费用明细 pzs1 = new 凭证费用明细();

                    decimal sum = 0;
                    foreach (费用 k4 in kvp.Value)
                    {
                        if (k4.收付标志 == asDzd收付标志.Value)
                        {
                            sum += k4.金额.Value;
                        }
                        else
                        {
                            sum -= k4.金额.Value;
                        }
                        k4.凭证费用明细 = pzs1;
                    }

                    //string s = NameValueMappingCollection.Instance.FindNameFromId("信息_业务类型_全部", kvp.Key.First);
                    //if (string.IsNullOrEmpty(s))
                    //{
                    //    pzs1.业务类型编号 = null;
                    //}
                    //else
                    //{
                    //    pzs1.业务类型编号 = kvp.Key.First;
                    //}
                    pzs1.业务类型编号 = kvp.Key.Item1;

                    pzs1.费用    = kvp.Value;
                    pzs1.费用项编号 = "000";    // 常规应收应付
                    pzs1.金额    = sum;
                    pzs1.收付标志  = asDzd收付标志.Value;
                    pzs1.相关人编号 = kvp.Key.Item2;

                    // pzs1.凭证 = pz;

                    ret.Add(pzs1);
                }
            }

            if (add)
            {
                foreach (凭证费用明细 item in ret)
                {
                    detailCm.AddNew();
                    detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item;
                    detailCm.EndEdit();

                    foreach (费用 i in item.费用)
                    {
                        i.凭证费用明细 = item;
                    }
                }
            }
            else
            {
                if (ret.Count == 0)
                {
                    return;
                }

                System.Diagnostics.Debug.Assert(ret.Count <= 1, "选出多个凭证费用明细,请查证!");
                System.Diagnostics.Debug.Assert(ret[0].费用项编号 == detailCm.DisplayManagerT.CurrentEntity.费用项编号, "凭证费用明细费用项和选择的费用项不同!");
                System.Diagnostics.Debug.Assert(ret[0].相关人编号 == detailCm.DisplayManagerT.CurrentEntity.相关人编号, "凭证费用明细费用项和选择的相关人不同!");
                System.Diagnostics.Debug.Assert(ret[0].收付标志 == detailCm.DisplayManagerT.CurrentEntity.收付标志, "凭证费用明细费用项和选择的相关人不同!");

                using (IRepository rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <费用>())
                {
                    rep.Initialize(detailCm.DisplayManagerT.CurrentEntity.费用, detailCm.DisplayManagerT.CurrentEntity);
                }

                if (detailCm.DisplayManagerT.CurrentEntity.费用 == null)
                {
                    detailCm.DisplayManagerT.CurrentEntity.费用 = new List <费用>();
                }
                foreach (费用 i in ret[0].费用)
                {
                    i.凭证费用明细 = detailCm.DisplayManagerT.CurrentEntity;
                }

                detailCm.EditCurrent();
                detailCm.EndEdit();
            }
        }
        public static bool DoEditS(IControlManager cm, string gridName)
        {
            var info = ADInfoBll.Instance.GetGridRowInfo(gridName);
            if (info != null && !string.IsNullOrEmpty(info.AllowEdit)
                && !Permission.AuthorizeByRule(info.AllowEdit, cm.DisplayManager.CurrentItem))
            {
                MessageForm.ShowError("��û���޸Ĵ˼�¼��Ȩ�ޣ�");
                return false;
            }

            cm.EditCurrent();

            return true;
        }
예제 #7
0
 /// <summary>
 /// btnEdit_Click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void btnEdit_Click(System.Object sender, System.EventArgs e)
 {
     m_cm.EditCurrent();
 }
예제 #8
0
        private static bool InternalExecuteWindowMenu2(IControlManager cm, WindowMenuInfo info, Form parentForm)
        {
            object entity = cm.DisplayManager.CurrentItem;
            int    pos    = cm.DisplayManager.Position;

            //ArchiveOperationForm opForm = masterForm as ArchiveOperationForm;
            switch (info.Type)
            {
            case WindowMenuType.Add:
            {
                ArchiveOperationForm.DoAddS(cm);
            }
            break;

            case WindowMenuType.Edit:
            {
                ArchiveOperationForm.DoEditS(cm, (parentForm as IGridNamesContainer).GridNames[0]);
            }
            break;

            case WindowMenuType.Delete:
            {
                ArchiveOperationForm.DoDeleteS(cm, (parentForm as IGridNamesContainer).GridNames[0]);
            }
            break;

            case WindowMenuType.Confirm:
            {
                parentForm.ValidateChildren();
                ArchiveDetailForm.DoSaveS(cm);
            }
            break;

            case WindowMenuType.Cancel:
            {
                ArchiveDetailForm.DoCancelS(cm);
            }
            break;

            case WindowMenuType.Submit:
            {
                if (entity == null)
                {
                    MessageForm.ShowError("请选择要提交的项!");
                    return(true);
                }
                if (!MessageForm.ShowYesNo("是否确认提交?"))
                {
                    return(true);
                }

                ISubmittedEntity se = entity as ISubmittedEntity;
                if (se == null)
                {
                    throw new ArgumentException("Submit Entity should be ISubmittedEntity!");
                }
                if (string.IsNullOrEmpty(info.ExecuteParam))
                {
                    cm.EditCurrent();
                    se.Submitted = true;
                    cm.EndEdit();
                }
                else
                {
                    ISubmittedEntityDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(info.ExecuteParam) as ISubmittedEntityDao;
                    if (dao == null)
                    {
                        throw new ArgumentException("Submit windowMenuType's ExecuteParam should be ISubmittedEntityDao!");
                    }

                    using (IRepository rep = dao.GenerateRepository())
                    {
                        try
                        {
                            se.Submitted = true;
                            rep.BeginTransaction();
                            dao.Submit(rep, entity);
                            rep.CommitTransaction();
                            cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                        }
                        catch (Exception ex)
                        {
                            se.Submitted = false;
                            rep.RollbackTransaction();
                            ExceptionProcess.ProcessWithNotify(ex);
                        }
                    }
                }
            }
            break;

            case WindowMenuType.Unsubmit:
            {
                if (entity == null)
                {
                    MessageForm.ShowError("请选择要撤销提交的项!");
                    return(true);
                }
                if (!MessageForm.ShowYesNo("是否确认撤销提交?", "确认", true))
                {
                    return(true);
                }

                ISubmittedEntity se = entity as ISubmittedEntity;
                if (se == null)
                {
                    throw new ArgumentException("Submit Entity should be ISubmittedEntity!");
                }
                if (string.IsNullOrEmpty(info.ExecuteParam))
                {
                    cm.EditCurrent();
                    se.Submitted = false;
                    cm.EndEdit();
                }
                else
                {
                    ISubmittedEntityDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(info.ExecuteParam) as ISubmittedEntityDao;
                    if (dao == null)
                    {
                        throw new ArgumentException("Submit windowMenuType's ExecuteParam should be ISubmittedEntityDao!");
                    }

                    using (IRepository rep = dao.GenerateRepository())
                    {
                        try
                        {
                            se.Submitted = false;
                            rep.BeginTransaction();
                            dao.Unsubmit(rep, entity);
                            rep.CommitTransaction();
                            cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                        }
                        catch (Exception ex)
                        {
                            se.Submitted = true;
                            rep.RollbackTransaction();
                            ExceptionProcess.ProcessWithNotify(ex);
                        }
                    }
                }
            }
            break;

            case WindowMenuType.SubmitMulti:
            {
                if (cm.DisplayManager.Count == 0)
                {
                    MessageForm.ShowError("请选择要提交的项!");
                    return(true);
                }
                if (!MessageForm.ShowYesNo("是否确认提交(当前全部)?"))
                {
                    return(true);
                }

                ISubmittedEntity se = entity as ISubmittedEntity;
                if (se == null)
                {
                    throw new ArgumentException("Submit Entity should be ISubmittedEntity!");
                }
                if (string.IsNullOrEmpty(info.ExecuteParam))
                {
                    IBatchDao batchDao = cm.Dao as IBatchDao;
                    if (batchDao != null)
                    {
                        batchDao.SuspendOperation();
                    }

                    for (int i = 0; i < cm.DisplayManager.Count; ++i)
                    {
                        cm.DisplayManager.Position = i;
                        cm.EditCurrent();
                        (cm.DisplayManager.Items[i] as ISubmittedEntity).Submitted = true;
                        cm.EndEdit();
                    }

                    if (batchDao != null)
                    {
                        batchDao.ResumeOperation();
                    }
                }
                else
                {
                    ISubmittedEntityDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(info.ExecuteParam) as ISubmittedEntityDao;
                    if (dao == null)
                    {
                        throw new ArgumentException("Submit windowMenuType's ExecuteParam should be ISubmittedEntityDao!");
                    }

                    using (IRepository rep = dao.GenerateRepository())
                    {
                        try
                        {
                            rep.BeginTransaction();
                            for (int i = 0; i < cm.DisplayManager.Count; ++i)
                            {
                                (cm.DisplayManager.Items[i] as ISubmittedEntity).Submitted = true;
                                dao.Submit(rep, cm.DisplayManager.Items[i]);
                            }
                            rep.CommitTransaction();
                            cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                        }
                        catch (Exception ex)
                        {
                            se.Submitted = false;
                            rep.RollbackTransaction();
                            ExceptionProcess.ProcessWithNotify(ex);
                        }
                    }
                }
            }
            break;

            case WindowMenuType.Cancellate:
            {
                if (entity == null)
                {
                    MessageForm.ShowError("请选择要作废的项!");
                    return(true);
                }
                if (!MessageForm.ShowYesNo("是否确认作废?", "确认", true))
                {
                    return(true);
                }

                ICancellateDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(info.ExecuteParam) as ICancellateDao;
                if (dao == null)
                {
                    throw new ArgumentException("Submit windowMenuType's ExecuteParam should be ICancellateDao!");
                }
                using (IRepository rep = dao.GenerateRepository())
                {
                    try
                    {
                        rep.BeginTransaction();
                        dao.Cancellate(rep, entity);
                        rep.CommitTransaction();
                        cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                    }
                    catch (Exception ex)
                    {
                        rep.RollbackTransaction();
                        ExceptionProcess.ProcessWithNotify(ex);
                    }
                }
            }
            break;

            case WindowMenuType.DaoProcess:
            {
                if (entity == null)
                {
                    MessageForm.ShowError("请选择要操作的项!");
                    return(true);
                }
                if (!MessageForm.ShowYesNo("是否要执行" + info.Text + "?"))
                {
                    return(true);
                }

                string[] ss = info.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (ss.Length != 2)
                {
                    throw new ArgumentException("DaoProcess windowMenuType's ExecuteParam should be IDao;MethodName!");
                }
                IRepositoryDao dao = Feng.Utils.ReflectionHelper.CreateInstanceFromName(ss[0].Trim()) as IRepositoryDao;
                if (dao == null)
                {
                    throw new ArgumentException("DaoProcess windowMenuType's ExecuteParam's first part should be IDao!");
                }

                using (IRepository rep = dao.GenerateRepository())
                {
                    try
                    {
                        rep.BeginTransaction();
                        Feng.Utils.ReflectionHelper.RunInstanceMethod(ss[0].Trim(), ss[1].Trim(), dao, new object[] { rep, entity });
                        rep.CommitTransaction();
                        cm.OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, pos));
                    }
                    catch (Exception ex)
                    {
                        rep.RollbackTransaction();
                        ExceptionProcess.ProcessWithNotify(ex);
                    }
                }
            }
            break;

            case WindowMenuType.Select:
            {
                string[] ss = info.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (ss.Length == 0)
                {
                    throw new ArgumentException("WindowMenu's ExecuteParam is Invalid of WindowMenu " + info.Name);
                }
                ArchiveCheckForm form = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo(ss[0])) as ArchiveCheckForm;
                if (ss.Length > 1)
                {
                    string exp = ss[1];
                    exp = EntityHelper.ReplaceEntity(exp, new EntityHelper.GetReplaceValue(delegate(string paramName)
                        {
                            Tuple <string, object> t = EventProcessUtils.GetDataControlValue(paramName, cm.DisplayManager);
                            if (t.Item2 == null)
                            {
                                throw new InvalidUserOperationException(string.Format("请先填写{0}!", paramName));
                            }
                            cm.DisplayManager.DataControls[t.Item1].ReadOnly = true;
                            // save controlValue to entity because readonly will not save
                            EntityScript.SetPropertyValue(cm.DisplayManager.CurrentItem, t.Item1, t.Item2);

                            return(t.Item2);
                        }));
                    if (string.IsNullOrEmpty(form.DisplayManager.SearchManager.AdditionalSearchExpression))
                    {
                        form.DisplayManager.SearchManager.AdditionalSearchExpression = exp;
                    }
                    else
                    {
                        form.DisplayManager.SearchManager.AdditionalSearchExpression = "(" + form.DisplayManager.SearchManager.AdditionalSearchExpression + ") and " + exp;
                    }
                }

                int detailGridIdx = 0;
                if (ss.Length > 2)
                {
                    detailGridIdx = Feng.Utils.ConvertHelper.ToInt(ss[2]).Value;
                }
                if (form.ShowDialog(parentForm) == System.Windows.Forms.DialogResult.OK)
                {
                    IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)(parentForm as IArchiveMasterForm).ArchiveDetailForm).DetailGrids[detailGridIdx] as IArchiveGrid).ControlManager;

                    var nowList = detailCm.DisplayManager.Items;
                    foreach (object i in form.SelectedEntites)
                    {
                        if (nowList.Contains(i))
                        {
                            continue;
                        }

                        detailCm.AddNew();
                        detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = i;
                        detailCm.EndEdit();
                    }
                }
                form.Dispose();
            }
            break;

            case WindowMenuType.Input:
                throw new NotSupportedException("Not supported now!");

            case WindowMenuType.ManyToOneWindow:
            {
                if (cm.DisplayManager.CurrentItem == null)
                {
                    MessageForm.ShowInfo("无当前项,不能操作!");
                    return(true);
                }
                string[] ss = info.ExecuteParam.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                if (ss.Length < 2)
                {
                    throw new ArgumentException("WindowMenu's ExecuteParam is Invalid of WindowMenu " + info.Name);
                }
                ArchiveDetailForm selectForm   = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo(ss[0])) as ArchiveDetailForm;
                string            propertyName = ss[1];
                object            masterEntity = EntityScript.GetPropertyValue(cm.DisplayManager.CurrentItem, propertyName);
                if (masterEntity == null)
                {
                    ArchiveOperationForm.DoAddS(selectForm.ControlManager);
                    selectForm.UpdateContent();
                    if (selectForm.ShowDialog(parentForm) == System.Windows.Forms.DialogResult.OK)
                    {
                        cm.EditCurrent();
                        EntityScript.SetPropertyValue(cm.DisplayManager.CurrentItem, propertyName, selectForm.DisplayManager.CurrentItem);
                        cm.EndEdit();

                        cm.OnCurrentItemChanged();
                    }
                }
                else
                {
                    selectForm.ControlManager.AddNew();
                    selectForm.DisplayManager.Items[selectForm.DisplayManager.Position] = masterEntity;
                    selectForm.ControlManager.EndEdit(false);
                    ArchiveOperationForm.DoEditS(selectForm.ControlManager, selectForm.GridName);
                    selectForm.UpdateContent();

                    if (selectForm.ShowDialog(parentForm) == System.Windows.Forms.DialogResult.OK)
                    {
                        ((parentForm as IArchiveMasterForm).MasterGrid as IBoundGrid).ReloadData();
                    }
                }
                selectForm.Dispose();
            }
            break;

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