private void btnHDThem_Click(object sender, EventArgs e) { if (txtMaHDN.Text == "") { MessageBox.Show("Mã HĐN trống ! "); } else if (cbNhanVien.Text == "") { MessageBox.Show("Mã nhân viên trống !"); } else if (cbNCC.Text == "") { MessageBox.Show("Mã NCC trống !"); } else { HDN hdn = new HDN(txtMaHDN.Text, dtpNgayNhap.Value.ToString("yyyy-MM-dd"), cbNhanVien.Text, cbNCC.Text); try { if (bus_hdn.Them(hdn)) { MessageBox.Show("Thêm rồi ! "); CTHD_nhap_Load(sender, e); } else { MessageBox.Show("Trùng mã ! "); } } catch (Exception) { MessageBox.Show("Trùng mã ! "); } } }
public async Task <IActionResult> RegisterAsync([FromBody] RegisterHDN command) { try { if (ModelState.IsValid) { // insert person HDN hdn = Mapper.Map <HDN>(command); _dbContext.Hdns.Add(hdn); await _dbContext.SaveChangesAsync(); // send event HDNRegistered e = Mapper.Map <HDNRegistered>(command); await _messagePublisher.PublishMessageAsync(e.MessageType, e, ""); // return result return(CreatedAtRoute("GetByHdnId", new { memberId = hdn.HdnId }, hdn)); } return(BadRequest()); } catch (DbUpdateException) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists " + "see your system administrator."); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public void Nhap() { Console.Clear(); Console.WriteLine("NHAP THONG TIN HANG HOA"); HDN hh = new HDN(); Console.Write("Nhap ma hang hoa:"); hh.mahh = int.Parse(Console.ReadLine()); Console.Write("Nhap ten hang hoa:"); hh.tenhang = Console.ReadLine(); Console.Write("Nhap so luong nhap ve:"); hh.slnhapve = int.Parse(Console.ReadLine()); Console.Write("Nhap so luong hien co:"); hh.slhienco = int.Parse(Console.ReadLine()); hanghoa.ThemHangHoa(hh); }
public bool Sua(HDN hdn) { try { conn.Open(); cmdSua = "update HĐN set thoigian_nhap = '" + hdn.ThoiGianNhap + "', manhanvien = '" + hdn.MaNhanVien + "' , mancc = '" + hdn.MaNCC + "' where mahdn = '" + hdn.MaHDN + "' "; SqlCommand cmd = new SqlCommand(cmdSua, conn); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception) { throw; } finally { conn.Close(); } return(false); }
public bool Them(HDN hdn) { try { conn.Open(); cmdThem = "insert into HĐN values ('" + hdn.MaHDN + "','" + hdn.ThoiGianNhap + "','" + hdn.MaNhanVien + "', '" + hdn.MaNCC + "' )"; SqlCommand cmd = new SqlCommand(cmdThem, conn); if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception) { throw; } finally { conn.Close(); } return(false); }
private void btnSua_Click(object sender, EventArgs e) { if (txtMaHDN.Text == "") { MessageBox.Show("Mã HĐN trống ! "); } else if (cbMaNhanVien.Text == "") { MessageBox.Show("Mã nhân viên trống !"); } else if (cbMaNCC.Text == "") { MessageBox.Show("Mã NCC trống !"); } else { HDN hdn = new HDN(txtMaHDN.Text, dtnNgayNhap.Value.ToString("yyyy-MM-dd"), cbMaNhanVien.Text, cbMaNCC.Text); try { if (bus_hdn.Sua(hdn)) { MessageBox.Show("Sửa rồi ! "); } else { MessageBox.Show("Không có mã đó ! "); } } catch (Exception) { MessageBox.Show("Không có mã đó ! "); } } frmHDN_Load(sender, e); }
public bool Sua(HDN hdn) { return(dal_hdn.Sua(hdn)); }
public bool Them(HDN hdn) { return(dal_hdn.Them(hdn)); }