예제 #1
0
 private void SetCTHDBanHang()
 {
     if (cthd == null)
     {
         cthd = new CTHDBanHangDTO();
     }
     cthd.MaHD    = hdBH.MaHD;
     cthd.SoLuong = Convert.ToInt32(txtSoLuong.Text);
     cthd.DonGia  = MonBUS.LayDonGiaMonAn(cthd.MaMon);
     cthd.GhiChu  = (rtbGhiChu.Text == "") ? "" : rtbGhiChu.Text;
 }
예제 #2
0
        //Cập nhật món ăn trong CTHD(SoLuong, Ghi chú)
        public static bool CapNhatMonAn(CTHDBanHangDTO cthd)
        {
            string query = "UPDATE tblCTHDBanHang SET SoLuong = @SoLuong, GhiChu = @GhiChu WHERE MaMon = @MaMon AND MaHD = @MaHD";

            SqlParameter[] pars = new SqlParameter[4];
            pars[0] = new SqlParameter("@MaHD", cthd.MaHD);
            pars[1] = new SqlParameter("@MaMon", cthd.MaMon);
            pars[2] = new SqlParameter("@SoLuong", cthd.SoLuong);
            pars[3] = new SqlParameter("@GhiChu", cthd.GhiChu);
            return(DataProvider.ExecuteUpdateQuery(query, pars) == 1);
        }
예제 #3
0
        //Thêm món ăn vào CTHDBanHang
        public static bool ThemMonAnVaoCTHD(CTHDBanHangDTO cthd)
        {
            string query = "INSERT INTO tblCTHDBanHang(MaHD, MaMon, DonGia, SoLuong, GhiChu) VALUES(@MaHD, @MaMon, @DonGia, @SoLuong, @GhiChu)";

            SqlParameter[] pars = new SqlParameter[5];
            pars[0] = new SqlParameter("@MaHD", cthd.MaHD);
            pars[1] = new SqlParameter("@MaMon", cthd.MaMon);
            pars[2] = new SqlParameter("@DonGia", cthd.DonGia);
            pars[3] = new SqlParameter("@SoLuong", cthd.SoLuong);
            pars[4] = new SqlParameter("@GhiChu", cthd.GhiChu);
            return(DataProvider.ExecuteInsertQuery(query, pars) == 1);
        }
예제 #4
0
 private void btnThanhToan_Click(object sender, EventArgs e)
 {
     if (txtMaKH.Text == "")
     {
         MessageBox.Show("Chưa nhập mã khách hàng,\r\nKhách lẻ vui lòng nhập '1'");
     }
     else
     {
         HDBanHangDTO HDBanDTO = new HDBanHangDTO();
         HDBanDTO.MaNV = Convert.ToInt32(lblMaNV.Text);
         HDBanDTO.MaKH = Convert.ToInt32(txtMaKH.Text);
         int  mahd                 = HDBanBUS.Them(HDBanDTO);
         bool isThanhCong          = true;
         List <CTHDBanHangDTO> lst = new List <CTHDBanHangDTO>();
         foreach (DataGridViewRow row in dgvCTHDBanHang.Rows)
         {
             CTHDBanHangDTO CTHDBanDTO = new CTHDBanHangDTO();
             CTHDBanDTO.MaHD      = mahd;
             CTHDBanDTO.MaSach    = Convert.ToInt32(row.Cells["colMaSach"].Value);
             CTHDBanDTO.TenSach   = row.Cells["colTenSach"].Value.ToString();
             CTHDBanDTO.SoLuong   = Convert.ToInt32(row.Cells["colSoLuong"].Value);
             CTHDBanDTO.GiaBan    = Convert.ToInt32(row.Cells["colDonGia"].Value);
             CTHDBanDTO.ThanhTien = Convert.ToInt32(row.Cells["colThanhTien"].Value);
             isThanhCong          = CTHDBanBUS.Them(CTHDBanDTO);
             if (!isThanhCong)
             {
                 break;
             }
             sachBUS.CapNhatSoLuong(CTHDBanDTO.MaSach, CTHDBanDTO.SoLuong);
             lst.Add(CTHDBanDTO);
         }
         if (isThanhCong)
         {
             MessageBox.Show("Thanh toán thành công!");
             HDBanBUS.CapNhatTongTien(mahd, Convert.ToInt32(txtTongTienSauKM.Text));
             using (frmThanhToan f = new frmThanhToan())
             {
                 f.rpvHoaDon.LocalReport.ReportEmbeddedResource = "QuanLyCuaHangSach.rptHDBanHang.rdlc";
                 f.rpvHoaDon.LocalReport.DataSources.Add(new ReportDataSource("InHDBanHang", lst));
                 f.rpvHoaDon.LocalReport.SetParameters(new ReportParameter("paTenNV", lblHoTenNV.Text, false));
                 f.ShowDialog();
             }
         }
         else
         {
             MessageBox.Show("Thanh toán không thành công");
         }
         dgvCTHDBanHang.Rows.Clear();
     }
 }
예제 #5
0
        public void getRow(CTHDBanHangDTO ctbh, string tenhh, string ghiChu)
        {
            DataGridViewRow row = (DataGridViewRow)dtgBanHang.Rows[0].Clone();

            row.Cells[1].Value = ctbh.MaHDBH;
            row.Cells[2].Value = tenhh;
            row.Cells[3].Value = ctbh.Dvt;
            row.Cells[4].Value = ctbh.Sl;
            row.Cells[5].Value = ctbh.DonGia;
            row.Cells[6].Value = ctbh.ThanhTien;
            row.Cells[7].Value = ghiChu;
            dtgBanHang.Rows.Add(row);
            kiemTraRowTrungValue();
        }
