Exemplo n.º 1
0
        private void editPermission()
        {
            if (this.dataView1.Count == 0)
            {
                return;
            }
            BindingManagerBase bm = (BindingManagerBase)this.BindingContext[this.dataView1];

            XSD.dsPermissionsList.PermissionsDescriptionsRow rw = (XSD.dsPermissionsList.PermissionsDescriptionsRow)((DataRowView)bm.Current).Row;
            PermissionsEdit pe = new PermissionsEdit(rw, this.dataView1, true);

            pe.Text += " [Редактирование]";
            pe.ShowDialog();
            if (pe.DialogResult == DialogResult.OK)
            {
                try
                {
                    this.oleDbDataAdapter1.Update(this.dsPermissionsList1.PermissionsDescriptions);
                }
                catch (Exception ex)
                {
                    AM_Controls.MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
        }
Exemplo n.º 2
0
        private void addPermission()
        {
            XSD.dsPermissionsList.PermissionsDescriptionsRow rw = (XSD.dsPermissionsList.PermissionsDescriptionsRow) this.dataView1.Table.NewRow();
            PermissionsEdit pe = new PermissionsEdit(rw, this.dataView1, false);

            pe.Text += " [Новое]";
            pe.ShowDialog();
            if (pe.DialogResult == DialogResult.OK)
            {
                this.dataView1.Table.Rows.Add((DataRow)rw);
                OleDbCommand cmdGetIdentity   = new OleDbCommand("SELECT @@IDENTITY", this.oleDbConnection1);
                OleDbCommand cmdInsInUserPerm = new OleDbCommand("INSERT INTO UsersPermissions (UserID, PermissionID)" +
                                                                 " SELECT UserID, ? AS PermissionID FROM Users", this.oleDbConnection1);
                cmdInsInUserPerm.Parameters.Add(new OleDbParameter("@PermissionID", OleDbType.Integer));
                OleDbCommand cmdInsInGroupPerm = new OleDbCommand("INSERT INTO UserGroupsPermissions (GroupID, PermissionID)" +
                                                                  " SELECT GroupID, ? AS PermissionID FROM UsersGroups", this.oleDbConnection1);
                cmdInsInGroupPerm.Parameters.Add(new OleDbParameter("@PermissionID", OleDbType.Integer));
                this.oleDbConnection1.Open();
                OleDbTransaction tr = this.oleDbConnection1.BeginTransaction();
                cmdGetIdentity.Transaction = this.oleDbDataAdapter1.InsertCommand.Transaction = cmdInsInUserPerm.Transaction = cmdInsInGroupPerm.Transaction = tr;
                try
                {
                    this.oleDbDataAdapter1.Update(this.dsPermissionsList1.PermissionsDescriptions);
                    object o = cmdGetIdentity.ExecuteScalar();
                    if (o == Convert.DBNull)
                    {
                        tr.Rollback();
                        return;
                    }
                    rw.PermissionID = Convert.ToInt32(o);
                    this.dsPermissionsList1.PermissionsDescriptions.AcceptChanges();
                    cmdInsInUserPerm.Parameters["@PermissionID"].Value = rw.PermissionID;
                    cmdInsInUserPerm.ExecuteNonQuery();
                    cmdInsInGroupPerm.Parameters["@PermissionID"].Value = rw.PermissionID;
                    cmdInsInGroupPerm.ExecuteNonQuery();
                    tr.Commit();
                }
                catch (Exception ex)
                {
                    tr.Rollback();
                    this.dsPermissionsList1.PermissionsDescriptions.RejectChanges();
                    AM_Controls.MsgBoxX.Show(ex.Message, "BPS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                finally
                {
                    this.oleDbConnection1.Close();
                }
            }
        }
Exemplo n.º 3
0
 public PermissionsEdit(XSD.dsPermissionsList.PermissionsDescriptionsRow rw, DataView dv, bool bIsEdit)
 {
     this.rw      = rw;
     this.bIsEdit = bIsEdit;
     InitializeComponent();
     this.dvPermissionsList.Table = dv.Table.Copy();
     XSD.dsPermissionsList.PermissionsDescriptionsRow dr = (XSD.dsPermissionsList.PermissionsDescriptionsRow) this.dvPermissionsList.Table.NewRow();
     dr.Description  = "<Нет>";
     dr.InternalName = "";
     dr.SetParentPermissionIDNull();
     dr.PermissionID     = 0;
     dr.PermissionTypeID = 1;
     this.dvPermissionsList.Table.Rows.Add((DataRow)dr);
     this.dvPermissionsList.Sort  = "Description";
     this.cmbParent.DataSource    = this.dvPermissionsList;
     this.cmbParent.DisplayMember = "Description";
     this.cmbParent.ValueMember   = "PermissionID";
 }