Beispiel #1
0
        private fee_allocation CreateFeeAllocation()
        {
            var feeallo = new fee_allocation()
            {
                allocate_class = cBoxClass.Text.Substring(0, 4),
                date_allocated = DateTime.Today.ToString("d"),
                fee_amount     = Convert.ToInt32(txtFee.Text),
                student_type   = cBoxType.Text
            };

            return(feeallo);
        }
Beispiel #2
0
        private void dGridStudents_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            var senderGrid = (DataGridView)sender;
            var es         = senderGrid.Rows[e.RowIndex].Cells[e.ColumnIndex];


            if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0)
            {
                var btn = (DataGridViewButtonColumn)senderGrid.Columns[e.ColumnIndex];

                if (btn.Text == "Delete")
                {
                    if (senderGrid.CurrentRow != null)
                    {
                        var _id = (int)senderGrid.CurrentRow.Cells["id"].Value;

                        try
                        {
                            using (var db = new Model1())
                            {
                                var feee_allo = new fee_allocation()
                                {
                                    id = _id
                                };
                                db.fee_allocation.Attach(feee_allo);
                                db.fee_allocation.Remove(feee_allo);
                                db.SaveChanges();

                                fees_allo = db.fee_allocation.ToList();
                                MessageBox.Show("Deleted");
                                dGridStudents.DataSource = fees_allo;
                            }
                        }
                        catch (Exception ex)
                        {
                            Utils.LogException(ex);
                            MessageBox.Show("An error occured. Please contact support");
                        }
                    }
                }
                else if (btn.Text == "Edit")
                {
                    if (senderGrid.CurrentRow != null)
                    {
                        txtIDedit.Text   = senderGrid.CurrentRow.Cells[0].Value.ToString();
                        txteditclas.Text = senderGrid.CurrentRow.Cells[2].Value.ToString();
                        txtedittype.Text = senderGrid.CurrentRow.Cells[3].Value.ToString();
                        txtFeeedit.Text  = senderGrid.CurrentRow.Cells[4].Value.ToString();
                    }
                }
            }
        }