コード例 #1
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (textBox3.Text != "" && textBox4.Text != "")
     {
         if (textBox3.Text == textBox4.Text)
         {
             u1.password = textBox3.Text;
             DataBase_connector dc     = new DataBase_connector();
             string             update = "UPDATE `sim_registaration`.`user` SET `Password`='" + u1.password + "' WHERE `UserID`='" + u1.userID + "';";
             dc.datainput(update);
             MessageBox.Show("Succsessfully reset you password");
             textBox1.Text = "";
             textBox2.Text = "";
             textBox3.Text = "";
             textBox4.Text = "";
             textBox5.Text = "";
         }
         else
         {
             MessageBox.Show("Password not match please re check");
         }
     }
     else
     {
         MessageBox.Show("fill the all fields");
     }
 }
コード例 #2
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");
     }
 }
コード例 #3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "" && textBox6.Text != "" && pictureBox1.Image != null && pictureBox2.Image != null && (radioButton1.Checked || radioButton2.Checked))
            {
                //pass customer details to Sim class
                Sim s1 = new Sim();
                s1.sim_num = textBox1.Text;
                s1.P_num   = textBox2.Text;
                s1.F_name  = textBox3.Text;
                s1.L_name  = textBox4.Text;
                s1.nic     = textBox5.Text;
                s1.address = textBox6.Text;
                s1.img1Loc = textBox8.Text;
                s1.img2Loc = textBox7.Text;
                string newFileName1 = s1.img1Loc.Replace("\\", "\\\\");
                string newFileName2 = s1.img2Loc.Replace("\\", "\\\\");
                if (radioButton1.Checked)
                {
                    s1.Gender = "Male";
                }
                else if (radioButton2.Checked)
                {
                    s1.Gender = "Female";
                }


                s1.SIM_Category = label9.Text;

                // pass data to database
                s1.date = DateTime.Now.ToString("yyyy/MM/dd");
                string             add = "INSERT INTO `sim_registaration`.`sim` (`phonnumbr`, `SIM_Number`, `First Name`, `Last Name`, `NIC Number`, `Address`, `Gender`, `SIM Category`, `Date`, `img1Location`, `img2Location`) VALUES ('" + s1.P_num + "', '" + s1.sim_num + "', '" + s1.F_name + "', '" + s1.L_name + "', '" + s1.nic + "', '" + s1.address + "', '" + s1.Gender + "', '" + s1.SIM_Category + "', '" + s1.date + "', '" + newFileName1 + "', '" + newFileName2 + "');";
                DataBase_connector db2 = new DataBase_connector();
                db2.datainput(add);
                MessageBox.Show("Successfuly save details");

                //image backup save
                //  File.Copy(textBox7.Text, Path.Combine(@"C:\Users\Chinthaka\Desktop\saveiamge\", Path.GetFileName(textBox7.Text)), true);


                //auto clear form data
                textBox1.Text     = "";
                textBox2.Text     = "";
                textBox3.Text     = "";
                textBox4.Text     = "";
                textBox5.Text     = "";
                textBox6.Text     = "";
                pictureBox1.Image = null;
                pictureBox2.Image = null;
            }
            else
            {
                MessageBox.Show("Please fill the all filed");
            }
        }
コード例 #4
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");
            }
        }
