Пример #1
0
        private void button11_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();
            databaza_con  db  = new databaza_con();// making connection

            con = new SqlConnection(db.Connection());
            SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM tbl_perdoruesit WHERE Emri='" + sendtext + "' AND Kodi='" + txtPassword.Text + "'", con);
            /* in above line the program is selecting the whole data from table and the matching it with the user name and password provided by user. */
            DataTable dt = new DataTable(); //this is creating a virtual table

            sda.Fill(dt);
            con.Open();
            if (dt.Rows[0][0].ToString() == "1")
            {
                con = new SqlConnection(db.Connection());
                con.Open();
                SqlCommand    cmd = new SqlCommand("SELECT Aksesi FROM tbl_perdoruesit WHERE Emri='" + sendtext + "' AND Kodi='" + txtPassword.Text + "'", con);
                SqlDataReader rdr;
                rdr = cmd.ExecuteReader();
                if (rdr.Read())
                {
                    UserType.Text = rdr.GetValue(0).ToString().Trim();
                }
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
                if (UserType.Text == "Staf")
                {
                    string st = "Successfully logged in";

                    this.Hide();
                    new Form_Dashboard().Show();
                }


                if (UserType.Text == "Menaxher")
                {
                    string st = "Successfully logged in";

                    this.Hide();

                    //sendtext = comboBox1.Text;
                    new Form_Dashboard().Show();
                    txtPassword.Text = "";
                }
                /* I have made a new page called home page. If the user is successfully authenticated then the form will be moved to the next form */
            }
            else
            {
                MessageBox.Show("Emri ose passwordi eshte GABIM");
            }
            txtPassword.Text = "";
            con.Close();
        }
Пример #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            txtPassword.Focus();
            SqlConnection con = new SqlConnection();
            databaza_con  db  = new databaza_con();// making connection

            con = new SqlConnection(db.Connection());
            DataTable      tbl = new DataTable();
            SqlDataAdapter da  = new SqlDataAdapter("select * from tbl_perdoruesit ", con);

            da.Fill(tbl);
            int     i;
            DataRow last = tbl.Rows[tbl.Rows.Count - 1];
            int     j    = tbl.Rows.Count;

            for (i = 0; i < (tbl.Rows.Count); i++)
            {
                RadioButton bt2 = new RadioButton();
                bt2.Name = tbl.Rows[i].ItemArray[0].ToString();
                bt2.Text = tbl.Rows[i]["Emri"].ToString();

                bt2.Width  = 126;
                bt2.Height = 66;

                bt2.ForeColor = Color.DarkBlue;
                bt2.BackColor = System.Drawing.Color.White;

                bt2.Appearance = Appearance.Button;
                bt2.FlatAppearance.CheckedBackColor = Color.DarkOrange;
                bt2.TabStop = true;
                bt2.UseVisualStyleBackColor = false;
                bt2.FlatStyle = FlatStyle.Flat;
                bt2.TextAlign = ContentAlignment.MiddleCenter;
                bt2.Font      = new Font("Century Gothic", 12, FontStyle.Bold);
                bt2.Cursor    = Cursors.Hand;
                bt2.Click    += new EventHandler(this.btn1_Click);
                //ThreadReceive = new System.Threading.Thread(table_list_click);
                flowLayoutPanel1.Controls.Add(bt2);
                con.Close();
            }
        }