/// <summary> /// 增加一行记录 /// </summary> private void AddNewItem() { //创建数据 HdpRoleGrant hdpRoleGrant = new HdpRoleGrant(); //创建行 int index = this.dataGridView1.Rows.Add(); DataTableViewRow row = this.dataGridView1.Rows[index]; hdpRoleGrant.GrantID = hdpRoleGrant.MakeGrantID(); row.Tag = hdpRoleGrant; this.dataGridView1.SetRowState(row, RowState.New); this.UpdateUIState(); this.dataGridView1.CurrentCell = row.Cells[this.colRoleRightKey.Index]; this.dataGridView1.BeginEdit(true); }
private void btnSave_Click(object sender, EventArgs e) { if (this.cboProduct.SelectedItem == null) { MessageBoxEx.Show("请选择产品"); return; } string szProduct = (this.cboProduct.SelectedItem as HdpProduct).NAME_SHORT; List <HdpRoleGrant> lstHdpRoleGrant = new List <HdpRoleGrant>(); foreach (Control item in this.flpGrant.Controls) { CheckBox chk = item as CheckBox; if (item == null) { continue; } if (chk.Checked == false) { continue; } RightPoint point = chk.Tag as RightPoint; HdpRoleGrant hdpRoleGrant = new HdpRoleGrant(); hdpRoleGrant.GrantID = hdpRoleGrant.MakeGrantID(); hdpRoleGrant.RoleCode = this.m_roleInfo.RoleCode; hdpRoleGrant.Product = szProduct; hdpRoleGrant.RoleRightCommand = point.RightCommand; hdpRoleGrant.RoleRightDesc = point.RightDesc; hdpRoleGrant.RoleRightKey = point.RightKey; lstHdpRoleGrant.Add(hdpRoleGrant); } short shRet = HdpRoleGrantAccess.Instance.SaveHdpRoleGrantList(this.m_roleInfo.RoleCode, szProduct, lstHdpRoleGrant); if (shRet != SystemData.ReturnValue.OK) { MessageBoxEx.Show("授权失败!"); return; } MessageBoxEx.ShowMessage("授权成功!"); this.DialogResult = DialogResult.OK; }