private void btnOK_Click(object sender, EventArgs e)
        {
            if (isselect)
            {
                DialogResult = DialogResult.OK;
                return;
            }

            if (!InputCheck())
            {
                return;
            }

            if (SaveRecord())
            {
                if (checkEdit1.Checked)
                {
                    ctrls.RefreshData();
                    _obj            = new PSP_PowerSubstationInfo();
                    _obj.Flag       = flags1 + "|" + Itop.Client.MIS.ProgUID.Substring(0, 20);
                    _obj.CreateDate = DateTime.Now;
                    IList <PSP_PowerSubstationInfo> list1 = new List <PSP_PowerSubstationInfo>();
                    list1.Add(_obj);
                    this.vGridControl.DataSource = list1;
                }
                else
                {
                    DialogResult = DialogResult.OK;
                }
            }
        }
Beispiel #2
0
 public void InitGrid2()
 {
     IList<PSP_PowerSubstationInfo> list = new List<PSP_PowerSubstationInfo>();
     PSP_PowerSubstationInfo info = new PSP_PowerSubstationInfo();
     info.Title = "现状";
     list.Add(info);
     PSP_PowerSubstationInfo info1 = new PSP_PowerSubstationInfo();
     info1.Title = "规划";
     list.Add(info1);
     this.gridControl2.DataSource = list;
 }
Beispiel #3
0
        /// <summary>
        /// 删除焦点对象
        /// </summary>
        public void DeleteObject()
        {
            //获取焦点对象
            PSP_PowerSubstationInfo obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

            //请求确认
            if (MsgBox.ShowYesNo(Strings.SubmitDelete) != DialogResult.Yes)
            {
                return;
            }

            //执行删除操作
            try
            {
                //  Services.BaseService.Delete<PSP_PowerSubstationInfo>(obj);
                Services.BaseService.Update("DeletePSP_PowerSubstationInfoByUID", obj.UID);
            }
            catch (Exception exc)
            {
                Debug.Fail(exc.Message);
                HandleException.TryCatch(exc);
                return;
            }

            this.gridView1.BeginUpdate();
            //记住当前焦点行索引
            int iOldHandle = this.gridView1.FocusedRowHandle;

            //从链表中删除
            ObjectList.Remove(obj);
            //刷新表格
            gridControl.RefreshDataSource();
            //设置新的焦点行索引
            GridHelper.FocuseRowAfterDelete(this.gridView1, iOldHandle);
            this.gridView1.EndUpdate();
        }
Beispiel #4
0
        /// <summary>
        /// 添加对象
        /// </summary>
        public void AddObject()
        {
            //检查对象链表是否已经加载
            if (ObjectList == null)
            {
                return;
            }
            //新建对象
            PSP_PowerSubstationInfo obj = new PSP_PowerSubstationInfo();

            obj.Flag       = flags1;
            obj.CreateDate = DateTime.Now;

            //执行添加操作
            using (FrmPSP_PowerDialog dlg = new FrmPSP_PowerDialog())
            {
                //dlg.Text = "";
                //dlg.Type = types1;
                dlg.Flag  = flags1;
                dlg.Type2 = types2;
                dlg.ctrlPSP_PowerSubstationInfo = this;
                dlg.Text     = this.text;
                dlg.IsCreate = true;    //设置新建标志
                dlg.Object   = obj;
                dlg.rowTitle.Properties.Caption     = this.colTitle.Caption;
                dlg.rowPowerName.Properties.Caption = this.colPowerName.Caption;
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //将新对象加入到链表中
            ObjectList.Add(obj);

            //刷新表格,并将焦点行定位到新对象上。
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView1, obj);
        }
