1/// <summary>
2 /// 初始化GridView,绑定数据
3 /// </summary>
4 /// <param name="parentId"></param>
5 private void GridViewBindData(string parentId)
6 {
7 this.gridView1.Columns.Clear();
8 this.FDs= areaSetupActionHelper.getDsRegionByParentId(parentId);
9 this.gridCArea.DataSource =this.FDs.Tables[0].DefaultView;
10
11 this.gridView1.Columns["id"].VisibleIndex = -1;
12 this.gridView1.Columns["childCounts"].VisibleIndex = -1;
13
14 this.gridView1.Columns["reg_id"].Caption = "区划编号";
15 this.gridView1.Columns["reg_name"].Caption = "区划名称";
16 this.gridView1.Columns["parent_id"].Caption = "父区划编号";
17 this.gridView1.Columns["reg_desc"].Caption = "区划描述";
18 this.gridView1.Columns["parent_id"].ImageIndex =1;
19 this.gridView1.Columns["reg_desc"].ImageIndex = 0;
20
21 RepositoryItemTextEdit textEditReg_Id = new RepositoryItemTextEdit();
22 textEditReg_Id.Mask.EditMask =parentId+"\\d{2,3}";
23 textEditReg_Id.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Regular;
24
25 this.gridView1.Columns["reg_id"].ColumnEdit = textEditReg_Id;
26
27 this.gridView1.Columns["reg_desc"].ColumnEdit = new RepositoryItemMemoExEdit();
28
29 TreeListNode node = this.treelArea.FocusedNode.ParentNode;
30 string fid = node==null?"0":node.GetValue("RegID").ToString().Trim();
31 DataSet ds = areaSetupActionHelper.getDsRegionByParentId(fid);
32 RepositoryItemLookUpEdit lookUEParent_Id = new RepositoryItemLookUpEdit();
33 lookUEParent_Id.Columns.Add(new LookUpColumnInfo("reg_id", 40, "区划编号"));
34 lookUEParent_Id.Columns.Add(new LookUpColumnInfo("reg_name", 40, "区划名称"));
35 lookUEParent_Id.DataSource = ds.Tables[0].DefaultView;
36 lookUEParent_Id.ValueMember = "reg_id";
37 lookUEParent_Id.DisplayMember = "reg_id";
38 this.gridView1.Columns["parent_id"].ColumnEdit = lookUEParent_Id;
39 }
2 /// 初始化GridView,绑定数据
3 /// </summary>
4 /// <param name="parentId"></param>
5 private void GridViewBindData(string parentId)
6 {
7 this.gridView1.Columns.Clear();
8 this.FDs= areaSetupActionHelper.getDsRegionByParentId(parentId);
9 this.gridCArea.DataSource =this.FDs.Tables[0].DefaultView;
10
11 this.gridView1.Columns["id"].VisibleIndex = -1;
12 this.gridView1.Columns["childCounts"].VisibleIndex = -1;
13
14 this.gridView1.Columns["reg_id"].Caption = "区划编号";
15 this.gridView1.Columns["reg_name"].Caption = "区划名称";
16 this.gridView1.Columns["parent_id"].Caption = "父区划编号";
17 this.gridView1.Columns["reg_desc"].Caption = "区划描述";
18 this.gridView1.Columns["parent_id"].ImageIndex =1;
19 this.gridView1.Columns["reg_desc"].ImageIndex = 0;
20
21 RepositoryItemTextEdit textEditReg_Id = new RepositoryItemTextEdit();
22 textEditReg_Id.Mask.EditMask =parentId+"\\d{2,3}";
23 textEditReg_Id.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Regular;
24
25 this.gridView1.Columns["reg_id"].ColumnEdit = textEditReg_Id;
26
27 this.gridView1.Columns["reg_desc"].ColumnEdit = new RepositoryItemMemoExEdit();
28
29 TreeListNode node = this.treelArea.FocusedNode.ParentNode;
30 string fid = node==null?"0":node.GetValue("RegID").ToString().Trim();
31 DataSet ds = areaSetupActionHelper.getDsRegionByParentId(fid);
32 RepositoryItemLookUpEdit lookUEParent_Id = new RepositoryItemLookUpEdit();
33 lookUEParent_Id.Columns.Add(new LookUpColumnInfo("reg_id", 40, "区划编号"));
34 lookUEParent_Id.Columns.Add(new LookUpColumnInfo("reg_name", 40, "区划名称"));
35 lookUEParent_Id.DataSource = ds.Tables[0].DefaultView;
36 lookUEParent_Id.ValueMember = "reg_id";
37 lookUEParent_Id.DisplayMember = "reg_id";
38 this.gridView1.Columns["parent_id"].ColumnEdit = lookUEParent_Id;
39 }
1 /// <summary>
2 /// gridView单元格验证的相关处理程序
3 /// </summary>
4 /// <param name="sender"></param>
5 /// <param name="e"></param>
6 private void gridView1_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
7 {
8 if (e.Valid == false&&this.gridView1.FocusedColumn.FieldName == "reg_id")
9 {
10 e.ErrorText = "区划编号不合法!\n应为父区划编号加2~3位数据组成!";
11 }
12 if (this.gridView1.FocusedColumn.FieldName == "reg_name")
13 {
14 Regex reg=new Regex(@"[\u4e00-\u9fa5]{1,20}");
15 Match m=reg.Match(e.Value.ToString().Trim());
16 if (m.Length != e.Value.ToString().Trim().Length)
17 {
18 e.Valid = false;
19 e.ErrorText = "区划名称应为汉字\n长度为1至20";
20 }
21 }
22 }
23
24 private void gridView1_InvalidValueException(object sender, InvalidValueExceptionEventArgs e)
25 {
26 if (MyDialog.Alert(" 您所填写的内容不符合规则\n 要放弃您刚才对此项所做的更改吗?", "您所编辑的内容不符合规则", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
27 {
28 e.ExceptionMode = ExceptionMode.Ignore;
29 }
30 }
2 /// gridView单元格验证的相关处理程序
3 /// </summary>
4 /// <param name="sender"></param>
5 /// <param name="e"></param>
6 private void gridView1_ValidatingEditor(object sender, DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs e)
7 {
8 if (e.Valid == false&&this.gridView1.FocusedColumn.FieldName == "reg_id")
9 {
10 e.ErrorText = "区划编号不合法!\n应为父区划编号加2~3位数据组成!";
11 }
12 if (this.gridView1.FocusedColumn.FieldName == "reg_name")
13 {
14 Regex reg=new Regex(@"[\u4e00-\u9fa5]{1,20}");
15 Match m=reg.Match(e.Value.ToString().Trim());
16 if (m.Length != e.Value.ToString().Trim().Length)
17 {
18 e.Valid = false;
19 e.ErrorText = "区划名称应为汉字\n长度为1至20";
20 }
21 }
22 }
23
24 private void gridView1_InvalidValueException(object sender, InvalidValueExceptionEventArgs e)
25 {
26 if (MyDialog.Alert(" 您所填写的内容不符合规则\n 要放弃您刚才对此项所做的更改吗?", "您所编辑的内容不符合规则", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
27 {
28 e.ExceptionMode = ExceptionMode.Ignore;
29 }
30 }
1 /// <summary>
2 /// gridView行验证的相关处理程序
3 /// </summary>
4 private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
5 {
6 string regid = this.gridView1.GetRowCellValue(e.RowHandle, "reg_id").ToString().Trim();
7 string regName = this.gridView1.GetRowCellValue(e.RowHandle, "reg_name").ToString().Trim();
8 if ( regid.Length < 1)
9 {
10 e.Valid = false;
11 this.gridView1.SetColumnError(this.gridView1.Columns["reg_id"], "请填写区划编号!", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Default);
12 // e.ErrorText = "区划名称不能为空!";
13 }
14 if (regName.Length < 1)
15 {
16 e.Valid = false;
17 this.gridView1.SetColumnError(this.gridView1.Columns["reg_name"], "区划名称不能为空!", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Default);
18 }
19 }
20
21 private void gridView1_InvalidRowException(object sender, DevExpress.XtraGrid.Views.Base.InvalidRowExceptionEventArgs e)
22 {
23
24 if (e.RowHandle >= 0)
25 {
26 if (this.gridView1.GetRowCellValue(e.RowHandle, this.gridView1.Columns["reg_id"]).ToString().Trim() == "" || this.gridView1.GetRowCellValue(e.RowHandle, this.gridView1.Columns["reg_name"]).ToString().Trim() == "")
27 {
28 if (MyDialog.Alert(" 您所填写的内容不符合规则\n 要放弃您刚才对此项所做的更改吗?", "您所编辑的内容不符合规则", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
29 {
30 e.ExceptionMode = ExceptionMode.Ignore;
31 }
32 else
33 {
34 e.ExceptionMode = ExceptionMode.NoAction;
35 }
36 }
37 }
38 else
39 {
40 e.ExceptionMode = ExceptionMode.Ignore;
41 }
42 }
2 /// gridView行验证的相关处理程序
3 /// </summary>
4 private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
5 {
6 string regid = this.gridView1.GetRowCellValue(e.RowHandle, "reg_id").ToString().Trim();
7 string regName = this.gridView1.GetRowCellValue(e.RowHandle, "reg_name").ToString().Trim();
8 if ( regid.Length < 1)
9 {
10 e.Valid = false;
11 this.gridView1.SetColumnError(this.gridView1.Columns["reg_id"], "请填写区划编号!", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Default);
12 // e.ErrorText = "区划名称不能为空!";
13 }
14 if (regName.Length < 1)
15 {
16 e.Valid = false;
17 this.gridView1.SetColumnError(this.gridView1.Columns["reg_name"], "区划名称不能为空!", DevExpress.XtraEditors.DXErrorProvider.ErrorType.Default);
18 }
19 }
20
21 private void gridView1_InvalidRowException(object sender, DevExpress.XtraGrid.Views.Base.InvalidRowExceptionEventArgs e)
22 {
23
24 if (e.RowHandle >= 0)
25 {
26 if (this.gridView1.GetRowCellValue(e.RowHandle, this.gridView1.Columns["reg_id"]).ToString().Trim() == "" || this.gridView1.GetRowCellValue(e.RowHandle, this.gridView1.Columns["reg_name"]).ToString().Trim() == "")
27 {
28 if (MyDialog.Alert(" 您所填写的内容不符合规则\n 要放弃您刚才对此项所做的更改吗?", "您所编辑的内容不符合规则", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
29 {
30 e.ExceptionMode = ExceptionMode.Ignore;
31 }
32 else
33 {
34 e.ExceptionMode = ExceptionMode.NoAction;
35 }
36 }
37 }
38 else
39 {
40 e.ExceptionMode = ExceptionMode.Ignore;
41 }
42 }