private void PaymentRecords_TabItem_GotFocus(object sender, RoutedEventArgs e)
 {
     var fdset = new financeapplicationDataSet();
     var fsdadapter =
         new financeapplicationDataSetTableAdapters.payment_summaryTableAdapter();
     fsdadapter.Fill(fdset.payment_summary);
     PaymentRecordsGrid.DataContext = fsdadapter.GetData();
 }
 private void IndividualPayRecord_TextChanged(object sender, TextChangedEventArgs e)
 {
     var fdset = new financeapplicationDataSet();
     var fsdadapter =
         new financeapplicationDataSetTableAdapters.payment_summaryTableAdapter();
     fsdadapter.Fill(fdset.payment_summary);
     PaymentRecordsGrid.DataContext = fsdadapter.GetData();
 }
示例#3
0
        public void New()
        {
            try
            {
                var adm=Convert.ToInt32(AdmNo);
                var fdataset = new financeapplicationDataSet();
                var sdetailsAdapter = new financeapplicationDataSetTableAdapters.students_detailsTableAdapter();
                var pdetailsAdapter = new financeapplicationDataSetTableAdapters.payment_detailsTableAdapter();

                try
                {
                    sdetailsAdapter.Insert(Convert.ToInt32(_admNo), _firstName, _lastName, _dofBirth, _gender, _admDate, _parentName, _parentContact);

                    //loop to initialize payment details of the new student from form 1-4 to 0 in db
                    for (var count1 = 1; count1 < 5; count1++)
                    {
                        for (var count2 = 1; count2 < 4; count2++)
                        {
                            pdetailsAdapter.Insert(Convert.ToInt32(_admNo), 0, 0, 0, 0, 0, 0, 0,
                                0, 0, 0, 0, 0, 0, count1, count2, 0);
                        }
                    }

                    MessageBox.Show("The Student " + _firstName + " has been added to the database");
                    var stv = new StudentView();
                    stv.PageClear();
                }
                catch (Exception e2)
                {
                    MessageBox.Show("An error has occured. Error Message: " + e2.Message.ToString());
                }

            }
            catch(Exception e1)
            {
                MessageBox.Show("Error occured while trying to write to the database. Please try again. Error Message: "+ e1.Message.ToString());
            }
        }
示例#4
0
        public Dictionary<string, string> Add(string form, string term)
        {
            var fdset = new financeapplicationDataSet();
            var fadapt = new financeapplicationDataSetTableAdapters.fee_structureTableAdapter();
            fadapt.Fill(fdset.fee_structure);
            var columncount = fdset.fee_structure.Columns.Count;
            var rowcount = fdset.fee_structure.Rows.Count;
            var feesitems = new Dictionary<string, string>();

            foreach (DataRow row in fdset.fee_structure.Rows)
            {
                var count = 0;

                if ((row["form"].ToString() != form) || (row["term"].ToString() != term)) continue;
                while (count < columncount)
                {
                    feesitems[fdset.fee_structure.Columns[count].ToString()] = Convert.ToString(row[fdset.fee_structure.Columns[count]]);
                    count++;
                }
            }

            return feesitems;
        }
 private void ViewStudents_Tab_GotFocus(object sender, RoutedEventArgs e)
 {
     var fdset = new financeapplicationDataSet();
     var fsdadapter = new financeapplicationDataSetTableAdapters.students_detailsTableAdapter();
     fsdadapter.Fill(fdset.students_details);
     ViewStudentsGrid.DataContext = fsdadapter.GetData();
 }
