Exemple #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidateChildren(ValidationConstraints.Enabled))
         {
             FormControls.ShowFields(false, txtName, txtSurname, txtAddress, txtPhoneNum, txtEmail, cBoxType, btnSave, btnCancel, label1, label2, label3, label4, label5, label6);
             SqlCommand command;
             if (isNew)
             {
                 command = new SqlCommand("insert into customer values ('" + txtName.Text + "','" + txtSurname.Text + "','" + txtAddress.Text + "','" + txtPhoneNum.Text + "','" + txtEmail.Text + "','" + cBoxType.Text + "','" + 0 + "')", FormControls.DbConnection);
             }
             else
             {
                 command = new SqlCommand("update customer set name = '" + txtName.Text + "', surname = '" + txtSurname.Text + "', address = '" + txtAddress.Text + "', phone_number = '" + txtPhoneNum.Text + "', email = '" + txtEmail.Text + "', type = '" + cBoxType.Text + "' where customer_id = '" + (int)dgv_Customer.CurrentRow.Cells[0].Value + "'", FormControls.DbConnection);
             }
             command.ExecuteNonQuery();
             FormControls.BindData(dgv_Customer, "customer");
             MessageBox.Show("Your data has been successfully saved.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #2
0
 private void btnNew_Click(object sender, EventArgs e)
 {
     FormControls.ShowFields(true, txtName, txtSurname, txtAddress, txtPhoneNum, txtEmail, cBoxType, btnSave, btnCancel, label1, label2, label3, label4, label5, label6);
     FormControls.ResetFields(txtName, txtSurname, txtAddress, txtPhoneNum, txtEmail, cBoxType);
     isNew = true;
     txtName.Focus();
 }
Exemple #3
0
 private void btn_Cancel_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Are you sure you want to cancel order editing?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         FormControls.ShowFields(false, gb_Status, gb_OrderDetails, btn_Save, btn_Cancel);
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidateChildren(ValidationConstraints.Enabled))
         {
             FormControls.ShowFields(false, txtProductId, txtName, txtPrice, txtStock, txtDiscount, cbBrand, cbColor, cbSize, rbClothing, rbFemale, rbFootwear, rbKids, rbMale, gb_Subtype, gb_Type, btnCancel, btnSave, label1, label2, label3, label4, label5, label6, label7, label8, label9, label11);
             SqlCommand command;
             if (isNew)
             {
                 command = new SqlCommand("insert into product values ('" + txtProductId.Text + "','" + txtName.Text + "','" + cbBrand.SelectedItem + "','" + CheckedRadioButton(gb_Type) + "','" + CheckedRadioButton(gb_Subtype) + "','" + cbColor.SelectedItem + "','" + cbSize.SelectedItem + "','" + txtPrice.Text + "','" + txtDiscount.Text + "','" + txtStock.Text + "')", FormControls.DbConnection);
             }
             else
             {
                 command = new SqlCommand("update product set product_id = '" + txtProductId.Text + "', name = '" + txtName.Text + "', brand = '" + cbBrand.SelectedItem + "', type = '" + CheckedRadioButton(gb_Type) + "', subtype = '" + CheckedRadioButton(gb_Subtype) + "', color = '" + cbColor.SelectedItem + "', size = '" + cbSize.SelectedItem + "', price = '" + txtPrice.Text + "', discount = '" + txtDiscount.Text + "', stock = '" + txtStock.Text + "' where id = '" + (int)dgv_Product.CurrentRow.Cells[0].Value + "'", FormControls.DbConnection);
             }
             command.ExecuteNonQuery();
             FormControls.BindData(dgv_Product, "product");
             MessageBox.Show("Your data has been successfully saved.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #5
0
 private void txt_Search_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txt_Search.Text))
     {
         FormControls.BindData(dgv_Orders, "orders");
     }
 }
