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);
            }
        }
Exemple #2
0
        private void btLapPhieu_Click(object sender, EventArgs e)
        {
            //Thread th = new Thread(new ThreadStart(showFrmPNS));
            //th.Start();
            //this.Close();
            if (btEditMa.Text == "" || dati.Text == "")
            {
                MessageBox.Show("Nhập đầy đủ thông tin phiếu nhập !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (!exist_MaPN(btEditMa.Text))
                {
                    if (exist_NgayPN(dati.Text))
                    {
                        DialogResult dr = MessageBox.Show("Ngày " + dati.Text + " đã có phiếu nhập, bạn có chắc muốn nhập thêm?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (dr != DialogResult.Yes)
                        {
                            return;
                        }
                    }

                    PHIEUNHAP pn = new PHIEUNHAP(btEditMa.Text, Convert.ToDateTime(dati.Text));
                    pn.Them();
                    fmLapPhieuNhap pns = new fmLapPhieuNhap(btEditMa.Text, dati.Text);
                    this.Hide();
                    pns.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Mã phiếu nhập đã tồn tại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemple #3
0
        public void Update_PHIEUNHAP(string sql, PHIEUNHAP pn)
        {
            DBService db = new DBService();

            db.openconn();
            SqlCommand cmd = new SqlCommand(sql, db.conn);
            //đánh dấu điểm bắt đầu
            SqlTransaction tran = db.conn.BeginTransaction("ThemLopTransaction");

            cmd.Transaction = tran;
            try
            {
                SqlParameter pa1 = new SqlParameter("@ma", pn.Ma);
                cmd.Parameters.Add(pa1);
                SqlParameter pa2 = new SqlParameter("@nn", pn.Ngaynhap);
                cmd.Parameters.Add(pa2);

                cmd.ExecuteNonQuery();
                tran.Commit();//kết thúc transaction
            }
            catch (Exception ex)
            {
                tran.Rollback();//quay lui tới thời điểm beginTran
                throw ex;
            }
            db.closeconn();
        }
        private void btCapNhat_Click(object sender, EventArgs e)
        {
            PHIEUNHAP pn = new PHIEUNHAP(txtMa.Text, Convert.ToDateTime(dati.Text));

            pn.Sua();
            MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }