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 / C++ / MFC
  4. code to disable

code to disable

Scheduled Pinned Locked Moved C / C++ / MFC
announcement
21 Posts 6 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.
  • Y yogendra kaushik

    i am sorry i an again disturbing u but i have a problem in loging in dialog box ihav dialog cbox which has tow edit boxes one for username and one for password so i want that when i enter username and password the it conform those from mysql table named user and when i enter admin type ysrname and passward it open one form and wheni enter pm username and password it open second dialog box note : mysql database may contain two tables one for users and one for authentication Please mail me

    V Offline
    V Offline
    Viorel
    wrote on last edited by
    #12

    If you are making a database application, you should be able to read from the database and check the type of the user -- simple user or administrator. For instance, the "users" data table may contain a column which describes this type, for instance 0 for simple users or 1 for administrators. After you read the type from the database, you can do something like this:

    int type = ... // the user’s type from database
    switch(type)
    {
    case 0: // regular user
        {
            CMyDialogForSimpleUsers dlg;
            dlg.DoModal();
        }
        break;
    case 1: // administrator
        {
            CMyDialogForAdministrators dlg;
            dlg.DoModal();
        }
        break;
    }
    

    If you have troubles with databases using C++, I think you can post a separate question to the forum.

    Y 1 Reply Last reply
    0
    • V Viorel

      If you are making a database application, you should be able to read from the database and check the type of the user -- simple user or administrator. For instance, the "users" data table may contain a column which describes this type, for instance 0 for simple users or 1 for administrators. After you read the type from the database, you can do something like this:

      int type = ... // the user’s type from database
      switch(type)
      {
      case 0: // regular user
          {
              CMyDialogForSimpleUsers dlg;
              dlg.DoModal();
          }
          break;
      case 1: // administrator
          {
              CMyDialogForAdministrators dlg;
              dlg.DoModal();
          }
          break;
      }
      

      If you have troubles with databases using C++, I think you can post a separate question to the forum.

      Y Offline
      Y Offline
      yogendra kaushik
      wrote on last edited by
      #13

      can u tel me how i make table in mysql for 0 and 1 type as u told me i simply create a table which contain username and password but as u told plz tel me abt how i create table for 0 user and 1 for adm Please mail me

      V 1 Reply Last reply
      0
      • Y yogendra kaushik

        can u tel me how i make table in mysql for 0 and 1 type as u told me i simply create a table which contain username and password but as u told plz tel me abt how i create table for 0 user and 1 for adm Please mail me

        V Offline
        V Offline
        Viorel
        wrote on last edited by
        #14

        In the same manner as you created your users table containing two columns, you can create a table containing three columns. Just add one more column named "type" and having an integer type. If you use some database tools, like MySQL Query Browser, it is easy to add a new column to an existing table.

        Y 1 Reply Last reply
        0
        • V Viorel

          In the same manner as you created your users table containing two columns, you can create a table containing three columns. Just add one more column named "type" and having an integer type. If you use some database tools, like MySQL Query Browser, it is easy to add a new column to an existing table.

          Y Offline
          Y Offline
          yogendra kaushik
          wrote on last edited by
          #15

          i am sorry for delay i try this code but as value fetched from mysql stored in row which is mysql variable and switch case does not work with this plz tel me . groupid is values 0 and 1 which store in mysql table. if (!mysql_query(myDB,"select groupid from users")) res=mysql_store_result(myDB); row = mysql_fetch_row(res); { i = (int) mysql_num_rows( res ); if (i != 1) { MessageBox("no match"); mysql_free_result( res ) ; goto exit_here; } } //int type = ... // the user's type from database switch(row) { case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAfterone dlg; dlg.DoModal(); } break; } exit_here: mysql_close( myDB); } Please mail me

          V 1 Reply Last reply
          0
          • Y yogendra kaushik

            i am sorry for delay i try this code but as value fetched from mysql stored in row which is mysql variable and switch case does not work with this plz tel me . groupid is values 0 and 1 which store in mysql table. if (!mysql_query(myDB,"select groupid from users")) res=mysql_store_result(myDB); row = mysql_fetch_row(res); { i = (int) mysql_num_rows( res ); if (i != 1) { MessageBox("no match"); mysql_free_result( res ) ; goto exit_here; } } //int type = ... // the user's type from database switch(row) { case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAfterone dlg; dlg.DoModal(); } break; } exit_here: mysql_close( myDB); } Please mail me

            V Offline
            V Offline
            Viorel
            wrote on last edited by
            #16

            I am not an expert in databases, but I think your MySQL statement for determining groupid for a user by username should look like this: "SELECT groupid from users **WHERE username='_the-user-name_'**". MYSQL_ROW contains string, so I think your switch must look like this: switch(**atoi(row[0])**).

            Y 1 Reply Last reply
            0
            • V Viorel

              I am not an expert in databases, but I think your MySQL statement for determining groupid for a user by username should look like this: "SELECT groupid from users **WHERE username='_the-user-name_'**". MYSQL_ROW contains string, so I think your switch must look like this: switch(**atoi(row[0])**).

              Y Offline
              Y Offline
              yogendra kaushik
              wrote on last edited by
              #17

              plz sir i distyurb u again but it gives no error but it does not go to second dialog box plz send me code for this if (!mysql_query(myDB,"SELECT groupid from users WHERE userid= \'" + user + "\' and \'" + pass + "\'")) res=mysql_store_result(myDB); row = mysql_fetch_row(res); { i = (int) mysql_num_rows( res ); if (i != 1) { MessageBox("no match"); mysql_free_result( res ) ; goto exit_here; } } switch(atoi(row[0])) { case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAfterone dlg; dlg.DoModal(); } break; } exit_here: mysql_close( myDB); Please mail me

              V 1 Reply Last reply
              0
              • Y yogendra kaushik

                plz sir i distyurb u again but it gives no error but it does not go to second dialog box plz send me code for this if (!mysql_query(myDB,"SELECT groupid from users WHERE userid= \'" + user + "\' and \'" + pass + "\'")) res=mysql_store_result(myDB); row = mysql_fetch_row(res); { i = (int) mysql_num_rows( res ); if (i != 1) { MessageBox("no match"); mysql_free_result( res ) ; goto exit_here; } } switch(atoi(row[0])) { case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAfterone dlg; dlg.DoModal(); } break; } exit_here: mysql_close( myDB); Please mail me

                V Offline
                V Offline
                Viorel
                wrote on last edited by
                #18

                Try to put a breakpoint at switch, or use MessageBox, in order to see which value contains row[0]. If it contains an unexpected NULL or a non-numeric string, then atoi returns 0.

                Y 1 Reply Last reply
                0
                • V Viorel

                  Try to put a breakpoint at switch, or use MessageBox, in order to see which value contains row[0]. If it contains an unexpected NULL or a non-numeric string, then atoi returns 0.

                  Y Offline
                  Y Offline
                  yogendra kaushik
                  wrote on last edited by
                  #19

                  sir u geneous thanks but sir iwill not display second dialog box as second dialog box has class named CAdmin and first dialog box has class CAfterone case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAdmin dlg; dlg.DoModal(); } break; } Please mail me

                  Y 1 Reply Last reply
                  0
                  • Y yogendra kaushik

                    sir u geneous thanks but sir iwill not display second dialog box as second dialog box has class named CAdmin and first dialog box has class CAfterone case 0: // regular user { CAfterone dlg; dlg.DoModal(); } break; case 1: // administrator { CAdmin dlg; dlg.DoModal(); } break; } Please mail me

                    Y Offline
                    Y Offline
                    yogendra kaushik
                    wrote on last edited by
                    #20

                    thanks a lot sir this works very well u r absolutly geneious Please mail me

                    1 Reply Last reply
                    0
                    • Y yogendra kaushik

                      plz tel me how can i check (mDisableSomeControls ) for updaet menu command how i write if(............) { GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE); } wat i write in if statement Please mail me

                      J Offline
                      J Offline
                      jhwurmbach
                      wrote on last edited by
                      #21

                      Please read this article[^] on why you do not want to use GetDlgItem and how you can avoid it while makeing your code mor readble. The author Joseph M. Newcomer is a old regular here on codeproject. His Page is full of great tips.


                      "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                      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