Exemple #6
0
        private void btn_New_Click(object sender, EventArgs e)
        {
            NewOrder newOrder = new NewOrder();

            newOrder.ShowDialog(this);
            FormControls.BindData(dgv_Orders, "orders");
        }
 private void btnNew_Click(object sender, EventArgs e)
 {
     FormControls.ShowFields(true, txtProductId, txtName, txtPrice, txtStock, txtDiscount, cbBrand, cbColor, cbSize, rbClothing, rbFemale, rbFootwear, rbKids, rbMale, gb_Subtype, gb_Type, btnCancel, btnSave, label1, label2, label3, label4, label5, label6, label7, label8, label9, label11);
     FormControls.ResetFields(txtProductId, txtName, txtPrice, txtStock, txtDiscount, cbBrand, cbColor, cbSize, rbClothing, rbFemale, rbFootwear, rbKids, rbMale);
     isNew = true;
     txtProductId.Focus();
 }
 private void BindFields()
 {
     try
     {
         if (dgv_Product.CurrentRow.Index < dgv_Product.Rows.Count - 1)
         {
             txtProductId.Text    = (string)dgv_Product.CurrentRow.Cells[1].Value;
             txtName.Text         = (string)dgv_Product.CurrentRow.Cells[2].Value;
             cbBrand.SelectedItem = (string)dgv_Product.CurrentRow.Cells[3].Value;
             cbColor.SelectedItem = (string)dgv_Product.CurrentRow.Cells[6].Value;
             cbSize.SelectedItem  = dgv_Product.CurrentRow.Cells[7].Value.ToString();
             txtPrice.Text        = dgv_Product.CurrentRow.Cells[8].Value.ToString();
             txtDiscount.Text     = dgv_Product.CurrentRow.Cells[9].Value.ToString();
             gb_Type.Controls.OfType <RadioButton>().Where(r => r.Text == (string)dgv_Product.CurrentRow.Cells[4].Value).FirstOrDefault().Checked    = true;
             gb_Subtype.Controls.OfType <RadioButton>().Where(r => r.Text == (string)dgv_Product.CurrentRow.Cells[5].Value).FirstOrDefault().Checked = true;
             txtStock.Text = dgv_Product.CurrentRow.Cells[10].Value.ToString();
         }
         else
         {
             FormControls.ResetFields(txtProductId, txtName, txtPrice, txtStock, txtDiscount, cbBrand, cbColor, cbSize, rbClothing, rbFemale, rbFootwear, rbKids, rbMale);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void txtSearch_TextChanged(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(txtSearch.Text))
     {
         FormControls.BindData(dgv_Product, "product");
     }
 }
Exemple #10
0
        private void txt_Search_KeyDown(object sender, KeyEventArgs e)
        {
            SqlCommand command = new SqlCommand("select * from customer where order_id = '" + txt_Search.Text + "'", FormControls.DbConnection);

            if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(txt_Search.Text))
            {
                FormControls.BindData(dgv_Orders, command: command);
            }
        }
Exemple #11
0
        private void txtSearch_KeyDown(object sender, KeyEventArgs e)
        {
            SqlCommand command = new SqlCommand("select * from customer where name LIKE '" + txtSearch.Text + "%' OR surname LIKE '" + txtSearch.Text + "%' OR address LIKE '" + txtSearch.Text + "%' OR phone_number = '" + txtSearch.Text + "' OR email = '" + txtSearch.Text + "' OR type = '" + txtSearch.Text + "'", FormControls.DbConnection);

            if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(txtSearch.Text))
            {
                FormControls.BindData(dgv_Customer, "customer", command);
            }
        }
        private void txtSearch_KeyDown(object sender, KeyEventArgs e)
        {
            SqlCommand command = new SqlCommand("select * from product where product_id LIKE '" + txtSearch.Text + "%' OR name LIKE '" + txtSearch.Text + "%' OR price LIKE '" + txtSearch.Text + "%' OR discount = '" + txtSearch.Text + "'", FormControls.DbConnection);

            if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(txtSearch.Text))
            {
                FormControls.BindData(dgv_Product, "product", command);
            }
        }
