コード例 #1
0
 /// <summary>
 /// btnOK_Click
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected virtual void btnOK_Click(System.Object sender, System.EventArgs e)
 {
     if (m_cm.SaveCurrent())
     {
         m_cm.EndEdit(true);
     }
 }
コード例 #2
0
        //public static void 自动凭证应付对账单生成费用(ArchiveOperationForm masterForm)
        //{
        //    IControlManager<业务费用> detailCm = (((IArchiveDetailFormWithDetailGrids)detailForm).DetailGrids[0] as IArchiveGrid).ControlManager
        //        as IControlManager<业务费用>;

        //    IList<费用> list = new List<费用>();
        //    foreach (业务费用 item in detailCm.DisplayManagerT.Entities)
        //    {
        //        list.Add(item.Clone() as 业务费用);
        //    }

        //    ArchiveOperationForm masterFormKj = TabbedMdiForm.ShowMenuFormInMdi("凭证_会计付款") as ArchiveOperationForm;
        //    if (masterFormKj != null)
        //    {
        //        if (masterFormKj.DoAdd())
        //        {
        //            IControlManager<凭证费用明细> detailCmKj = (((IArchiveDetailFormWithDetailGrids)detailForm).DetailGrids[0] as IArchiveGrid).ControlManager as IControlManager<凭证费用明细>;
        //            IBaseDao masterDao = ((IArchiveGrid)masterFormKj.ActiveGrid).Bll as IBaseDao;
        //            MemoryDao<凭证费用明细> memoryBll = (masterDao.GetSubDao(0) as IMasterDao).DetailMemoryDao as MemoryDao<凭证费用明细>;
        //            MemoryDao<费用> memoryBll2 = (((masterDao.GetSubDao(0) as IMasterDao).DetailDao as IBaseDao).GetSubDao(0) as IMasterDao).DetailMemoryDao as MemoryDao<费用>;

        //            (masterFormKj.DisplayManager.CurrentItem as 凭证).自动手工标志 = 自动手工标志.对账单;

        //            process_pz.AddFees(masterFormKj.DisplayManager.CurrentItem as 凭证, list, detailCmKj, memoryBll, memoryBll2);
        //            //frm_cw_fkpz_kj_detail detailFormTo = form.ArchiveDetailForm as frm_cw_fkpz_kj_detail;

        //            detailCmKj.DisplayManager.DataControls["金额.数额"].SelectedDataValue = detailForm.ControlManager.DisplayManager.DataControls["凭证金额"].SelectedDataValue;
        //            detailCmKj.DisplayManager.DataControls["金额.币制编号"].SelectedDataValue = detailForm.ControlManager.DisplayManager.DataControls["凭证币制编号"].SelectedDataValue;
        //        }
        //    }
        //}

        public static void  择应付对账单费用(ArchiveOperationForm masterForm)
        {
            if (masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue == null)
            {
                MessageForm.ShowError("请先填写相关人编号!");
                return;
            }
            masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].ReadOnly = true;
            EntityScript.SetPropertyValue(masterForm.DisplayManager.CurrentItem, "相关人编号", masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue);

            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict["相关人编号"] = masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue;
            ArchiveCheckForm form = ProcessSelect.Execute((masterForm.ArchiveDetailForm as IDisplayManagerContainer).DisplayManager, "选择_应付对账单_费用", dict);

            if (form != null)
            {
                IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

                using (var rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <业务费用>())
                {
                    foreach (object i in form.SelectedEntites)
                    {
                        业务费用 item = i as 业务费用;
                        item.对账单 = masterForm.DisplayManager.CurrentItem as 对账单;
                        detailCm.AddNew();
                        detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item;
                        detailCm.EndEdit();
                    }
                }
            }
        }
