Beispiel #1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            List <DatabaseColumn> list = new List <DatabaseColumn>();
            CombineDataGridView   combineDataGridView = new CombineDataGridView();

            if (txtSearch.Text != "")
            {
                DatabaseColumn databaseColumn = new DatabaseColumn();
                Connector      connector      = new MYSQLDatabaseConnection();
                connector.establish();

                if (redioBtnCompanyName.Checked == true)
                {
                    databaseColumn.company_name = txtSearch.Text.ToString();
                    connector.SetData(databaseColumn);
                    list = connector.SearchCompanyWithName();
                    combineDataGridView.SetDataGridViewList(list, mDgv);//connect main window datagridview
                }
                else if (redioBtnCompanyAddress.Checked == true)
                {
                    databaseColumn.company_address = txtSearch.Text.ToString();
                    connector.SetData(databaseColumn);
                    list = connector.SearchCompanyWithAddress();
                    combineDataGridView.SetDataGridViewList(list, mDgv);
                }
                else if (redioBtnCompanyPhoneNumber.Checked == true)
                {
                    databaseColumn.company_phone_no = txtSearch.Text.ToString();
                    connector.SetData(databaseColumn);
                    list = connector.SearchCompanyWithPhoneNo();
                    combineDataGridView.SetDataGridViewList(list, mDgv);
                }
                else if (redioBtnCompanyId.Checked == true)
                {
                    databaseColumn.company_id = txtSearch.Text.ToString();
                    connector.SetData(databaseColumn);
                    list = connector.SearchCompanyWithId();
                    combineDataGridView.SetDataGridViewList(list, mDgv);
                }

                if (list.Count > 0)
                {
                    txtCompanyAddress.Text     = list[0].company_address;
                    txtCompanyId.Text          = list[0].company_id;
                    txtCompanyName.Text        = list[0].company_name;
                    txtCompanyPhoneNumber.Text = list[0].company_phone_no;
                }
                else
                {
                    txtCompanyAddress.Clear();
                    txtCompanyId.Clear();
                    txtCompanyName.Clear();
                    txtCompanyPhoneNumber.Clear();
                }
            }
            else
            {
                combineDataGridView.SetDataGridViewList(list, mDgv);
            }
        }
Beispiel #2
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            if (cmbCompanyName.SelectedItem != null && cmbCategoryName.SelectedItem != null && cmbProductName.SelectedItem != null)
            {
                Connector connection = new MYSQLDatabaseConnection();

                DatabaseColumn dataset = new DatabaseColumn();
                dataset.product_id     = connection.SearchProductList(tempProductList, cmbProductName.SelectedIndex.ToString()).product_id;
                dataset.stock_date     = txtStockDate.Text.ToString();
                dataset.invoice_number = txtInvoiceNumber.Text.ToString();
                dataset.start_quantity = txtQuantity.Text.ToString();
                dataset.exp_date       = txtExpDate.Text.ToString();
                dataset.get_price      = txtGetPrice.Text.ToString();
                dataset.barcode        = barcode;
                connection.SetData(dataset);

                connection.establish();
                if (connection.ChangeStockDetails())
                {
                    List <DatabaseColumn> dgvList = new List <DatabaseColumn>();
                    dgvList.Add(dataset);
                    CombineDataGridView combindDataGrid = new CombineDataGridView();
                    combindDataGrid.SetDataGridViewList(dgvList, dgv);
                    MessageBox.Show("changed");
                }
                else
                {
                    MessageBox.Show("can't changed");
                }
            }
            else
            {
                MessageBox.Show("fill all requred data");
            }
        }
Beispiel #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Connector      databaseConnect = new MYSQLDatabaseConnection();
            DatabaseColumn databaseColumn  = new DatabaseColumn();

            databaseColumn.category_name = txtCategoryName.Text.ToString();
            databaseColumn.category_id   = txtCategoryId.Text.ToString();

            databaseConnect.SetData(databaseColumn);



            if (databaseConnect.establish() == true && databaseConnect.InsertCategoryDetails() == true)
            {
                var list = new List <DatabaseColumn>()
                {
                    new DatabaseColumn {
                        category_name = txtCategoryName.Text.ToString(), category_id = txtCategoryId.Text.ToString()
                    }
                };
                CombineDataGridView combineDataGridView = new CombineDataGridView();
                combineDataGridView.SetDataGridViewList(list, mDgv);//connect main window datagridview

                txtCategoryId.Clear();
                txtCategoryName.Clear();
            }
            else
            {
                MessageBox.Show("operation error");
            }
        }
Beispiel #4
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DatabaseColumn        databaseColumn      = new DatabaseColumn();
            List <DatabaseColumn> list                = new List <DatabaseColumn>();
            CombineDataGridView   combineDataGridView = new CombineDataGridView();

            if (txtSearch.Text != "")
            {
                Connector connector = new MYSQLDatabaseConnection();
                connector.establish();


                if (redioBtnCategoryName.Checked == true)
                {
                    databaseColumn.category_name = txtSearch.Text.ToString();
                    connector.SetData(databaseColumn);
                    list = connector.SearchCategoryWithName();
                    combineDataGridView.SetDataGridViewList(list, mDgv);//connect main window datagridview
                }
                else if (redioBtnCategoryId.Checked == true)
                {
                    databaseColumn.category_id = txtSearch.Text.ToString();
                    connector.SetData(databaseColumn);
                    list = connector.SearchCategoryWithId();
                    combineDataGridView.SetDataGridViewList(list, mDgv);
                }
                if (list.Count > 0)
                {
                    txtCategoryId.Text   = list[0].category_id;
                    txtCategoryName.Text = list[0].category_name;
                }
                else
                {
                    txtCategoryName.Clear();
                    txtCategoryId.Clear();
                }
            }
            else
            {
                txtCategoryName.Clear();
                txtCategoryId.Clear();
            }
        }
