Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the BIEN_NHAN class and populates it with data from the specified SqlDataReader.
        /// </summary>
        private BIENNHAN_DTO MakeBIENNHAN_DTO(SqlDataReader dataReader)
        {
            BIENNHAN_DTO BienNhan = new BIENNHAN_DTO();

            BienNhan.Ma            = SqlClientUtility.GetInt32(dataReader, "MA", 0);
            BienNhan.MaHoaDon      = SqlClientUtility.GetInt32(dataReader, "MA_HOA_DON", 0);
            BienNhan.NgayThanhToan = SqlClientUtility.GetDateTime(dataReader, "NGAY_THANH_TOAN", DateTime.Now);
            BienNhan.MaNhanVien    = SqlClientUtility.GetInt32(dataReader, "MA_NHAN_VIEN", 0);
            BienNhan.SoTien        = SqlClientUtility.GetDecimal(dataReader, "SO_TIEN", Decimal.Zero);

            return(BienNhan);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves a record to the BIEN_NHAN table.
        /// </summary>
        public void Insert(BIENNHAN_DTO BienNhan)
        {
            ValidationUtility.ValidateArgument("BienNhan", BienNhan);

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@MA_HOA_DON", BienNhan.MaHoaDon),
                new SqlParameter("@NGAY_THANH_TOAN", BienNhan.NgayThanhToan),
                new SqlParameter("@MA_NHAN_VIEN", BienNhan.MaNhanVien),
                new SqlParameter("@SO_TIEN", BienNhan.SoTien)
            };

            BienNhan.Ma = (int)SqlClientUtility.ExecuteScalar(m_ConnectionString, CommandType.StoredProcedure, "PROC_BienNhan_Insert", parameters);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Selects all records from the BIEN_NHAN table.
        /// </summary>
        public List <BIENNHAN_DTO> SelectAll()
        {
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_BienNhan_SelectAll"))
            {
                List <BIENNHAN_DTO> BienNhanList = new List <BIENNHAN_DTO>();
                while (dataReader.Read())
                {
                    BIENNHAN_DTO BienNhan = MakeBIENNHAN_DTO(dataReader);
                    BienNhanList.Add(BienNhan);
                }

                return(BienNhanList);
            }
        }
        private void btn_LapPhieu_Click(object sender, EventArgs e)
        {
            if (txt_BN_SoTienTra.Text != String.Empty)
            {
                BIENNHAN_DTO biennhanDto = new BIENNHAN_DTO();
                biennhanDto.MaHoaDon      = int.Parse(txt_HD_MaHoaDon.Text);
                biennhanDto.MaNhanVien    = int.Parse(txt_BN_MaNV_LapBienNhan.Text);
                biennhanDto.NgayThanhToan = DateTime.Today;
                biennhanDto.SoTien        = decimal.Parse(txt_BN_SoTienTra.Text.Trim());

                new BIENNHAN_BUS().Insert(biennhanDto);
                txt_BN_MaBienNhan.Text = biennhanDto.Ma.ToString();
                MessageBox.Show("Đã lập xong biên nhận thanh toán đợt mới cho hóa đơn " + txt_HD_MaHoaDon.Text, "", MessageBoxButtons.OK);
                btn_LapPhieu.Enabled = false;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Selects all records from the BIEN_NHAN table by a foreign key.
        /// </summary>
        public List <BIENNHAN_DTO> SelectAllByMaNhanVien(int MaNhanVien)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@MA_NHAN_VIEN", MaNhanVien)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(m_ConnectionString, CommandType.StoredProcedure, "PROC_BienNhanSelectAllByMaNhanVien", parameters))
            {
                List <BIENNHAN_DTO> BienNhanList = new List <BIENNHAN_DTO>();
                while (dataReader.Read())
                {
                    BIENNHAN_DTO BienNhan = MakeBIENNHAN_DTO(dataReader);
                    BienNhanList.Add(BienNhan);
                }

                return(BienNhanList);
            }
        }
 /// <summary>
 /// Updates a record in the BIEN_NHAN table.
 /// </summary>
 public void Update(BIENNHAN_DTO BienNhan)
 {
     ValidationUtility.ValidateArgument("BienNhan", BienNhan);
     new BIENNHAN_DAO().Update(BienNhan);
 }