Beispiel #1
0
 public int UpdateCongNhan(congnhan cn)
 {
     using (MySqlConnection conn = GetConnection())
     {
         conn.Open();
         var          str = "update CONGNHAN set TenCongNhan = @tencongnhan, GioiTinh = @gt, NamSinh = @ns, NuocVe = @nv where MaCongNhan=@macongnhan";
         MySqlCommand cmd = new MySqlCommand(str, conn);
         cmd.Parameters.AddWithValue("macongnhan", cn.MaCongNhan);
         cmd.Parameters.AddWithValue("tencongnhan", cn.TenCongNhan);
         cmd.Parameters.AddWithValue("gt", cn.GioiTinh);
         cmd.Parameters.AddWithValue("ns", cn.NamSinh);
         cmd.Parameters.AddWithValue("nv", cn.NuocVe);
         return(cmd.ExecuteNonQuery());
     }
 }
Beispiel #2
0
        public congnhan ViewCongNhan(string Id)
        {
            congnhan cn = new congnhan();

            using (MySqlConnection conn = GetConnection())
            {
                conn.Open();
                var          str = "select * from congnhan where MaCongNhan=@mcn";
                MySqlCommand cmd = new MySqlCommand(str, conn);
                cmd.Parameters.AddWithValue("mcn", Id);
                using (var reader = cmd.ExecuteReader())
                {
                    reader.Read();
                    cn.MaCongNhan  = reader["MaCongNhan"].ToString();
                    cn.TenCongNhan = reader["TenCongNhan"].ToString();
                    cn.GioiTinh    = bool.Parse(reader["GioiTinh"].ToString());
                    cn.NamSinh     = int.Parse(reader["NamSinh"].ToString());
                    cn.NuocVe      = reader["NuocVe"].ToString();
                }
            }

            return(cn);
        }