Example #1
0
        private void btXoaPhieu_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < gView_DSachPN.RowCount; i++)
            {
                string mapn, mas, sln;
                mapn = gView_DSachPN.GetRowCellValue(i, "Mã phiếu nhập").ToString();
                mas  = gView_DSachPN.GetRowCellValue(i, "Mã sách").ToString();
                sln  = gView_DSachPN.GetRowCellValue(i, "Số lượng nhập").ToString();
                CTPHIEUNHAP ctpn = new CTPHIEUNHAP(mapn, mas);
                ctpn.Xoa_mapn_mas();
                //PHIEUNHAP pn = new PHIEUNHAP(ctpn.MaCt);
                //pn.Xoa();
                SACH sa = new SACH(mas);
                sa.Sua_SLT(long.Parse(sln));
            }
            PHIEUNHAP pn = new PHIEUNHAP(txtMaPhieu.Text);

            pn.Xoa();
            MessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            if (cbTimTheo.Text == "All")
            {
                loadds_PN();
            }
            else
            {
                loadds_PN_TheoKhoangNgay(datiTu.Text, datiToi.Text);
            }
        }
Example #2
0
        private void btSua_Click(object sender, EventArgs e)
        {
            if (timSach_Ma(btEditMa.Text.Trim()) == true && timSach_Ten(btEditTen.Text.Trim()) == true) // nếu sách đã có
            {
                if (txtSLN.Text != "")
                {
                    CTPHIEUNHAP xoa_ctpn = new CTPHIEUNHAP(mapn, mas_old);
                    xoa_ctpn.Xoa_mapn_mas();
                    SACH xoasa = new SACH(mas_old);
                    xoasa.Sua_SLT(long.Parse(sln_old));

                    //long newSLT = long.Parse(txtSLT.Text) + long.Parse(txtSLN.Text);
                    SACH sa = new SACH(btEditMa.Text.Trim());
                    sa.Sua_PNS(long.Parse(txtSLN.Text.Trim()));
                    //string mapn = DateTime.Now.ToString("ddMMhhmmss");
                    //PHIEUNHAP pn = new PHIEUNHAP(mapn, Convert.ToDateTime(dati.Text));
                    //pn.Them();

                    CTPHIEUNHAP ctpn = new CTPHIEUNHAP(DateTime.Now.ToString("ddMMhhmmss"), mapn, btEditMa.Text.Trim(), int.Parse(txtSLN.Text.Trim()));
                    ctpn.Them();
                    // load_DSPN();
                }
                else
                {
                    MessageBox.Show("Số lượng nhập của sách chưa có !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else // nếu sách chưa có
            {
                if (txtSLN.Text != "")
                {
                    DialogResult dr = MessageBox.Show("Sách này hiện chưa có trong nhà sách, bạn có muốn thêm sách mới vào danh sách sách?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (dr != DialogResult.Yes)
                    {
                        return;
                    }
                    CTPHIEUNHAP xoa_ctpn = new CTPHIEUNHAP(mapn, mas_old);
                    xoa_ctpn.Xoa_mapn_mas();
                    SACH xoasa = new SACH(mas_old);
                    xoasa.Sua_SLT(long.Parse(sln_old));

                    // if (txtGia.Text.Trim() == "") txtGia.Text = "0";
                    SACH sa = new SACH(btEditMa.Text.Trim(), btEditTen.Text.Trim(), txtTL.Text.Trim(), txtTG.Text.Trim(), long.Parse(txtSLN.Text.Trim()), 0);
                    sa.Them();

                    CTPHIEUNHAP ctpn = new CTPHIEUNHAP(DateTime.Now.ToString("ddMMhhmmss"), mapn, btEditMa.Text, int.Parse(txtSLN.Text.Trim()));
                    ctpn.Them();
                    //load_DSPN();
                }
                else
                {
                    MessageBox.Show("Số lượng nhập của sách chưa có !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            MessageBox.Show("Cập nhật thành công", "Chúc mừng", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }
Example #3
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            CTPHIEUNHAP ctpn = new CTPHIEUNHAP(gView_DSPN.GetRowCellValue(gView_DSPN.FocusedRowHandle, "Mã phiếu nhập").ToString(), gView_DSPN.GetRowCellValue(gView_DSPN.FocusedRowHandle, "Mã sách").ToString());

            ctpn.Xoa_mapn_mas();
            //PHIEUNHAP pn = new PHIEUNHAP(ctpn.MaCt);
            //pn.Xoa();
            SACH sa = new SACH(gView_DSPN.GetRowCellValue(gView_DSPN.FocusedRowHandle, "Mã sách").ToString());

            sa.Sua_SLT(long.Parse(gView_DSPN.GetRowCellValue(gView_DSPN.FocusedRowHandle, "Số lượng nhập").ToString()));
            load_DSPN();
        }