コード例 #3
0
        public static void ReadCk(ArchiveOperationForm masterForm)
        {
            IControlManager masterCm = masterForm.ControlManager;

            if (masterCm.DisplayManager.DataControls["提单号"].SelectedDataValue == null)
            {
                ServiceProvider.GetService <IMessageBox>().ShowWarning("请输入提单号!");
                return;
            }

            string tdh = masterCm.DisplayManager.DataControls["提单号"].SelectedDataValue.ToString().Trim();

            m_nbeportGrab.SetLoginInfo(SystemProfileFile.DefaultUserProfile.GetValue("Hd.Options", "NetReadUserName", ""),
                                       SystemProfileFile.DefaultUserProfile.GetValue("Hd.Options", "NetReadPassword", ""));
            IList <集装箱数据> boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.出口集装箱, tdh);

            if (boxList.Count <= 0)
            {
                return;
            }

            AskToReplace(masterCm, "船名航次", boxList[0].船舶英文名称 + "/" + boxList[0].航次);
            AskToReplace(masterCm, "进港地编号", NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", boxList[0].堆场区));
            AskToReplace(masterCm, "离港时间", boxList[0].进场时间);
            AskToReplace(masterCm, "提单号", boxList[0].提单号);
            AskToReplace(masterCm, "箱量", boxList.Count);

            IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

            foreach (集装箱数据 data in boxList)
            {
                bool have = false;
                foreach (Xceed.Grid.DataRow row in ((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0].DataRows)
                {
                    if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == data.集装箱号.Trim())
                    {
                        have = true;
                        break;
                    }
                }
                if (!have)
                {
                    出口箱 newItem = new 出口箱
                    {
                        箱号    = data.集装箱号,
                        箱型    = Feng.Utils.ConvertHelper.ChangeType(data.箱型, typeof(箱型)) as 箱型,
                        装货地编号 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", data.堆场区),
                        进港时间  = data.Real进场时间,
                        提箱时间  = data.Real提箱时间
                    };

                    detailCm.AddNew();
                    detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = newItem;
                    detailCm.EndEdit();
                }
            }
        }
コード例 #4
0
        internal static bool Save(IControlManager cm, SaveType saveType)
        {
            if (cm.State == StateType.Edit)
            {
                if (!cm.SaveCurrent())
                {
                    return(false);
                }
            }

            任务 entity = cm.DisplayManager.CurrentItem as 任务;

            switch (saveType)
            {
            case SaveType.正式备案确认:
                任务Dao.生成任务号(entity);
                break;

            case SaveType.拒绝确认:
                entity.是否拒绝     = true;
                entity.IsActive = false;
                entity.任务号      = null;
                break;

            default:
                break;
            }

            bool ret;

            if (cm.State == StateType.Edit)
            {
                ret = cm.EndEdit(true);
            }
            else
            {
                try
                {
                    cm.Dao.Update(entity);
                    ret = true;
                }
                catch (Exception ex)
                {
                    ExceptionProcess.ProcessWithNotify(ex);
                    ret = false;
                }
            }

            return(ret);
        }
コード例 #5
0
        public static void ReadNmcg(ArchiveOperationForm masterForm)
        {
            IControlManager masterCm = masterForm.ControlManager;

            if (masterCm.DisplayManager.DataControls["预配提单号"].SelectedDataValue == null)
            {
                ServiceProvider.GetService <IMessageBox>().ShowWarning("请输入预配提单号!");
                return;
            }

            string tdh = masterCm.DisplayManager.DataControls["预配提单号"].SelectedDataValue.ToString().Trim();

            IList <集装箱进门查询结果> boxList = m_npediGrab.集装箱进门查询(tdh);

            if (boxList.Count <= 0)
            {
                //boxList = m_npediGrab.集装箱进门查询(tdh);
                return;
            }

            AskToReplace(masterCm, "预配船名航次", boxList[0].船名航次);
            //AskToReplace(masterCm, "进港地编号", NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", boxList[0].码头));
            //AskToReplace(masterCm, "到港时间", boxList[0].进场时间);
            //AskToReplace(masterCm, "提单号", boxList[0].提单号);
            AskToReplace(masterCm, "箱量", boxList.Count);

            IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

            foreach (集装箱进门查询结果 data in boxList)
            {
                bool have = false;
                foreach (Xceed.Grid.DataRow row in ((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0].DataRows)
                {
                    if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == data.集装箱号.Trim())
                    {
                        have = true;
                        break;
                    }
                }
                if (!have)
                {
                    内贸出港箱 newItem = new 内贸出港箱 {
                        箱号 = data.集装箱号, 封志号 = data.铅封号
                    };
                    detailCm.AddNew();
                    detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = newItem;
                    detailCm.EndEdit();
                }
            }
        }
