コード例 #1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         Authory updateAuthory = _authoryBll.GetBLL(selectedID);
         updateAuthory.AuthoryName = txtAuthoryName.Text;
         _authoryBll.UpdateBLL(updateAuthory);
         RefleshGrid();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #2
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         Authory deleteAuthory = _authoryBll.GetBLL(selectedID);
         selectedID = 0;
         _authoryBll.DeleteBLL(deleteAuthory);
         RefleshGrid();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         Authory newAuthory = new Authory();
         newAuthory.AuthoryName = txtAuthoryName.Text;
         _authoryBll.SaveBLL(newAuthory);
         RefleshGrid();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #4
0
 private void dgvAuthoryNameList_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         if (dgvAuthoryNameList.SelectedRows.Count > 0)
         {
             DataGridViewRow dr            = dgvAuthoryNameList.SelectedRows[0];
             string          updateIdInput = dr.Cells[0].Value.ToString();
             selectedID = int.Parse(updateIdInput);
             Authory updateAuthory = _authoryBll.GetBLL(selectedID);
             txtAuthoryName.Text = updateAuthory.AuthoryName;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
コード例 #5
0
        private void btnAddListBox_Click(object sender, EventArgs e)
        {
            Authory useAuthory = (Authory)cmbAuthory.SelectedItem;

            lstAuthory.Items.Add(useAuthory);
        }
コード例 #6
0
        public Role Get(int key)
        {
            /*
             *  create proc sp_GetRole
             *   @Id int
             *   as
             *   begin
             *   select ID, RoleName from Role where ID = @Id
             */
            _command.CommandText = "sp_GetRole";
            _command.CommandType = CommandType.StoredProcedure;
            _command.Parameters.Clear();
            _command.Parameters.AddWithValue("@Id", key);
            Role role = new Role();

            try
            {
                if (_command.Connection.State == System.Data.ConnectionState.Closed)
                {
                    _command.Connection.Open();
                }
                SqlDataReader reader = _command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        role          = new Role();
                        role.ID       = (int)reader["ID"];
                        role.RoleName = reader["RoleName"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Role getirirken bir sorun oluştu" + ex.Message);
            }
            finally
            {
                _command.Connection.Close();
            }

            /*
             *     begin try
             *      drop procedure sp_GetRoleAuthoryByID
             *      end try
             *      begin catch
             *      end catch
             *      go
             *      create procedure sp_GetRoleAuthoryByID
             *       @roleID int
             *       as
             *       begin
             *           select RoleID,AuthorID from  RoleAuthory  where RoleID=@roleID
             *       end
             *       go
             */
            _command.CommandText = "sp_GetRoleAuthoryByID";
            _command.CommandType = CommandType.StoredProcedure;
            _command.Parameters.Clear();
            _command.Parameters.AddWithValue("@roleID", key);

            try
            {
                if (_command.Connection.State == ConnectionState.Closed)
                {
                    _command.Connection.Open();
                }
                SqlDataReader reader = _command.ExecuteReader();
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        AuthoryDataMapper authoryDataMapper = new AuthoryDataMapper();
                        int     authoryID = (int)reader[1];
                        Authory authory   = authoryDataMapper.Get(authoryID);
                        role.AuthoryList.Add(authory);;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Bu Bus tipinine ait kayt bulunamadı !!" + ex.Message);
            }

            finally
            {
                _command.Connection.Close();
            }
            return(role);
        }