コード例 #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox8.Text != "" && textBox9.Text != "")
            {
                if (textBox7.Text == textBox8.Text)
                {
                    //pass user input to user class
                    Userclass u1 = new Userclass();
                    u1.F_name     = textBox1.Text;
                    u1.L_name     = textBox2.Text;
                    u1.address    = textBox3.Text;
                    u1.nic        = textBox4.Text;
                    u1.contact    = textBox5.Text;
                    u1.u_name     = textBox6.Text;
                    u1.password   = textBox7.Text;
                    u1.c_question = comboBox1.Text;
                    u1.c_answer   = textBox9.Text;

                    //pass data to database
                    string             add = "INSERT INTO `sim_registaration`.`user` (`UserName`, `Password`, `F_name`, `L_name`, `address`, `nic_num`, `contact_num`, `confirm_qustn`, `confirm_anwr`) VALUES('" + u1.u_name + "', '" + u1.password + "', '" + u1.F_name + "', '" + u1.L_name + "', '" + u1.address + "', '" + u1.nic + "', '" + u1.contact + "', '" + u1.c_question + "', '" + u1.c_answer + "');";
                    DataBase_connector db1 = new DataBase_connector();
                    db1.datainput(add);
                    MessageBox.Show("You have been successfuly");
                    // data clear
                    textBox1.Text  = "";
                    textBox2.Text  = "";
                    textBox3.Text  = "";
                    textBox4.Text  = "";
                    textBox5.Text  = "";
                    textBox6.Text  = "";
                    textBox7.Text  = "";
                    textBox8.Text  = "";
                    textBox9.Text  = "";
                    comboBox1.Text = "Select";
                }
                else
                {
                    MessageBox.Show("not match password please recheck");
                }
            }
            else
            {
                MessageBox.Show("Fill all fields");
            }
        }
コード例 #6
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);
            }
        }
コード例 #7
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox3.Text != "" && textBox4.Text != "" && textBox5.Text != "" && textBox6.Text != "" && pictureBox1.Image != null && pictureBox2.Image != null && (radioButton1.Checked || radioButton2.Checked))
            {
                //pass customer details to Sim class
                Sim s1 = new Sim();
                s1.sim_num = textBox1.Text;
                s1.P_num   = textBox2.Text;
                s1.F_name  = textBox3.Text;
                s1.L_name  = textBox4.Text;
                s1.nic     = textBox5.Text;
                s1.address = textBox6.Text;
                s1.img1Loc = textBox8.Text;
                s1.img2Loc = textBox7.Text;
                string newFileName1 = s1.img1Loc.Replace("\\", "\\\\");
                string newFileName2 = s1.img2Loc.Replace("\\", "\\\\");
                Int32  id           = Convert.ToInt32(label10.Text);
                if (radioButton1.Checked)
                {
                    s1.Gender = "Male";
                }
                else if (radioButton2.Checked)
                {
                    s1.Gender = "Female";
                }


                s1.SIM_Category = label9.Text;

                // update database data
                s1.date = DateTime.Now.ToString("yyyy/MM/dd");
                string             update = "UPDATE `sim_registaration`.`sim` SET `phonnumbr`='" + s1.P_num + "', `SIM_Number`='" + s1.sim_num + "', `First Name`='" + s1.F_name + "', `Last Name`='" + s1.L_name + "', `NIC Number`='" + s1.nic + "', `Address`='" + s1.address + "', `Gender`='" + s1.Gender + "', `SIM Category`='" + s1.SIM_Category + "', `Date`='" + s1.date + "', `img1Location`='" + newFileName1 + "', `img2Location`='" + newFileName2 + "' WHERE `SIM_Id`='" + id + "';";
                DataBase_connector db3    = new DataBase_connector();
                db3.datainput(update);

                //image backup save
                // File.Copy(textBox7.Text, Path.Combine(@"C:\Users\Chinthaka\Desktop\saveiamge\", Path.GetFileName(textBox7.Text)), true);

                //print
                printDocument1.PrintPage += printDocument1_PrintPage;
                if (printDialog1.ShowDialog() == DialogResult.OK)
                {
                    button1.Hide();
                    button2.Hide();
                    button3.Hide();
                    button4.Hide();
                    button5.Hide();
                    button6.Hide();
                    button7.Hide();

                    printDocument1.Print();
                }
                //auto clear form data
                textBox1.Text     = "";
                textBox2.Text     = "";
                textBox3.Text     = "";
                textBox4.Text     = "";
                textBox5.Text     = "";
                textBox6.Text     = "";
                pictureBox1.Image = null;
                pictureBox2.Image = null;
            }
            else
            {
                MessageBox.Show("Please fill the all filed");
            }
        }
コード例 #8
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();
            }
        }