Beispiel #1
0
        private void cmbBranch_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbBranch.Text = cmbBranch.Text.Trim();
            Semester.Items.Clear();
            Semester.Text    = "";
            Semester.Enabled = true;
            Semester.Focus();

            try
            {
                con = new SqlConnection(cs.DBConn);
                con.Open();


                string ct = "select distinct RTRIM(SemesterName) from Semester where course = '" + cmbCourse.Text + "' order by 1 ";

                cmd            = new SqlCommand(ct);
                cmd.Connection = con;

                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    Semester.Items.Add(rdr[0]);
                }
                con.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (Course.Text == "")
                {
                    MessageBox.Show("Please select course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Course.Focus();
                    return;
                }
                if (Branch.Text == "")
                {
                    MessageBox.Show("Please select branch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Branch.Focus();
                    return;
                }
                if (Session.Text == "")
                {
                    MessageBox.Show("Please select session", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Session.Focus();
                    return;
                }
                if (Semester.Text == "")
                {
                    MessageBox.Show("Please select semester", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Semester.Focus();
                    return;
                }
                if (Section.Text == "")
                {
                    MessageBox.Show("Please select section", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Section.Focus();
                    return;
                }
                con = new SqlConnection("Data Source=GHAFFARI\\ALIGHAFFARI;Initial Catalog=CMS;Integrated Security=True;");

                con.Open();
                cmd = new SqlCommand("select RTrim(ScholarNo)[Scholar No.], RTRIM(Student_Name)[Student Name], RTRIM(Admission_No)[Admission No.], RTRIM(DateOfAdmission)[Date Of Admission], RTRIM(Roll_No)[Roll No.], RTRIM(Fathers_Name)[Father's Name],RTRIM(Mother_name)[Mother's Name], RTRIM(Gender)[Gender], RTRIM(DOB)[DOB],RTRIM(Category)[Category],RTRIM(Religion)[Religion],RTRIM(Session)[Session], RTRIM(Address)[Address], RTRIM(Contact_No)[Contact No.], RTRIM(Email)[Email], RTRIM(Course)[Course], RTRIM(Branch)[Branch],RTRIM(Semester)[Semester],RTRIM(Section)[Section], RTRIM(Submitted_Documents)[Documents Submitted], RTRIM(Nationality)[Nationality], RTRIM(High_School_name)[High School], RTRIM(HS_Year_of_passing)[Year Of Passing], RTRIM(HS_Percentage)[Percentage], RTRIM(HS_Board)[Board], RTRIM(Higher_secondary_Name)[Higher Secondary], RTRIM(H_year_of_passing)[HS Year Of Passing], RTRIM(H_percentage)[HS Percentage], RTRIM(H_board)[HS Board]  from student where  Course= '" + Course.Text + "'and branch='" + Branch.Text + "'and Session='" + Session.Text + "'", con);


                SqlDataAdapter myDA = new SqlDataAdapter(cmd);

                DataSet myDataSet = new DataSet();

                myDA.Fill(myDataSet, "Student");

                dataGridView1.DataSource = myDataSet.Tables["Student"].DefaultView;



                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (Course.Text == "")
                {
                    MessageBox.Show("Please select course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Course.Focus();
                    return;
                }
                if (Branch.Text == "")
                {
                    MessageBox.Show("Please select branch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Branch.Focus();
                    return;
                }
                if (Semester.Text == "")
                {
                    MessageBox.Show("Please select semester", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Semester.Focus();
                    return;
                }

                var _with1 = listView1;
                _with1.Clear();
                _with1.Columns.Add("Subject Code", 100, HorizontalAlignment.Left);
                _with1.Columns.Add("Subject Name", 500, HorizontalAlignment.Center);

                con = new SqlConnection(cs.DBConn);

                con.Open();
                cmd = new SqlCommand("select RTrim(SubjectCode)[Subject Code], RTRIM(SubjectName)[Subject Name] from subjectinfo where  CourseName= '" + Course.Text + "'and branch='" + Branch.Text + "'and Semester='" + Semester.Text + "'", con);

                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    var item = new ListViewItem();
                    item.Text = rdr[0].ToString();
                    item.SubItems.Add(rdr[1].ToString());
                    listView1.Items.Add(item);
                }
                con.Close();



                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (Course.Text == "")
                {
                    MessageBox.Show("Please select course", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Course.Focus();
                    return;
                }
                if (Branch.Text == "")
                {
                    MessageBox.Show("Please select branch", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Branch.Focus();
                    return;
                }
                if (Semester.Text == "")
                {
                    MessageBox.Show("Please select semester", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Semester.Focus();
                    return;
                }
                if (TutionFees.Text == "")
                {
                    MessageBox.Show("Please enter tution fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TutionFees.Focus();
                    return;
                }
                if (UDFees.Text == "")
                {
                    MessageBox.Show("Please enter university development fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UDFees.Focus();
                    return;
                }
                if (LibraryFees.Text == "")
                {
                    MessageBox.Show("Please enter library fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    LibraryFees.Focus();
                    return;
                }
                if (USFees.Text == "")
                {
                    MessageBox.Show("Please enter university student welfare fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    USFees.Focus();
                    return;
                }
                if (OtherFees.Text == "")
                {
                    MessageBox.Show("Please enter other fees", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    OtherFees.Focus();
                    return;
                }
                if (Semester.Text == "1st")
                {
                    if (CautionMoney.Text == "")
                    {
                        MessageBox.Show("Please enter caution money", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        CautionMoney.Focus();
                        return;
                    }
                }
                con = new SqlConnection(cs.DBConn);
                con.Open();
                string ct = "select Semester,Course,Branch from FeesDetails where Semester= '" + Semester.Text + "' and Course = '" + Course.Text + "' and branch= '" + Branch.Text + "'";

                cmd            = new SqlCommand(ct);
                cmd.Connection = con;

                rdr = cmd.ExecuteReader();

                if (rdr.Read())
                {
                    MessageBox.Show("Record Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    Reset();

                    if ((rdr != null))
                    {
                        rdr.Close();
                    }
                    return;
                }

                if (Semester.Text == "1st")
                {
                    TotalFees.Text = (int.Parse(TutionFees.Text) + int.Parse(LibraryFees.Text) + int.Parse(UDFees.Text) + int.Parse(USFees.Text) + int.Parse(OtherFees.Text) + int.Parse(CautionMoney.Text)).ToString();
                }
                else
                {
                    TotalFees.Text = (int.Parse(TutionFees.Text) + int.Parse(LibraryFees.Text) + int.Parse(UDFees.Text) + int.Parse(USFees.Text) + int.Parse(OtherFees.Text)).ToString();
                }

                auto();

                con = new SqlConnection(cs.DBConn);
                con.Open();
                string ct1 = "select feeid from feesdetails where feeid=@find";

                cmd            = new SqlCommand(ct1);
                cmd.Connection = con;
                cmd.Parameters.Add(new SqlParameter("@find", System.Data.SqlDbType.NChar, 20, "feeid"));
                cmd.Parameters["@find"].Value = FeeID.Text;
                rdr = cmd.ExecuteReader();

                if (rdr.Read())
                {
                    MessageBox.Show("Fee ID Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    FeeID.Text = "";



                    if ((rdr != null))
                    {
                        rdr.Close();
                    }
                    return;
                }

                con = new SqlConnection(cs.DBConn);
                con.Open();

                string cb = "insert into feesdetails(FeeID,Course,Branch,Semester,TutionFees,LibraryFees,UniversityDevelopmentFees,UniversityStudentWelfareFees,CautionMoney,OtherFees,TotalFees) VALUES (@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d8,@d9,@d10,@d11)";

                cmd = new SqlCommand(cb);

                cmd.Connection = con;


                cmd.Parameters.Add(new SqlParameter("@d1", System.Data.SqlDbType.NChar, 20, "FeeId"));

                cmd.Parameters.Add(new SqlParameter("@d2", System.Data.SqlDbType.NChar, 20, "Course"));

                cmd.Parameters.Add(new SqlParameter("@d3", System.Data.SqlDbType.NChar, 30, "Branch"));

                cmd.Parameters.Add(new SqlParameter("@d4", System.Data.SqlDbType.NChar, 10, "Semester"));

                cmd.Parameters.Add(new SqlParameter("@d5", System.Data.SqlDbType.NChar, 10, "TutionFees"));

                cmd.Parameters.Add(new SqlParameter("@d6", System.Data.SqlDbType.NChar, 10, "LibraryFees"));

                cmd.Parameters.Add(new SqlParameter("@d7", System.Data.SqlDbType.NChar, 10, "UniversityDevelopmentFees"));

                cmd.Parameters.Add(new SqlParameter("@d8", System.Data.SqlDbType.NChar, 15, "UniversityStudentWelfareFees"));

                cmd.Parameters.Add(new SqlParameter("@d9", System.Data.SqlDbType.NChar, 10, "CautionMoney"));

                cmd.Parameters.Add(new SqlParameter("@d10", System.Data.SqlDbType.NChar, 10, "OtherFees"));
                cmd.Parameters.Add(new SqlParameter("@d11", System.Data.SqlDbType.NChar, 10, "TotalFees"));

                cmd.Parameters["@d1"].Value = FeeID.Text.Trim();
                cmd.Parameters["@d2"].Value = Course.Text.Trim();
                cmd.Parameters["@d3"].Value = Branch.Text.Trim();
                cmd.Parameters["@d4"].Value = Semester.Text.Trim();
                cmd.Parameters["@d5"].Value = (TutionFees.Text);
                cmd.Parameters["@d6"].Value = (LibraryFees.Text);
                cmd.Parameters["@d7"].Value = (UDFees.Text);
                cmd.Parameters["@d8"].Value = (USFees.Text);
                if (Semester.Text == "1st")
                {
                    cmd.Parameters["@d9"].Value = (CautionMoney.Text);
                }
                else
                {
                    cmd.Parameters["@d9"].Value = 0;
                }
                cmd.Parameters["@d10"].Value = (OtherFees.Text);
                cmd.Parameters["@d11"].Value = (TotalFees.Text);
                cmd.ExecuteNonQuery();
                MessageBox.Show("Successfully saved", "Fees Record", MessageBoxButtons.OK, MessageBoxIcon.Information);


                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (SubjectCode.Text == "")
            {
                MessageBox.Show("Please enter subject code", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SubjectCode.Focus();
                return;
            }
            if (SubjectName.Text == "")
            {
                MessageBox.Show("Please enter subject name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                SubjectName.Focus();
                return;
            }
            if (cmbCourse.Text == "")
            {
                MessageBox.Show("Please select course name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbCourse.Focus();
                return;
            }
            if (cmbBranch.Text == "")
            {
                MessageBox.Show("Please select Branch name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cmbBranch.Focus();
                return;
            }
            if (Semester.Text == "")
            {
                MessageBox.Show("Please select semester", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Semester.Focus();
                return;
            }

            try
            {
                con = new SqlConnection(cs.DBConn);
                con.Open();
                string ct = "select subjectcode from subjectinfo where subjectcode=@find";

                cmd            = new SqlCommand(ct);
                cmd.Connection = con;
                cmd.Parameters.Add(new SqlParameter("@find", System.Data.SqlDbType.NChar, 20, "subjectcode"));
                cmd.Parameters["@find"].Value = SubjectCode.Text;
                rdr = cmd.ExecuteReader();

                if (rdr.Read())
                {
                    MessageBox.Show("Subject Code Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    SubjectCode.Text = "";
                    SubjectCode.Focus();


                    if ((rdr != null))
                    {
                        rdr.Close();
                    }
                    return;
                }

                con = new SqlConnection(cs.DBConn);
                con.Open();

                string cb = "insert into subjectinfo(subjectcode,subjectname,coursename,branch,semester) VALUES (@d1,@d2,@d4,@d5,@d6)";

                cmd = new SqlCommand(cb);

                cmd.Connection = con;
                cmd.Parameters.Add(new SqlParameter("@d1", System.Data.SqlDbType.NChar, 20, "SubjectCode"));

                cmd.Parameters.Add(new SqlParameter("@d2", System.Data.SqlDbType.VarChar, 250, "subjectname"));


                cmd.Parameters.Add(new SqlParameter("@d4", System.Data.SqlDbType.NChar, 20, "coursename"));

                cmd.Parameters.Add(new SqlParameter("@d5", System.Data.SqlDbType.NChar, 50, "branchname"));
                cmd.Parameters.Add(new SqlParameter("@d6", System.Data.SqlDbType.NChar, 10, "semester"));
                cmd.Parameters["@d1"].Value = SubjectCode.Text.Trim();
                cmd.Parameters["@d2"].Value = SubjectName.Text.Trim();

                cmd.Parameters["@d4"].Value = cmbCourse.Text.Trim();
                cmd.Parameters["@d5"].Value = cmbBranch.Text.Trim();
                cmd.Parameters["@d6"].Value = Semester.Text.Trim();
                cmd.ExecuteNonQuery();
                MessageBox.Show("Successfully saved", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
                btnSave.Enabled = false;
                Autocomplete();
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }