Esempio n. 1
0
        private void dgvMiscFee_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                id = Convert.ToInt32(dgvMiscFee.Rows[e.RowIndex].Cells[2].Value.ToString());//for editing criteria

                //pass value to edit mode
                txtMiscName.Text = dgvMiscFee.Rows[e.RowIndex].Cells[3].Value.ToString(); //Name
                txtAmount.Text   = dgvMiscFee.Rows[e.RowIndex].Cells[4].Value.ToString(); //Name

                btnAdd.Text = "&Update";                                                  //set button to Update
            }

            else if (e.ColumnIndex == 1)
            {
                string message = "Do you want to delete this record?";
                string title   = "Enrollment System";

                MessageBoxButtons buttons = MessageBoxButtons.YesNo;
                DialogResult      result  = MessageBox.Show(message, title, buttons, MessageBoxIcon.Warning);

                if (result == DialogResult.Yes)
                {
                    MiscFee miscFee = new MiscFee();
                    miscFee.Id = Convert.ToInt32(dgvMiscFee.Rows[e.RowIndex].Cells[2].Value.ToString());//for editing criteria
                    miscFee.Delete();

                    miscFee.LoadDataTable(dgvMiscFee);
                }
                else
                {
                    return;
                }
            }
        }
Esempio n. 2
0
        public List <MiscFee> Load()
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(GOCSystem2018.Config.GetConnectionString()))
                {
                    con.Open();

                    string sql = "SELECT * FROM misc_fee";

                    MySqlCommand cmd = new MySqlCommand(sql, con);

                    MySqlDataReader reader = cmd.ExecuteReader();

                    //loop while have record
                    while (reader.Read())
                    {
                        //instantiate model
                        MiscFee miscFee = new MiscFee();

                        //prepare properties
                        miscFee.id          = Convert.ToInt32(reader["id"].ToString());
                        miscFee.miscFeeName = reader["misc_fee_name"].ToString();
                        //miscFee.miscFeeAmount = reader["misc_amount"].ToString();
                        miscFee.miscFeeAmount = Convert.ToDouble(reader["misc_amount"]);
                        miscFees.Add(miscFee);
                    }
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("ERROR : " + ex.ToString(), "GOCINFOSYS", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return(miscFees);
        }//End of Load