Beispiel #5
0
        /// <summary>
        /// 修改焦点对象
        /// </summary>
        public void UpdateObject()
        {
            //获取焦点对象
            PSP_PowerSubstationInfo obj = FocusedObject;

            if (obj == null)
            {
                return;
            }

            //创建对象的一个副本
            PSP_PowerSubstationInfo objCopy = new PSP_PowerSubstationInfo();

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

            //执行修改操作
            using (FrmPSP_PowerDialog dlg = new FrmPSP_PowerDialog())
            {
                dlg.IsSelect = isselect;
                dlg.Type     = types1;
                dlg.Flag     = flags1;
                dlg.Type2    = types2;
                dlg.Text     = this.text;
                dlg.ctrlPSP_PowerSubstationInfo = this;

                dlg.Object = objCopy;   //绑定副本
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //用副本更新焦点对象
            DataConverter.CopyTo <PSP_PowerSubstationInfo>(objCopy, obj);
            //刷新表格
            gridControl.RefreshDataSource();
        }
        private void barDel1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            GridColumn gc = this.ctrlPSP_PowerSubstationInfo1.GridView.FocusedColumn;
               if (gc == null)
               return;

               if (gc.FieldName.Substring(0, 1) != "S")
               {
               MsgBox.Show("����ɾ���̶���");
               return;
               }
               bool bl = false;
            for(int i=0;i<ctrlPSP_PowerSubstationInfo1.GridView.VisibleColumns.Count;i++)
            {
                if (gc.Caption == ctrlPSP_PowerSubstationInfo1.GridView.VisibleColumns[i].Caption)
                {
                    if (MsgBox.ShowYesNo("�Ƿ�ɾ�� " + gc.Caption + " ���������ݣ�") != DialogResult.Yes)
                    {
                        return;
                    }
                    bl = true;
                    break;
                }
                else
                {
                    bl = false;
                }

            }
            if (bl == true)
            {
                int colIndex = ctrlPSP_PowerSubstationInfo1.GridView.FocusedColumn.VisibleIndex;

                foreach (GridColumn gc1 in ctrlPSP_PowerSubstationInfo1.GridView.Columns)
                {
                    try
                    {
                        if (gc1.Name == gc.Name)
                        {
                            gc1.Visible = false;
                        }
                    }
                    catch { }
                }

                gc.Visible = false;
                gc.OptionsColumn.ShowInCustomizationForm = false;
                PSP_PowerSubstationInfo si = new PSP_PowerSubstationInfo();
                si.Title = gc.FieldName + "=''";
                si.Flag = flag;
                Itop.Client.Common.Services.BaseService.Update("UpdatePSP_PowerSubstationInfoByFlag", si);

                PowerSubstationLine psl = new PowerSubstationLine();
                psl.ClassType = gc.FieldName;
                psl.Flag = flag;
                //psl.Type = type;
                psl.Title = gc.Caption;
                psl.Type2="PowerSubstation" + "|" + Itop.Client.MIS.ProgUID.Substring(0, 20);
                Itop.Client.Common.Services.BaseService.Update("DeletePowerSubstationLineByNoType", psl);

                if (colIndex >= ctrlPSP_PowerSubstationInfo1.GridView.VisibleColumns.Count)
                {
                    colIndex--;
                }
                ctrlPSP_PowerSubstationInfo1.GridView.FocusedColumn = ctrlPSP_PowerSubstationInfo1.GridView.VisibleColumns[colIndex];

            }
            else
            {
                return;
            }
        }
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string columnname = "";
            try
            {

                DataTable dts = new DataTable();
                OpenFileDialog op = new OpenFileDialog();
                op.Filter = "Excel�ļ�(*.xls)|*.xls";

                if (op.ShowDialog() == DialogResult.OK)
                {
                    dts = GetExcel(op.FileName);

                    IList<PSP_PowerSubstationInfo> lii = new List<PSP_PowerSubstationInfo>();

                    //string year = dts.Rows[0][0].ToString();
                    //string da = dts.Rows[1][1].ToString();
                    DateTime dt= DateTime.Now;
                    for (int i =0; i < dts.Rows.Count; i++)
                    {
                        PSP_PowerSubstationInfo li = new PSP_PowerSubstationInfo();

                            li.Title = dts.Rows[i][0].ToString();

                            li.Flag = "1"+ "|" + Itop.Client.MIS.ProgUID.Substring(0, 20);
                            li.UID = Guid.NewGuid().ToString();
                            li.CreateDate = dt.AddSeconds(i);
                           // li.S1 = dts.Rows[i][1].ToString();

                            foreach (DataColumn dc in dts.Columns)
                            {
                                columnname = dc.ColumnName;
                                if (dts.Rows[i][dc.ColumnName].ToString() == "")
                                    continue;

                                string LL2 = "";
                                try
                                {
                                    LL2 = dts.Rows[i][dc.ColumnName].ToString();
                                }
                                catch { }
                                li.GetType().GetProperty(dc.ColumnName).SetValue(li, LL2, null);

                            }
                            //try { li.PowerName = dts.Rows[i][1].ToString(); }
                            //catch { }
                            //try { li.S1 = dts.Rows[i][2].ToString(); }
                            //catch { }
                            //try { li.S2 = dts.Rows[i][3].ToString(); }
                            //catch { }

                            //try { li.S3 = dts.Rows[i][4].ToString(); }
                            //catch { }

                            //try { li.S4 = dts.Rows[i][5].ToString(); }
                            //catch { }

                            //try { li.S5 = dts.Rows[i][6].ToString(); }
                            //catch { }

                            //try { li.S6 = dts.Rows[i][7].ToString(); }
                            //catch { }

                            //try { li.S7 = dts.Rows[i][8].ToString(); }
                            //catch { }

                            //try { li.S8 = dts.Rows[i][9].ToString(); }
                            //catch { }

                            //try { li.S9 = dts.Rows[i][10].ToString(); }
                            //catch { }

                            //try { li.S10 = dts.Rows[i][11].ToString(); }
                            //catch { }

                            //try { li.S11 = dts.Rows[i][12].ToString(); }
                            //catch { }

                            //try { li.S12 = dts.Rows[i][13].ToString(); }
                            //catch { }

                            //try { li.S13 = dts.Rows[i][14].ToString(); }
                            //catch { }
                            //try { li.S14 = dts.Rows[i][15].ToString(); }
                            //catch { }
                            //try { li.S15 = dts.Rows[i][16].ToString(); }
                            //catch { }

                            //try { li.S16 = dts.Rows[i][17].ToString(); }
                            //catch { }

                            //try { li.S17 = dts.Rows[i][18].ToString(); }
                            //catch { }

                            //try { li.S18 = dts.Rows[i][19].ToString(); }
                            //catch { }

                            //try { li.S19 = dts.Rows[i][20].ToString(); }
                            //catch { }

                            //try { li.S20 = dts.Rows[i][21].ToString(); }
                            //catch { }
                            lii.Add(li);

                    }

                    foreach (PSP_PowerSubstationInfo lll in lii)
                    {
                      Services.BaseService.Update("UpdatePSP_PowerSubstationInfo", lll);

                    }

                    this.ctrlPSP_PowerSubstationInfo1.RefreshData1();

                }
            }
            catch { MessageBox.Show(columnname+"�����ʽ����ȷ��"); }
        }
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string columnname = "";

            try
            {
                DataTable      dts = new DataTable();
                OpenFileDialog op  = new OpenFileDialog();
                op.Filter = "Excel文件(*.xls)|*.xls";

                if (op.ShowDialog() == DialogResult.OK)
                {
                    dts = GetExcel(op.FileName);

                    IList <PSP_PowerSubstationInfo> lii = new List <PSP_PowerSubstationInfo>();

                    //string year = dts.Rows[0][0].ToString();
                    //string da = dts.Rows[1][1].ToString();
                    DateTime dt = DateTime.Now;
                    for (int i = 0; i < dts.Rows.Count; i++)
                    {
                        PSP_PowerSubstationInfo li = new PSP_PowerSubstationInfo();

                        li.Title = dts.Rows[i][0].ToString();

                        li.Flag       = "1" + "|" + Itop.Client.MIS.ProgUID.Substring(0, 20);
                        li.UID        = Guid.NewGuid().ToString();
                        li.CreateDate = dt.AddSeconds(i);
                        // li.S1 = dts.Rows[i][1].ToString();

                        foreach (DataColumn dc in dts.Columns)
                        {
                            columnname = dc.ColumnName;
                            if (dts.Rows[i][dc.ColumnName].ToString() == "")
                            {
                                continue;
                            }

                            string LL2 = "";
                            try
                            {
                                LL2 = dts.Rows[i][dc.ColumnName].ToString();
                            }
                            catch { }
                            li.GetType().GetProperty(dc.ColumnName).SetValue(li, LL2, null);
                        }
                        //try { li.PowerName = dts.Rows[i][1].ToString(); }
                        //catch { }
                        //try { li.S1 = dts.Rows[i][2].ToString(); }
                        //catch { }
                        //try { li.S2 = dts.Rows[i][3].ToString(); }
                        //catch { }

                        //try { li.S3 = dts.Rows[i][4].ToString(); }
                        //catch { }

                        //try { li.S4 = dts.Rows[i][5].ToString(); }
                        //catch { }

                        //try { li.S5 = dts.Rows[i][6].ToString(); }
                        //catch { }

                        //try { li.S6 = dts.Rows[i][7].ToString(); }
                        //catch { }

                        //try { li.S7 = dts.Rows[i][8].ToString(); }
                        //catch { }

                        //try { li.S8 = dts.Rows[i][9].ToString(); }
                        //catch { }

                        //try { li.S9 = dts.Rows[i][10].ToString(); }
                        //catch { }

                        //try { li.S10 = dts.Rows[i][11].ToString(); }
                        //catch { }

                        //try { li.S11 = dts.Rows[i][12].ToString(); }
                        //catch { }

                        //try { li.S12 = dts.Rows[i][13].ToString(); }
                        //catch { }


                        //try { li.S13 = dts.Rows[i][14].ToString(); }
                        //catch { }
                        //try { li.S14 = dts.Rows[i][15].ToString(); }
                        //catch { }
                        //try { li.S15 = dts.Rows[i][16].ToString(); }
                        //catch { }


                        //try { li.S16 = dts.Rows[i][17].ToString(); }
                        //catch { }

                        //try { li.S17 = dts.Rows[i][18].ToString(); }
                        //catch { }

                        //try { li.S18 = dts.Rows[i][19].ToString(); }
                        //catch { }

                        //try { li.S19 = dts.Rows[i][20].ToString(); }
                        //catch { }

                        //try { li.S20 = dts.Rows[i][21].ToString(); }
                        //catch { }
                        lii.Add(li);
                    }

                    foreach (PSP_PowerSubstationInfo lll in lii)
                    {
                        Services.BaseService.Update("UpdatePSP_PowerSubstationInfo", lll);
                    }

                    this.ctrlPSP_PowerSubstationInfo1.RefreshData1();
                }
            }
            catch { MessageBox.Show(columnname + "导入格式不正确!"); }
        }
        private void barDel1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            GridColumn gc = this.ctrlPSP_PowerSubstationInfo1.GridView.FocusedColumn;

            if (gc == null)
            {
                return;
            }

            if (gc.FieldName.Substring(0, 1) != "S")
            {
                MsgBox.Show("不能删除固定列");
                return;
            }
            bool bl = false;

            for (int i = 0; i < ctrlPSP_PowerSubstationInfo1.GridView.VisibleColumns.Count; i++)
            {
                if (gc.Caption == ctrlPSP_PowerSubstationInfo1.GridView.VisibleColumns[i].Caption)
                {
                    if (MsgBox.ShowYesNo("是否删除 " + gc.Caption + " 的所有数据?") != DialogResult.Yes)
                    {
                        return;
                    }
                    bl = true;
                    break;
                }
                else
                {
                    bl = false;
                }
            }
            if (bl == true)
            {
                int colIndex = ctrlPSP_PowerSubstationInfo1.GridView.FocusedColumn.VisibleIndex;

                foreach (GridColumn gc1 in ctrlPSP_PowerSubstationInfo1.GridView.Columns)
                {
                    try
                    {
                        if (gc1.Name == gc.Name)
                        {
                            gc1.Visible = false;
                        }
                    }
                    catch { }
                }

                gc.Visible = false;
                gc.OptionsColumn.ShowInCustomizationForm = false;
                PSP_PowerSubstationInfo si = new PSP_PowerSubstationInfo();
                si.Title = gc.FieldName + "=''";
                si.Flag  = flag;
                Itop.Client.Common.Services.BaseService.Update("UpdatePSP_PowerSubstationInfoByFlag", si);

                PowerSubstationLine psl = new PowerSubstationLine();
                psl.ClassType = gc.FieldName;
                psl.Flag      = flag;
                //psl.Type = type;
                psl.Title = gc.Caption;
                psl.Type2 = "PowerSubstation" + "|" + Itop.Client.MIS.ProgUID.Substring(0, 20);
                Itop.Client.Common.Services.BaseService.Update("DeletePowerSubstationLineByNoType", psl);


                if (colIndex >= ctrlPSP_PowerSubstationInfo1.GridView.VisibleColumns.Count)
                {
                    colIndex--;
                }
                ctrlPSP_PowerSubstationInfo1.GridView.FocusedColumn = ctrlPSP_PowerSubstationInfo1.GridView.VisibleColumns[colIndex];
            }
            else
            {
                return;
            }
        }
