示例#1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            PhieuBanDTO phieuBan = new PhieuBanDTO();

            phieuBan.MaPB         = txtPhieu.Text;
            phieuBan.MaKH         = txtMaKH.Text;
            phieuBan.KhoXuat      = int.Parse(cbKhoXuat.SelectedValue.ToString());
            phieuBan.Ngay         = txtNgay.Text;
            phieuBan.NgayGiao     = txtNgayGiao.Text;
            phieuBan.HanThanhToan = txtHanThanhToan.Text;
            phieuBan.GhiChu       = txtGhiChu.Text;
            phieuBan.TongTien     = tongTien;

            PhieuBanBUS phieuBanBUS = new PhieuBanBUS();

            phieuBanBUS.LuuPhieuBan(phieuBan);

            int i = 0;

            foreach (DataGridViewRow row in dgvBanHang.Rows)
            {
                CT_PhieuBan cT_PhieuBan = new CT_PhieuBan();
                cT_PhieuBan.MaPB      = txtPhieu.Text;
                cT_PhieuBan.STT       = i;
                cT_PhieuBan.TenHang   = row.Cells["TenHang"].Value.ToString();
                cT_PhieuBan.DonVi     = 1;
                cT_PhieuBan.DonGia    = float.Parse(row.Cells["DonGia"].Value.ToString());
                cT_PhieuBan.ThanhTien = float.Parse(row.Cells["ThanhTien"].Value.ToString());

                phieuBanBUS = new PhieuBanBUS();
                phieuBanBUS.LuuCTPhieuBan(cT_PhieuBan);
            }

            MessageBox.Show("Lưu thành công");
        }
 public int LuuCTPhieuBan(CT_PhieuBan p)
 {
     return(phieuBanDAO.LuuCTPhieuNhap(p));
 }
示例#3
0
        public int LuuCTPhieuNhap(CT_PhieuBan p)
        {
            string sql = string.Format("INSERT INTO CT_PB VALUES ('{0}','{1}', '{2}', '{3}', '{4}', '{5}', '{6}')", p.MaPB, p.STT, p.TenHang, p.DonGia, p.SoLuong, p.DonGia, p.ThanhTien);

            return(dB.ExecuteNonQuery(System.Data.CommandType.Text, sql));
        }