コード例 #6
0
        public static void  择出口应收对账单费用(ArchiveOperationForm masterForm)
        {
            if (masterForm.ControlManager.DisplayManager.DataControls["费用项编号"].SelectedDataValue == null)
            {
                MessageForm.ShowError("请先填写费用项编号!");
                return;
            }
            if (masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue == null)
            {
                MessageForm.ShowError("请先填写相关人编号!");
                return;
            }

            masterForm.ControlManager.DisplayManager.DataControls["费用项编号"].ReadOnly = true;
            masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].ReadOnly = true;
            EntityScript.SetPropertyValue(masterForm.DisplayManager.CurrentItem, "费用项编号", masterForm.ControlManager.DisplayManager.DataControls["费用项编号"].SelectedDataValue);
            EntityScript.SetPropertyValue(masterForm.DisplayManager.CurrentItem, "相关人编号", masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue);

            string           type = (string)masterForm.ControlManager.DisplayManager.DataControls["费用项编号"].SelectedDataValue;
            ArchiveCheckForm form = null;

            Dictionary <string, object> dict = new Dictionary <string, object>();

            dict["相关人编号"] = masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue;
            if (type == "000")  // 常规
            {
                form = ProcessSelect.Execute((masterForm.ArchiveDetailForm as IDisplayManagerContainer).DisplayManager, "选择_出口_应收对账单_常规费用", dict);
            }
            else if (type == "001") // 额外
            {
                form = ProcessSelect.Execute((masterForm.ArchiveDetailForm as IDisplayManagerContainer).DisplayManager, "选择_出口_应收对账单_额外费用", dict);
            }

            if (form != null)
            {
                IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

                foreach (object i in form.SelectedEntites)
                {
                    业务费用 item = i as 业务费用;
                    item.对账单 = masterForm.DisplayManager.CurrentItem as 对账单;
                    detailCm.AddNew();
                    detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item;
                    detailCm.EndEdit();
                }
            }
        }
コード例 #7
0
ファイル: process_fy_yw.cs プロジェクト: qq5013/mERP-HD
        public static void 批量添加进口箱费用(ArchiveOperationForm masterForm)
        {
            IControlManager cm = masterForm.ControlManager;

            ArchiveCheckForm form = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("选择_批量添加费用_进口箱")) as ArchiveCheckForm;

            if (form != null && form.ShowDialog() == DialogResult.OK)
            {
                foreach (object i in form.SelectedEntites)
                {
                    业务费用 item = new 业务费用();
                    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;
                    }
                }
            }
        }
コード例 #8
0
ファイル: process_fy_yw.cs プロジェクト: qq5013/mERP-HD
        public static void 批量添加进口费用(ArchiveOperationForm masterForm)
        {
            IControlManager cm = masterForm.ControlManager;

            ArchiveCheckForm form = ServiceProvider.GetService <IWindowFactory>().CreateWindow(ADInfoBll.Instance.GetWindowInfo("选择_批量添加费用_进口票")) 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
                    {
                        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;
                    }
                }
            }
        }
コード例 #9
0
        public static void  择固定资产(ArchiveOperationForm masterForm)
        {
            Dictionary <string, object> dict = new Dictionary <string, object>();
            ArchiveCheckForm            form = ProcessSelect.Execute((masterForm.ArchiveDetailForm as IDisplayManagerContainer).DisplayManager, "选择_非业务财务_固定资产折旧", dict);

            if (form != null)
            {
                IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

                using (var rep = ServiceProvider.GetService <IRepositoryFactory>().GenerateRepository <非业务费用>())
                {
                    foreach (object i in form.SelectedEntites)
                    {
                        非业务费用 item = i as 非业务费用;
                        item.对账单 = masterForm.DisplayManager.CurrentItem as 对账单;
                        detailCm.AddNew();
                        detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item;
                        detailCm.EndEdit();
                    }

                    //foreach (object i in form.SelectedEntites)
                    //{
                    //    非业务费用 item = new 非业务费用();
                    //    DataRowView row = i as DataRowView;
                    //    item.费用实体 = rep.Get<费用实体>((Guid)row["Id"]);
                    //    item.相关人编号 = masterForm.ControlManager.DisplayManager.DataControls["相关人编号"].SelectedDataValue.ToString();
                    //    item.费用项编号 = "387";        // 固定资产折旧
                    //    item.收付标志 = 收付标志.付;

                    //    detailCm.AddNew();
                    //    detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = item;
                    //    detailCm.EndEdit();
                    //}
                }
            }
        }