Beispiel #5
0
 private void txtBarcodeValue_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (insertStock.InsertStock())
         {
             CombineDataGridView datagrid = new CombineDataGridView();
             datagrid.SetDataGridViewList(columnList, mDGV);
             this.Close();
         }
     }
 }
Beispiel #6
0
        private void btnAdd_Click_1(object sender, EventArgs e)
        {
            if (txtDiscount.Text != "" && txtMinimumQuantity.Text != "" && txtProductId.Text != "" && txtProductName.Text != "" && txtSellPrice.Text != "" && cmbCategoryName.Text != "" && cmbCompanyName.Text != "")
            {
                Connector      databaseConnect = new MYSQLDatabaseConnection();
                DatabaseColumn databaseColumn  = new DatabaseColumn();

                CombineDataGridView   combineDataGridView = new CombineDataGridView();
                List <DatabaseColumn> list = new List <DatabaseColumn>();

                /*get data into database column object*/
                databaseColumn.product_id             = txtProductId.Text.ToString();
                databaseColumn.product_name           = txtProductName.Text.ToString();
                databaseColumn.company_name           = cmbCompanyName.Text;
                databaseColumn.category_id            = databaseConnect.SearchCategoryList(TempCategoryList, cmbCategoryName.Text).category_id;
                databaseColumn.category_name          = cmbCategoryName.Text;
                databaseColumn.company_id             = databaseConnect.SearchCompanyList(TempCompanyList, cmbCompanyName.Text).company_id;
                databaseColumn.minimum_quantity       = txtMinimumQuantity.Text.ToString();
                databaseColumn.product_discount_price = txtDiscount.Text.ToString();
                databaseColumn.sell_price             = txtSellPrice.Text.ToString();


                databaseConnect.SetData(databaseColumn);
                databaseConnect.establish();

                if (databaseConnect.InsertProductDetails() == true)
                {
                    list.Add(databaseColumn);
                    combineDataGridView.SetDataGridViewList(list, mDgv);//connect main window datagridview
                    MessageBox.Show("comlete");
                    txtDiscount.Clear();
                    txtMinimumQuantity.Clear();
                    txtProductId.Clear();
                    txtProductName.Clear();
                    txtSellPrice.Clear();
                    cmbCategoryName.Text = "";
                    cmbCompanyName.Text  = "";
                }
                else
                {
                    MessageBox.Show("operation error");
                }
            }
            else
            {
                MessageBox.Show("Fill all deteils");
            }
        }
Beispiel #7
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you Sure update product details?", "Veryfy", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Connector connector = new MYSQLDatabaseConnection();

                /*catch update details into databaseColumn*/
                DatabaseColumn updateDatabaseColumn = new DatabaseColumn();
                updateDatabaseColumn.company_id             = connector.SearchCompanyList(TempCompanyList, cmbCompanyName.SelectedItem.ToString()).company_id;
                updateDatabaseColumn.category_id            = connector.SearchCategoryList(TempCategoryList, cmbCategoryName.SelectedItem.ToString()).category_id;
                updateDatabaseColumn.product_id             = txtProductId.Text.ToString();
                updateDatabaseColumn.product_name           = txtProductName.Text;
                updateDatabaseColumn.sell_price             = txtSellPrice.Text;
                updateDatabaseColumn.product_discount_price = txtDiscount.Text;
                updateDatabaseColumn.minimum_quantity       = txtMinimumQuantity.Text;

                List <DatabaseColumn> TempListForDGV = new List <DatabaseColumn>();
                TempListForDGV.Add(updateDatabaseColumn);


                connector.establish();
                connector.SetData(updateDatabaseColumn);

                if (connector.ChangeProductDetails() == true)
                {
                    CombineDataGridView combineDataGridView = new CombineDataGridView();
                    combineDataGridView.SetDataGridViewList(TempListForDGV, mDgv);
                    MessageBox.Show("Update compliete");
                    txtDiscount.Clear();
                    txtMinimumQuantity.Clear();
                    txtProductId.Clear();
                    txtProductName.Clear();
                    txtSellPrice.Clear();
                }
                else
                {
                    MessageBox.Show("Try again");
                }
            }
        }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {   // Add company details into database
            DatabaseColumn databaseColumn = new DatabaseColumn();

            Connector connector = new MYSQLDatabaseConnection();


            databaseColumn.company_name     = txtCompayName.Text.ToString();
            databaseColumn.company_phone_no = txtCompanyPhoneNumber.Text.ToString();
            databaseColumn.company_address  = txtCompanyAddress.Text.ToString();
            databaseColumn.company_id       = txtCompanyId.Text.ToString();
            connector.SetData(databaseColumn);

            if (connector.establish() == true && connector.InsertCompanyDetails() == true)
            {
                //create database column list with data
                var list = new List <DatabaseColumn>()
                {
                    new DatabaseColumn {
                        company_name = txtCompayName.Text.ToString(), company_phone_no = txtCompanyPhoneNumber.Text.ToString(), company_address = txtCompanyAddress.Text.ToString(), company_id = txtCompanyId.Text.ToString()
                    }
                };

                CombineDataGridView combineDataGridView = new CombineDataGridView();
                combineDataGridView.SetDataGridViewList(list, mDgv);//connect main window datagridview

                MessageBox.Show("Compleat");

                txtCompanyPhoneNumber.Clear();
                txtCompayName.Clear();
                txtCompanyAddress.Clear();
                txtCompanyId.Clear();
            }
            else
            {
                MessageBox.Show("operation error");
            }
        }