private void toolStripStokIn_Click(object sender, EventArgs e) { string constring = ConString.DbConnection(); SqlConnection con = new SqlConnection(constring); con.Open(); MessageBox.Show("connection open"); con.Close(); }
private void saveButton_Click(object sender, EventArgs e) { if (nameTextBox.Text == String.Empty) { MessageBox.Show("please enter the category"); } else { Category category = new Category(); category.Name = nameTextBox.Text; //unique check bool flag = false; string conString1 = ConString.DbConnection(); SqlConnection connection = new SqlConnection(conString1); string query2 = "select id,name from category"; SqlCommand command = new SqlCommand(query2, connection); connection.Open(); SqlDataReader dr = command.ExecuteReader(); while (dr.Read()) { if (dr[1].ToString() == category.Name) { flag = true; break; } } if (flag == true) { lblNameValidation.Text = "This Category Exists"; lblNameValidation.ForeColor = Color.Red; return; } bool isInserted = _categoryManager.IsInserted(category); if (isInserted) { MessageBox.Show("Data Inserted "); nameTextBox.Text = String.Empty; lblNameValidation.Text = String.Empty; nameTextBox.Focus(); // string _conString = ConString.DbConnection(); SqlConnection con = new SqlConnection(_conString); string query = "select id,name from category order by id desc"; SqlCommand cmd = new SqlCommand(query, con); SqlDataAdapter da = new SqlDataAdapter(cmd); con.Open(); DataTable dt = new DataTable(); da.Fill(dt); con.Close(); categoryVMBindingSource.DataSource = dt; return; } MessageBox.Show("Data Failed"); } }
private void btnLogin_Click(object sender, EventArgs e) { string conString = ConString.DbConnection(); SqlConnection con = new SqlConnection(conString); string query = "select id,name,password from login"; SqlCommand command = new SqlCommand(query, con); SqlDataAdapter da = new SqlDataAdapter(command); DataTable dt = new DataTable(); this.Hide(); MainUI mainUi = new MainUI(); mainUi.ShowDialog(); }
private void CategorySetupUI_Load(object sender, EventArgs e) { this.MinimumSize = this.Size; this.MaximumSize = this.Size; this.MinimizeBox = false; this.MaximizeBox = false; //Grid view string _conString = ConString.DbConnection(); SqlConnection con = new SqlConnection(_conString); string query = "select id,name from category order by id desc"; SqlCommand cmd = new SqlCommand(query, con); SqlDataAdapter da = new SqlDataAdapter(cmd); con.Open(); DataTable dt = new DataTable(); da.Fill(dt); con.Close(); categoryVMBindingSource.DataSource = dt; }