コード例 #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox2.Text != "")
     {
         string             nic_num = textBox2.Text;
         DataBase_connector dc      = new DataBase_connector();
         string             check   = "SELECT * FROM sim_registaration.user where nic_num='" + nic_num + "';";
         DataTable          dt      = dc.read(check);
         if (dt.Rows.Count != 0)
         {
             foreach (DataRow row in dt.Rows)
             {
                 textBox1.Text     = row[1].ToString();;
                 groupBox2.Visible = true;
                 label9.Text       = row[8].ToString();
                 u1.c_answer       = row[9].ToString();
                 u1.userID         = Convert.ToInt32(row[0]);
             }
         }
         else
         {
             MessageBox.Show("User name or NIC incorrect");
         }
     }
     else
     {
         MessageBox.Show("Empty user name or password");
     }
 }
コード例 #2
0
        private void btn_lgn_Click_3(object sender, EventArgs e)
        {
            if (txt_user.Text != "" && txt_pswd.Text != "")
            {
                string             username = txt_user.Text;
                DataBase_connector dc       = new DataBase_connector();
                string             add      = "SELECT * FROM sim_registaration.user where UserName='******';";
                DataTable          dt       = dc.read(add);
                if (dt.Rows.Count != 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        Userclass u1 = new Userclass();
                        u1.password = row[2].ToString();
                        u1.job      = row[10].ToString();

                        if (u1.password == txt_pswd.Text)
                        {
                            if (u1.job == "Admin")
                            {
                                Form2 f2 = new Form2();
                                f2.menuStripadmin.Visible = true;
                                f2.label7.Text            = "Admin";
                                this.Hide();
                                f2.ShowDialog();
                                this.Show();
                            }
                            else
                            {
                                Form2 f2 = new Form2();
                                f2.menuStrip2.Visible = true;
                                f2.label7.Text        = "employee";
                                this.Hide();
                                f2.ShowDialog();
                                this.Show();
                            }
                        }
                        else
                        {
                            MessageBox.Show(" passsword incorrect");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("wrong user name");
                }
            }
            else
            {
                MessageBox.Show("Empty User name or Password");
            }
        }
コード例 #3
0
        private void dataload()
        {
            string             date   = dateTimePicker1.Value.ToString("yyyy/MM/dd");
            Sim                s2     = new Sim();
            Form2              f1     = new Form2();
            DataBase_connector bd1    = new DataBase_connector();
            string             select = "SELECT * FROM sim_registaration.sim where Date = '" + date + "' ;";
            DataTable          dt1    = bd1.read(select);

            foreach (DataRow dr in dt1.Rows)
            {
                DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
                row.Cells[0].Value = dr[0].ToString();
                row.Cells[1].Value = dr[1].ToString();
                row.Cells[2].Value = dr[3].ToString();
                row.Cells[3].Value = dr[4].ToString();
                row.Cells[4].Value = dr[2].ToString();
                row.Cells[5].Value = dr[5].ToString();
                row.Cells[6].Value = dr[9].ToString();
                row.Cells[7].Value = "More deteils";
                dataGridView1.Rows.Add(row);
            }
        }
コード例 #4
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            Sim             s3   = new Sim();
            Int32           rows = (e.RowIndex);
            DataGridViewRow row  = (DataGridViewRow)dataGridView1.Rows[rows];

            s3.userID = Convert.ToInt32(row.Cells[0].Value);
            string             select = "SELECT * FROM sim_registaration.sim where SIM_Id='" + s3.userID + "';";
            DataBase_connector db1    = new DataBase_connector();
            DataTable          dt     = db1.read(select);

            foreach (DataRow dr in dt.Rows)
            {
                Form3 f1 = new Form3();
                f1.textBox1.Text = dr[2].ToString();
                if (row.Cells[1].Value.ToString() == "")
                {
                    f1.textBox2.Enabled = false;
                }
                else
                {
                    f1.textBox2.Text = dr[1].ToString();
                }
                f1.textBox3.Text = dr[3].ToString();
                f1.textBox4.Text = dr[4].ToString();
                f1.textBox5.Text = dr[5].ToString();
                f1.textBox6.Text = dr[6].ToString();
                f1.label9.Text   = dr[8].ToString();
                f1.label10.Text  = dr[0].ToString();
                string mobiletype = dr[8].ToString();
                f1.Text          = "SIMRegistration [" + mobiletype + "]";
                f1.textBox8.Text = dr[10].ToString();
                f1.textBox7.Text = dr[11].ToString();
                string img1location = dr[10].ToString();
                string img2location = dr[11].ToString();

                f1.pictureBox1.Image = Image.FromFile(img1location);
                f1.pictureBox2.Image = Image.FromFile(img2location);

                string Gender = dr[7].ToString();
                if (Gender == "Male")
                {
                    f1.radioButton1.Checked = true;
                }
                else
                {
                    f1.radioButton2.Checked = true;
                }
                Form2 f2 = new Form2();
                {
                    f1.button1.Visible = false;
                    f1.button2.Visible = true;
                }

                this.Hide();
                f1.ShowDialog();
                dataGridView1.Rows.Clear();
                this.dataload();
                this.Show();
            }
        }