Exemple #13
0
 private void btn_Save_Click(object sender, EventArgs e)
 {
     try
     {
         SqlCommand command = new SqlCommand("update orders set status = '" + gb_Status.Controls.OfType <RadioButton>().Where(r => r.Checked).FirstOrDefault().Text + "' where order_id = '" + (int)dgv_Orders.CurrentRow.Cells[0].Value + "'", FormControls.DbConnection);
         command.ExecuteNonQuery();
         FormControls.BindData(dgv_Orders, "orders");
         FormControls.ShowFields(false, gb_Status, gb_OrderDetails, btn_Save, btn_Cancel);
         MessageBox.Show("Your changes have been successfully saved.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         SqlCommand command = new SqlCommand("delete product where id = '" + (int)dgv_Product.CurrentRow.Cells[0].Value + "'", FormControls.DbConnection);
         if (MessageBox.Show("Are you sure you want to delete selected products?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             command.ExecuteNonQuery();
             FormControls.BindData(dgv_Product, "product");
             MessageBox.Show("Product successfully removed.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #15
0
        private void BindFields()
        {
            if (dgv_Orders.SelectedRows.Count == 1)
            {
                //binding customer who made the order
                SqlCommand getCustomer = new SqlCommand("select * from customer where customer_id = (select cast(customer_id as int) from customer_orders where order_id = '" + dgv_Orders.CurrentRow.Cells[0].Value + "')", FormControls.DbConnection);
                FormControls.BindData(dgv_Customer, command: getCustomer);
                FormControls.HideDGVColumns(dgv_Customer.Columns[0], dgv_Customer.Columns[6], dgv_Customer.Columns[7]);

                //binding products from order
                SqlCommand getProducts = new SqlCommand("select * from product where product_id = (select product_id from order_products where order_id = '" + dgv_Orders.CurrentRow.Cells[0].Value + "')", FormControls.DbConnection);
                FormControls.BindData(dgv_Products, command: getProducts);
                FormControls.HideDGVColumns(dgv_Products.Columns[1], dgv_Products.Columns[11]);
                UpdateProductAmount();

                //binding order status
                gb_Status.Controls.OfType <RadioButton>().Where(r => r.Text == dgv_Orders.CurrentRow.Cells[3].Value.ToString().Trim()).FirstOrDefault().Checked = true;
            }
        }
Exemple #16
0
 private void BindFields()
 {
     try
     {
         if (dgv_Customer.CurrentRow.Index < dgv_Customer.Rows.Count - 1)
         {
             txtName.Text          = (string)dgv_Customer.CurrentRow.Cells[1].Value;
             txtSurname.Text       = (string)dgv_Customer.CurrentRow.Cells[2].Value;
             txtAddress.Text       = (string)dgv_Customer.CurrentRow.Cells[3].Value;
             txtPhoneNum.Text      = (string)dgv_Customer.CurrentRow.Cells[4].Value;
             txtEmail.Text         = (string)dgv_Customer.CurrentRow.Cells[5].Value;
             cBoxType.SelectedItem = (string)dgv_Customer.CurrentRow.Cells[6].Value;
         }
         else
         {
             FormControls.ResetFields(txtName, txtSurname, txtAddress, txtPhoneNum, txtEmail, cBoxType);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #17
0
 private void OrdersManagement_Load(object sender, EventArgs e)
 {
     FormControls.BindData(dgv_Orders, "orders");
 }
 private void ProductsManagement_Load(object sender, EventArgs e)
 {
     FormControls.ShowFields(false, txtProductId, txtName, txtPrice, txtStock, txtDiscount, cbBrand, cbColor, cbSize, rbClothing, rbFemale, rbFootwear, rbKids, rbMale, gb_Subtype, gb_Type, btnCancel, btnSave, label1, label2, label3, label4, label5, label6, label7, label8, label9, label11);
     FormControls.SetComboboxDefaultValue(cbBrand, cbColor, cbSize);
     FormControls.BindData(dgv_Product, "product");
 }
Exemple #19
0
 private void btn_Edit_Click(object sender, EventArgs e)
 {
     FormControls.ShowFields(true, gb_Status, gb_OrderDetails, btn_Save, btn_Cancel, label2, label3);
 }
 private void txtStock_Validating(object sender, CancelEventArgs e)
 {
     FormControls.ProvideError(e, txtStock, errorProvider);
 }
 private void cbColor_Validating(object sender, CancelEventArgs e)
 {
     FormControls.ProvideError(e, cbColor, errorProvider);
 }
 private void gb_Subtype_Validating(object sender, CancelEventArgs e)
 {
     FormControls.ProvideError(e, gb_Subtype, errorProvider);
 }
Exemple #23
0
 private void CustomersManagement_Load(object sender, EventArgs e)
 {
     FormControls.ShowFields(false, txtName, txtSurname, txtAddress, txtPhoneNum, txtEmail, cBoxType, btnSave, btnCancel, label1, label2, label3, label4, label5, label6);
     FormControls.SetComboboxDefaultValue(cBoxType);
     FormControls.BindData(dgv_Customer, "customer");
 }