示例#6
0
        internal void Modify()
        {
            try
            {
                var adm = Convert.ToInt32(AdmNo);
                var fdataset = new financeapplicationDataSet();
                var fdatasetadapter = new financeapplicationDataSetTableAdapters.students_detailsTableAdapter();
                fdatasetadapter.Fill(fdataset.students_details);
                var sqlwhere = "admission_no=" + adm;
                var newDataTable = fdataset.students_details.Select(sqlwhere).CopyToDataTable();
                var row = newDataTable.Rows[0];
                try
                {
                    MessageBox.Show((Convert.ToInt32(row[0].ToString())).ToString());
                    //fdatasetadapter.Update(Convert.ToInt32(admNo), firstName, lastName, dofBirth, gender, admDate, parentName, parentContact);
                    MessageBox.Show("The Student " + row[0].ToString() + " has been added to the database");
                    var stv = new StudentView();
                    stv.PageClear();
                }
                catch (Exception e2)
                {
                    MessageBox.Show("An error has occured. Error Message: " + e2.Message.ToString());
                }

            }
            catch (Exception e1)
            {
                MessageBox.Show("Error occured while trying to write to the database. Please try again. Error Message: " + e1.Message.ToString());
            }
        }
示例#7
0
        public Dictionary<string, string> RetrieveDetails(string admissionNo)
        {
            var adm = admissionNo;
            var fdset = new financeapplicationDataSet();
            var fadapter = new financeapplicationDataSetTableAdapters.students_detailsTableAdapter();
            fadapter.Fill(fdset.students_details);

            var stdictionary=new Dictionary<string, string>();
            var columncount=fdset.students_details.Columns.Count;
            var count = 0;
            var sqlwhere = "admission_no=" + adm;
            try
            {
                var newDataTable = fdset.students_details.Select(sqlwhere).CopyToDataTable();
                var row = newDataTable.Rows[0];

                while (count < columncount)
                {
                    stdictionary[newDataTable.Columns[count].ToString()] = Convert.ToString(row[newDataTable.Columns[count]]);
                    count++;
                }
            }
            catch
            {

            }

            return stdictionary;
        }
