Esempio n. 1
0
        private void btnThanhToan_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtMaHD.Text != "" && cbMaKH.Text != "" && cbMaNV.Text != "" && dtpNgayLap.Text != "" && txtThanhTien.Text != "0")
                {
                    nvhd.ThemHD(txtMaHD.Text, cbMaKH.Text, cbMaNV.Text, dtpNgayLap.Text, txtThanhTien.Text, ref err);
                    for (int i = 0; i < dgvSPDC.Rows.Count - 1; i++)
                    {
                        masp      = dgvSPDC.Rows[i].Cells[0].Value.ToString();
                        tensp     = dgvSPDC.Rows[i].Cells[1].Value.ToString();
                        gia       = float.Parse(dgvSPDC.Rows[i].Cells[3].Value.ToString());
                        soluong   = (dgvSPDC.Rows[i].Cells[4].Value.ToString());
                        donvi     = dgvSPDC.Rows[i].Cells[2].Value.ToString();
                        thanhtien = float.Parse(dgvSPDC.Rows[i].Cells[5].Value.ToString());
                        nvhd.ThemHDCT(txtMaHD.Text, masp, tensp, donvi, gia, soluong, thanhtien, ref err);

                        BienToanCuc.NgapNhap = (string)nvkho.getNgayNhapKho_MaSP(masp);
                        BienToanCuc.SP1Thung = (int)nvkho.getSLSPThung_MaSP(masp);
                        BienToanCuc.Don      = (int)nvkho.getSLSPDonTrongTongSLSPSi_MaSP(masp);
                        BienToanCuc.Thung    = Convert.ToSingle(nvkho.getSLThung_MaSP(masp));
                        BienToanCuc.DVT      = (string)nvkho.getDVTL_MaSP(masp);
                        BienToanCuc.DVT2     = (string)nvkho.getDVTC_MaSP(masp);
                        if (donvi == BienToanCuc.DVT)
                        {
                            nvkho.Update(masp, tensp, BienToanCuc.NgapNhap, (BienToanCuc.Thung - int.Parse(soluong)), BienToanCuc.SP1Thung, BienToanCuc.Don - (int.Parse(soluong) * BienToanCuc.SP1Thung), ref err);
                        }
                        if (donvi == BienToanCuc.DVT2)
                        {
                            nvkho.Update(masp, tensp, BienToanCuc.NgapNhap, (((BienToanCuc.Don - (int.Parse(soluong))) * BienToanCuc.Thung) / BienToanCuc.Don), BienToanCuc.SP1Thung, BienToanCuc.Don - (int.Parse(soluong)), ref err);
                        }
                    }
                    MessageBox.Show("Thanh Toán Thành Công!!", "Thông Báo");
                    reportInHoaDon rp = new reportInHoaDon();
                    rp.Show();
                }
                else
                {
                    MessageBox.Show("Thiếu Thông Tin");
                }
            }
            catch
            {
                MessageBox.Show("Lỗi Rồi");
            }
        }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            reportInHoaDon rp = new reportInHoaDon();

            rp.Show();
        }