コード例 #1
0
        private void categoriasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FormCategory category = new FormCategory();

            category.Show();
        }
コード例 #2
0
        private void btnDoClick(object sender, EventArgs e)
        {
            /*Check Selected Index*/
            int index = 0;

            if (dgvProduct.Rows.Count > 0)
            {
                index = (int)dgvProduct.Rows[dgvProduct.CurrentCell.RowIndex].Cells[0].Value;
            }
            if (sender == btnDetails)
            {
                if (index != 0)
                {
                    FormProductDetails proDetails = new FormProductDetails(0, index);
                    proDetails.ShowDialog();
                }
            }
            else if (sender == btnUpdate)
            {
                if (index != 0)
                {
                    FormProductDetails proDetails = new FormProductDetails(2, index);
                    proDetails.ShowDialog();
                    if (proDetails.SuccesUpdate == true)
                    {
                        MessageSuccess("Update Success", "Update");
                        if (!UpdateDataRow())
                        {
                            LoadDatabase("FillProducData");
                        }
                    }
                    SetFooter();
                }
            }
            else if (sender == btnAdd)
            {
                if (index != 0)
                {
                    FormProductDetails frmAdd = new FormProductDetails(1, index);
                    frmAdd.Created += frmAdd_Created;
                    frmAdd.ShowDialog();
                }
            }
            else if (sender == btnCategory)
            {
                if (categoryForm == null)
                {
                    categoryForm = new FormCategory();
                    categoryForm.Show();
                    categoryForm.FormClosed += cate_FormClosed;
                }
                else
                {
                    categoryForm.BringToFront();
                }
            }
            else if (sender == btnSearch)
            {
                if (!string.IsNullOrEmpty(txtSearch.Text))
                {
                    searchType = cboTypeSearch.SelectedIndex + 1;
                    searchText = txtSearch.Text;
                    if (searchType == 3)
                    {
                        SearchDatabase("SearchByPrice");
                    }
                    else
                    {
                        SearchDatabase("SearchProductData");
                    }
                    searchType     = 1;
                    searchText     = "";
                    txtSearch.Text = "";
                    SetFooter();
                }
            }
            else if (sender == btnRefresh)
            {
                LoadDatabase("FillProductData");
                SetFooter();
            }
        }