Dastur kodi:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace kinoteatr
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.biletlarTableAdapter.Fill(this.biletlarbazasiDataSet.biletlar);
biletlarBindingSource.DataSource = this.biletlarbazasiDataSet.biletlar;
label3.Text = ((this.dataGridView1.Rows.Count)-1).ToString();
}
private void button1_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Biletni sotmoqchimisiz ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
biletlarBindingSource.RemoveCurrent();
}
}
private void button2_Click(object sender, EventArgs e)
{
biletlarBindingSource.EndEdit();
biletlarTableAdapter.Update(this.biletlarbazasiDataSet.biletlar);
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == (char)13)
{
if (string.IsNullOrEmpty(textBox1.Text))
{
dataGridView1.DataSource = biletlarBindingSource;
}
else
{
var quuery = from o in this.biletlarbazasiDataSet.biletlar
where o.Biletga_mos_joy.Contains(textBox1.Text)
select o;
dataGridView1.DataSource = quuery.ToList();
}
}
}
private void dataGridView1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (MessageBox.Show("Biletni sotmoqchimisiz ?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
biletlarBindingSource.RemoveCurrent();
}
}
}
private void dataGridView1_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
{
label3.Text = this.dataGridView1.Rows.Count.ToString();
}
}
}
|