コード例 #10
0
ファイル: process_fy_fyw.cs プロジェクト: qq5013/mERP-HD
        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);
                    }
                }
            }
        }
コード例 #11
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();
            }
        }
コード例 #12
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;
        }
コード例 #13
0
        public static void ReadJk(ArchiveOperationForm masterForm)
        {
            IControlManager masterCm = masterForm.ControlManager;

            if (masterCm.DisplayManager.DataControls["提单号"].SelectedDataValue == null)
            {
                ServiceProvider.GetService <IMessageBox>().ShowWarning("请输入提单号!");
                return;
            }

            string tdh = masterCm.DisplayManager.DataControls["提单号"].SelectedDataValue.ToString().Trim();

            #region 从"npedi进口卸箱查询"获取箱信息
            IList <进口卸箱查询结果> boxList = m_npediGrab.进口卸箱查询(tdh);
            if (boxList.Count <= 0)
            {
                return;
            }

            AskToReplace(masterCm, "船名航次", boxList[0].船名航次);
            AskToReplace(masterCm, "卸箱地编号", NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", boxList[0].码头));
            AskToReplace(masterCm, "到港时间", boxList[0].卸船时间);
            AskToReplace(masterCm, "提单号", boxList[0].提单号);
            AskToReplace(masterCm, "箱量", boxList.Count);

            IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

            int?   xxbh = null;
            string pm   = null;
            foreach (进口卸箱查询结果 data in boxList)
            {
                bool have = false;
                foreach (Xceed.Grid.DataRow row in ((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0].DataRows)
                {
                    if (row.Cells["箱型编号"].Value != null)
                    {
                        xxbh = (int)row.Cells["箱型编号"].Value;
                    }

                    if (row.Cells["品名"].Value != null)
                    {
                        pm = row.Cells["品名"].Value.ToString();
                    }

                    if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == data.集装箱号.Trim())
                    {
                        have = true;
                        break;
                    }
                }
                if (!have)
                {
                    if (xxbh == null)
                    {
                        xxbh = Convert.ToInt32(NameValueMappingCollection.Instance.FindIdFromName("备案_箱型_全部", boxList[0].尺寸类型));
                    }
                    进口箱 newItem = new 进口箱 {
                        箱号 = data.集装箱号, 箱型编号 = xxbh, 重量 = Convert.ToInt32(data.箱毛重), 品名 = pm
                    };
                    detailCm.AddNew();
                    detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = newItem;
                    detailCm.EndEdit();
                }
            }
            #endregion

            #region 从"nbeport集装箱进场信息"获取箱信息
            //m_nbeportGrab.SetLoginInfo(SystemDirectory.DefaultUserProfile.GetValue("Hd.Options", "NetReadUserName", ""),
            //    SystemDirectory.DefaultUserProfile.GetValue("Hd.Options", "NetReadPassword", ""));
            //IList<集装箱数据> boxList = m_nbeportGrab.查询集装箱数据(ImportExportType.进口集装箱, tdh);

            //if (boxList.Count <= 0)
            //{
            //    return;
            //}

            //AskToReplace(masterCm, "船名航次", boxList[0].船舶英文名称 + "/" + boxList[0].航次);
            //AskToReplace(masterCm, "卸箱地编号", NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", boxList[0].堆场区));
            //AskToReplace(masterCm, "到港时间", boxList[0].进场时间);
            //AskToReplace(masterCm, "提单号", boxList[0].提单号);
            //AskToReplace(masterCm, "箱量", boxList.Count);

            //IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

            //int? xxbh = null;
            //string pm = null;
            //foreach (集装箱数据 data in boxList)
            //{
            //    bool have = false;
            //    foreach (Xceed.Grid.DataRow row in ((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0].DataRows)
            //    {
            //        if (row.Cells["箱型编号"].Value != null)
            //        {
            //            xxbh = (int)row.Cells["箱型编号"].Value;
            //        }

            //        if (row.Cells["品名"].Value != null)
            //        {
            //            pm = row.Cells["品名"].Value.ToString();
            //        }

            //        if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == data.集装箱号.Trim())
            //        {
            //            have = true;
            //            break;
            //        }
            //    }
            //    if (!have)
            //    {
            //        //进口箱 newItem = new 进口箱 { 箱号 = data.集装箱号, 箱型 = ConvertHelper.ChangeType(data.箱型, typeof(箱型)) as 箱型 };
            //        进口箱 newItem = new 进口箱 { 箱号 = data.集装箱号, 箱型编号 = xxbh, 品名 = pm };
            //        detailCm.AddNew();
            //        detailCm.DisplayManager.Items[detailCm.DisplayManager.Position] = newItem;
            //        detailCm.EndEdit();
            //    }
            //}
            #endregion
        }
コード例 #14
0
        public static void ReadPx_报关单号(ArchiveOperationForm masterForm)
        {
            IControlManager masterCm = masterForm.ControlManager;

            if (masterCm.DisplayManager.DataControls["报关单号"].SelectedDataValue == null)
            {
                ServiceProvider.GetService <IMessageBox>().ShowWarning("请输入报关单号!");
                return;
            }

            string bgdh = masterCm.DisplayManager.DataControls["报关单号"].SelectedDataValue.ToString().Trim();

            报关单数据 bgdInfo = null;

            foreach (KeyValuePair <string, string> id in Get_nbediRead_ID())
            {
                nbediRead m_nbediRead = new nbediRead();
                m_nbediRead.SetLoginInfo(id.Key, id.Value);
                bgdInfo = m_nbediRead.长短号查询报关单数据(bgdh);
                if (bgdInfo != null && !string.IsNullOrEmpty(bgdInfo.报关单号))
                {
                    break;
                }
            }

            if (bgdInfo == null)
            {
                return;
            }

            AskToReplace(masterCm, "报关单号", bgdInfo.报关单长号);
            AskToReplace(masterCm, "抬头", bgdInfo.经营单位);
            AskToReplace(masterCm, "提单号", bgdInfo.提运单号);
            AskToReplace(masterCm, "核销单号", bgdInfo.批准文号);
            AskToReplace(masterCm, "通关单号", bgdInfo.通关单号);
            AskToReplace(masterCm, "箱号", bgdInfo.箱号);
            AskToReplace(masterCm, "箱量", bgdInfo.箱量);
            AskToReplace(masterCm, "委托时间", bgdInfo.申报日期);
            AskToReplace(masterCm, "船名航次", bgdInfo.船名航次);
            AskToReplace(masterCm, "报关单快照", bgdInfo.网页快照);
            AskToReplace(masterCm, "报关员编号", bgdInfo.报关员);
            AskToReplace(masterCm, "报关公司", bgdInfo.报关公司);

            if (string.IsNullOrEmpty(bgdInfo.提运单号))
            {
                return;
            }

            IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

            IList <集装箱数据> boxList = 查询出口集装箱数据By提单号航次(bgdInfo.提运单号.Trim(), bgdInfo.船名航次.Split('/')[1]);
            string        进港地     = null;
            DateTime?     离港时间    = null;

            foreach (集装箱数据 data in boxList)
            {
                bool have = false;
                foreach (Xceed.Grid.DataRow row in ((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0].DataRows)
                {
                    if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == data.集装箱号.Trim())
                    {
                        have = true;
                        break;
                    }

                    进港地  = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", data.堆场区);
                    离港时间 = data.Real进场时间;
                }
                if (!have)
                {
                    拼箱箱 newItem = new 拼箱箱
                    {
                        箱号    = data.集装箱号,
                        箱型    = Feng.Utils.ConvertHelper.ChangeType(data.箱型, typeof(箱型)) as 箱型,
                        装货地编号 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", data.堆场区),
                        进港时间  = data.Real进场时间,
                        提箱时间  = data.Real提箱时间
                    };

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

            AskToReplace(masterCm, "进港地编号", 进港地);
            AskToReplace(masterCm, "离港时间", 离港时间);
        }
コード例 #15
0
        public static void ReadCk_报关单号(ArchiveOperationForm masterForm)
        {
            IControlManager masterCm = masterForm.ControlManager;

            if (masterCm.DisplayManager.DataControls["报关单号"].SelectedDataValue == null)
            {
                ServiceProvider.GetService <IMessageBox>().ShowWarning("请输入报关单号!");
                return;
            }

            string bgdh = masterCm.DisplayManager.DataControls["报关单号"].SelectedDataValue.ToString().Trim();

            报关单数据 bgdInfo = null;

            foreach (KeyValuePair <string, string> id in Get_nbediRead_ID())
            {
                m_nbediRead = new nbediRead();
                m_nbediRead.SetLoginInfo(id.Key, id.Value);
                bgdInfo = m_nbediRead.长短号查询报关单数据(bgdh);
                if (bgdInfo != null && !string.IsNullOrEmpty(bgdInfo.报关单号))
                {
                    break;
                }
            }

            if (bgdInfo == null)
            {
                ReadCk(masterForm);
            }
            else
            {
                AskToReplace(masterCm, "报关单号", bgdInfo.报关单长号);
                AskToReplace(masterCm, "抬头", bgdInfo.经营单位);
                AskToReplace(masterCm, "提单号", bgdInfo.提运单号);
                AskToReplace(masterCm, "核销单号", bgdInfo.批准文号);
                AskToReplace(masterCm, "通关单号", bgdInfo.通关单号);
                AskToReplace(masterCm, "箱号", bgdInfo.箱号);
                AskToReplace(masterCm, "箱量", bgdInfo.箱量);
                AskToReplace(masterCm, "委托时间", bgdInfo.申报日期);
                AskToReplace(masterCm, "船名航次", bgdInfo.船名航次);
                //AskToReplace(masterCm, "报关单快照", bgdInfo.网页快照);
                AskToReplace(masterCm, "报关员编号", bgdInfo.报关员);
                AskToReplace(masterCm, "报关公司", bgdInfo.报关公司);

                if (string.IsNullOrEmpty(bgdInfo.提运单号))
                {
                    return;
                }

                IControlManager detailCm = (((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0] as IArchiveGrid).ControlManager;

                IList <集装箱数据> boxList = m_nbediRead.查询集装箱数据(bgdInfo.提运单号.Trim(), bgdInfo.船名航次.Split('/')[0], bgdInfo.船名航次.Split('/')[1]);
                //IList<集装箱数据> boxList = 查询出口集装箱数据By提单号航次(bgdInfo.提运单号.Trim(), bgdInfo.船名航次.Split('/')[1]);
                string 进港地 = null;
                //bool is查验 = true; // 海关查验是否正常,异常将不查询查验结果

                foreach (集装箱数据 data in boxList)
                {
                    bool have = false;
                    foreach (Xceed.Grid.DataRow row in ((IArchiveDetailFormWithDetailGrids)masterForm.ArchiveDetailForm).DetailGrids[0].DataRows)
                    {
                        if (row.Cells["箱号"].Value != null && row.Cells["箱号"].Value.ToString().Trim() == data.集装箱号.Trim())
                        {
                            have = true;
                            break;
                        }

                        进港地 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", data.堆场区);
                    }
                    if (!have)
                    {
                        int xx = 0;
                        if (int.TryParse(data.箱型, out xx))
                        {
                            if (xx < 40)
                            {
                                xx = 20;
                            }

                            if (xx >= 45)
                            {
                                xx = 41;
                            }
                            else
                            {
                                xx = 40;
                            }
                        }

                        int?箱型编号 = null;
                        if (xx != 0)
                        {
                            箱型编号 = xx;
                        }

                        出口箱 newItem = new 出口箱
                        {
                            箱号    = data.集装箱号,
                            箱型编号  = 箱型编号,
                            装货地编号 = (string)NameValueMappingCollection.Instance.FindColumn2FromColumn1("人员单位_港区堆场", "全称", "编号", data.堆场区),
                            进港时间  = data.Real进场时间,
                            //提箱时间 = data.Real提箱时间
                        };

                        //if (is查验)
                        //{
                        //    try
                        //    {
                        //        查询海关查验结果(newItem);
                        //    }
                        //    catch (Exception ex)
                        //    {
                        //        is查验 = false;
                        //        MessageForm.ShowError(ex.Message, "海关查验");
                        //    }
                        //}

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

                AskToReplace(masterCm, "进港地编号", 进港地);

                保存报关单快照(bgdInfo.报关单长号, bgdInfo.网页快照);
            }
        }
コード例 #16
0
        internal static bool Save(IControlManager cm, SaveType saveType)
        {
            if (cm.State == StateType.Edit)
            {
                if (!cm.SaveCurrent())
                {
                    return false;
                }
            }

            任务 entity = cm.DisplayManager.CurrentItem as 任务;
            switch (saveType)
            {
                case SaveType.正式备案确认:
                    任务Dao.生成任务号(entity);
                    break;
                case SaveType.拒绝确认:
                    entity.是否拒绝 = true;
                    entity.IsActive = false;
                    entity.任务号 = null;
                    break;
                default:
                    break;
            }

            bool ret;
            if (cm.State == StateType.Edit)
            {
                ret = cm.EndEdit(true);
            }
            else
            {
                try
                {
                    cm.Dao.Update(entity);
                    ret = true;
                }
                catch (Exception ex)
                {
                    ExceptionProcess.ProcessWithNotify(ex);
                    ret = false;
                }
            }

            return ret;
        }
コード例 #17
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);
        }
コード例 #18
0
ファイル: process_fy_yw.cs プロジェクト: qq5013/mERP-HD
        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);
                    }
                }
            }
        }