Beispiel #10
0
 private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (this.gridView2.FocusedRowHandle >= 0)
     {
         FrmAddPowerState frm = new FrmAddPowerState();
         frm.Area = this;
         frm.Text = "添加记录";
         frm.IsCreate = true;
         frm.ProjectID = ProjectID;
         string f = this.gridView2.GetRowCellValue(this.gridView2.FocusedRowHandle, "Title").ToString();
         if (f == "现状")
             f = "1";
         else if (f == "规划")
             f = "2";
         frm.Flag = f;
         PSP_PowerSubstationInfo obj = new PSP_PowerSubstationInfo();
         obj.UID = Guid.NewGuid().ToString();
         frm.Object = obj;
         if (frm.ShowDialog() == DialogResult.OK)
         {
             frm.Close();
             InitGrid1();
         }
     }
     else
     {
         MessageBox.Show("请先选择规划或现状", "添加", MessageBoxButtons.OK);
     }
 }
Beispiel #11
0
 private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     if (this.gridView2.FocusedRowHandle > -1)
     {
         IList<string> filedList = new List<string>();
         IList<string> capList = new List<string>();
         for (int i = 0; i < gridView1.Columns.Count; i++)
         {
             capList.Add(gridView1.Columns[i].Caption);
             filedList.Add(gridView1.Columns[i].FieldName);
         }
         OpenFileDialog op = new OpenFileDialog();
         op.Filter = "Excel文件(*.xls)|*.xls";
         if (op.ShowDialog() == DialogResult.OK)
         {
             try
             {
                 DataTable table = OperTable.GetExcel(op.FileName, filedList, capList);
                 for (int i = 0; i < table.Rows.Count; i++)
                 {
                     if (table.Rows[i][0].ToString().IndexOf("合计") > 0 || table.Rows[i][1].ToString().IndexOf("合计") > 0)
                         continue;
                     PSP_PowerSubstationInfo area = new PSP_PowerSubstationInfo();
                     area.UID =Guid.NewGuid().ToString()+ "|" + ProjectID;
                     area.AreaID = ProjectID;
                     area.CreateDate = DateTime.Now;
                     string f = this.gridView2.GetRowCellValue(this.gridView2.FocusedRowHandle, "Title").ToString();
                     if (f == "现状")
                         f = "1";
                     else if (f == "规划")
                         f = "2";
                     area.Flag = f;
                     foreach (DataColumn col in table.Columns)
                     {
                         area.GetType().GetProperty(col.ColumnName).SetValue(area, table.Rows[i][col].ToString(), null);
                     }
                     Common.Services.BaseService.Create<PSP_PowerSubstationInfo>(area);
                 }
             }
             catch (Exception a) { MessageBox.Show(a.Message); }
             InitGrid1();
         }
     }
     else
         MessageBox.Show("没有选择规划或现状","导入EXCEL",MessageBoxButtons.OK);
 }
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (isselect)
            {
                DialogResult = DialogResult.OK;
                return;
            }

            if (!InputCheck())
            {
                return;
            }

            if (SaveRecord())
            {
                if (checkEdit1.Checked)
                {
                    ctrls.RefreshData();
                    _obj = new PSP_PowerSubstationInfo();
                    _obj.Flag = flags1;
                    _obj.CreateDate = DateTime.Now;
                    IList<PSP_PowerSubstationInfo> list1 = new List<PSP_PowerSubstationInfo>();
                    list1.Add(_obj);
                    this.vGridControl.DataSource = list1;
                }
                else
                {
                    DialogResult = DialogResult.OK;
                }
            }
        }
Beispiel #13
0
 private void btnOK_Click(object sender, EventArgs e)
 {
     if (SaveRecord())
     {
         if (checkEdit1.Checked)
         {
             area.InitGrid1();
             _obj = new PSP_PowerSubstationInfo();
             _obj.UID = Guid.NewGuid().ToString();
             IList<PSP_PowerSubstationInfo> list1 = new List<PSP_PowerSubstationInfo>();
             list1.Add(_obj);
             this.vGridControl.DataSource = list1;
         }
         else
         {
             DialogResult = DialogResult.OK;
         }
     }
 }
        /// <summary>
        /// �޸Ľ������
        /// </summary>
        public void UpdateObject()
        {
            //��ȡ�������
            PSP_PowerSubstationInfo obj = FocusedObject;
            if (obj == null)
            {
                return;
            }

            //���������һ������
            PSP_PowerSubstationInfo objCopy = new PSP_PowerSubstationInfo();
            DataConverter.CopyTo<PSP_PowerSubstationInfo>(obj, objCopy);

            //ִ���޸IJ���
            using (FrmPSP_PowerSubstationInfoDialog dlg = new FrmPSP_PowerSubstationInfoDialog())
            {
                dlg.IsSelect = isselect;
                dlg.Type = types1;
                dlg.Flag = flags1;
                dlg.Type2 = types2 + "|" + Itop.Client.MIS.ProgUID.Substring(0, 20);
                dlg.Text = this.text;
                dlg.ctrlPSP_PowerSubstationInfo = this;

                dlg.Object = objCopy;   //�󶨸���
                if (dlg.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
            }

            //�ø������½������
            DataConverter.CopyTo<PSP_PowerSubstationInfo>(objCopy, obj);
            //ˢ�±��
            gridControl.RefreshDataSource();
        }
        /// <summary>
        /// ��Ӷ���
        /// </summary>
        public void AddObject()
        {
            //�����������Ƿ��Ѿ�����
            if (ObjectList == null)
            {
                return;
            }
            //�½�����
            PSP_PowerSubstationInfo obj = new PSP_PowerSubstationInfo();

            obj.Flag = flags1;
            obj.CreateDate = DateTime.Now;

            //ִ����Ӳ���
            using (FrmPSP_PowerSubstationInfoDialog dlg = new FrmPSP_PowerSubstationInfoDialog())
            {
                //dlg.Text = "";
                dlg.Type = types1;
                dlg.Flag = flags1 ;
                dlg.Type2 = types2 + "|" + Itop.Client.MIS.ProgUID.Substring(0, 20);
                dlg.ctrlPSP_PowerSubstationInfo = this;
                dlg.Text = this.text;
                dlg.IsCreate = true;    //�����½���־
                dlg.Object = obj;
                dlg.rowTitle.Properties.Caption = this.colTitle.Caption;
                dlg.rowPowerName.Properties.Caption = this.colPowerName.Caption;
                if (dlg.ShowDialog() != DialogResult.OK)
                {

                    return;
                }
            }

            //���¶�����뵽������
            ObjectList.Add(obj);

            //ˢ�±�񣬲��������ж�λ���¶����ϡ�
            gridControl.RefreshDataSource();
            GridHelper.FocuseRow(this.gridView1, obj);
        }