Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. giving authorization to the user

giving authorization to the user

Scheduled Pinned Locked Moved C#
helpquestionsharepointsecurityannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Erdinc27
    wrote on last edited by
    #1

    hey guys..i try to make a login panel and authorization..first i created a StoredProcedure like below

    ALTER proc [dbo].[sp_KullaniciYetkiDegistir]
    (
    @KullaniciNo int,
    @Yetki0 int,
    @Yetki1 int,
    @Yetki2 int,
    @Yetki3 int,
    @Yetki4 int
    )
    As
    Begin
    update Izin set ErisebilirMi = @Yetki0 where KullaniciNo = @KullaniciNo and YetkiNo = 1
    update Izin set ErisebilirMi = @Yetki1 where KullaniciNo = @KullaniciNo and YetkiNo = 2
    update Izin set ErisebilirMi = @Yetki2 where KullaniciNo = @KullaniciNo and YetkiNo = 3
    update Izin set ErisebilirMi = @Yetki3 where KullaniciNo = @KullaniciNo and YetkiNo = 4
    update Izin set ErisebilirMi = @Yetki4 where KullaniciNo = @KullaniciNo and YetkiNo = 5
    End

    in here i give some authority according to the KullaniciNo(here Erisebilirmi column is set as bit..so i can give or not give authority to the user)...and in my button's click i wrote like that

    cmd = new SqlCommand("sp_KullaniciYetkiDegistir", conn);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.AddWithValue("@KullaniciNo", System.Data.SqlDbType.Int).Value = KullaniciNo;
    cmd.Parameters.AddWithValue("@Yetki0", System.Data.SqlDbType.Bit).Value = chkAdmin.Checked;
    cmd.Parameters.AddWithValue("@Yetki1", System.Data.SqlDbType.Bit).Value = chkKullaniciEkle.Checked;
    cmd.Parameters.AddWithValue("@Yetki2", System.Data.SqlDbType.Bit).Value = chkKullaniciSil.Checked;
    cmd.Parameters.AddWithValue("@Yetki3", System.Data.SqlDbType.Bit).Value = chkYekilendir.Checked;
    cmd.Parameters.AddWithValue("@Yetki4", System.Data.SqlDbType.Bit).Value = chkProjeGor.Checked;

                if (cmd.ExecuteNonQuery() == 1)
                    MessageBox.Show("Authorities Are Set", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                else
                    MessageBox.Show("Authorization Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
    

    here cmd.ExecuteNonQuery() drops directly Else block..what is wrong here?? any help will be appreciated

    L 1 Reply Last reply
    0
    • E Erdinc27

      hey guys..i try to make a login panel and authorization..first i created a StoredProcedure like below

      ALTER proc [dbo].[sp_KullaniciYetkiDegistir]
      (
      @KullaniciNo int,
      @Yetki0 int,
      @Yetki1 int,
      @Yetki2 int,
      @Yetki3 int,
      @Yetki4 int
      )
      As
      Begin
      update Izin set ErisebilirMi = @Yetki0 where KullaniciNo = @KullaniciNo and YetkiNo = 1
      update Izin set ErisebilirMi = @Yetki1 where KullaniciNo = @KullaniciNo and YetkiNo = 2
      update Izin set ErisebilirMi = @Yetki2 where KullaniciNo = @KullaniciNo and YetkiNo = 3
      update Izin set ErisebilirMi = @Yetki3 where KullaniciNo = @KullaniciNo and YetkiNo = 4
      update Izin set ErisebilirMi = @Yetki4 where KullaniciNo = @KullaniciNo and YetkiNo = 5
      End

      in here i give some authority according to the KullaniciNo(here Erisebilirmi column is set as bit..so i can give or not give authority to the user)...and in my button's click i wrote like that

      cmd = new SqlCommand("sp_KullaniciYetkiDegistir", conn);
      cmd.CommandType = CommandType.StoredProcedure;
      cmd.Parameters.AddWithValue("@KullaniciNo", System.Data.SqlDbType.Int).Value = KullaniciNo;
      cmd.Parameters.AddWithValue("@Yetki0", System.Data.SqlDbType.Bit).Value = chkAdmin.Checked;
      cmd.Parameters.AddWithValue("@Yetki1", System.Data.SqlDbType.Bit).Value = chkKullaniciEkle.Checked;
      cmd.Parameters.AddWithValue("@Yetki2", System.Data.SqlDbType.Bit).Value = chkKullaniciSil.Checked;
      cmd.Parameters.AddWithValue("@Yetki3", System.Data.SqlDbType.Bit).Value = chkYekilendir.Checked;
      cmd.Parameters.AddWithValue("@Yetki4", System.Data.SqlDbType.Bit).Value = chkProjeGor.Checked;

                  if (cmd.ExecuteNonQuery() == 1)
                      MessageBox.Show("Authorities Are Set", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                  else
                      MessageBox.Show("Authorization Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
      

      here cmd.ExecuteNonQuery() drops directly Else block..what is wrong here?? any help will be appreciated

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Your sproc updates a number of things, and that would cause ExecuteNonQuery to return an int larger than 1. How about assigning the result to a variable and displaying that, just to make sure?

      I are Troll :suss:

      E 1 Reply Last reply
      0
      • L Lost User

        Your sproc updates a number of things, and that would cause ExecuteNonQuery to return an int larger than 1. How about assigning the result to a variable and displaying that, just to make sure?

        I are Troll :suss:

        E Offline
        E Offline
        Erdinc27
        wrote on last edited by
        #3

        thanks friend..i did what u said and i noticed that i made mistake in my if block..so it was working already but it is seen like it gives errror because of my wrong idea thanks for help

        L 1 Reply Last reply
        0
        • E Erdinc27

          thanks friend..i did what u said and i noticed that i made mistake in my if block..so it was working already but it is seen like it gives errror because of my wrong idea thanks for help

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          You're welcome :)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups