private void thânNhânToolStripMenuItem_Click(object sender, EventArgs e) { Thannhan tn = new Thannhan(); tn.Show(); this.Hide(); }
public void ThemThannhan(Thannhan tn) { StreamWriter fwrite = File.AppendText(txtfile); fwrite.WriteLine(); fwrite.WriteLine(tn.maTN + "#" + tn.TenTN + "#" + tn.Gioitinh + "#" + tn.Ngaysinh); fwrite.Close(); }
public async Task <IActionResult> Create([FromBody] Thannhan model) { if (model == null) { return(BadRequest()); } await thanNhanRepository.Create(model); return(Ok(model)); }
public void ThemThannhan(Thannhan tn) { if (!string.IsNullOrEmpty(tn.TenTN)) { //Tiến hành chuẩn hóa dữ liệu nếu cần tnn.ThemThannhan(tn); } else { throw new Exception("Du lieu sai"); } }
public async Task <IActionResult> Update(int id, [FromBody] Thannhan model) { //if (id != model.Id) //{ // return BadRequest(); //} model.Id = id; await thanNhanRepository.Update(model); return(Ok(model)); }
public void Nhap() { Console.Clear(); Console.SetCursorPosition(25, 5); Console.WriteLine("-----------------------------------------------------------------------------"); Console.SetCursorPosition(25, 6); Console.WriteLine("| Them thong tin than nhan |"); Console.SetCursorPosition(25, 7); Console.WriteLine("|----------------------------------------------------------------------------|"); Console.SetCursorPosition(25, 19); Console.WriteLine("----------------------------------------------------------------------------"); Thannhan tn = new Thannhan(); Console.SetCursorPosition(27, 8); Console.Write("Nhap ma than nhan:"); tn.maTN = Console.ReadLine(); Console.SetCursorPosition(27, 10); Console.Write("Nhap ten than nhan:"); tn.TenTN = Console.ReadLine(); Console.SetCursorPosition(27, 12); Console.Write("Nhap gioi tinh:"); tn.Gioitinh = Console.ReadLine(); TN.ThemThannhan(tn); }
public void Sua() { Console.Clear(); Console.SetCursorPosition(25, 5); Console.WriteLine("-----------------------------------------------------------------------------"); Console.SetCursorPosition(25, 6); Console.WriteLine("| Sua thong tin than nhan |"); Console.SetCursorPosition(25, 7); Console.WriteLine("|---------------------------------------------------------------------------|"); Console.SetCursorPosition(25, 20); Console.WriteLine("-----------------------------------------------------------------------------"); List <Thannhan> list = TN.GetAllThannhan(); string Tensua; Console.SetCursorPosition(27, 9); Console.Write("NHAP TEN THAN NHAN CAN SUA:"); Tensua = Console.ReadLine(); int i = 0; for (i = 0; i < list.Count; ++i) { if (list[i].TenTN == Tensua) { if (i < list.Count) { Thannhan tn = new Thannhan(list[i]); Console.SetCursorPosition(27, 17); Console.Write("Nhap ten moi :"); string ten = Console.ReadLine(); if (!string.IsNullOrEmpty(ten)) { tn.TenTN = ten; } Console.SetCursorPosition(27, 17); Console.Write("Nhap ma than nhan moi:"); string ma = Console.ReadLine(); if (!string.IsNullOrEmpty(ten)) { tn.maTN = ma; } Console.SetCursorPosition(27, 17); Console.Write("Nhap gioi tinh :"); string GT = Console.ReadLine(); if (!string.IsNullOrEmpty(GT)) { tn.Gioitinh = GT; } TN.SuaThannhan(tn); } } else { Console.SetCursorPosition(27, 17); Console.WriteLine("khong ton tai ten than nhan nay"); } } }
public void SuaThannhan(Thannhan tn) { int i; List <Thannhan> list = GetAllThannhan(); for (i = 0; i < list.Count; ++i) { if (list[i].maTN == tn.maTN) { break; } } if (i < list.Count) { list.RemoveAt(i); list.Add(tn); tnn.Update(list); } else { throw new Exception("Khong ton tai tn nay"); } }
public List <Thannhan> TimThannhan(Thannhan tn) { List <Thannhan> list = GetAllThannhan(); List <Thannhan> kq = new List <Thannhan>(); if (string.IsNullOrEmpty(tn.maTN) && string.IsNullOrEmpty(tn.TenTN)) { kq = list; } //Tim theo ten nv if (!string.IsNullOrEmpty(tn.TenTN)) { for (int i = 0; i < list.Count; ++i) { if (list[i].TenTN.IndexOf(tn.TenTN) >= 0) { kq.Add(new Thannhan(list[i])); } } } return(kq); }
public void SuaThannhanh(Thannhan tn) { throw new NotImplementedException(); }