Exemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtTermName.Text == "")
            {
                txtTermName.BackColor = Color.MistyRose;
                MessageBox.Show("Please Enter Term Name");
                txtTermName.BackColor = Color.White;


                return;
            }
            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "insert into schoolterm (termname, startdate, enddate) values ('" + txtTermName.Text + "','" + dtpStartDate.Text + "','" + dtpEndDate.Text + "') ";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                SQLConn.cmd.ExecuteNonQuery();

                MessageBox.Show("Successfully Saved", "Events Records", MessageBoxButtons.OK, MessageBoxIcon.Information);
                SQLConn.ConnClose();
                Clears();
            }
            catch (NpgsqlException ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public StringCollection  FeeTypes()
        {
            StringCollection SC = new StringCollection();

            try
            {
                SQLConn.ConnOpen();

                SQLConn.sqL = "Select feetypename from  feetype ";
                //  MessageBox.Show(SQLConn.sqL);
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                SQLConn.dr = SQLConn.cmd.ExecuteReader();
                while (SQLConn.dr.Read() == true)
                {
                    SC.Add(SQLConn.dr["feetypename"].ToString());
                }
                SQLConn.ConnClose();

                return(SC);
            }
            catch (NpgsqlException ex)
            {
                MessageBox.Show(ex.Message);
                return(null);
            }

            finally
            {
                SQLConn.cmd.Dispose();
            }
        }
        public void LoadSubjects()
        {
            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "select id ,subjectcode, subjectname,classname  from subject   where 1=1 ";

                if (int.Parse(cmbClass.SelectedValue.ToString()) > 0)
                {
                    SQLConn.sqL += " AND classname= '" + cmbClass.Text + "' ";
                }

                SQLConn.sqL += " order by classname,subjectcode";


                SQLConn.da = new NpgsqlDataAdapter(SQLConn.sqL, SQLConn.conn);

                dataGridView1.DataSource = null;
                DataTable dt = new DataTable();


                SQLConn.da.Fill(dt);
                dataGridView1.DataSource = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SQLConn.cmd.Dispose();
                SQLConn.ConnClose();
            }
        }
        private void UpdateFee()
        {
            if (!ValidEntry())
            {
                return;
            }


            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "update feeschedule set term='" + cmbTerm.SelectedValue + "',feetype='" + cmbFeeType.Text + "' ,amount='" + txtAmount.Text + "'  , sclass='" + cmbClass.Text + "'   where  id='" + txtAmount.Tag + "'";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                SQLConn.cmd.ExecuteNonQuery();

                MessageBox.Show("Successfully updated", "Exam Details", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    st1 = lblUser.Text;
                //  st2 = "Updated Exam'" +txtExamName.Text+ "'";
                //    cf.LogFunc(st1, System.DateTime.Now, st2);

                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public DataTable SearchStudent(string srch)
        {
            DataTable dt = new DataTable();

            try
            {
                SQLConn.ConnOpen();


                SQLConn.sqL = "Select  concat (firstname, ' ', othername) as fullname , admissionno from  studentdetail Where admissionno ILike  '%" + srch + "%'  or  firstname ILike  '%" + srch + "%' ";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                SQLConn.da = new NpgsqlDataAdapter(SQLConn.cmd);
                dt.Columns.Add("admissionno", typeof(string));
                dt.Columns.Add("fullname", typeof(string));

                SQLConn.da.Fill(dt);
                SQLConn.ConnClose();
                return(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(null);
            }
            finally
            {
                SQLConn.cmd.Dispose();
                SQLConn.ConnClose();
            }
        }
        private void SaveSchoolDetails()
        {
            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "Update studentdetail set school= @school,category= @category,sclass= @sclass,section= @section,term= @term, status= @status  WHERE admissionno='" + txtAdmNo.Text + "'";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                SQLConn.cmd.Parameters.AddWithValue("@school", cmbSchool.SelectedValue.ToString());
                SQLConn.cmd.Parameters.AddWithValue("@category", cmbCategory.Text);
                SQLConn.cmd.Parameters.AddWithValue("@sclass", cmbClass.Text);
                SQLConn.cmd.Parameters.AddWithValue("@section", cmbSection.Text);
                SQLConn.cmd.Parameters.AddWithValue("@term", cmbTerm.SelectedValue.ToString());
                SQLConn.cmd.Parameters.AddWithValue("@status", cmbStatus.SelectedValue.ToString());
                SQLConn.cmd.ExecuteNonQuery();
                MessageBox.Show(" " + fname.Text + " " + sname.Text + " 's" + " " + "Records saved successfully", "Data Saved!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                SQLConn.ConnClose();
            }

            catch (NpgsqlException ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                SQLConn.cmd.Dispose();
            }
        }
Exemplo n.º 7
0
        private void Update_record_Click(object sender, EventArgs e)
        {
            if (!ValidEntry())
            {
                return;
            }


            try
            {
                SQLConn.ConnOpen();
                //SQLConn.sqL = "update exam set examname='" + cmbExam.SelectedValue + "', startdate='', class='" + cmbClass.SelectedValue + "'  , schoolterm='" + cmbTerm.SelectedValue + "'      , enddate=''    where  id='" + cmbExam.SelectedValue + "'";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                SQLConn.cmd.ExecuteNonQuery();

                MessageBox.Show("Successfully updated", "Exam Details", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    st1 = lblUser.Text;
                //  st2 = "Updated Exam'" +cmbExam.SelectedValue+ "'";
                //    cf.LogFunc(st1, System.DateTime.Now, st2);


                ListStudentMarks();
                Reset();


                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void DeleteUser()
        {
            try
            {
                SQLConn.ConnOpen();
                if (txtUserId.Tag.ToString() == "1")
                {
                    MessageBox.Show("Cannot Delete Super Admin");
                    return;

                }
                SQLConn.sqL = "delete from user_registration where id=@f1";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                SQLConn.cmd.Parameters.AddWithValue("@f1", txtUserId.Tag);
                SQLConn.cmd.ExecuteNonQuery();
                SQLConn.ConnClose();
                MessageBox.Show("Deleted Successfully");
                Clears();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());

            }
        }
Exemplo n.º 9
0
        public void LoadEvents()
        {
            try
            {
                SQLConn.ConnOpen();


                DataTable dt = new DataTable();

                DGV.DataSource = null;
                SQLConn.sqL    = "SELECT id, eventname, startdate, enddate, manager, activity FROM event order by startdate  asc";
                SQLConn.cmd    = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                // data adapter making request from our connection
                SQLConn.da = new NpgsqlDataAdapter(SQLConn.cmd);
                MessageBox.Show(dt.Rows.Count.ToString());
                SQLConn.da.Fill(dt);

                DGV.DataSource = dt;


                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Update_record_Click(object sender, EventArgs e)
        {
            if (!ValidEntry())
            {
                return;
            }


            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "update exam set examname='" + txtExamName.Text + "',examtype='" + cmbExamType.SelectedValue + "' , startdate='" + TM.TimeToString(dtpStart.Value) + "', schoolclass='" + cmbClass.Text + "'  , schoolterm='" + cmbTerm.SelectedValue + "'      , enddate='" + TM.TimeToString(dtpEnd.Value) + "'    where  id='" + txtExamName.Tag + "'";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                SQLConn.cmd.ExecuteNonQuery();
                Debug.WriteLine(SQLConn.sqL);
                MessageBox.Show("Successfully updated", "Exam Details", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    st1 = lblUser.Text;
                //  st2 = "Updated Exam'" +txtExamName.Text+ "'";
                //    cf.LogFunc(st1, System.DateTime.Now, st2);
                btnUpdate.Enabled = false;

                ListExams();

                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Update_record_Click(object sender, EventArgs e)
        {
            try
            {
                SQLConn.ConnOpen();

                SQLConn.sqL = "update staffset staffname=@d2,department=@d3,gender=@d4,fathername=@d5,permanentaddress=@d6,temporaryaddress=@d7,phoneno=@d8,mobileno=@d9,dateofjoining=@d10,qualification=@d11,yearofexperience=@d12,designation=@d13,email=@d14,Basicsalary=@d15,picture=@d16,DOB=@d17,mothername=@d19,status=@d18 where staffid=@d1";


                SQLConn.cmd.ExecuteNonQuery();
                SQLConn.ConnClose();

                MessageBox.Show("Successfully Updated", "staffRecord", MessageBoxButtons.OK, MessageBoxIcon.Information);


                st2 = "Updated the Staff'" + txtStaffName.Text + "' having StaffID '" + txtStaffID.Text + "'";
                //     cf.LogFunc(st1, System.DateTime.Now, st2);
                btnupdate.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SQLConn.cmd.Dispose();
                SQLConn.ConnClose();
            }
        }
Exemplo n.º 12
0
        private void InitialiseDB()
        {
            lblinit.Text      = "Initialising Database. Please Wait..";
            lblinit.ForeColor = Color.Red;
            lblinit.Visible   = true;
            txtSQL.Visible    = true;
            try
            {
                string appPath = Path.GetDirectoryName(Application.ExecutablePath);
                string file    = appPath + "\\SQL\\schoolguru.sql";
                SQLConn.sqL = File.ReadAllText(file).ToString();

                txtSQL.Text = SQLConn.sqL;
                SQLConn.ConnOpen();

                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                int r = SQLConn.cmd.ExecuteNonQuery();
                if (r > 0)
                {
                    MessageBox.Show("Database has been Initialised Successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                SQLConn.ConnClose();
            }
            catch (NpgsqlException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 13
0
        private void Update_record_Click(object sender, EventArgs e)
        {
            try{
                SQLConn.ConnOpen();

                string cb = "update subject set subjectcode=@d1, subjectname=@d2,classname=@d4 where subjectcode='" + txtSubjectCode.Text + "'";

                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                SQLConn.cmd.Parameters.Add(new NpgsqlParameter("@d1", txtSubjectCode.Text.Trim()));
                SQLConn.cmd.Parameters.Add(new NpgsqlParameter("@d2", txtSubjectName.Text.Trim()));
                SQLConn.cmd.Parameters.Add(new NpgsqlParameter("@d4", cmbClass.Text));


                SQLConn.cmd.ExecuteNonQuery();
                MessageBox.Show("Successfully updated", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);

                st2 = "Updated subject whose subjectCode is'" + txtSubjectCode.Text + "'";
                cf.LogFunc(st1, System.DateTime.Now, st2);
                Update_record.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SQLConn.cmd.Dispose();
                SQLConn.ConnClose();
            }
        }
Exemplo n.º 14
0
        public void LoadSchoolTerms()
        {
            try
            {
                SQLConn.ConnOpen();


                DataTable dt = new DataTable();

                DataGridView1.DataSource = null;
                SQLConn.sqL = "SELECT id, termname, startdate, enddate  FROM schoolterm order by startdate";


                // data adapter making request from our connection
                NpgsqlDataAdapter da = new NpgsqlDataAdapter(SQLConn.sqL, SQLConn.conn);

                da.Fill(dt);

                DataGridView1.DataSource = dt;


                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "Update class set classname= '" + txtClass.Text.Trim() + "', section= '" + cmbSection.Text.Trim() + "' where id='" + GroupBox1.Tag + "'";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                SQLConn.cmd.ExecuteReader();
                SQLConn.ConnClose();



                GetData();  //  1 table update karna h to yha tak ka code hata de
                MessageBox.Show("Successfully updated", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);

                st2 = "Updated the class='" + txtClass.Text + "'";
                cf.LogFunc(st1, System.DateTime.Now, st2);
                btnUpdate.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SQLConn.cmd.Dispose();
                SQLConn.ConnClose();
            }
        }
        private void delete_records()
        {
            try
            {
                int RowsAffected = 0;
                SQLConn.ConnOpen();
                SQLConn.sqL = "delete from examtype where id = '" + txtExamName.Tag + "'";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                SQLConn.cmd.ExecuteNonQuery();


                if (RowsAffected > 0)
                {
                    MessageBox.Show("Successfully deleted", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    string st2 = "Deleted Exam '" + txtExamName.Text + "'";
                    // cf.LogFunc(st1, System.DateTime.Now, st2);
                    Reset();
                }
                else
                {
                    MessageBox.Show("No Record found", "Sorry", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Reset();
                }
                SQLConn.ConnClose();
                GetData();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void FillSections()
        {
            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "SELECT distinct sectionname FROM section ";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                SQLConn.dr = SQLConn.cmd.ExecuteReader();

                while (SQLConn.dr.Read())
                {
                    cmbSection.Items.Add(SQLConn.dr[0]);
                }
                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SQLConn.cmd.Dispose();
                SQLConn.ConnClose();
            }
        }
        private void ScholarNo_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "select RTrim(FeePaymentID)[Fee Payment ID], RTRIM(Student.AdmissionNo)[Admission No.],RTRIM(Studentname)[Student Name],RTRIM(Student.Class)[Class],RTRIM(Section)[Section],RTRIM(Transportation.SourceLocation)[Source Location],RTRIM(BusFeePayment.BusCharges)[Bus Charges],RTRIM(DateOfPayment)[Payment Date],RTRIM(ModeOfPayment)[Mode Of Payment],RTRIM(PaymentModeDetails)[Payment Mode Details],RTRIM(TotalPaid)[Total Paid],RTRIM(Fine)[Fine],RTRIM(DueFees)[Due Fees]  from BusFeePayment,Student,Transportation,BusHolders where Student.AdmissionNo=BusHolders.AdmissionNo and BusFeePayment.AdmissionNo=Student.AdmissionNo and Transportation.SourceLocation=BusHolders.SourceLocation  and Busfeepayment.AdmissionNo= '" + AdmissionNo.Text + "'order by DateOfPayment";

                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                NpgsqlDataAdapter da = new NpgsqlDataAdapter();

                DataSet myDataSet = new DataSet();

                da.Fill(myDataSet, "BusFeePayment");
                da.Fill(myDataSet, "Transportation");
                da.Fill(myDataSet, "Student");
                da.Fill(myDataSet, "BusHolders");
                dataGridView2.DataSource = myDataSet.Tables["BusFeePayment"].DefaultView;
                dataGridView2.DataSource = myDataSet.Tables["Transportation"].DefaultView;
                dataGridView2.DataSource = myDataSet.Tables["Student"].DefaultView;
                dataGridView2.DataSource = myDataSet.Tables["BusHolders"].DefaultView;
                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 19
0
        private void  SaveMarks()
        {
            if (!ValidEntry())
            {
                return;
            }
            try {
                SQLConn.sqL = "insert into exammarks(examid, admissionno , subjectcode, markobtained,  totalmark) VALUES ('" + lblExamtitle.Tag + "','" + txtStudent.Text + "', '" + lblSubject.Tag + "', '" + txtMark.Text + "', '" + txtTotal.Text + "' )";
                SQLConn.ConnOpen();
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                SQLConn.cmd.ExecuteNonQuery();
                ListStudentMarks();
                Reset();

                // cf.LogFunc(st1, System.DateTime.Now, st2);
                MessageBox.Show("Successfully saved", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            finally
            {
                SQLConn.ConnClose();
            }
        }
        private void button14_Click(object sender, EventArgs e)
        {
            try
            {
                SQLConn.ConnOpen();

                SQLConn.sqL = "select RTrim(FeePaymentID)[Fee Payment ID], RTRIM(Student.AdmissionNo)[Admission No.],RTRIM(Studentname)[Student Name],RTRIM(Student.Class)[Class],RTRIM(Section)[Section],RTRIM(Transportation.SourceLocation)[Source Location],RTRIM(BusFeePayment.BusCharges)[Bus Charges],RTRIM(DateOfPayment)[Payment Date],RTRIM(ModeOfPayment)[Mode Of Payment],RTRIM(PaymentModeDetails)[Payment Mode Details],RTRIM(TotalPaid)[Total Paid],RTRIM(Fine)[Fine],RTRIM(DueFees)[Due Fees]  from BusFeePayment,Student,Transportation,BusHolders where Student.AdmissionNo=BusHolders.AdmissionNo and BusFeePayment.AdmissionNo=Student.AdmissionNo and Transportation.SourceLocation=BusHolders.SourceLocation  and DateofPayment between @date1 and @date2 and Fine>0 order by DateOfPayment";
                SQLConn.cmd.Parameters.AddWithValue("@date1", "DateOfPayment").Value = dateTimePicker1.Value.Date;
                SQLConn.cmd.Parameters.AddWithValue("@date2", "DateOfPayment").Value = dateTimePicker2.Value.Date;

                NpgsqlDataAdapter myDA = new NpgsqlDataAdapter(SQLConn.cmd);

                DataSet myDataSet = new DataSet();

                myDA.Fill(myDataSet, "BusFeePayment");
                myDA.Fill(myDataSet, "Transportation");
                myDA.Fill(myDataSet, "Student");
                myDA.Fill(myDataSet, "BusHolders");
                dataGridView5.DataSource = myDataSet.Tables["BusFeePayment"].DefaultView;
                dataGridView5.DataSource = myDataSet.Tables["Transportation"].DefaultView;
                dataGridView5.DataSource = myDataSet.Tables["Student"].DefaultView;
                dataGridView5.DataSource = myDataSet.Tables["BusHolders"].DefaultView;
                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 21
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            SQLConn.ConnOpen();
            SQLConn.sqL = "delete from ClassFeePayment where AdmissionNo=@admission";
            SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

            SQLConn.cmd.Parameters.AddWithValue("@admission", txtAdmNo.Text);
            SQLConn.dr = SQLConn.cmd.ExecuteReader();


            SQLConn.ConnOpen();
            string cb = "insert into ClassFeePayment (AdmissionNo, StudentName, EnrolmentDate, SchoolName, Class, Session, Section, Month, Year, Fee, PaymentMode, Fine, GrandTotal, TotalPaid, PaymentModeDescription, PaymentDate, PreviousDue, CurrentDue) values (@1,@2,@3,@4,@5,@6,@7,@8,@9,@10,@11,@12,@13,@14,@15,@16,@17,@18)";

            SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

            SQLConn.cmd.Parameters.AddWithValue("@1", txtAdmNo.Text);
            SQLConn.cmd.Parameters.AddWithValue("@2", txtStudName.Text);
            SQLConn.cmd.Parameters.AddWithValue("@3", txtAdmissionDate.Text);


            SQLConn.cmd.Parameters.AddWithValue("@8", cmbTermQuery.Text);

            SQLConn.cmd.Parameters.AddWithValue("@10", cmbFeeTypeQuery.Text);
            SQLConn.cmd.Parameters.AddWithValue("@11", cmbPayMode.Text);

            SQLConn.cmd.Parameters.AddWithValue("@14", txtTotalPaid.Text);
            SQLConn.cmd.Parameters.AddWithValue("@15", txtComment.Text);
            SQLConn.cmd.Parameters.AddWithValue("@16", dtpPaydate.Text);
            SQLConn.cmd.Parameters.AddWithValue("@17", txtFeePaid.Text);
            SQLConn.cmd.Parameters.AddWithValue("@18", txtFeeAmount.Text);
            SQLConn.dr = SQLConn.cmd.ExecuteReader();

            MessageBox.Show(txtStudName.Text + " " + " has paid " + txtTotalPaid.Text + " as school fee ", "Payment Records", MessageBoxButtons.OK, MessageBoxIcon.Information);
            ResetAll();
        }
        private void AutocompleteClass()
        {
            try
            {
                SQLConn.ConnOpen();



                SQLConn.sqL = "SELECT distinct RTRIM(Class) FROM BusFeePayment,Student,BusHolders where BusFeePayment.AdmissionNo=Student.AdmissionNo and BusHolders.AdmissionNo=Student.AdmissionNo";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                da.Fill(dt);

                txtclass.Items.Clear();

                foreach (DataRow drow in dt.Rows)
                {
                    txtclass.Items.Add(drow[0].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void FillComboExamType(ComboBox cb)
        {
            try
            {
                SQLConn.ConnOpen();

                SQLConn.sqL = "select id, examtypename from examtype ";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);


                SQLConn.da = new NpgsqlDataAdapter(SQLConn.cmd);

                DataTable dt = new DataTable();

                dt.Columns.Add("id", typeof(string));
                dt.Columns.Add("examtypename", typeof(string));

                dt.Rows.Add(new Object[] { -1, "Select Exam Type" });


                SQLConn.da.Fill(dt);


                cb.DataSource    = dt;
                cb.DisplayMember = "examtypename";
                cb.ValueMember   = "id";
                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void AutocompleteScholarNo()
        {
            try
            {
                SQLConn.ConnOpen();


                SQLConn.sqL      = "SELECT distinct admissionno FROM BusFeePayment";
                da.SelectCommand = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                dt.Clear();

                da.Fill(dt);

                AdmissionNo.Items.Clear();

                foreach (DataRow drow in dt.Rows)
                {
                    AdmissionNo.Items.Add(drow[0].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void FillComboSubject(ComboBox cb, string sclass)
        {
            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "select subjectcode, subjectname from subject  ";
                if (sclass != "")
                {
                    SQLConn.sqL += " WHERE  classname= '" + sclass + "'";
                }
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                SQLConn.da  = new NpgsqlDataAdapter(SQLConn.cmd);
                DataTable dt = new DataTable();
                dt.Columns.Add("subjectcode", typeof(string));
                dt.Columns.Add("subjectname", typeof(string));

                dt.Rows.Add(new Object[] { "-1", "Select Subject" });
                SQLConn.da.Fill(dt);
                cb.DataSource    = dt;
                cb.DisplayMember = "subjectname";
                cb.ValueMember   = "subjectcode";
                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void Course_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtsection.Items.Clear();
            txtsection.Text    = "";
            txtsection.Enabled = true;

            try
            {
                SQLConn.ConnOpen();


                SQLConn.sqL = "select distinct RTRIM(section) from BusFeePayment,BusHolders,Student where BusFeePayment.AdmissionNo=Student.AdmissionNo and BusHolders.AdmissionNo=Student.AdmissionNo and Student.class= '" + txtclass.Text + "'";


                SQLConn.dr = SQLConn.cmd.ExecuteReader();

                while (SQLConn.dr.Read())
                {
                    txtsection.Items.Add(SQLConn.dr[0]);
                }
                SQLConn.ConnClose();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void LoadClassCombo(ComboBox cb)
        {
            try
            {
                SQLConn.ConnOpen();
                SQLConn.da = new NpgsqlDataAdapter("SELECT id, classname  FROM sclass order by classname", SQLConn.conn);

                DataTable dt = new DataTable();
                SQLConn.da.Fill(dt);

                dt.Rows.Add(-1, "All Classes");


                cb.DataSource = dt;


                cb.DisplayMember = "classname";
                cb.ValueMember   = "id";


                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error is", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SQLConn.cmd.Dispose();
                SQLConn.ConnClose();
            }
        }
        public void GetData()
        {
            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "SELECT sclass.id, sclass.classname,section from sclass order by classname , section";
                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);
                SQLConn.da  = new NpgsqlDataAdapter(SQLConn.cmd);
                DataTable dt = new DataTable();
                SQLConn.da.Fill(dt);
                DataGridView1.DataSource = dt;



                SQLConn.ConnClose();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SQLConn.cmd.Dispose();
                SQLConn.ConnClose();
            }
        }
        private void SearchStudents(bool sname)
        {
            try
            {
                SQLConn.ConnOpen();
                SQLConn.sqL = "SELECT admissionno,CONCAT(firstname,  ' '  ,othername) as fullname,status , sclass,section,termname,term, admissiondate,gender,category from studentdetail LEFT JOIN schoolterm on  studentdetail.term=schoolterm.id WHERE 1=1";



                if (int.Parse(cmbTerm.SelectedValue.ToString()) > 0)
                {
                    SQLConn.sqL += " AND term ='" + cmbTerm.SelectedValue.ToString() + "'";
                }
                if (int.Parse(cmbClass.SelectedValue.ToString()) > 0)
                {
                    SQLConn.sqL += " AND sclass ='" + cmbClass.SelectedValue.ToString() + "'";
                }



                if (sname)
                {
                    if (txtAdmissionNo.Text.Trim() != "")
                    {
                        SQLConn.sqL += " AND  admissionno ILike  '%" + txtAdmissionNo.Text.Trim() + "%' or othername ILIKE '%" + txtAdmissionNo.Text.Trim() + "%' or  firstname ILike  '%" + txtAdmissionNo.Text.Trim() + "%' ";
                    }
                }



                DGV.DataSource = null;



                SQLConn.sqL += "  order by admissionno";



                SQLConn.cmd = new NpgsqlCommand(SQLConn.sqL, SQLConn.conn);

                SQLConn.da = new NpgsqlDataAdapter(SQLConn.cmd);
                DataTable dt = new DataTable();


                SQLConn.da.Fill(dt);
                DGV.DataSource = dt;



                SQLConn.ConnClose();
            }
            catch (NpgsqlException ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                SQLConn.cmd.Dispose();
            }
        }
Exemplo n.º 30
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtTermName.Tag == null)
            {
                MessageBox.Show("Select Term in Grid to Edit");
                return;
            }
            try
            {
                SQLConn.ConnOpen();

                string startdate = tm.TimeToString(dtpStartDate.Value);
                string enddate   = tm.TimeToString(dtpEndDate.Value);
                SQLConn.cmd.CommandText = "update schoolterm set termname='" + txtTermName.Text + "', startdate ='" + startdate + "', enddate='" + enddate + "' WHERE id=" + txtTermName.Tag + " ";
                SQLConn.cmd.ExecuteNonQuery();
                SQLConn.conn.Close();
                MessageBox.Show("Updated Saved", "Term Records", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Clears();
                LoadSchoolTerms();
            }
            catch (NpgsqlException ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }