Пример #1
0
        //删除结点
        public void DeleteNode(TreeListNode tln)
        {
            if (tln.HasChildren) {
                for (int i = 0; i < tln.Nodes.Count; i++) {
                    DeleteNode(tln.Nodes[i]);
                }
                DeleteNode(tln);
            } else {
                Ps_pdreltype pf = new Ps_pdreltype();
                pf.ID = tln["ID"].ToString();
                string nodestr = tln["Title"].ToString();
                try {
                    TreeListNode node = tln.TreeList.FindNodeByKeyID(pf.ID);
                    if (node != null)
                        tln.TreeList.DeleteNode(node);
                    RemoveDataTableRow(dataTable, pf.ID);
                    Ps_pdtypenode pn = new Ps_pdtypenode();
                    pn.pdreltypeid = pf.ID;
                    Itop.Client.Common.Services.BaseService.Update("DeletePs_pdtypepdreltypeid", pn);
                    Itop.Client.Common.Services.BaseService.Delete<Ps_pdreltype>(pf);

                } catch (Exception e) {

                    MessageBox.Show(e.Message + "删除结点出错!");
                }

            }
        }
Пример #2
0
        //��������豸Ԫ����ʱ��
        private void xtraTabControl1_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            if (xtraTabControl1.SelectedTabPage.Name == "xtraTabPage4")
            {
                if (newflag)
                {
                    //����һ���ɿ��Է����ķ��� ��id�����ߵ�ID��ͬ��
                    //�����жϴ����������ݿ���û��
                    PSPDEV obj = Services.BaseService.GetOneByKey<PSPDEV>(dev);
                    if (obj==null)
                    {
                        MessageBox.Show("����·��û�б��浽���ݿ��У��뱣����ٲ�����");
                        return;
                    }
                    //���������ͬ��������ɾ��ԭ����
                    Ps_pdreltype pdr = new Ps_pdreltype();
                    pdr.ID = dev.SUID;
                    pdr = Services.BaseService.GetOneByKey<Ps_pdreltype>(pdr);
                    if (pdr!=null)
                    {
                        Ps_pdtypenode pn2 = new Ps_pdtypenode();
                        pn2.pdreltypeid = pdr.ID;
                        Services.BaseService.Update("DeletePs_pdtypepdreltypeid", pn2);
                        Services.BaseService.Delete<Ps_pdreltype>(pdr);
                    }
                    pdr = new Ps_pdreltype();
                    pdr.ID = dev.SUID;
                    pdr.ProjectID = this.ProjectSUID;
                    pdr.Createtime = DateTime.Now;
                    pdr.Title = textEdit1.Text;
                    pdr.S1 = dev.IName;
                    //pdr.PeopleSum = PDT.Peplesum;
                    //pdr.AreaName = PDT.Areaname;
                    //pdr.Year = PDT.Year;
                    Services.BaseService.Create<Ps_pdreltype>(pdr);
                    //������Դ
                    Ps_pdtypenode pn = new Ps_pdtypenode();
                    pn.pdreltypeid = pdr.ID;
                    pn.devicetype = "01";
                    PSPDEV devzx = new PSPDEV();
                    devzx.SUID = pdr.S1;
                    devzx = Services.BaseService.GetOneByKey<PSPDEV>(devzx);
                    if (devzx != null)
                    {
                        pn.title = devzx.Name;
                        pn.DeviceID = devzx.SUID;
                    }
                    else
                    {
                        pn.title = "�޵�Դ"+pdr.Title;

                    }
                    pn.Code = "0";
                    Services.BaseService.Create<Ps_pdtypenode>(pn);

                   //���������Ԫ����
                    Ps_pdtypenode pn1 = new Ps_pdtypenode();
                    pn1.ID = dev.SUID;
                    pn1.title = textEdit1.Text;
                    pn1.pdreltypeid = pdr.ID;
                    pn1.devicetype = "73";
                    pn1.DeviceID = dev.SUID;
                    pn1.ParentID = pn.ID;
                    pn1.Code = "111";
                    Services.BaseService.Create<Ps_pdtypenode>(pn1);
                    //�����֧·��Ϣ ���ҵ��������� ������������
                    //if (!string.IsNullOrEmpty(dev.JName))
                    //{
                    //    pn = new Ps_pdtypenode();
                    //    pn.ID = dev.JName;
                    //    pn = Services.BaseService.GetOneByKey<Ps_pdtypenode>(pn);
                    //    if (pn!=null)
                    //    {
                    //        pn1 = new Ps_pdtypenode();

                    //        pn1.title = textEdit1.Text;
                    //        pn1.pdreltypeid =pn.pdreltypeid;
                    //        pn1.devicetype = "73";
                    //        pn1.DeviceID = dev.SUID;
                    //        pn1.ParentID = pn.ID;
                    //        pn1.Code = "211";
                    //        Services.BaseService.Create<Ps_pdtypenode>(pn1);
                    //    }
                    //}
                    AddPDtypenode(pn1, "2", pn1.pdreltypeid);
                }
                else
                {
                    Ps_pdreltype pdr = new Ps_pdreltype();
                    pdr.ID = dev.SUID;
                    pdr = Services.BaseService.GetOneByKey<Ps_pdreltype>(pdr);
                    if (pdr!=null)
                    {
                        pdr.Title = textEdit1.Text;
                        pdr.S1 = dev.IName;
                        Services.BaseService.Update<Ps_pdreltype>(pdr);
                        //�޸ĵ�Դ��Ϣ
                        IList<Ps_pdtypenode> list1 = Services.BaseService.GetList<Ps_pdtypenode>("SelectPs_pdtypenodeByCon", "pdreltypeid='" + pdr.ID + "' and devicetype = '01'");
                        Ps_pdtypenode pn = new Ps_pdtypenode();
                        if (list1.Count>0)
                      {
                          pn = list1[0];
                          pn.DeviceID = dev.IName;
                          Services.BaseService.Update<Ps_pdtypenode>(pn);
                      }
                        else
                      {

                          pn.pdreltypeid = pdr.ID;
                          pn.devicetype = "01";
                          PSPDEV devzx = new PSPDEV();
                          devzx.SUID = pdr.S1;
                          devzx = Services.BaseService.GetOneByKey<PSPDEV>(devzx);
                          if (devzx != null)
                          {
                              pn.title = devzx.Name;
                              pn.DeviceID = devzx.SUID;
                          }
                          else
                          {
                              pn.title = "�޵�Դ" + pdr.Title;

                          }
                          pn.Code = "0";
                          Services.BaseService.Create<Ps_pdtypenode>(pn);
                      }

                      //�޸Ĵ����߽ڵ����Ϣ

                      Ps_pdtypenode pdn = new Ps_pdtypenode();
                      pdn.ID = dev.SUID;
                      pdn = Services.BaseService.GetOneByKey<Ps_pdtypenode>(pdn);
                        if (pdn!=null)
                        {
                            pdn.title = dev.Name;
                            pdn.devicetype = "73";
                            pdn.ParentID = pn.ID;
                            Services.BaseService.Update<Ps_pdtypenode>(pdn);
                        }
                        else
                        {
                            pdn = new Ps_pdtypenode();
                            pdn.ID = dev.SUID;
                            pdn.title = textEdit1.Text;
                            pdn.pdreltypeid = pdr.ID;
                            pdn.devicetype = "73";
                            pdn.DeviceID = dev.SUID;
                            pdn.ParentID = pn.ID;
                            pdn.Code = "111";
                            Services.BaseService.Create<Ps_pdtypenode>(pdn);
                        }
                     //�ҵ�������Ϣ �޸�������Ϣ
                        DeleteNode(pdn);
                        AddPDtypenode(pdn, "2", pdn.pdreltypeid);

                    }
                    else
                    {
                        pdr = new Ps_pdreltype();
                        pdr.ID = dev.SUID;
                        pdr.ProjectID = this.ProjectSUID;
                        pdr.Createtime = DateTime.Now;
                        pdr.Title = textEdit1.Text;
                        pdr.S1 = dev.IName;
                        //pdr.PeopleSum = PDT.Peplesum;
                        //pdr.AreaName = PDT.Areaname;
                        //pdr.Year = PDT.Year;
                        Services.BaseService.Create<Ps_pdreltype>(pdr);
                        //������Դ
                        Ps_pdtypenode pn = new Ps_pdtypenode();
                        pn.pdreltypeid = pdr.ID;
                        pn.devicetype = "01";
                        PSPDEV devzx = new PSPDEV();
                        devzx.SUID = pdr.S1;
                        devzx = Services.BaseService.GetOneByKey<PSPDEV>(devzx);
                        if (devzx != null)
                        {
                            pn.title = devzx.Name;
                            pn.DeviceID = devzx.SUID;
                        }
                        else
                        {
                            pn.title = "�޵�Դ" + pdr.Title;

                        }
                        pn.Code = "0";
                        Services.BaseService.Create<Ps_pdtypenode>(pn);
                        //���������Ԫ����
                        Ps_pdtypenode pn1 = new Ps_pdtypenode();
                        pn1.ID = dev.SUID;
                        pn1.title = textEdit1.Text;
                        pn1.pdreltypeid = pdr.ID;
                        pn1.devicetype = "73";
                        pn1.DeviceID = dev.SUID;
                        pn1.ParentID = pn.ID;
                        pn1.Code = "111";
                        Services.BaseService.Create<Ps_pdtypenode>(pn1);
                        //if (!string.IsNullOrEmpty(dev.JName))
                        //{
                        //    pn = new Ps_pdtypenode();
                        //    pn.ID = dev.JName;
                        //    pn = Services.BaseService.GetOneByKey<Ps_pdtypenode>(pn);
                        //    if (pn != null)
                        //    {
                        //        pn1 = new Ps_pdtypenode();

                        //        pn1.title = textEdit1.Text;
                        //        pn1.pdreltypeid = pn.pdreltypeid;
                        //        pn1.devicetype = "73";
                        //        pn1.DeviceID = dev.SUID;
                        //        pn1.ParentID = pn.ID;
                        //        pn1.Code = "211";
                        //        Services.BaseService.Create<Ps_pdtypenode>(pn1);
                        //    }
                        //}
                        AddPDtypenode(pn1, "2", pn1.pdreltypeid);
                    }

                    //pdr.PeopleSum = PDT.Peplesum;
                    //pdr.AreaName = PDT.Areaname;
                    //pdr.Year = PDT.Year;

                }
                  //�ж���֧·�Ƿ���Ԫ�� ���û�� Ȼ���ж�����û������Ԫ�� ����
                //Ps_pdtypenode pnf = new Ps_pdtypenode();
                //pnf.ID = dev.SUID;
                //pnf = Services.BaseService.GetOneByKey<Ps_pdtypenode>(pnf);
                //   string sql = "where JName='" + dev.SUID + "' and type='73' ";
                //   IList<PSPDEV> list = UCDeviceBase.DataService.GetList<PSPDEV>("SelectPSPDEVByCondition", sql);
                //if (list.Count>0)
                //{
                //    int count = 0;
                //    foreach (PSPDEV ps in list)
                //    {
                //        count++;
                //        sql = "pdreltypeid='" + dev.SUID + "'and devicetype='73'and deviceID='" + ps.SUID + "'";
                //        Ps_pdtypenode ptn = UCDeviceBase.DataService.GetObject("SelectPs_pdtypenodeByCon", sql) as Ps_pdtypenode;
                //        if (ptn!=null)
                //        {
                //            //�ж��丽���Ԫ��û�������
                //            AddPDtypenode(ps.SUID, (Convert.ToInt32(ptn.Code.Substring(0, 1)) + 1).ToString(), dev.SUID);
                //        }
                //        else
                //        {
                //            Ps_pdtypenode pn1 = new Ps_pdtypenode();

                //            pn1.title = ps.Name;
                //            pn1.pdreltypeid = dev.SUID;
                //            pn1.devicetype = "73";
                //            pn1.DeviceID = ps.SUID;
                //            pn1.ParentID = dev.SUID;
                //            pn1.Code =(Convert.ToInt32(pnf.Code.Substring(0,1))+1).ToString()+"1"+count.ToString();
                //            Services.BaseService.Create<Ps_pdtypenode>(pn1);
                //        }
                //    }
                //}
                ucdxchildnode1.DXObj = dev;

            }
        }
