/// <summary>
        /// ɾ���������
        /// </summary>
        public void DeleteObject()
        {
            //��ȡ�������
            PowerProjectList obj = FocusedObject;
            if (obj == null)
            {
                return;
            }

            PowerProject pp=new PowerProject();
            pp.PowerLineUID=obj.UID;

            IList<PowerProject> li= Services.BaseService.GetList<PowerProject>("SelectPowerProjectList", pp);
            if (li.Count > 0)
            {
                MsgBox.Show("�÷���������������Ŀ���¼���޷�ɾ��");
                return;
            }

            //����ȷ��
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                return;
            }

            //ִ��ɾ������
            try
            {
                Services.BaseService.Delete<PowerProjectList>(obj);
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return;
            }

            this.gridView.BeginUpdate();
            //��ס��ǰ����������
            int iOldHandle = this.gridView.FocusedRowHandle;
            //��������ɾ��
            ObjectList.Remove(obj);
            //ˢ�±��
            gridControl.RefreshDataSource();
            //�����µĽ���������
            GridHelper.FocuseRowAfterDelete(this.gridView, iOldHandle);
            this.gridView.EndUpdate();
        }
Beispiel #2
0
        /// <summary>
        /// �޸Ľ������
        /// </summary>
        public void UpdateObject()
        {
            if (treeList1.FocusedNode == null)
                return;

            string uid = treeList1.FocusedNode["UID"].ToString();
            PowerProject obj = Services.BaseService.GetOneByKey<PowerProject>(uid);
            PowerProject objCopy = new PowerProject();
            DataConverter.CopyTo<PowerProject>(obj, objCopy);

            FrmPowerProjectDialog dlg = new FrmPowerProjectDialog();
            dlg.Object = objCopy;

            if (dlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            DataConverter.CopyTo<PowerProject>(objCopy, obj);
            treeList1.FocusedNode.SetValue("StuffName", obj.StuffName);
            treeList1.FocusedNode.SetValue("Lengths", obj.Lengths);
            treeList1.FocusedNode.SetValue("Volume", obj.Volume);
            treeList1.FocusedNode.SetValue("Type", obj.Type);
            treeList1.FocusedNode.SetValue("Total", obj.Total);
            treeList1.FocusedNode.SetValue("PlanStartYear", obj.PlanStartYear);
            treeList1.FocusedNode.SetValue("PlanEndYear", obj.PlanEndYear);
        }
Beispiel #3
0
        /// <summary>
        /// ��Ӷ���
        /// </summary>
        public void AddObject()
        {
            int count = 0;
            string parentid = "";
            if (treeList1.FocusedNode != null)
            {
                parentid = treeList1.FocusedNode["ParentID"].ToString();
            }

            object objs = Services.BaseService.GetObject("SelectPowerProjectBySortID", parentid);
            if (objs != null)
                count = (int)objs;

            PowerProject obj = new PowerProject();
            obj.SortID = count + 1;
            obj.ParentID = parentid;
            obj.PowerLineUID = lineuid;
            using (FrmPowerProjectDialog dlg = new FrmPowerProjectDialog())
            {
                dlg.IsCreate = true;    //�����½���־
                dlg.Object = obj;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            dataTable.Rows.Add(DataConverter.ObjectToRow(obj, dataTable.NewRow()));
        }
Beispiel #4
0
        /// <summary>
        /// ˢ�±���е�����
        /// </summary>
        /// <returns>ture:�ɹ�  false:ʧ��</returns>
        public bool RefreshData()
        {
            try
            {
                PowerProject pp = new PowerProject();
                pp.PowerLineUID = lineuid;

                list.Clear();
                list = Services.BaseService.GetList<PowerProject>("SelectPowerProjectList", pp);
                dataTable=new DataTable();

                dataTable = DataConverter.ToDataTable((IList)list, typeof(PowerProject));

                //foreach (PowerProject pp in list)
                //{
                //    if (pp.ParentID != "")
                //        pp.StuffName = "   " + pp.StuffName;
                //}

                this.treeList1.DataSource = dataTable;

                this.treeList1.ExpandAll();

                treeList1.MoveFirst();
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return false;
            }

            return true;
        }