private void menuItemDefault_Click(object sender, EventArgs e) { int rowIndex = this.listViewLienHe.SelectedItems[0].Index; LienHeDto lienHe = this.listLienHe[rowIndex]; this.listLienHe.RemoveAt(rowIndex); this.listLienHe.Insert(0, lienHe); loadData(); }
private void btnThem_Click(object sender, EventArgs e) { if (txtNguoiLienHe.Text.Trim() != "" && txtDienThoai.Text.Trim() != "") { LienHeDto lienHe = new LienHeDto(txtNguoiLienHe.Text, txtDienThoai.Text); listLienHe.Add(lienHe); loadData(); txtNguoiLienHe.Text = ""; txtDienThoai.Text = ""; } }
public async Task <int> CreateOrUpdate(LienHeDto input) { if (input.Id > 0) { // update var updateData = await _blogRepos.GetAsync(input.Id); input.MapTo(updateData); await _blogRepos.UpdateAsync(updateData); return(1); } else { var insertData = input.MapTo <LienHe>(); int id = await _blogRepos.InsertAndGetIdAsync(insertData); return(id); } }
public List <LienHeDto> getListLienHe(String idKhachHang) { String strQuery = "SELECT ID, TEN, SDT FROM LIEN_HE WHERE ID_KHACH_HANG = @idKhachHang"; SqlCommand cmd = new SqlCommand(strQuery); cmd.CommandType = CommandType.Text; cmd.Connection = Connection.getConnection(); cmd.Parameters.AddWithValue("@idKhachHang", idKhachHang); SqlDataReader reader = cmd.ExecuteReader(); List <LienHeDto> listLienHeDto = new List <LienHeDto>(); while (reader.Read()) { LienHeDto dto = new LienHeDto(); dto.id = reader.GetInt32(0); dto.name = reader.GetString(1); dto.phone = reader.GetString(2); listLienHeDto.Add(dto); } reader.Close(); return(listLienHeDto); }
public List <LienHeDto> getListLienHeByKhachHang(String idKhachHang) { List <LienHeDto> listLienHe = new List <LienHeDto>(); String strQuery = "" + "SELECT " + " ID " + ", TEN " + ", SDT " + " FROM LIEN_HE " + " WHERE ID_KHACH_HANG = @idKhachHang"; SqlCommand cmd = new SqlCommand(strQuery); cmd.CommandType = CommandType.Text; cmd.Connection = Connection.getConnection(); cmd.Parameters.AddWithValue("@idKhachHang", idKhachHang); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { LienHeDto lienHe = new LienHeDto(); if (!reader.IsDBNull(0)) { lienHe.id = reader.GetInt32(0); } if (!reader.IsDBNull(1)) { lienHe.name = reader.GetString(1); } if (!reader.IsDBNull(2)) { lienHe.phone = reader.GetString(2); } listLienHe.Add(lienHe); } reader.Close(); return(listLienHe); }