private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                Employee employee = new Employee();
                employee.ID       = Convert.ToInt32(txtID.Text);
                employee.FistName = txtFirstName.Text;
                employee.LastName = txtLastName.Text;
                employee.Sex      = txtSex.Text;
                employee.Age      = Convert.ToInt32(txtAge.Text);

                IDBManager db = new MySQLDBManager();
                db.AddEmployee(employee);
                BindingSource bindingsource = new BindingSource();
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = bindingsource;
                dataGridView1.Refresh();
                con = new MySqlConnection();
                con.ConnectionString = @"datasource=127.0.0.1;port=3306;username=root;password=;database=assigment1;Convert Zero Datetime=True;";
                con.Open();
                adapt = new MySqlDataAdapter("select id,first_name,last_name,sex,age from employees", con);
                ds    = new System.Data.DataSet();
                adapt.Fill(ds, "Employee_Details");
                dataGridView1.DataSource = ds.Tables[0];
                MessageBox.Show("Created!", "Add", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                Product product = new Product();
                product.Title       = txtTitle.Text;
                product.Description = txtDescription.Text;
                product.Color       = txtColor.Text;
                product.Size        = Convert.ToDouble(txtSize.Text);
                product.Price       = Convert.ToDouble(txtPrice.Text);
                product.Stock       = Convert.ToInt32(txtSize.Text);

                IDBManager db = new MySQLDBManager();
                db.Create(product);
                BindingSource bindingsource = new BindingSource();
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = bindingsource;
                dataGridView1.Refresh();
                con = new MySqlConnection();
                con.ConnectionString = @"datasource=127.0.0.1;port=3306;username=root;password=;database=assigment1;Convert Zero Datetime=True;";
                con.Open();
                adapt = new MySqlDataAdapter("select title ,description,color,size,price,stock from product", con);
                ds    = new System.Data.DataSet();
                adapt.Fill(ds, "Product_Details");
                dataGridView1.DataSource = ds.Tables[0];
                MessageBox.Show("Created!", "Add", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try{
         User user = new User();
         user.UserName = txtUserName.Text;
         user.Password = txtPassword.Text;
         user.FistName = txtFirstName.Text;
         user.LastName = textBox1.Text;
         if (!(user.UserName.Equals("admin")))
         {
             IDBManager db = new MySQLDBManager();
             db.RegisterUser(user);
             MessageBox.Show("Successfully registered!", "Register", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Hide();
         }
         else
         {
             MessageBox.Show("Invalid username!!!", "Register", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            DataGridViewRow newDataRow = dataGridView1.Rows[indexRow];

            newDataRow.Cells[0].Value = txtID.Text;
            newDataRow.Cells[1].Value = txtCustomer.Text;
            newDataRow.Cells[2].Value = txtAddress.Text;
            newDataRow.Cells[3].Value = txtDeliveryDate.Text;
            newDataRow.Cells[4].Value = txtStatus.Text;
            newDataRow.Cells[5].Value = txtPieces.Text;
            newDataRow.Cells[6].Value = txtValue.Text;
            newDataRow.Cells[7].Value = txtProductID.Text;
            try
            {
                Order order = new Order();
                order.ID           = Convert.ToInt32(txtID.Text);
                order.Customer     = txtCustomer.Text;
                order.Address      = txtAddress.Text;
                order.DeliveryDate = Convert.ToDateTime(txtDeliveryDate.Text);
                order.Status       = txtStatus.Text;
                order.Pieces       = Convert.ToInt32(txtPieces.Text);
                order.Value        = Convert.ToInt32(txtValue.Text);
                order.ProductID    = Convert.ToInt32(txtProductID.Text);


                IDBManager db = new MySQLDBManager();
                db.UpdateOrder(order);
                BindingSource bindingsource = new BindingSource();
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = bindingsource;
                dataGridView1.Refresh();
                con = new MySqlConnection();
                con.ConnectionString = @"datasource=127.0.0.1;port=3306;username=root;password=;database=assigment1;Convert Zero Datetime=True;";
                con.Open();
                adapt = new MySqlDataAdapter("SELECT `id`, `customer`, `address`, `delivery_date`, `status`, `pieces`, `value`, `product_id` FROM `order` ", con);
                ds    = new System.Data.DataSet();
                adapt.Fill(ds, "Order_Details");
                dataGridView1.DataSource = ds.Tables[0];
                MessageBox.Show("Updated!", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }