Tuesday, 5 March 2019

C#,Mini School Management System Project in VB.NET | Fee detail | Part-17

C#, Mini School Management System Project in VB.NET Part-17:


Hello Everyone here i will show you how to Search student fee details..

Step 1: Add Label ,Textbox, Combobox, button & datagridview control on the form
Step2: write the following code.....

For more detail watch School Management System Project part-17



Source code of School Management System Project:

  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.Collections;
using System.Web;
using System.Linq;
using System.Data.SqlClient;
using System.Configuration;


namespace MySchoolProject
{
    public partial class feeDetails : Form
    {
        public feeDetails()
        {
            InitializeComponent();
        }

        public void paidfee()
        {
            int sum = 0;
            for (int i = 0; i < dataGridView1.Rows.Count; ++i)
            {
                sum += Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value);
            }
            label5.Text = sum.ToString();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty)
            {
                MessageBox.Show("Plz enter Student RollNo.");
            }
            else
            {
                GetListByRoll();
               
            }

        }
        private void GetListByRoll()
        {
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mydb"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand("Select  * from tblStudentFee where RollNo='" + Convert.ToInt32(textBox1.Text) + "' ", con))
                {

                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable dt2 = new DataTable();
                    da.Fill(dt2);
                    dataGridView1.DataSource = dt2;

                    //sum paidfee column
                    paidfee();

                }

            }

        }

        private void feeDetails_Load(object sender, EventArgs e)
        {
            this.SearchStudent();
        
        }
        private void SearchStudent()
        {
            using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["mydb"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    string qr = "Select RollNo,StudentName,Class,TotalFee,PaidFee,Balance,FeeDiscount,FeeTerm,Date_Fee,Status from tblStudentFee";
                    if(!string .IsNullOrEmpty(textBox1 .Text .Trim ())) 
                    {
                        qr += "WHERE RollNo=@ROllNo";
                        cmd.Parameters.AddWithValue("@RollNo",textBox1 .Text .Trim ());

                    }

                    cmd.CommandText = qr;
                    cmd.Connection = con;
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        DataTable dt = new DataTable();
                        da.Fill(dt);
                        dataGridView1.DataSource = dt;
                        
                    }
                }
            }
        }
    }
}



....................................................................
Output:






youtube
my youtube channel 











No comments:

Post a comment

Popular Posts