예제 #1
0
        public static List <COInsured> GetUsers(string _cocno)
        {
            List <COInsured> users = new List <COInsured>();
            String           cmdText;
            MySqlDataReader  reader = null;

            MySqlConnection con = null;

            con = DBConnection.GetDBConnection();

            //get data from db and load...

            //To query data from the database using MySqlDataReader
            cmdText = "SELECT id,cid,firstname,middlename,lastname, DATE_FORMAT(birthdate,'%m-%d-%Y'),relationship FROM tblcoinsured WHERE cid=@cocno";
            MySqlCommand cmd = new MySqlCommand(cmdText, con);

            cmd.Parameters.AddWithValue("@cocno", _cocno);

            reader = cmd.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    COInsured s = new COInsured(reader.GetInt16(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetString(6));
                    //Console.WriteLine(reader.GetString(0) + "|" + reader.GetString(1) + "|" + reader.GetString(2));
                    users.Add(s);
                }
            }
            reader.Close();
            return(users);
        }
예제 #2
0
        private void loadTable()
        {
            List <COInsured> ss = COInsured.GetUsers(cocno);
            int row             = 0;

            dgv_COInsured.RowCount = 1;

            try
            {
                foreach (DataGridViewRow row1 in dgv_COInsured.Rows)
                {
                    if (!row1.IsNewRow)
                    {
                        dgv_COInsured.Rows.Remove(row1);
                    }
                }


                foreach (COInsured s in ss)
                {
                    dgv_COInsured.Rows.Add();
                    dgv_COInsured[0, row].Value   = s.Id;
                    dgv_COInsured[1, row].Value   = s.CID;
                    dgv_COInsured[2, row].Value   = s.Firstname;
                    dgv_COInsured[3, row].Value   = s.Middlename;
                    dgv_COInsured[4, row].Value   = s.Lastname;
                    dgv_COInsured[5, row].Value   = s.BirthDate;
                    dgv_COInsured[6, row++].Value = s.Relationship;
                    //id = s.Id;
                }
            }
            catch
            {
            }
        }
예제 #3
0
        private void btnCI_Save_Click(object sender, EventArgs e)
        {
            var    v          = cbCI_Month.SelectedItem as Level;
            int    _month     = v.Number;
            string birthdate2 = _month + "/" + cbCI_Day.Text + "/" + cbCI_Year.Text;

            if (option == 1)
            {
                DialogResult rs = MessageBox.Show("Do You Want To Add This Information?", "Confirmation", MessageBoxButtons.YesNo);
                if (rs == DialogResult.Yes)
                {
                    COInsured ben = new COInsured(0, txtCI_CID.Text, txtCI_Firstname.Text, txtCI_Middlename.Text, txtCI_Lastname.Text, birthdate2, cbCI_Relationship.Text);
                    ben.AddNewCI();
                }
            }
            else
            {
                DialogResult rs = MessageBox.Show("Do You Want To Edit This Information?", "Confirmation", MessageBoxButtons.YesNo);
                if (rs == DialogResult.Yes)
                {
                    COInsured ben = new COInsured(id, txtCI_CID.Text, txtCI_Firstname.Text, txtCI_Middlename.Text, txtCI_Lastname.Text, birthdate2, cbCI_Relationship.Text);
                    ben.EditCI();
                    //MessageBox.Show(_birthdate, "df", MessageBoxButtons.YesNo);
                }
            }
        }
예제 #4
0
        private void btnCOI_Delete_Click(object sender, EventArgs e)
        {
            COInsured b = new COInsured(id);

            DialogResult rs = MessageBox.Show("Do You Want To Delete This Information?", "Confirmation", MessageBoxButtons.YesNo);

            if (rs == DialogResult.Yes)
            {
                b.DeleteCI();
                loadTable();
            }
        }
예제 #5
0
        public static COInsured GetUser(int personId)
        {
            COInsured       p = null;
            string          cmdText;
            MySqlConnection con = null;

            con = DBConnection.GetDBConnection();


            cmdText  = "SELECT * FROM tblcoinsured";
            cmdText += "WHERE id=" + personId;

            MySqlCommand cmd = new MySqlCommand(cmdText, con);

            MySqlDataReader reader = null;

            try
            {
                reader = cmd.ExecuteReader();

                if (reader.HasRows)
                {
                    reader.Read();
                    //call sproc and load from database...
                    p = new COInsured(reader.GetInt16(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetString(5), reader.GetString(6));
                }

                reader.Close();
            }
            catch (Exception err)
            {
                Console.WriteLine("Error: " + err.ToString());
            }
            finally
            {
                con.Close();
            }

            return(p);
        }