コード例 #1
0
        private void BunifuFlatButton1_Click(object sender, EventArgs e)
        {
            string ext = Path.GetExtension(filepath);

            if (string.IsNullOrEmpty(bunifuMaterialTextbox1.Text.Trim()) && string.IsNullOrEmpty(bunifuMaterialTextbox2.Text.Trim()) && string.IsNullOrEmpty(bunifuMaterialTextbox3.Text.Trim()))
            {
                MessageBox.Show("You must provide all fields", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                DBconnect dBconnect = new DBconnect();
                void insert()
                {
                    dBconnect.Insert($"INSERT INTO customers (CustomerName,Mobile,Address,Picture) VALUES('{bunifuMaterialTextbox1.Text}','{bunifuMaterialTextbox2.Text}','{bunifuMaterialTextbox3.Text}','{pictureBox1.Tag}')");
                    dBconnect.Select("SELECT * FROM  customers", dataGridView1);
                    dataGridView1.Update();
                }

                if (pictureBox1.Image == null)
                {
                    insert();
                }
                else
                {
                    File.Copy(filepath, imagesPath + bunifuMaterialTextbox2.Text + ext, true);
                    pictureBox1.Tag = bunifuMaterialTextbox2.Text + ext;
                    insert();
                }
            }

            dataGridView1.Rows[dataGridView1.Rows.Count - 1].Selected = true;
            dataGridView1.FirstDisplayedScrollingRowIndex             = dataGridView1.Rows.Count - 1;
        }
コード例 #2
0
        public Data()
        {
            DBconnect dBconnect = new DBconnect();

            InitializeComponent();
            backgroundWorker1.RunWorkerAsync();
        }
コード例 #3
0
        private void btn_update_Click(object sender, EventArgs e)
        {
            string RegNumber = textBox2.Text;

            DBconnect db = new DBconnect();

            db.Update($"UPDATE students SET RegistrationNumber={RegNumber} WHERE Name='john'");
        }
コード例 #4
0
        public Form2()
        {
            InitializeComponent();
            //load the combobox
            DBconnect DB = new DBconnect();

            DB.LoadComboBox("SELECT * FROM users ", name);
        }
コード例 #5
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            string Name      = textBox1.Text;
            string RegNumber = textBox2.Text;

            DBconnect db = new DBconnect();

            db.Insert("INSERT INTO students (Name, RegistrationNumber) VALUES('" + Name + "', '" + RegNumber + "')");
        }
コード例 #6
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DBconnect dBconnect = new DBconnect();

            int index = e.RowIndex;

            DataGridViewRow row = dataGridView1.Rows[index];

            bunifuMaterialTextbox1.Text = row.Cells[0].Value.ToString();
            bunifuMaterialTextbox2.Text = row.Cells[1].Value.ToString();
            bunifuMaterialTextbox3.Text = row.Cells[2].Value.ToString();
            dBconnect.LoadImage($"SELECT Picture FROM customers WHERE id='{row.Cells[0].Value.ToString()}'", pictureBox1);
            toolStripStatusLabel1.Text = (row.Cells[e.ColumnIndex].Value.ToString());
        }
コード例 #7
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            DBconnect dBconnect = new DBconnect();

            dBconnect.LoadTextBox("SELECT CustomerName FROM customers", textBox1);
            DBconnect bconnect = new DBconnect();

            bconnect.LoadComboBox("SELECT id FROM customers", comboBox1);


            DBconnect dBcconnect = new DBconnect();

            dBcconnect.Select("SELECT * FROM  customers", dataGridView1);
            dataGridView1.Sort(dataGridView1.Columns["Mobile"], ListSortDirection.Ascending);
        }
コード例 #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            String    Username = username.Text;
            String    Password = password.Text;
            String    Level    = level.Text;
            DBconnect db       = new DBconnect();

            // pictureBox1.Visible = true;
            if (db.hasRegistered($"SELECT * FROM users WHERE Username='******' AND Level='{Level}'") == false)
            {
                db.Register($"INSERT INTO users (Username,Password,Level) VALUES('{Username}','{Password}','{Level}')");
                // pictureBox1.Visible = false;
                DialogResult result = MessageBox.Show("Successfully Registerd", "Secured", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (result == DialogResult.OK)
                {
                }
            }
            else
            {
                MessageBox.Show("User Exists", "Secured", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //  pictureBox1.Visible = false;
            }
        }
コード例 #9
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(username.Text.Trim()))
            {
                infor.Visible   = true;
                infor.BackColor = Color.IndianRed;

                label4.Text = "Please Provide Your Username !";
                username.Focus();
            }
            else if (string.IsNullOrEmpty(password.Text.Trim()))
            {
                infor.Visible = true;
                label4.Text   = "Please Provide Your Password !";

                password.Focus();
            }
            else
            {
                String    Username = username.Text;
                String    Password = password.Text;
                String    Level    = level.Text;
                DBconnect db       = new DBconnect();
                //Clipboard.SetText($" SELECT * FROM users WHERE Username = '******'AND Password = '******' AND Level = '{level}'");

                if (db.IsLogin($"SELECT * FROM users WHERE Username='******'AND Password='******' AND Level='{Level}'"))

                {
                    new MainMenu(username.Text, level.Text).ShowDialog();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Password/Username Incorrect", "Secured", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #10
0
        private void DeletebunifuFlatButton_Click(object sender, EventArgs e)
        {
            DBconnect dBconnect = new DBconnect();

            dBconnect.Delete($"DELETE FROM customers WHERE CustomerName='{bunifuMaterialTextbox1.Text}'");
        }
コード例 #11
0
        private void UpdatebunifuFlatButton_Click(object sender, EventArgs e)
        {
            DBconnect dBconnect = new DBconnect();

            dBconnect.Update($"UPDATE customers SET Mobile={bunifuMaterialTextbox2.Text},Address={bunifuMaterialTextbox3.Text},Picture={pictureBox1.Image} WHERE CustomerName='{bunifuMaterialTextbox1.Text}'");
        }
コード例 #12
0
        private void textBox1_TextChanged_1(object sender, EventArgs e)
        {
            DBconnect dBconnect = new DBconnect();

            dBconnect.Select($"SELECT * FROM customers WHERE CustomerName LIKE '{textBox1.Text + "%"}'", dataGridView1);
        }
コード例 #13
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DBconnect dBconnect = new DBconnect();

            dBconnect.Select($"Select * FROM customers WHERE id={comboBox1.Text}", dataGridView1);
        }
コード例 #14
0
        private void name_TextChanged(object sender, EventArgs e)
        {
            DBconnect DB = new DBconnect();

            DB.LoadComboBox("SELECT id FROM customers ", comboBox1);
        }
コード例 #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            DBconnect db = new DBconnect();

            db.Select("SELECT * FROM students", dataGridView1);
        }
コード例 #16
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            DBconnect db = new DBconnect();

            db.Delete("DELETE FROM students WHERE name='john'");
        }