Skip to content

Instantly share code, notes, and snippets.

@farhanfahim
Created January 16, 2019 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farhanfahim/9a16e779ee72ffc349400e3117917055 to your computer and use it in GitHub Desktop.
Save farhanfahim/9a16e779ee72ffc349400e3117917055 to your computer and use it in GitHub Desktop.
Courier Management System
private void button1_Click(object sender, EventArgs e)
{
panel3.BackColor = Color.FromArgb(144, 144, 144);
SqlConnection conn = new SqlConnection();
conn.ConnectionString = @"Data Source=Desktop-D8FP0VA;Initial Catalog=cms;Integrated Security=True";
conn.Open();
SqlDataAdapter da;
DataTable dt;
using (da = new SqlDataAdapter
("select Username,Password from Admin where Password='" + password.Text + "' and Username ='" + textBox3.Text + "'", conn))
{
dt = new DataTable();
da.Fill(dt);
}
if (dt.Rows.Count > 0)
{
this.Visible = false;
Home h = new Home();
h.Show();
}
else {
MessageBox.Show("Invalid Username or Password");
}
conn.Close();
textBox3.Text = "";
password.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(@"Data Source=Desktop-D8FP0VA;Initial Catalog=cms;Integrated Security=True");
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into Courier_detail(fname,fcity,fphone,faddress,tname,tcity,tphone,taddress,piece,weight) values ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox8.Text + "','" + textBox7.Text + "','" + textBox6.Text + "','" + textBox5.Text + "','" + textBox11.Text + "','" + textBox10.Text + "')";
cmd.ExecuteNonQuery();
conn.Close();
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || textBox7.Text == "" || textBox8.Text == "" || textBox10.Text == "" || textBox11.Text == "")
{
MessageBox.Show("Error");
}
else
{
MessageBox.Show("Record Added Successfully");
button5.Visible = true;
fname = textBox1.Text;
tname = textBox8.Text;
}
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
try {
SqlConnection conn = new SqlConnection(@"Data Source=Desktop-D8FP0VA;Initial Catalog=cms;Integrated Security=True");
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "delete from Staff_detail where SId='" + textBox1.Text + "' AND Name ='"+textBox2.Text+"' AND PhoneNo='"+textBox3.Text+"'";
cmd.ExecuteNonQuery();
conn.Close();
if (textBox1.Text == ""|| textBox2.Text =="" || textBox3.Text== "" )
{
MessageBox.Show("Error");
}
else
{
MessageBox.Show("Record Deleted Successfully");
}
}catch(Exception ex){
MessageBox.Show(ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
SqlConnection conn = new SqlConnection(@"Data Source=Desktop-D8FP0VA;Initial Catalog=cms;Integrated Security=True");
conn.Open();
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "update Staff_detail set Name='" + textBox1.Text + "' , City='" + textBox2.Text + "' , PhoneNo='" + textBox3.Text + "' , Address='" + textBox4.Text + "', Qualification='" + textBox5.Text + "' , Designation='" + textBox6.Text + "' where SId = '" + textBox7.Text + "'";
cmd.ExecuteNonQuery();
conn.Close();
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "")
{
MessageBox.Show("Error");
}
else
{
MessageBox.Show("Record Updated Successfully");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment