private void button3_Click(object sender, EventArgs e)
{
string coursetype = "";
if (cbxType.Text == "JUNIOR")
{
coursetype = "JUNIOR_STUDENT";
}
else if (cbxType.Text == "DEGREE")
{
coursetype = "DEGREE_STUDENT";
}
else
{
MessageBox.Show("Please choose one of the CourseType.", "BFMS-ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
using (SqlConnection con = new SqlConnection("Data Source=ROHIT-PC\\SQLEXPRESS;Initial Catalog=FMS;Integrated Security=True"))
using (SqlCommand cmd = new SqlCommand("select from" + coursetype + "where UID = @UID", con))
{
cmd.Parameters.AddWithValue("@UId", textBox1.Text);
con.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
txtName.Text = reader["STUDENT_NAME"].ToString();
txtUid.Text = reader["UID"].ToString();
txtRoll.Text = reader["ROLL_NO"].ToString();
textGender.Text = reader["GENDER"].ToString();
textYear.Text = reader["YEAR_ID"].ToString();
txtRemarks.Text = reader["REMARKS"].ToString();
txtAcademicYear.Text = reader["ACADEMIC_YEAR"].ToString();
txtAdmissiontype.Text = reader["ADMISSION_TYPE"].ToString();
textCategory.Text = reader["CATEGORY_ID"].ToString();
txtSubcategory.Text = reader["SUB_CATEGORY"].ToString();
textCource.Text = reader["CLASS_ID"].ToString();
}
}
}
}
catch (Exception er)
{
MessageBox.Show("There was an Error : " + er, "BFMS CRITICAL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
using (SqlConnection con = new SqlConnection("Data Source=ROHIT-PC\\SQLEXPRESS;Initial Catalog=FMS;Integrated Security=True"))
using (SqlCommand cmd = new SqlCommand("select * from PAYMENT where STUD_UID= @UID", con))
{
cmd.Parameters.AddWithValue("@UId", textBox1.Text);
con.Open();
using (SqlDataReader reader = cmd.ExecuteReader())
{
if (reader.Read())
{
textAmtpaid.Text = reader["AMOUNT_PAID"].ToString();
textBalance.Text = reader["BALANCE"].ToString();
mbxChequeno.Text = reader["CHEQUE_NO"].ToString();
txtBankname.Text = reader["BANK_NAME"].ToString();
textPayType.Text = reader["PAYMENT_TYPE"].ToString();
}
reader.Close();
con.Close();
}
}
}
catch (Exception er)
{
MessageBox.Show("There was an Error : " + er, "BFMS CRITICAL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
public SqlConnection con { get; set; }
private void Cancellation_Load(object sender, EventArgs e)
{
this.cLASSTableAdapter.Fill(this.bFMSDataSet3.CLASS);
this.cATEGORYTableAdapter.Fill(this.bFMSDataSet2.CATEGORY);
this.yEAR_INTableAdapter.Fill(this.bFMSDataSet4.YEAR_IN);
}
public string PAYMENTTYPE { get; set; }
public string TYPE { get; set; }
public string PAYMENT_TYPE { get; set; }
private void button1_Click(object sender, EventArgs e)
{
try
{
con = new SqlConnection("Data Source=ROHIT-PC\\SQLEXPRESS;Initial Catalog=FMS;Integrated Security=True");
string insertQuery = @"INSERT INTO CANCEL_STUDENT_RECORDS (STUDENT_NAME, UID,ROLL_NO,ADMISSION_TYPE, GENDER, SUB_CATEGORY,ACADEMIC_YEAR, REMARKS, CLASS, CATEGORY)
VALUES(@NAME,@UID ,@ROLL_NO, @ADM_TYPE, @GENDER, @SUB_CAT, @ACDMYEAR, @REMARKS, @CLASSID, @CATID)";
insertCommand = new SqlCommand(insertQuery);
insertCommand.Parameters.AddWithValue("@NAME", txtName.Text);
insertCommand.Parameters.AddWithValue("@UID", txtUid.Text);
insertCommand.Parameters.AddWithValue("@ROLL_NO", txtRoll.Text);
insertCommand.Parameters.AddWithValue("@ADM_TYPE", txtAdmissiontype.Text);
insertCommand.Parameters.AddWithValue("@GENDER", textGender.Text);
insertCommand.Parameters.AddWithValue("@SUB_CAT", txtSubcategory.Text);
insertCommand.Parameters.AddWithValue("@ACDMYEAR", txtAcademicYear.Text);
insertCommand.Parameters.AddWithValue("@REMARKS", txtRemarks.Text);
insertCommand.Parameters.AddWithValue("@CLASSID", textCource.Text);
insertCommand.Parameters.AddWithValue("@CATID", textCategory.Text);
insertCommand.Connection = con;
con.Open();
insertCommand.ExecuteNonQuery();
MessageBox.Show("Student : " + txtName.Text + " Data Successfully Inserted ", "Student Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (SqlException ex)
{
MessageBox.Show("Could not insert " + txtName.Text + " Data \n " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
con = new SqlConnection("Data Source=ROHIT-PC\\SQLEXPRESS;Initial Catalog=FMS;Integrated Security=True");
string insertQuery = "DELETE FROM" + coursetype + "WHERE UID = '@UID'";
}
catch (SqlException ex1)
{
MessageBox.Show("Could not Delete " + txtName.Text + " Data \n " + ex1.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MessageBox.Show("Confirm Deletion" + txtName.Text + " Data \n ");
}
Thankss in advanced