Пример #1
0
        /// <summary>
        /// 修改焦点对象
        /// </summary>
        public void UpdateObject()
        {
            //获取焦点对象
            PSP_VolumeBalance_Calc obj = FocusedObject;

            if (obj == null)
            {
                return;
            }
            PSP_VolumeBalance_Calc objtemp = new PSP_VolumeBalance_Calc();

            objtemp.Title = obj.Title;
            objtemp.Type  = obj.Type;
            //创建对象的一个副本
            PSP_VolumeBalance_Calc objCopy = new PSP_VolumeBalance_Calc();

            DataConverter.CopyTo <PSP_VolumeBalance_Calc>(obj, objCopy);

            //执行修改操作
            using (FrmPSP_VolumeBalance_CalcDialog dlg = new FrmPSP_VolumeBalance_CalcDialog())
            {
                dlg.Object    = objCopy;                //绑定副本
                dlg.Type      = type;
                dlg.CtrTitle  = ctrtitle;
                dlg.FormTitle = FormTitle;
                if (type == "1" && dy == "220")
                {
                    dlg.editorRow2.Visible = true;
                }
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //用副本更新焦点对象
            DataConverter.CopyTo <PSP_VolumeBalance_Calc>(objCopy, obj);
            //刷新表格
            SaveSum();
            gridControl.RefreshDataSource();
            if (objtemp.Title != obj.Title)
            {
                if (obj.Type == "1")
                {
                    IList <PSP_VolumeBalance_Calc> list = Services.BaseService.GetList <PSP_VolumeBalance_Calc>("SelectPSP_VolumeBalance_CalcByTypeTitle", objtemp);
                    foreach (PSP_VolumeBalance_Calc pvm in list)
                    {
                        PSP_VolumeBalance_Calc pvc = new PSP_VolumeBalance_Calc();
                        pvc       = pvm;
                        pvc.Title = obj.Title;

                        Services.BaseService.Update <PSP_VolumeBalance_Calc>(pvc);
                    }
                }
            }
        }
        /// <summary>
        /// �޸Ľ������
        /// </summary>
        public void UpdateObject()
        {
            //��ȡ�������
            PSP_VolumeBalance_Calc obj = FocusedObject;
            if (obj == null)
            {
                return;
            }
            PSP_VolumeBalance_Calc objtemp = new PSP_VolumeBalance_Calc ();
            objtemp.Title = obj.Title;
            objtemp.Type = obj.Type;
            //���������һ������
            PSP_VolumeBalance_Calc objCopy = new PSP_VolumeBalance_Calc();
            DataConverter.CopyTo<PSP_VolumeBalance_Calc>(obj, objCopy);

            //ִ���޸IJ���
            using (FrmPSP_VolumeBalance_CalcDialog dlg = new FrmPSP_VolumeBalance_CalcDialog())
            {
                dlg.Object = objCopy;   //�󶨸���
                dlg.Type = type;
                dlg.CtrTitle = ctrtitle;
                dlg.FormTitle = FormTitle;
                if (type == "1" && dy == "220")
                    dlg.editorRow2.Visible = true;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //�ø������½������
            DataConverter.CopyTo<PSP_VolumeBalance_Calc>(objCopy, obj);
            //ˢ�±��
            SaveSum();
            gridControl.RefreshDataSource();
            if (objtemp.Title!=obj.Title)
             if (obj.Type == "1")
            {

                IList<PSP_VolumeBalance_Calc> list = Services.BaseService.GetList<PSP_VolumeBalance_Calc>("SelectPSP_VolumeBalance_CalcByTypeTitle", objtemp);
                foreach (PSP_VolumeBalance_Calc pvm in list)
                {
                    PSP_VolumeBalance_Calc pvc = new PSP_VolumeBalance_Calc();
                    pvc = pvm;
                    pvc.Title = obj.Title;

                    Services.BaseService.Update<PSP_VolumeBalance_Calc>(pvc);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 添加对象
        /// </summary>
        public void AddObject()
        {
            //检查对象链表是否已经加载
            if (ObjectList == null)
            {
                return;
            }
            //新建对象
            PSP_VolumeBalance_Calc obj = new PSP_VolumeBalance_Calc();

            obj.Flag       = flag;
            obj.Type       = type;
            obj.Col1       = dy;
            obj.CreateTime = DateTime.Now;

            //执行添加操作
            using (FrmPSP_VolumeBalance_CalcDialog dlg = new FrmPSP_VolumeBalance_CalcDialog())
            {
                dlg.IsCreate  = true;                   //设置新建标志
                dlg.Object    = obj;
                dlg.Type      = type;
                dlg.CtrTitle  = ctrtitle;
                dlg.FormTitle = FormTitle;
                if (type == "1" && dy == "220")
                {
                    dlg.editorRow2.Visible = true;
                }
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //将新对象加入到链表中
            ObjectList.Add(obj);
            SaveSum();
            //刷新表格,并将焦点行定位到新对象上。
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView, obj);
            if (obj.Type == "1")
            {
                PSP_VolumeBalance ob = new PSP_VolumeBalance();
                //ob.TypeID = dy;
                ob.UID = obj.Flag;
                //string s ="";
                IList <PSP_VolumeBalance> list = Services.BaseService.GetList <PSP_VolumeBalance>("SelectPSP_VolumeBalanceByKey", ob);
                if (list != null)
                {
                    if (list.Count == 1)
                    {
                        ob.Flag   = list[0].Flag;
                        ob.TypeID = list[0].TypeID;
                        //s = obj.Flag;
                        list.Clear();
                        list = Services.BaseService.GetList <PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeID", ob);
                        foreach (PSP_VolumeBalance pvm in list)
                        {
                            if (pvm.UID == ob.UID)
                            {
                                continue;
                            }
                            PSP_VolumeBalance_Calc pvc = new PSP_VolumeBalance_Calc();
                            pvc      = obj;
                            pvc.Flag = pvm.UID;
                            pvc.UID  = Guid.NewGuid().ToString();
                            pvc.Vol  = 0;
                            pvc.Col2 = "";
                            Services.BaseService.Create <PSP_VolumeBalance_Calc>(pvc);
                        }
                    }
                }
                RefreshData();
            }
        }
        /// <summary>
        /// ��Ӷ���
        /// </summary>
        public void AddObject()
        {
            //�����������Ƿ��Ѿ�����
            if (ObjectList == null)
            {
                return;
            }
            //�½�����
            PSP_VolumeBalance_Calc obj = new PSP_VolumeBalance_Calc();
            obj.Flag = flag;
            obj.Type = type;
            obj.Col1 = dy;
            obj.CreateTime = DateTime.Now;

            //ִ����Ӳ���
            using (FrmPSP_VolumeBalance_CalcDialog dlg = new FrmPSP_VolumeBalance_CalcDialog())
            {
                dlg.IsCreate = true;    //�����½���־
                dlg.Object = obj;
                dlg.Type = type;
                dlg.CtrTitle = ctrtitle;
                dlg.FormTitle = FormTitle;
                if (type == "1" && dy=="220")
                dlg.editorRow2.Visible = true;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //���¶�����뵽������
            ObjectList.Add(obj);
            SaveSum();
            //ˢ�±�񣬲��������ж�λ���¶����ϡ�
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView, obj);
            if (obj.Type == "1")
            {
                PSP_VolumeBalance ob = new PSP_VolumeBalance();
                //ob.TypeID = dy;
                ob.UID = obj.Flag;
                //string s ="";
                IList<PSP_VolumeBalance> list = Services.BaseService.GetList<PSP_VolumeBalance>("SelectPSP_VolumeBalanceByKey", ob);
                if(list!=null)
                    if (list.Count == 1)
                    {

                        ob.Flag = list[0].Flag;
                        ob.TypeID = list[0].TypeID;
                        //s = obj.Flag;
                        list.Clear();
                        list = Services.BaseService.GetList<PSP_VolumeBalance>("SelectPSP_VolumeBalanceByTypeID", ob);
                        foreach (PSP_VolumeBalance pvm in list)
                        {
                            if (pvm.UID == ob.UID)
                                continue;
                            PSP_VolumeBalance_Calc pvc = new PSP_VolumeBalance_Calc();
                            pvc = obj;
                            pvc.Flag = pvm.UID;
                            pvc.UID = Guid.NewGuid().ToString();
                            pvc.Vol = 0;
                            pvc.Col2 = "";
                            Services.BaseService.Create<PSP_VolumeBalance_Calc>(pvc);
                        }
                    }
                RefreshData();
            }
        }