public int Update(Karyawan kary)
        {
            int i;

            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlCommand com = new SqlCommand("InsertUpdateKaryawan", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Id", kary.kode);
                com.Parameters.AddWithValue("@nama", kary.nama);
                com.Parameters.AddWithValue("@kd_type", kary.kd_type);
                com.Parameters.AddWithValue("@alamat", kary.alamat);
                com.Parameters.AddWithValue("@Action", "Update");
                i = com.ExecuteNonQuery();
            }
            return(i);
        }
        public int Add(Karyawan kary)
        {
            using (SqlConnection con = new SqlConnection(cs))
            {
                con.Open();
                SqlCommand com = new SqlCommand("InsertUpdateKaryawan", con);
                com.CommandType = CommandType.StoredProcedure;
                com.Parameters.AddWithValue("@Id", kary.kode);
                com.Parameters.AddWithValue("@nama", kary.nama);
                com.Parameters.AddWithValue("@kd_type", kary.kd_type);
                com.Parameters.AddWithValue("@alamat", kary.alamat);
                com.Parameters.AddWithValue("@Action", "Insert");

                SqlDataReader i = com.ExecuteReader(CommandBehavior.CloseConnection);
                if (i.HasRows)
                {
                    return(0);  // data exist
                }
                else
                {
                    return(1); //data not exist
                }
            }
        }