예제 #6
0
        void eventDeThemHangHoaVaoHoaDon()
        {
            CTHDBanHangDTO ctbh = new CTHDBanHangDTO();

            ctbh.MaHDBH = Convert.ToInt32(txtMahh.Text);
            string tehh = txtTenHH.Text;

            ctbh.Dvt       = lblDonvitinh.Text;
            ctbh.Sl        = Convert.ToInt32(txtSoluong.Text);
            ctbh.DonGia    = Convert.ToInt32(txtGiaban.Text);
            ctbh.ThanhTien = Convert.ToInt32(txtThanhtien.Text);
            string ghiChu = txtGhichu.Text;

            eventGetRow(ctbh, tehh, ghiChu);
        }
예제 #7
0
        public bool Them(CTHDBanHangDTO cthd)
        {
            conn.Open();
            SqlCommand com = new SqlCommand();

            com.CommandType = CommandType.StoredProcedure;
            com.CommandText = "SP_ThemCTHDBanHang";
            com.Parameters.Add("@mahd", SqlDbType.Int).Value      = cthd.MaHD;
            com.Parameters.Add("@masach", SqlDbType.Int).Value    = cthd.MaSach;
            com.Parameters.Add("@soluong", SqlDbType.Int).Value   = cthd.SoLuong;
            com.Parameters.Add("@giaban", SqlDbType.Int).Value    = cthd.GiaBan;
            com.Parameters.Add("@khuyenmai", SqlDbType.Int).Value = cthd.KhuyenMai;
            com.Parameters.Add("@thanhtien", SqlDbType.Int).Value = cthd.ThanhTien;
            com.Connection = conn;
            int kq = com.ExecuteNonQuery();

            conn.Close();
            return(kq > 0);
        }
예제 #8
0
        private void lsChonThayDoi(object sender)
        {
            AddStatus(-1);
            ListView lsvChon = (ListView)sender;

            if (lsvChon.SelectedItems.Count > 0)
            {
                ListViewItem lvi = lsvChon.SelectedItems[0];
                monChon        = new MonDTO();
                monChon.TenMon = lsvChon.SelectedItems[0].Text;
                monChon.DonGia = Convert.ToInt32(lsvChon.SelectedItems[0].SubItems[2].Text);
                cthd           = new CTHDBanHangDTO();
                cthd.MaMon     = lsvChon.SelectedItems[0].SubItems[1].Text;
            }
            else
            {
                monChon = null;
            }
        }
예제 #9
0
 private void dgvCTHDThanhToan_SelectionChanged(object sender, EventArgs e)
 {
     AddStatus(1);
     if (dgvCTHDThanhToan.SelectedRows.Count > 0)
     {
         DataRowView drv = (DataRowView)dgvCTHDThanhToan.SelectedRows[0].DataBoundItem;
         cthd         = new CTHDBanHangDTO();
         cthd.MaHD    = Convert.ToInt32(drv[0]);
         cthd.MaMon   = drv[1].ToString();
         cthd.DonGia  = Convert.ToInt32(drv[2]);
         cthd.SoLuong = Convert.ToInt32(drv[3]);
         cthd.GhiChu  = drv[4].ToString();
     }
     else
     {
         cthd = null;
     }
     DuaThongTinVaoCTHD();
 }
예제 #10
0
        private void btnThanhtoan_Click(object sender, EventArgs e)
        {
            mangCTHD = new ArrayList();
            for (int i = 0; i < dtgBanHang.Rows.Count - 1; i++)
            {
                CTHDBanHangDTO cTHDBan = new CTHDBanHangDTO();
                cTHDBan.SanPham = Convert.ToInt32(dtgBanHang.Rows[i].Cells[1].Value.ToString());
                cTHDBan.Sl      = Convert.ToInt32(dtgBanHang.Rows[i].Cells[4].Value.ToString());
                cTHDBan.DonGia  = Convert.ToDecimal(dtgBanHang.Rows[i].Cells[5].Value.ToString());

                mangCTHD.Add(cTHDBan);
            }


            cbTenkh.ValueMember = "MaKH";
            string    maKH     = cbTenkh.SelectedValue.ToString();
            string    tenKH    = cbTenkh.Text;
            string    tienHang = lblTongcong.Text;
            string    noCuKH   = lblNocukh.Text;
            ThanhToan tt       = new ThanhToan(tenKH, tienHang, noCuKH, maKH, mangCTHD);

            tt.eventLuu += thanhToan;
            tt.ShowDialog();
        }
예제 #11
0
 //Cập nhật món ăn trong CTHD(SoLuong, Ghi chú)
 public static bool CapNhatMonAn(CTHDBanHangDTO cthd)
 {
     return(CTHDBanHangDAO.CapNhatMonAn(cthd));
 }
예제 #12
0
 //Thêm món ăn vào CTHDBanHang
 public static bool ThemMonAnVaoCTHD(CTHDBanHangDTO cthd)
 {
     return(CTHDBanHangDAO.ThemMonAnVaoCTHD(cthd));
 }
예제 #13
0
 public bool Them(CTHDBanHangDTO cthd)
 {
     return(cthdDAO.Them(cthd));
 }