private void btn_pay_Click(object sender, EventArgs e) { if (!(txt_DATE.Text == "" && txt_Fee.Text == "")) { da = new SqlDataAdapter("select s_sem from std where s_grno='" + txt_grno.Text + "'", con); DataTable dt = new DataTable(); da.Fill(dt); if (!(dt.Rows[0][0].ToString() == txt_nextSEM.Text)) { String sql; sql = "INSERT INTO admission (s_grno, s_name, s_course, s_sem, s_fee, s_date,s_type) VALUES ('" + txt_grno.Text + "','" + txt_stud_name.Text + "','" + txt_Course.Text + "'," + txt_nextSEM.Text + "," + fee + ",'" + txt_DATE.Text + "','Old')"; try { cmd = new SqlCommand(sql, con); int i = cmd.ExecuteNonQuery(); if (i == 0) { MessageBox.Show("Oops Error.!!"); } else { DataTable xxx = new DataTable(); xxx.Columns.Add("s_grno", typeof(String)); xxx.Columns.Add("s_name", typeof(String)); xxx.Columns.Add("s_course", typeof(String)); xxx.Columns.Add("s_sem", typeof(String)); xxx.Columns.Add("s_fee", typeof(String)); xxx.Rows.Add(txt_grno.Text, txt_stud_name.Text, txt_Course.Text, txt_nextSEM.Text, txt_Fee.Text); Std_fee_print a = new Std_fee_print(xxx); a.MdiParent = this.MdiParent; a.Location = new Point(0, 66); a.Size = new Size(deskWidth, deskHeight); a.ShowDialog(); } cmd = new SqlCommand("UPDATE std SET s_sem = '" + txt_nextSEM.Text + "',s_fee='" + fee + "' WHERE (std.s_grno = '" + txt_grno.Text + "')", con); i = cmd.ExecuteNonQuery(); if (i == 0) { MessageBox.Show("Student Semester NOT Updated"); } } catch (Exception x) { MessageBox.Show("Error ::" + x); } } else { MessageBox.Show("Fee Already Tacken"); } } else { MessageBox.Show("Student G.R.No Not Found"); } }
//Save Student private void btn_SAVE_Click(object sender, EventArgs e) { int tmp; tmp = getresult(); if (tmp == 1) { try { if (ImageByte == null) { MessageBox.Show("Select Image"); } else { // //\\GET G.R. NO. // grno = get_grno(); cmd = new SqlCommand("INSERT INTO grno([year], course, [no]) VALUES(" + DateTime.Now.Year + ",'" + grno_course + "'," + grNO + ");", con); cmd.ExecuteNonQuery(); // //\\GET SEM FEE // cmd = new SqlCommand("select c_id from course where c_name='" + cmbCourse.Text + "'", con); SqlDataReader dr1 = cmd.ExecuteReader(); dr1.Read(); int sem_id = Int32.Parse(dr1.GetValue(0).ToString()); cmd = new SqlCommand("SELECT SUM(fee_rs) FROM semester WHERE (sem = " + cmb_sem.Text + " and c_id='" + sem_id + "')", con); Object a = cmd.ExecuteScalar(); fee = Int32.Parse(a.ToString()); // //\\ADMISSION OF STUDENT // cmd = new SqlCommand("INSERT INTO std (s_name, s_grno, s_city, s_add, s_gen, s_email, s_mobile, s_dob, s_course, s_sem,s_fee,s_img,s_join_dt) VALUES('" + txtfnm.Text + "','" + grno + "','" + cmb_city.Text + "','" + txtAdd.Text + "', '" + gen + "' ,'" + txtEmail.Text + "','" + txtMobile.Text + "','" + DOB.Text + "','" + cmbCourse.Text + "','" + cmb_sem.Text + "'," + fee + ",@s_img,'" + DateTime.Now.ToString() + "')", con); cmd.Parameters.Add("@s_img", ImageByte); int m = cmd.ExecuteNonQuery(); if (m == 1) { if (MessageBox.Show("Admission Done \n Print Recipt.?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { String date = DateTime.Now.ToString(); cmd = new SqlCommand("INSERT INTO admission (s_grno, s_name, s_course, s_sem, s_fee, s_date,s_type) VALUES ('" + grno + "', '" + txtfnm.Text + "', '" + cmbCourse.Text + "', '" + cmb_sem.Text + "', " + fee.ToString() + ",'" + date + "','New')", con); int f = cmd.ExecuteNonQuery(); if (f == 0) { } else { da = new SqlDataAdapter("select a_id from admission where s_grno='" + grno + "' and s_sem='" + cmb_sem.Text + "'", con); dt = new DataTable(); da.Fill(dt); DataTable xxx = new DataTable(); xxx.Columns.Add("a_id", typeof(String)); xxx.Columns.Add("s_grno", typeof(String)); xxx.Columns.Add("s_name", typeof(String)); xxx.Columns.Add("s_course", typeof(String)); xxx.Columns.Add("s_sem", typeof(String)); xxx.Columns.Add("s_fee", typeof(String)); xxx.Rows.Add(dt.Rows[0][0].ToString(), grno, txtfnm.Text, cmbCourse.Text, cmb_sem.Text, fee.ToString()); Std_fee_print z = new Std_fee_print(xxx); z.Show(); Reload_Controls(); } } Reload_Controls(); } else { MessageBox.Show("Student admission failed"); } } } catch (Exception xx) { MessageBox.Show("Error Check The Course/Semester fee"); } } }