private void newEntryToolStripMenuItem2_Click(object sender, EventArgs e)
 {
     Material m = new Material();
     m.Show();
 }
 private void addDetailsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Material m = new Material();
     m.Show();
 }
 private void button1_Click(object sender, EventArgs e)
 {
     Material m = new Material();
     m.Show();
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtName.Text != "")
     {
         con.Open();
         cmd = new SqlCommand("Insert into MaterialInfo(MaterialName,Department,Make,Model) values(@b,@c,@d,@e)", con);
         cmd.Parameters.AddWithValue("@b", txtName.Text);
         cmd.Parameters.AddWithValue("@c", txtDepartment.Text);
         cmd.Parameters.AddWithValue("@d", txtMake.Text);
         cmd.Parameters.AddWithValue("@e", txtModel.Text);
         try
         {
             int r = cmd.ExecuteNonQuery();
             cmd = new SqlCommand("Select MaterialID from MaterialInfo", con);
             SqlDataReader dr = cmd.ExecuteReader();
             if (dr.HasRows)
             {
                 while (dr.Read())
                 {
                     res = dr[0].ToString();
                 }
             }
             MessageBox.Show("Material Unique Number" + ":" + "" + "" + res, "Material Added Succesfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception exc)
         {
             MessageBox.Show(exc.ToString());
         }
         finally
         {
             txtName.Text = "";
             txtDepartment.Text = "";
             txtMake.Text = "";
             txtModel.Text = "";
             con.Close();
         }
         Material m = new Material();
         m.Show();
     }
     else
     {
         MessageBox.Show("Fill Required Feilds","",MessageBoxButtons.OK,MessageBoxIcon.Stop);
     }
 }