예제 #1
0
        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int nRow = gridView1.FocusedRowHandle;

            if (nRow < 2)
            {
                MsgBox.Show("固定内容不能删除!");
                return;
            }

            if (gridView1.GetRowCellValue(nRow, "ID") == DBNull.Value)
            {
                return;
            }

            if ((int)gridView1.GetRowCellValue(nRow, "ParentTypeID") == 0)
            {
                MsgBox.Show("固定内容不能删除!");
                return;
            }

            if (!CanDelete)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }

            if (MsgBox.ShowYesNo("是否删除 " + gridView1.GetRowCellValue(nRow, "Col1").ToString() + gridView1.GetRowCellValue(nRow, "Col2").ToString() + " ?") == DialogResult.No)
            {
                return;
            }

            PSP_WGBCValues v = DataConverter.RowToObject <PSP_WGBCValues>(dataTable.Rows[nRow]);

            try
            {
                Common.Services.BaseService.Delete <PSP_WGBCValues>(v);
                dataTable.Rows.RemoveAt(nRow);

                //改变后面的序号
                for (int i = nRow; i < gridView1.RowCount; i++)
                {
                    if (gridView1.GetRowCellValue(i, "ID") == DBNull.Value)
                    {
                        break;
                    }

                    if (Convert.ToInt32(gridView1.GetRowCellValue(i, "Col1")) == Convert.ToInt32(v.Col1) + i - nRow + 1)
                    {
                        gridView1.SetRowCellValue(i, "Col1", Convert.ToInt32(v.Col1) + i - nRow);
                    }
                }
            }
            catch
            {
            }
        }
예제 #2
0
        private void InsertFixedRows(int typeID, string col1)
        {
            PSP_WGBCValues v = new PSP_WGBCValues();

            v.Col1     = col1;
            v.ReportID = _wgbcReport.ID;
            v.TypeID   = typeID;

            try
            {
                Common.Services.BaseService.Create("InsertPSP_WGBCFixedValues", v);
            }
            catch
            {
            }
        }
예제 #3
0
        //添加
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            int nFRow = gridView1.FocusedRowHandle;

            if (nFRow < 1)
            {
                return;
            }

            if (!CanAdd)
            {
                MsgBox.Show("您没有权限进行此项操作!");
                return;
            }

            if (gridView1.GetRowCellValue(nFRow, "ID") == DBNull.Value)
            {
                nFRow--;
            }

            int            nParentPos = GetParentPos(nFRow);
            PSP_WGBCValues v          = new PSP_WGBCValues();

            v.ReportID     = _wgbcReport.ID;
            v.TypeID       = (int)gridView1.GetRowCellValue(nFRow, "TypeID");
            v.ParentTypeID = (int)gridView1.GetRowCellValue(nParentPos, "TypeID");
            v.Col1         = GetInsertNumber(nParentPos).ToString();

            try
            {
                v.ID = (int)Common.Services.BaseService.Create <PSP_WGBCValues>(v);
                DataRow newRow = dataTable.NewRow();
                DataConverter.ObjectToRow(v, newRow);

                int nInsertPos = GetInsertPos(nFRow);
                dataTable.Rows.InsertAt(newRow, nInsertPos);
                gridView1.FocusedRowHandle = nInsertPos;
            }
            catch
            {
            }
        }
예제 #4
0
        private void LoadData()
        {
            gridView1.BeginUpdate();

            dataTable = new DataTable();
            dataTable.Columns.Add("ID", typeof(int));
            dataTable.Columns.Add("ReportID", typeof(int));
            dataTable.Columns.Add("TypeID", typeof(int));
            dataTable.Columns.Add("ParentTypeID", typeof(int));

            for (int i = 0; i < 7; i++)
            {
                dataTable.Columns.Add("Col" + (i + 1), typeof(string));
            }

            PSP_WGBCValues v = new PSP_WGBCValues();

            v.ReportID = _wgbcReport.ID;

            IList listWGBCValues = Common.Services.BaseService.GetList("SelectPSP_WGBCValuesByReportID", v);

            if (listWGBCValues.Count == 0)
            {
                InsertFixedRows();
            }

            listWGBCValues = Common.Services.BaseService.GetList("SelectPSP_WGBCValuesByReportID", v);

            foreach (PSP_WGBCValues item in listWGBCValues)
            {
                DataRow newRow = dataTable.NewRow();
                Itop.Common.DataConverter.ObjectToRow(item, newRow);

                if (item.ParentTypeID == 0 && item.TypeID > 2)
                {
                    dataTable.Rows.Add(new object[] { });
                }
                dataTable.Rows.Add(newRow);
            }
            gridControl1.DataSource = dataTable;

            gridView1.Columns["ID"].Visible           = false;
            gridView1.Columns["ReportID"].Visible     = false;
            gridView1.Columns["TypeID"].Visible       = false;
            gridView1.Columns["ParentTypeID"].Visible = false;

            gridView1.Columns["Col1"].Caption = "";
            gridView1.Columns["Col1"].AppearanceCell.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
            gridView1.Columns["Col2"].Caption = "安装地点";
            gridView1.Columns["Col3"].Caption = "可投切并联电容器";
            gridView1.Columns["Col4"].Caption = "高压电抗器";
            gridView1.Columns["Col5"].Caption = "低压电抗器";
            gridView1.Columns["Col6"].Caption = "静止补偿器";
            gridView1.Columns["Col7"].Caption = "备注";

            for (int i = 0; i < gridView1.Columns.Count; i++)
            {
                gridView1.Columns[i].ColumnEdit = repositoryItemTextEdit1;
                gridView1.Columns[i].Width      = 110;
            }
            gridView1.Columns["Col3"].Width = 140;

            gridView1.EndUpdate();
        }
예제 #5
0
        private void SaveRowValue(DataRow dr)
        {
            PSP_WGBCValues v = DataConverter.RowToObject <PSP_WGBCValues>(dr);

            Common.Services.BaseService.Update <PSP_WGBCValues>(v);
        }