private void CompanyForm_Load(object sender, EventArgs e) { //fill gridView with data from db string fetch = "SELECT * FROM companies ORDER BY id DESC"; _common.FillGrid(fetch, connection, companyGridView); }
private void addButton_Click(object sender, EventArgs e) { User user = new User(); if (adminRadioButton.Checked) { user.userType = 1; } else if (userRadioButton.Checked) { user.userType = 2; } if (userNameSetTextBox.Text != "" && passwordSetTextBox.Text != "" && RadioButtonValidation() == true) { user.userName = userNameSetTextBox.Text; user.PassWord = passwordSetTextBox.Text; try { //search for same category string search = "SELECT * FROM Users WHERE UserName='******' AND PassWord='******' "; bool result = _common.Reader(connection, search); if (result == true) { warningLabel.Text = "User already Exist!"; return; } else { //insert string userAddQuery = @"INSERT INTO Users VALUES('" + user.userName + "', '" + user.PassWord + "', '" + user.userType + "')"; _common.QueryOperation(userAddQuery, connection); MessageBox.Show("Added Successfully!!"); userNameSetTextBox.ResetText(); passwordSetTextBox.ResetText(); } //Update Function string fetch = "SELECT * FROM Users ORDER BY Id DESC"; _common.FillGrid(fetch, connection, userGridView); } catch (Exception exception) { Console.WriteLine(exception); throw; } } else { MessageBox.Show("Please Fill properly!!"); return; } }
public void LoadData(DataGridView gridView, string table) { //grid fill with data from db string fetch = "SELECT * FROM " + table + " ORDER BY id DESC"; _common.FillGrid(fetch, connection, gridView); }
private void searchButton_Click(object sender, EventArgs e) { if (RadioButtonValidation() == true) { string fromDate = fromDatePicker.Value.Date.ToShortDateString(); string toDate = toDatePicker.Value.Date.ToShortDateString(); string type; string query; if (soldRadioButton.Checked) { type = "sold"; } else if (damagedRadioButton.Checked) { type = "damaged"; } else if (lostRadioButton.Checked) { type = "lost"; } else { type = ""; } if (allRadioButton.Checked) { query = " SELECT * FROM stockout where date BETWEEN '" + fromDate + "'AND '" + toDate + "'"; } else { query = " SELECT * FROM stockout WHERE stockouttype = '" + type + "' And date BETWEEN '" + fromDate + "'AND '" + toDate + "'"; } try { _common.FillGrid(query, connection, summaryGridView); summaryGridView.Columns["Id"].Visible = false; summaryGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; } catch (Exception exception) { MessageBox.Show(exception.Message); connection.Close(); } } else { MessageBox.Show("Please check type of StockOut"); } }
private void searchButton_Click(object sender, EventArgs e) { int companyId = Convert.ToInt32(companyComboBox.SelectedValue); int categoryId = Convert.ToInt32(categoryComboBox.SelectedValue); string searchQuery = " SELECT name,reorderlevel,Quantity FROM items INNER JOIN stockin ON items.Id=stockin.itemId where items.categoryid =" + categoryId + ""; //companyId="+companyId+" try { _common.FillGrid(searchQuery, connection, resultDataGridView); resultDataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; } catch (Exception exception) { string msg = "No Items found in selected Category for this Company."; MessageBox.Show(msg); connection.Close(); } }