示例#8
0
        public void MakePayment()
        {
            var fdataset = new financeapplicationDataSet();
            var psummaryadapter =
                new financeapplicationDataSetTableAdapters.payment_summaryTableAdapter();
            var fstructureadapter =
                new financeapplicationDataSetTableAdapters.fee_structureTableAdapter();
            var pdetailsadapter =
                new financeapplicationDataSetTableAdapters.payment_detailsTableAdapter();

            fstructureadapter.Fill(fdataset.fee_structure);
            psummaryadapter.Fill(fdataset.payment_summary);
            pdetailsadapter.Fill(fdataset.payment_details);

            //to add the payment to the payment summary table
            switch (Type)
            {
                case "Check":
                    try
                    {
                        psummaryadapter.Insert(Convert.ToInt32(AdmNo), Type, SlipCheckNo, Purpose, null,
                            Amount.ToString());
                        MessageBox.Show("The Entry has been added to the database");
                        var str = new StudentPaymentRecord();
                        str.PageClear();
                    }
                    catch (Exception e1)
                    {
                        MessageBox.Show(
                            "There was an Error while trying to write to the database. Please try again. Error Message: " +
                            e1.Message);
                    }
                    break;
                case "Bank Slip":
                    try
                    {
                        psummaryadapter.Insert(Convert.ToInt32(AdmNo), Type, null, Purpose, SlipCheckNo,
                            Amount.ToString());
                        MessageBox.Show("The Entry has been added to the database");
                        var str = new StudentPaymentRecord();
                        str.PageClear();
                    }
                    catch (Exception e2)
                    {
                        MessageBox.Show(
                            "There was an Error while trying to write to the database. Please try again.Error Message: " +
                            e2.Message);
                    }
                    break;

                default:
                    try
                    {
                        psummaryadapter.Insert(Convert.ToInt32(AdmNo), Type, null, Purpose, null, Amount.ToString());
                        MessageBox.Show("The Entry has been added to the database");
                        var str = new StudentPaymentRecord();
                        str.PageClear();
                    }
                    catch (Exception e2)
                    {
                        MessageBox.Show(
                            "There was an Error while trying to write to the database. Please try again.Error Message: " +
                            e2.Message);
                    }
                    break;
            }

            //compare the total paid by the particular student with each year's total in the fee structure
            for (var count1 = 1; count1 < 5; count1++)
            {
                for (var count2 = 1; count2 < 4; count2++)
                {
                    var whereFormTerm = "form=" + count1 + "and term=" + count2;
                    var whereAdm = "admission_no=" + Convert.ToInt32(AdmNo) + "and form=" + count1 + "and term=" +
                                   count2;

                    var fstructureDataTable = fdataset.fee_structure.Select(whereFormTerm).CopyToDataTable();
                    var fstructureDataRow = fstructureDataTable.Rows[0]; //since only one datarow will be returned
                    var totalPayable = fstructureDataRow["total"]; //contains total of the fee structure votehead

                    //specific payment details for the particular student
                    var paydetailsDataTable = fdataset.payment_details.Select(whereAdm).CopyToDataTable();
                    var paydetailsDataRow = paydetailsDataTable.Rows[0];

                    //check if the value in the payment_details relation is equal to the corresponding value in the fee_structure relation

                    try
                    {
                        pdetailsadapter.Fill(fdataset.payment_details);
                        var pdetailsDataTable = fdataset.payment_details.Select(whereAdm).CopyToDataTable();
                        var pdetailsDataRow = pdetailsDataTable.Rows[0];

                        if (count1 == 1) //for form 1
                        {
                            //select values of each votehead from fee structure
                            var voteheads = new Dictionary<int, string>();
                            voteheads[2] = fstructureDataRow["bes"].ToString();
                            voteheads[9] = fstructureDataRow["rmi"].ToString();
                            voteheads[8] = fstructureDataRow["ltt"].ToString();
                            voteheads[7] = fstructureDataRow["adm"].ToString();
                            voteheads[11] = fstructureDataRow["ewc"].ToString();
                            voteheads[6] = fstructureDataRow["medical"].ToString();
                            voteheads[5] = fstructureDataRow["pe"].ToString();
                            voteheads[4] = fstructureDataRow["bog"].ToString();
                            voteheads[1] = fstructureDataRow["pta"].ToString();
                            voteheads[3] = fstructureDataRow["activity"].ToString();
                            voteheads[10] = fstructureDataRow["mentorship"].ToString();
                            voteheads[0] = fstructureDataRow["caution_money"].ToString();
                            voteheads[12] = fstructureDataRow["district_mock"].ToString();

                            //votehead names stored in a systematic manner in an array so as to ensure systematic deduction
                            //of any money paid e.g, caution money should be deducted before pta
                            string[] voteheadNames =
                            {
                                "caution_money", "pta", "bes", "activity", "bog", "pe", "medical", "adm", "ltt",
                                "rmi", "mentorship", "ewc", "district_mock"
                            };

                            //loop to feed in the values into the database
                            var j = 0;
                            while (Amount > 0 && j < 13)
                            {

                                if (Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                    Convert.ToInt32(voteheads[j]) &&
                                    (Amount >= Convert.ToInt32(voteheads[j])))
                                {
                                    Amount = Amount -
                                             (Convert.ToInt32(voteheads[j]) -
                                              Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]));
                                    pdetailsDataRow[voteheadNames[j]] = voteheads[j];

                                }

                                else if ((Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                          Convert.ToInt32(voteheads[j]) &&
                                          Amount >
                                          (Convert.ToInt32(voteheads[j]) -
                                           Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]))))
                                {
                                    Amount -= Convert.ToInt32(voteheads[j]) -
                                              Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]);
                                    pdetailsDataRow[voteheadNames[j]] =
                                        pdetailsDataRow[voteheadNames[j]] = voteheads[j];

                                }
                                else if (Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                         Convert.ToInt32(voteheads[j]) &&
                                         ((Amount + Convert.ToInt32(pdetailsDataRow[voteheadNames[j]])) <=
                                          Convert.ToInt32(voteheads[j])))
                                {

                                    pdetailsDataRow[voteheadNames[j]] =
                                        Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) + Amount;
                                    Amount = 0;

                                }

                                pdetailsadapter.Update(pdetailsDataRow);
                                j++;
                            }

                        }

                        else if (count1 == 2) //for form 2
                        {
                            //select values of each votehead from fee structure
                            var voteheads = new Dictionary<int, string>();
                            voteheads[1] = fstructureDataRow["bes"].ToString();
                            voteheads[8] = fstructureDataRow["rmi"].ToString();
                            voteheads[7] = fstructureDataRow["ltt"].ToString();
                            voteheads[6] = fstructureDataRow["adm"].ToString();
                            voteheads[10] = fstructureDataRow["ewc"].ToString();
                            voteheads[5] = fstructureDataRow["medical"].ToString();
                            voteheads[4] = fstructureDataRow["pe"].ToString();
                            voteheads[3] = fstructureDataRow["bog"].ToString();
                            voteheads[0] = fstructureDataRow["pta"].ToString();
                            voteheads[2] = fstructureDataRow["activity"].ToString();
                            voteheads[9] = fstructureDataRow["mentorship"].ToString();
                            voteheads[11] = fstructureDataRow["caution_money"].ToString();
                            voteheads[12] = fstructureDataRow["district_mock"].ToString();

                            //votehead names stored in a systematic manner in an array so as to ensure systematic deduction
                            //of any money paid e.g, caution money should be deducted before pta
                            string[] voteheadNames =
                            {
                                "pta", "bes", "activity", "bog", "pe", "medical", "adm", "ltt",
                                "rmi", "mentorship", "ewc", "caution_money", "district_mock"
                            };

                            //loop to feed in the values into the database
                            var j = 0;
                            while (Amount > 0 && j < 13)
                            {

                                if (Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                    Convert.ToInt32(voteheads[j]) &&
                                    (Amount >= Convert.ToInt32(voteheads[j])))
                                {
                                    Amount = Amount -
                                             (Convert.ToInt32(voteheads[j]) -
                                              Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]));
                                    pdetailsDataRow[voteheadNames[j]] = voteheads[j];

                                }

                                else if ((Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                          Convert.ToInt32(voteheads[j]) &&
                                          Amount >
                                          (Convert.ToInt32(voteheads[j]) -
                                           Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]))))
                                {
                                    Amount -= Convert.ToInt32(voteheads[j]) -
                                              Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]);
                                    pdetailsDataRow[voteheadNames[j]] =
                                        pdetailsDataRow[voteheadNames[j]] = voteheads[j];

                                }
                                else if (Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                         Convert.ToInt32(voteheads[j]) &&
                                         ((Amount + Convert.ToInt32(pdetailsDataRow[voteheadNames[j]])) <=
                                          Convert.ToInt32(voteheads[j])))
                                {

                                    pdetailsDataRow[voteheadNames[j]] =
                                        Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) + Amount;
                                    Amount = 0;

                                }

                                pdetailsadapter.Update(pdetailsDataRow);
                                j++;
                            }

                        }

                        if (count1 == 3) //for form 3
                        {

                            //select values of each votehead from fee structure
                            var voteheads = new Dictionary<int, string>();
                            voteheads[1] = fstructureDataRow["bes"].ToString();
                            voteheads[8] = fstructureDataRow["rmi"].ToString();
                            voteheads[7] = fstructureDataRow["ltt"].ToString();
                            voteheads[6] = fstructureDataRow["adm"].ToString();
                            voteheads[10] = fstructureDataRow["ewc"].ToString();
                            voteheads[5] = fstructureDataRow["medical"].ToString();
                            voteheads[4] = fstructureDataRow["pe"].ToString();
                            voteheads[3] = fstructureDataRow["bog"].ToString();
                            voteheads[0] = fstructureDataRow["pta"].ToString();
                            voteheads[2] = fstructureDataRow["activity"].ToString();
                            voteheads[9] = fstructureDataRow["mentorship"].ToString();
                            voteheads[11] = fstructureDataRow["caution_money"].ToString();
                            voteheads[12] = fstructureDataRow["district_mock"].ToString();

                            //votehead names stored in a systematic manner in an array so as to ensure systematic deduction
                            //of any money paid e.g, caution money should be deducted before pta
                            string[] voteheadNames =
                            {
                                "pta", "bes", "activity", "bog", "pe", "medical", "adm", "ltt",
                                "rmi", "mentorship", "ewc", "caution_money", "district_mock"
                            };

                            //loop to feed in the values into the database
                            var j = 0;
                            while (Amount > 0 && j < 13)
                            {

                                if (Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                    Convert.ToInt32(voteheads[j]) &&
                                    (Amount >= Convert.ToInt32(voteheads[j])))
                                {
                                    Amount = Amount -
                                             (Convert.ToInt32(voteheads[j]) -
                                              Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]));
                                    pdetailsDataRow[voteheadNames[j]] = voteheads[j];

                                }

                                else if ((Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                          Convert.ToInt32(voteheads[j]) &&
                                          Amount >
                                          (Convert.ToInt32(voteheads[j]) -
                                           Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]))))
                                {
                                    Amount -= Convert.ToInt32(voteheads[j]) -
                                              Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]);
                                    pdetailsDataRow[voteheadNames[j]] =
                                        pdetailsDataRow[voteheadNames[j]] = voteheads[j];

                                }
                                else if (Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                         Convert.ToInt32(voteheads[j]) &&
                                         ((Amount + Convert.ToInt32(pdetailsDataRow[voteheadNames[j]])) <=
                                          Convert.ToInt32(voteheads[j])))
                                {

                                    pdetailsDataRow[voteheadNames[j]] =
                                        Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) + Amount;
                                    Amount = 0;

                                }

                                pdetailsadapter.Update(pdetailsDataRow);
                                j++;
                            }

                        }

                        if (count1 == 4) //for form 4
                        {
                            //select values of each votehead from fee structure
                            var voteheads = new Dictionary<int, string>();
                            voteheads[1] = fstructureDataRow["bes"].ToString();
                            voteheads[8] = fstructureDataRow["rmi"].ToString();
                            voteheads[7] = fstructureDataRow["ltt"].ToString();
                            voteheads[6] = fstructureDataRow["adm"].ToString();
                            voteheads[11] = fstructureDataRow["ewc"].ToString();
                            voteheads[5] = fstructureDataRow["medical"].ToString();
                            voteheads[4] = fstructureDataRow["pe"].ToString();
                            voteheads[3] = fstructureDataRow["bog"].ToString();
                            voteheads[0] = fstructureDataRow["pta"].ToString();
                            voteheads[2] = fstructureDataRow["activity"].ToString();
                            voteheads[9] = fstructureDataRow["mentorship"].ToString();
                            voteheads[12] = fstructureDataRow["caution_money"].ToString();
                            voteheads[10] = fstructureDataRow["district_mock"].ToString();

                            //votehead names stored in a systematic manner in an array so as to ensure systematic deduction
                            //of any money paid e.g, caution money should be deducted before pta
                            string[] voteheadNames =
                            {
                                "pta", "bes", "activity", "bog", "pe", "medical", "adm", "ltt",
                                "rmi", "mentorship", "district_mock", "ewc", "caution_money"
                            };

                            //loop to feed in the values into the database
                            var j = 0;
                            while (Amount > 0 && j < 13)
                            {

                                if (Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                    Convert.ToInt32(voteheads[j]) &&
                                    (Amount >= Convert.ToInt32(voteheads[j])))
                                {
                                    Amount = Amount -
                                             (Convert.ToInt32(voteheads[j]) -
                                              Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]));
                                    pdetailsDataRow[voteheadNames[j]] = voteheads[j];

                                }

                                else if ((Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                          Convert.ToInt32(voteheads[j]) &&
                                          Amount >
                                          (Convert.ToInt32(voteheads[j]) -
                                           Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]))))
                                {
                                    Amount -= Convert.ToInt32(voteheads[j]) -
                                              Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]);
                                    pdetailsDataRow[voteheadNames[j]] =
                                        pdetailsDataRow[voteheadNames[j]] = voteheads[j];

                                }
                                else if (Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) <
                                         Convert.ToInt32(voteheads[j]) &&
                                         ((Amount + Convert.ToInt32(pdetailsDataRow[voteheadNames[j]])) <=
                                          Convert.ToInt32(voteheads[j])))
                                {

                                    pdetailsDataRow[voteheadNames[j]] =
                                        Convert.ToInt32(pdetailsDataRow[voteheadNames[j]]) + Amount;
                                    Amount = 0;

                                }

                                pdetailsadapter.Update(pdetailsDataRow);
                                j++;
                            }

                        }
                    }
                    catch
                    {

                    }

                }
            }
        }