using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Configuration;
namespace agency
{
public partial class showcustomer : Form
{
public showcustomer()
{
InitializeComponent();
}
OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
OleDbDataAdapter da;
private void showcustomer_Load(object sender, EventArgs e)
{
gridshow();
}
public void gridshow()
{
try
{
da = new OleDbDataAdapter("select * from customer", con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
catch (Exception)
{ }
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
da = new OleDbDataAdapter("select * from customer where cname like '" + textBox1.Text + "%'", con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
catch (Exception)
{ }
}
public static string itcd;
private void editCustomerToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
int id = Convert.ToInt32(dataGridView1.CurrentRow.Index.ToString());
itcd = dataGridView1.Rows[id].Cells[0].Value.ToString();
editcustomer ap = new editcustomer();
ap.Show();
this.Close();
}
catch (Exception)
{ }
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
int id = Convert.ToInt32(dataGridView1.CurrentRow.Index.ToString());
itcd = dataGridView1.Rows[id].Cells[0].Value.ToString();
OleDbCommand cmd = new OleDbCommand("delete * from customer where ID=" + itcd + "", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
gridshow();
}
catch (Exception ex)
{
con.Close();
MessageBox.Show(ex.Message);
}
}
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void paymentToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
int id = Convert.ToInt32(dataGridView1.CurrentRow.Index.ToString());
itcd = dataGridView1.Rows[id].Cells[0].Value.ToString();
WindowsFormsApplication2.payreceived ap = new WindowsFormsApplication2.payreceived();
ap.Show();
this.Close();
}
catch (Exception)
{ }
}
private void addCustomerToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
addcustomer ac = new addcustomer();
ac.Show();
}
public static string me;
private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
try
{
int index = e.RowIndex;
me = dataGridView1.Rows[index].Cells[1].Value.ToString();
specificcustomer si = new specificcustomer();
si.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Configuration;
namespace agency
{
public partial class showcustomer : Form
{
public showcustomer()
{
InitializeComponent();
}
OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
OleDbDataAdapter da;
private void showcustomer_Load(object sender, EventArgs e)
{
gridshow();
}
public void gridshow()
{
try
{
da = new OleDbDataAdapter("select * from customer", con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
catch (Exception)
{ }
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
try
{
da = new OleDbDataAdapter("select * from customer where cname like '" + textBox1.Text + "%'", con);
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
}
catch (Exception)
{ }
}
public static string itcd;
private void editCustomerToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
int id = Convert.ToInt32(dataGridView1.CurrentRow.Index.ToString());
itcd = dataGridView1.Rows[id].Cells[0].Value.ToString();
editcustomer ap = new editcustomer();
ap.Show();
this.Close();
}
catch (Exception)
{ }
}
private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
int id = Convert.ToInt32(dataGridView1.CurrentRow.Index.ToString());
itcd = dataGridView1.Rows[id].Cells[0].Value.ToString();
OleDbCommand cmd = new OleDbCommand("delete * from customer where ID=" + itcd + "", con);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
gridshow();
}
catch (Exception ex)
{
con.Close();
MessageBox.Show(ex.Message);
}
}
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
private void paymentToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
int id = Convert.ToInt32(dataGridView1.CurrentRow.Index.ToString());
itcd = dataGridView1.Rows[id].Cells[0].Value.ToString();
WindowsFormsApplication2.payreceived ap = new WindowsFormsApplication2.payreceived();
ap.Show();
this.Close();
}
catch (Exception)
{ }
}
private void addCustomerToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
addcustomer ac = new addcustomer();
ac.Show();
}
public static string me;
private void dataGridView1_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
try
{
int index = e.RowIndex;
me = dataGridView1.Rows[index].Cells[1].Value.ToString();
specificcustomer si = new specificcustomer();
si.Show();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
Code
No comments:
Post a Comment