Пример #3
0
 void ucPdtype1_FocusedNodeChanged(object sender, Ps_pdreltype e)
 {
     ucPdtypenode1.ParentObj = e;
 }
Пример #4
0
        //private void UcPdtype_Load(object sender, EventArgs e) {
        //    init();
        //}
        private void treeList1_MouseClick(object sender, MouseEventArgs e)
        {
            if (FocusedNodeChanged != null) {
                if (treeList1.FocusedNode!=null)
                {
                    TreeListNode tn = treeList1.FocusedNode;
                    Ps_pdreltype pdr = new Ps_pdreltype();
                    pdr.ID = tn["ID"].ToString();
                    pdr = Services.BaseService.GetOneByKey<Ps_pdreltype>(pdr);
                    FocusedNodeChanged(treeList1, pdr);
                }

            }
        }
Пример #5
0
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            PDreltypefrmedit PDT = new PDreltypefrmedit();
            if (PDT.ShowDialog()==DialogResult.OK)
            {
                Ps_pdreltype pdr = new Ps_pdreltype();
                pdr.ProjectID = Itop.Client.MIS.ProgUID;
                pdr.Createtime = DateTime.Now;
                pdr.Title = PDT.Title;
                pdr.S1 = PDT.S1;
                //pdr.PeopleSum = PDT.Peplesum;
                //pdr.AreaName = PDT.Areaname;
                //pdr.Year = PDT.Year;
                Services.BaseService.Create<Ps_pdreltype>(pdr);
                //创建电源
                Ps_pdtypenode pn = new Ps_pdtypenode();
                pn.pdreltypeid = pdr.ID;
                pn.devicetype = "01";
                PSPDEV devzx = new PSPDEV();
                devzx.SUID =pdr. S1;
                devzx = Services.BaseService.GetOneByKey<PSPDEV>(devzx);
                if (devzx != null)
                {
                    pn.title = devzx.Name;
                    pn.DeviceID = devzx.SUID;
                }
                else
                {
                    pn.title = pdr.Title;

                }
                pn.Code = "0";
                Services.BaseService.Create<Ps_pdtypenode>(pn);
                dataTable.Rows.Add(Itop.Common.DataConverter.ObjectToRow(pdr, dataTable.NewRow()));

                //init();
            }
        }
Пример #6
0
        public void init()
        {
            try {
                if (dataTable != null) {
                    dataTable.Columns.Clear();
                    treeList1.Columns.Clear();
                }
                AddFixColumn();
                Ps_pdreltype pr = new Ps_pdreltype();
                pr.ProjectID = Itop.Client.MIS.ProgUID;
                IList<Ps_pdreltype> listTypes = Services.BaseService.GetList<Ps_pdreltype>("SelectPs_pdreltypeByProjectID", pr);

                dataTable = Itop.Common.DataConverter.ToDataTable((IList)listTypes, typeof(Ps_pdreltype));
                treeList1.BeginInit();
                if (dataTable!=null)
                {
                    treeList1.DataSource = dataTable;
                }

                //treeList1.Columns["Sort"].SortOrder = SortOrder.Ascending;
                treeList1.EndInit();
                Application.DoEvents();
                treeList1.ExpandAll();
            } catch (System.Exception ex) {

            }
        }