コード例 #1
0
 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ã  ! ");
         }
     }
 }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
ファイル: FormHDN.cs プロジェクト: MaiAnh-06/do-an-1
        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);
        }
コード例 #4
0
ファイル: DAL_HDN.cs プロジェクト: DangVanDo160397/btlc-
        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);
        }
コード例 #5
0
ファイル: DAL_HDN.cs プロジェクト: DangVanDo160397/btlc-
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 public bool Sua(HDN hdn)
 {
     return(dal_hdn.Sua(hdn));
 }
コード例 #8
0
 public bool Them(HDN hdn)
 {
     return(dal_hdn.Them(hdn));
 }