private void btnAddAccount_Click(object sender, EventArgs e) { DatabaseColumn dataset = new DatabaseColumn(); Connector connection = new MYSQLDatabaseConnection(); dataset.counter_id = connection.SearchCounterList(counterList, cmbCounterName.Text.ToString()).counter_id; dataset.type = cmbType.SelectedIndex.ToString(); dataset.user_name = txtUserName.Text.ToString(); dataset.user_id = txtUserId.Text.ToString(); dataset.password = txtPassword.Text.ToString(); dataset.counter_name = cmbCounterName.Text.ToString(); connection.SetData(dataset); connection.establish(); if (connection.InsertUser()) { MessageBox.Show("Complete"); txtPassword.Clear(); txtUserId.Clear(); txtUserName.Clear(); txtVerifyPassowrd.Clear(); } else { MessageBox.Show("Error"); } }
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"); } }
private void cmbCompanyName_SelectedIndexChanged(object sender, EventArgs e) { var t = new Task(() => { }); t.Start(); t.ContinueWith(task => { Connector databaseConnectCategory = new MYSQLDatabaseConnection(); companyId = databaseConnectCategory.SearchCompanyList(tempCompanyList, cmbCompanyName.SelectedItem.ToString()); if (databaseConnectCategory.establish() == true) { databaseConnectCategory.SetData(companyId); List <DatabaseColumn> CategoryList = databaseConnectCategory.GetCategoryNameForEachCompany(); foreach (DatabaseColumn databseColumn in CategoryList) { cmbCategoryName.Items.Add(databseColumn.category_name);//add category name into combo box tempCategoryList.Add(new DatabaseColumn() { category_name = databseColumn.category_name, category_id = databseColumn.category_id, } ); } } else { MessageBox.Show("connection error"); } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
private void btnChange_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you Sure update company details?", "Veryfy", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { /*catch update details into databaseColumn*/ DatabaseColumn updateDatabaseColumn = new DatabaseColumn(); updateDatabaseColumn.company_id = txtCompanyId.Text.ToString(); updateDatabaseColumn.company_name = txtCompanyName.Text.ToString(); updateDatabaseColumn.company_address = txtCompanyAddress.Text.ToString(); updateDatabaseColumn.company_phone_no = txtCompanyPhoneNumber.Text.ToString(); Connector connector = new MYSQLDatabaseConnection(); connector.establish(); connector.SetData(updateDatabaseColumn); if (connector.ChangeCompany() == true) { MessageBox.Show("Update compliete"); /*refresh main data grid view and show update company deteils*/ redioBtnCompanyId.Checked = true; txtSearch.Text = txtCompanyId.Text; btnSearch.PerformClick(); } else { MessageBox.Show("Try again"); } } }
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"); } }
private void AddStock_Shown(object sender, EventArgs e) { var t = new Task(() => { }); t.Start(); t.ContinueWith(task => { Connector databaseConnectCompany = new MYSQLDatabaseConnection(); if (databaseConnectCompany.establish() == true) { List <DatabaseColumn> CompanyList = databaseConnectCompany.GetAllCompanyNameWithId(); foreach (DatabaseColumn databseColumn in CompanyList) { cmbCompanyName.Items.Add(databseColumn.company_name);//add company name into combo box tempCompanyList.Add(new DatabaseColumn() { company_name = databseColumn.company_name, company_id = databseColumn.company_id, } ); } } else { MessageBox.Show("connection error"); } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
private void btnRemove_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you Sure delete category?", "Veryfy", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { /*catch update details into databaseColumn*/ DatabaseColumn deleteDatabaseColumn = new DatabaseColumn(); deleteDatabaseColumn.category_id = txtCategoryId.Text.ToString(); deleteDatabaseColumn.category_name = txtCategoryName.Text.ToString(); Connector connector = new MYSQLDatabaseConnection(); connector.establish(); connector.SetData(deleteDatabaseColumn); if (connector.RemoveCategory() == true) { MessageBox.Show("Delete compliete"); /*refresh main data grid view*/ redioBtnCategoryId.Checked = true; txtSearch.Text = txtCategoryId.Text; btnSearch.PerformClick(); txtSearch.Clear(); } else { MessageBox.Show("Try again"); } } }
private void SetCategoryListIntoCategoryComboBox() { var t = new Task(() => { }); t.Start(); t.ContinueWith(task => { Connector databaseConnectCategory = new MYSQLDatabaseConnection(); if (databaseConnectCategory.establish() == true) { DatabaseColumn databaseColumn = new DatabaseColumn(); databaseColumn.company_id = databaseConnectCategory.SearchCompanyList(TempCompanyList, cmbSearchCompanyName.SelectedItem.ToString()).company_id; databaseConnectCategory.SetData(databaseColumn); List <DatabaseColumn> CategoryList = databaseConnectCategory.GetCategoryNameForEachCompany(); cmbSearchCategoryName.Items.Clear(); cmbSearchCategoryName.Text = ""; foreach (DatabaseColumn databseColumn in CategoryList) { cmbSearchCategoryName.Items.Add(databseColumn.category_name);//add category name into combo box } } else { MessageBox.Show("connection error"); } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
private void btnRemove_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("Are you Sure delete stock?", "Veryfy", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Connector connection = new MYSQLDatabaseConnection(); DatabaseColumn dataset = new DatabaseColumn(); dataset.barcode = barcode; connection.SetData(dataset); connection.establish(); if (connection.RemoveStockDetails()) { MessageBox.Show("Deleted"); } txtExpDate.Clear(); txtGetPrice.Clear(); txtInvoiceNumber.Clear(); txtQuantity.Clear(); txtStockDate.Clear(); cmbCategoryName.Text = ""; cmbCompanyName.Text = ""; cmbProductName.Text = ""; txtBarcode.Focus(); } }
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); } }
private void txtBarcode_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { Connector conection = new MYSQLDatabaseConnection(); DatabaseColumn dataset = new DatabaseColumn(); dataset.barcode = txtBarcode.Text.ToString(); barcode = txtBarcode.Text.ToString(); conection.SetData(dataset); conection.establish(); DatabaseColumn data = conection.GetStockUsingBarcode(); txtBarcode.Clear(); txtExpDate.Text = data.exp_date; txtGetPrice.Text = data.get_price; txtInvoiceNumber.Text = data.invoice_number; txtQuantity.Text = data.start_quantity; txtStockDate.Text = data.stock_date; cmbCompanyName.Text = data.company_name; cmbCategoryName.Text = data.category_name; cmbProductName.Text = data.product_name; var t = new Task(() => { }); t.Start(); t.ContinueWith(task => { Connector databaseConnectCompany = new MYSQLDatabaseConnection(); if (databaseConnectCompany.establish() == true) { List <DatabaseColumn> CompanyList = databaseConnectCompany.GetAllCompanyNameWithId(); foreach (DatabaseColumn databseColumn in CompanyList) { cmbCompanyName.Items.Add(databseColumn.company_name);//add company name into combo box tempCompanyList.Add(new DatabaseColumn() { company_name = databseColumn.company_name, company_id = databseColumn.company_id, } ); } } else { MessageBox.Show("connection error"); } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); } }
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"); } }
private void AddAccount_Shown(object sender, EventArgs e) { cmbCounterName.Focus(); Connector connection = new MYSQLDatabaseConnection(); connection.establish(); List <DatabaseColumn> Data = connection.GetCounter(); // counterList.Clear(); cmbCounterName.Items.Clear(); foreach (DatabaseColumn data in Data) { cmbCounterName.Items.Add(data.counter_name); counterList.Add(data); } }
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(); } }
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"); } } }
private void cmbCategoryName_SelectedIndexChanged(object sender, EventArgs e) { cmbProductName.Text = ""; cmbProductName.Items.Clear(); var t = new Task(() => { }); t.Start(); t.ContinueWith(task => { Connector databaseConnectProduct = new MYSQLDatabaseConnection(); DatabaseColumn dataSet = new DatabaseColumn(); categoryId = databaseConnectProduct.SearchCategoryList(tempCategoryList, cmbCategoryName.SelectedItem.ToString()); if (databaseConnectProduct.establish() == true) { dataSet.company_id = companyId.company_id; dataSet.category_id = categoryId.category_id; databaseConnectProduct.SetData(dataSet); List <DatabaseColumn> ProductList = databaseConnectProduct.GetProductNameForEachCompanyAndCategory(); foreach (DatabaseColumn databseColumn in ProductList) { cmbProductName.Items.Add(databseColumn.product_name);//add category name into combo box tempProductList.Add(new DatabaseColumn() { product_name = databseColumn.product_name, product_id = databseColumn.product_id, } ); } } else { MessageBox.Show("connection error"); } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
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"); } }
private void getProductDetails() { var t = new Task(() => { }); t.Start(); t.ContinueWith(task => { Connector databaseConnectProductDetails = new MYSQLDatabaseConnection(); if (databaseConnectProductDetails.establish() == true) { DatabaseColumn databaseColumn = new DatabaseColumn(); databaseColumn.company_id = databaseConnectProductDetails.SearchCompanyList(TempCompanyList, cmbSearchCompanyName.SelectedItem.ToString()).company_id; databaseColumn.category_id = databaseConnectProductDetails.SearchCategoryList(TempCategoryList, cmbSearchCategoryName.SelectedItem.ToString()).category_id; databaseColumn.product_id = databaseConnectProductDetails.SearchProductList(TempProductList, cmbSearchProductName.SelectedItem.ToString()).product_id; databaseConnectProductDetails.SetData(databaseColumn); DatabaseColumn ProductDetails = databaseConnectProductDetails.GetProductDetails(); txtProductId.Text = ProductDetails.product_id; txtProductName.Text = ProductDetails.product_name; txtSellPrice.Text = ProductDetails.sell_price; txtDiscount.Text = ProductDetails.product_discount_price; txtMinimumQuantity.Text = ProductDetails.minimum_quantity; cmbCategoryName.Text = ProductDetails.category_name; cmbCompanyName.Text = ProductDetails.company_name; } else { MessageBox.Show("connection error"); } }, System.Threading.CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext()); }
private void btnLogin_Click(object sender, EventArgs e) { prograsbarLogin.Value = 50; Connector databaseConnection = new MYSQLDatabaseConnection(); DatabaseColumn databaseColumn = new DatabaseColumn(); databaseColumn.user_name = txtUserName.Text.ToString(); databaseColumn.password = txtPassword.Text.ToString(); databaseConnection.SetData(databaseColumn); prograsbarLogin.Value = 80; if (databaseConnection.establish() == true) { if (databaseConnection.CheckLogin() == true) { prograsbarLogin.Value = 100; MainWindow mainWindow = new MainWindow(); this.Hide(); mainWindow.Show(); } else { prograsbarLogin.Value = 100; MessageBox.Show("wrong Password!"); } } else { ServerConfiguration serverConfiguration = new ServerConfiguration(); serverConfiguration.Show(); } }
private void cmbProductName_SelectedIndexChanged(object sender, EventArgs e) { Connector databaseConnectProductId = new MYSQLDatabaseConnection(); productId = databaseConnectProductId.SearchProductList(tempProductList, cmbProductName.SelectedItem.ToString()); }