コード例 #19
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            if (m_haveSaved)
            {
                if (!ServiceProvider.GetService <IMessageBox>().ShowYesNoDefaultNo("已保存过一次,是否再次保存(会导致2份记录)?", "确认"))
                {
                    return;
                }
            }
            int cnt = 0;

            IBatchDao batchDao = m_cm.Dao as IBatchDao;

            if (batchDao == null)
            {
                ServiceProvider.GetService <IMessageBox>().ShowWarning("不支持批量保存,将逐条保存!");
            }

            try
            {
                m_cm.CancelEdit();
                MyGrid.CancelEditCurrentDataRow(m_excelGrid);

                if (batchDao != null)
                {
                    batchDao.SuspendOperation();
                }

                foreach (Xceed.Grid.DataRow row in m_excelGrid.DataRows)
                {
                    bool hasValue = false;
                    foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(m_excelGrid.GridName))
                    {
                        if (row.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName))
                        {
                            if (row.Cells[info.GridColumnName].ReadOnly)
                            {
                                continue;
                            }
                            if (row.Cells[info.GridColumnName].Value != null)
                            {
                                hasValue = true;
                            }
                        }
                    }
                    if (!hasValue)
                    {
                        continue;
                    }

                    object entity = m_cm.AddNew();
                    if (entity == null)
                    {
                        continue;
                    }

                    foreach (GridColumnInfo info in ADInfoBll.Instance.GetGridColumnInfos(m_excelGrid.GridName))
                    {
                        if (row.Cells[info.GridColumnName] != null && !string.IsNullOrEmpty(info.PropertyName))
                        {
                            if (row.Cells[info.GridColumnName].ReadOnly)
                            {
                                continue;
                            }

                            EntityScript.SetPropertyValue(entity, info.Navigator, info.PropertyName, row.Cells[info.GridColumnName].Value);
                        }
                    }

                    m_cm.EndEdit(false);

                    m_cm.Dao.Save(entity);
                    cnt++;
                }
                if (batchDao != null)
                {
                    batchDao.ResumeOperation();
                }

                m_haveSaved = true;
                MessageForm.ShowInfo(string.Format("已保存{0}条记录!", cnt));
            }
            catch (Exception ex)
            {
                if (batchDao != null)
                {
                    batchDao.CancelSuspendOperation();
                }
                ExceptionProcess.ProcessWithNotify(ex);
            }
        }
コード例 #20
0
ファイル: process_fy_yw.cs プロジェクト: qq5013/mERP-CD
        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);
                    }
                }
            }
        }
コード例 #21
0
ファイル: process_pz.cs プロジェクト: qq5013/mERP-HD
        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();
            }
        }
コード例 #22
0
 public static bool DoSaveS(IControlManager cm)
 {
     if (cm.SaveCurrent())
     {
         return cm.EndEdit(true);
     }
     else
     {
         return false;
     }
 }