Example #1
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 #2
0
        private void btThem_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 != "")
                {
                    if (int.Parse(txtSLN.Text) < nhaptt || int.Parse(txtSLT.Text) < tontruocnhap)
                    {
                        MessageBox.Show("Vi phạm điều kiện trong lưu ý!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    //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()));

                    CTPHIEUNHAP ctpn = new CTPHIEUNHAP(DateTime.Now.ToString("ddMMhhmmss"), txtMaPhieu.Text.Trim(), 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;
                    }
                    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()), float.Parse(txtGia.Text.Trim()));
                    sa.Them();

                    CTPHIEUNHAP ctpn = new CTPHIEUNHAP(DateTime.Now.ToString("ddMMhhmmss"), txtMaPhieu.Text, 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);
                }
            }
        }