Esempio n. 1
0
        private void btnSaveEdit_Click(object sender, EventArgs e)
        {
            DialogResult dr;

            dr = MessageBox.Show("Bạn có muốn lưu dữ liệu không ?", "Xác nhận", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (dr == DialogResult.OK)
            {
                DataTable dt  = PHIEU_XUAT_NGUYEN_LIEU.LayThongTinPhieuXuatNL("WHERE PSO = '" + txtbPhieuSo.Text + "'");
                DataTable dt3 = PHIEU_XUAT_NGUYEN_LIEU.LayThongTinCTPhieuNhapNL("WHERE MSPXNL = '" + dt.Rows[0]["MSPXNL"].ToString() + "'");

                PHIEU_XUAT_NGUYEN_LIEU.ChinhSuaPhieuXuatNL(int.Parse(dt.Rows[0]["MSPXNL"].ToString()), int.Parse(cbbKhoXuat.SelectedValue.ToString()), int.Parse(cbbKhoNhap.SelectedValue.ToString())
                                                           , txtLiDo.Text.ToString(), dtpNgayXuat.Value.Date, int.Parse(txtTongTien.Text.ToString()), txtbPhieuSo.Text.ToString(), txtNguoiGiao.Text.ToString());
                // lưu ct_hóa đơn
                PHIEU_XUAT_NGUYEN_LIEU.XoaCTPhieuXuatNguyenLieu(int.Parse(dt.Rows[0]["MSPXNL"].ToString()));
                for (int i = 0; i < dt3.Rows.Count; i++)
                {
                    NGUYEN_LIEU.CongThemNguyenLieu(int.Parse(dt3.Rows[i]["MSNL"].ToString()), int.Parse(dt3.Rows[i]["SOLUONG"].ToString()));
                }
                for (int i = 0; i < dgvXuatNL.Rows.Count - 1; i++)
                {
                    PHIEU_XUAT_NGUYEN_LIEU.ThemCTPhieuXuatNguyenLieu(int.Parse(dt.Rows[0]["MSPXNL"].ToString()), int.Parse(dgvXuatNL.Rows[i].Cells[0].Value.ToString()),
                                                                     int.Parse(dgvXuatNL.Rows[i].Cells[5].Value.ToString()),
                                                                     int.Parse(dgvXuatNL.Rows[i].Cells[6].Value.ToString()), int.Parse(dgvXuatNL.Rows[i].Cells[7].Value.ToString()),
                                                                     dgvXuatNL.Rows[i].Cells[4].Value.ToString() + dgvXuatNL.Rows[i].Cells[3].Value.ToString());
                    NGUYEN_LIEU.TruBotNguyenLieu(int.Parse(dgvXuatNL.Rows[i].Cells[0].Value.ToString()),
                                                 int.Parse(dgvXuatNL.Rows[i].Cells[5].Value.ToString()));
                }
                MessageBox.Show("Lưu dữ liệu thành công");
                Reset();
                btnSave.Enabled = false;
            }
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DialogResult dr;

            dr = MessageBox.Show("Bạn có muốn lưu dữ liệu không ?", "Xác nhận", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (dr == DialogResult.OK)
            {
                DataTable dt   = PHIEU_NHAP_NGUYEN_LIEU.DemPhieuSo();
                int       MSPN = 1;
                if (dt.Rows.Count > 0)
                {
                    string current = dt.Rows[0]["PSO"].ToString();
                    current = current.Substring(2);
                    int cur = int.Parse(current);
                    cur  = cur + 1;
                    MSPN = cur;
                }
                PHIEU_NHAP_NGUYEN_LIEU.ThemPhieuNhapNL(MSPN, int.Parse(cbbMaKH.SelectedValue.ToString()), int.Parse(cbbMaKho.SelectedValue.ToString())
                                                       , int.Parse(txtVat1.Text.ToString()), txtHDNhap.Text.ToString(), dtpNgayPHHD.Value.Date, txtLido.Text.ToString(),
                                                       dtpNgayNhap.Value.Date, int.Parse(txtTongTien.Text.ToString()), int.Parse(txtThanhToan.Text.ToString()), txtbPhieuSo.Text.ToString());
                DataTable dt1 = PHIEU_NHAP_NGUYEN_LIEU.LayThongTinPhieuNhapNL("WHERE PSO = '" + txtbPhieuSo.Text + "'");
                // lưu ct_hóa đơn
                for (int i = 0; i < dgvNL.Rows.Count - 1; i++)
                {
                    string dvt = dgvNL.Rows[i].Cells[4].Value.ToString();
                    if (dvt == "")
                    {
                        dvt = dgvNL.Rows[i].Cells[3].Value.ToString();
                    }



                    PHIEU_NHAP_NGUYEN_LIEU.ThemCTPhieuNhapLieu(int.Parse(dt1.Rows[0]["MSPN"].ToString()), int.Parse(dgvNL.Rows[i].Cells[0].Value.ToString()),
                                                               int.Parse(dgvNL.Rows[i].Cells[5].Value.ToString()),
                                                               int.Parse(dgvNL.Rows[i].Cells[6].Value.ToString()), int.Parse(dgvNL.Rows[i].Cells[7].Value.ToString()),
                                                               dvt);
                    NGUYEN_LIEU.CongThemNguyenLieu(int.Parse(dgvNL.Rows[i].Cells[0].Value.ToString()), int.Parse(dgvNL.Rows[i].Cells[5].Value.ToString()));
                }
                MessageBox.Show("Lưu dữ liệu thành công");
                Reset();
                btnSave.Enabled = false;
            }
        }
Esempio n. 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dr;

            dr = MessageBox.Show("Bạn có muốn xóa liệu không ?", "Xác nhận", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
            if (dr == DialogResult.OK)
            {
                DataTable dt = PHIEU_XUAT_NGUYEN_LIEU.LayPhieuXuatLieuByPhieuSo("WHERE PSO = '" + txtbPhieuSo.Text + "'");
                if (int.Parse(dt.Rows[0]["count_mspn"].ToString()) > 0)
                {
                    DataTable dt2 = PHIEU_XUAT_NGUYEN_LIEU.LayThongTinPhieuXuatNL("WHERE PSO = '" + txtbPhieuSo.Text + "'");
                    DataTable dt3 = PHIEU_XUAT_NGUYEN_LIEU.LayThongTinCTPhieuNhapNL("WHERE MSPXNL = '" + dt2.Rows[0]["MSPXNL"].ToString() + "'");
                    PHIEU_XUAT_NGUYEN_LIEU.XoaCTPhieuXuatNguyenLieu(int.Parse(dt2.Rows[0]["MSPXNL"].ToString()));
                    PHIEU_XUAT_NGUYEN_LIEU.XoaPhieuXuatNguyenLieu(txtbPhieuSo.Text);
                    for (int i = 0; i < dt3.Rows.Count; i++)
                    {
                        NGUYEN_LIEU.CongThemNguyenLieu(int.Parse(dt3.Rows[i]["MSNL"].ToString()), int.Parse(dt3.Rows[i]["SOLUONG"].ToString()));
                    }
                    MessageBox.Show("Xóa dữ liệu thành công");
                    Reset();
                }
            }
        }