예제 #1
0
        private void DelUpdateSo_luongMVT(string ma_mayVTxoa, double slxoa, double giabanxoa)
        {
            //Cập nhập số lượng nguyên liệu vào bảng nguyên liệu theo công thức
            //Slmoi= slg trong bảng nguyên liệu - slg đã bị xóa
            double sl    = Convert.ToDouble(ThucthiSQL.DocBang("SELECT So_luong FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" + ma_mayVTxoa + "'").Rows[0][0].ToString());
            double slmoi = sl - slxoa;
            string sql   = "UPDATE dboMay_vi_tinh SET So_luong=" + slmoi + "WHERE Ma_mayVT=N'" + ma_mayVTxoa + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
        }
예제 #2
0
        private void DelUpdateSo_luongMVT(string ma_mayVTxoa, double slxoa, double gianhapxoa)
        {
            //Cập nhập số lượng nguyên liệu vào bảng nguyên liệu theo công thức
            //Slmoi= slg trong bảng nguyên liệu - slg đã bị xóa
            double sl    = Convert.ToDouble(ThucthiSQL.DocBang("SELECT So_luong FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" + ma_mayVTxoa + "'").Rows[0][0].ToString());
            double slmoi = sl - slxoa;
            string sql   = "UPDATE dboMay_vi_tinh SET So_luong=" + slmoi + "WHERE Ma_mayVT=N'" + ma_mayVTxoa + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
            //Cập nhập lại đơn giá nhập vào bảng Máy vi tính sau khi xóa máy vi tính trong chi tiết hóa đơn nhập
            //Đơn giá nhập mới=(slg trong bảng nguyên liệu trước khi xóa * Đơn giá nhập trong bảng nguyên liệu trước khi xóa - slg của nguyên
            //liệu bị xóa * Đơn giá nhập nguyên liệu bị xóa)/Slg trong bảng nguyên liệu sau khi xóa
            double dgn = Convert.ToDouble(ThucthiSQL.DocBang("SELECT Gia_nhap FROM dboMa_vi_tinh WHERE Ma_mayVT=N'" +
                                                             ma_mayVTxoa + "'").Rows[0][0].ToString());
            double dgnmoi = (sl * dgn) - (slxoa * gianhapxoa) / slxoa;
            string sql1   = "UPDATE dboMay_vi_tinh SET Gia_nhap =" + dgnmoi + "WHERE Ma_mayVT=N'" + ma_mayVTxoa + "'";

            ThucthiSQL.CapNhatDuLieu(sql);
        }
예제 #3
0
 private void btnHuy_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn hủy hóa đơn không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         string    sql = "SELECT Ma_HDB, So_luong, Ma_mayVT FROM tblChitietHDB WHERE Ma_HDB = N'" + txtMa_HDB.Text + "'";
         DataTable tbl = ThucthiSQL.DocBang(sql);
         sql = "DELETE tblHDB WHERE Ma_HDB = N'" + txtMa_HDB.Text + "'";
         ThucthiSQL.CapNhatDuLieu(sql);
         ResetValues();
         Hienthi_Luoi();
         // cập nhật lại số lượng máy tính
         for (int i = 0; i < tbl.Rows.Count; i++)
         {
             DelUpdateSo_luongMVT(tbl.Rows[i][0].ToString(),
                                  Convert.ToDouble(tbl.Rows[0][1]),
                                  Convert.ToDouble(tbl.Rows[0][2]));
         }
         btnHuy.Enabled = false;
     }
 }
예제 #4
0
        private void Hienthi_Luoi()
        {
            string sql;

            sql = "SELECT a.Ma_HDN,b.Ma_mayVT, b.Ten_mayVT, a.So_luong,a.Thanh_tien FROM tblChitietHDB as a, dboMay_vi_tinh as b WHERE a.Ma_HDB = N'" +
                  txtMa_HDB.Text + "'AND a.Ma_mayVT=b.Ma_mayVT";
            dataGridView_HDB.DataSource            = ThucthiSQL.DocBang(sql);
            dataGridView_HDB.Columns[0].HeaderText = "Mã HDN";
            dataGridView_HDB.Columns[1].HeaderText = "Mã MVT";
            dataGridView_HDB.Columns[3].HeaderText = "Tên MVT";
            dataGridView_HDB.Columns[2].HeaderText = "Số lượng ";
            dataGridView_HDB.Columns[4].HeaderText = "Thành tiền";
            dataGridView_HDB.Columns[0].Width      = 100;
            dataGridView_HDB.Columns[1].Width      = 100;
            dataGridView_HDB.Columns[2].Width      = 100;
            dataGridView_HDB.Columns[3].Width      = 100;
            dataGridView_HDB.Columns[4].Width      = 100;
            dataGridView_HDB.AllowUserToAddRows    = false;
            dataGridView_HDB.EditMode = DataGridViewEditMode.EditProgrammatically;
        }
예제 #5
0
        private void Hienthi_Luoi()
        {
            string sql;

            sql = "SELECT Ma_HDN,Ma_mayVT,So_luong,Don_gia,Thanh_tien FROM tblChitietHBN WHERE Ma_HDN = N'" +
                  txtMa_HDN.Text + "'";
            dataGridView_HDN.DataSource            = ThucthiSQL.DocBang(sql);
            dataGridView_HDN.Columns[0].HeaderText = "Mã HDN";
            dataGridView_HDN.Columns[1].HeaderText = "Mã MVT";
            dataGridView_HDN.Columns[2].HeaderText = "Số lượng ";
            dataGridView_HDN.Columns[3].HeaderText = "Đơn giá";
            dataGridView_HDN.Columns[4].HeaderText = "Thành tiền";
            dataGridView_HDN.Columns[0].Width      = 100;
            dataGridView_HDN.Columns[1].Width      = 100;
            dataGridView_HDN.Columns[2].Width      = 100;
            dataGridView_HDN.Columns[3].Width      = 100;
            dataGridView_HDN.Columns[4].Width      = 100;
            dataGridView_HDN.AllowUserToAddRows    = false;
            dataGridView_HDN.EditMode = DataGridViewEditMode.EditProgrammatically;
        }
예제 #6
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (dtpNgayban.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập ngày nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgayban.Focus();
                return;
            }
            if (txtMa_HDB.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập Mã Hóa Đơn nhập hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMa_HDB.Focus();
                return;
            }
            if (txtMaKH.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập nhà cung cấp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaKH.Focus();
                return;
            }
            if (txtMaNV.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập Mã Nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaNV.Focus();
                return;
            }

            sql = "INSERT INTO tblHDB(Ma_HDB,MaNV,MaKH,Ngayban,Tong_tien) VALUES(N'" + txtMa_HDB.Text.Trim() + "',N'" + txtMaNV.Text + "',N'" + txtMaKH.Text + "',N'" + dtpNgayban.Value.ToShortDateString() + "'," + txtTong_tien.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            btnLuu.Enabled = false;

            // Lưu thông tin của các mặt hàng
            if (txtMa_mayVT.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã máy vi tính", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMa_mayVT.Focus();
                return;
            }


            if ((txtSo_luong.Text.Length == 0) || (txtSo_luong.Text == "0"))
            {
                MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSo_luong.Text = "";
                txtSo_luong.Focus();
                return;
            }


            sql = "SELECT Ma_mayVT FROM tblChitietHDB WHERE Ma_mayVT=N'" + txtMa_mayVT.Text +
                  "' AND Ma_HDB = N'" + txtMa_HDB.Text.Trim() + "'";
            if (ThucthiSQL.DocBang(sql).Rows.Count > 0)
            {
                MessageBox.Show("Mã hàng này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ResetValues();
                txtMa_mayVT.Focus();
                return;
            }

            sql = "INSERT INTO tblChitietHDN(Ma_HDN,Ma_mayVT,TenNL,So_luong,Don_gia,Thanh_tien) VALUES(N'" + txtMa_HDB.Text.Trim() + "','" + txtMa_mayVT.Text.ToString() + "',N'" + txtSo_luong.Text.ToString() + "'," + txtSo_luong.Text + "," + txtThanh_tien.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            Hienthi_Luoi();


            //Cập nhập số lượng mới vào bảng nguyên liệu theo công thức
            //Slg mới= Slg trong bảng dboMay_vi_tinh - Slg đang nhập trên frmChitietHDB
            double sl = Convert.ToDouble(ThucthiSQL.DocBang("SELECT So_luong FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" +
                                                            txtMa_mayVT.Text + "'").Rows[0][0].ToString());
            double slmoi = sl - Convert.ToDouble(txtSo_luong.Text);

            sql = "UPDATE dboMay_vi_tinh SET So_luong=" + slmoi + "WHERE Ma_mayVT=N'" + txtMa_mayVT.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
        }
예제 #7
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            string sql;

            if (dtpNgay_nhap.Text == "")
            {
                MessageBox.Show("Bạn phải nhập ngày nhập", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dtpNgay_nhap.Focus();
                return;
            }
            if (txtMa_HDN.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Mã Hóa Đơn nhập hàng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMa_HDN.Focus();
                return;
            }
            if (txtMaNCC.Text == "")
            {
                MessageBox.Show("Bạn phải nhập nhà cung cấp", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaNCC.Focus();
                return;
            }
            if (txtMaNV.Text == "")
            {
                MessageBox.Show("Bạn phải nhập Mã Nhân viên", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMaNV.Focus();
                return;
            }
            else
            {
                sql = "INSERT INTO tblHDN VALUES('" + txtMa_HDN.Text + "','" + dtpNgay_nhap.Text + "','" + txtMaNV.Text + "','" + txtMaNCC.Text + "'";
                if (txtTong_tien.Text != "")
                {
                    sql = sql + "," + txtTong_tien.Text.Trim();
                }
                sql = sql + ")";
                ThucthiSQL.CapNhatDuLieu(sql);
                btnLuu.Enabled = false;
            }

            sql = "INSERT INTO tblHDN(Ma_HDN, Ngay_nhap, MaNV, MaNCC, Thanh_tien) VALUES(N'" +
                  txtMa_HDN.Text + "','" + dtpNgay_nhap.Text + "','" + txtMaNV.Text + "','" + txtMaNCC.Text + "'," + txtTong_tien.Text + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            btnLuu.Enabled = false;

            // Lưu thông tin của các mặt hàng
            if (txtMa_mayVT.Text.Length == 0)
            {
                MessageBox.Show("Bạn phải nhập mã máy vi tính", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtMa_mayVT.Focus();
                return;
            }


            if ((txtSo_luong.Text.Length == 0) || (txtSo_luong.Text == "0"))
            {
                MessageBox.Show("Bạn phải nhập số lượng", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtSo_luong.Text = "";
                txtSo_luong.Focus();
                return;
            }
            if (txtDon_gia.Text.Trim().Length == 0)
            {
                MessageBox.Show("Bạn phải nhập đơn giá", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDon_gia.Text = "";
                txtDon_gia.Focus();
                return;
            }

            sql = "SELECT Ma_mayVT FROM tblChitietHBN WHERE Ma_mayVT=N'" + txtMa_mayVT.Text +
                  "' AND Ma_HDN = N'" + txtMa_HDN.Text.Trim() + "'";
            if (ThucthiSQL.DocBang(sql).Rows.Count > 0)
            {
                MessageBox.Show("Mã hàng này đã có, bạn phải nhập mã khác", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ResetValues();
                txtMa_mayVT.Focus();
                return;
            }

            sql = "INSERT INTO tblChitietHBN(Ma_HDN, Ma_mayVT, So_luong, Don_gia, Thanh_tien) VALUES(N'" +
                  txtMa_HDN.Text.Trim() + "','" + txtMa_mayVT.Text.ToString() + "','" + txtSo_luong.Text.ToString() + "'," + txtDon_gia.Text.ToString() + "," + txtThanh_tien.Text.ToString() + ")";
            ThucthiSQL.CapNhatDuLieu(sql);
            Hienthi_Luoi();



            //Cập nhập số lượng mới vào bảng máy vi tính theo công thức
            //Slg mới= Slg trong bảng dbomayvi tính + Slg đang nhập trên frmHoadonnhap
            double sl = Convert.ToDouble(ThucthiSQL.DocBang("SELECT So_luong FROM dboMay_vi_tinh WHERE Ma_mayVT=N'" +
                                                            txtMa_mayVT.Text + "'").Rows[0][0].ToString());
            double slmoi = sl + Convert.ToDouble(txtSo_luong.Text);

            sql = "UPDATE dboMay_vi_tinh SET So_luong=" + slmoi + "WHERE Ma_mayVT=N'" + txtMa_mayVT.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);

            //Cập nhập đơn giá nhập mới vào bảng nguyên liệu theo công thức
            //Đơn giá nhập mới= Đơn giá nhập * 1.1

            double dgn = Convert.ToDouble(ThucthiSQL.DocBang("SELECT Dongia FROM tblNguyenlieu WHERE MaNL = N'" +
                                                             txtMa_mayVT.Text + "'").Rows[0][0].ToString());
            double giaban = Math.Round(((1.1 * dgn) + 1.1 * Convert.ToDouble(txtDon_gia.Text)));

            sql = "UPDATE dboMay_vi_tinh SET Gia_ban =" + giaban + "WHERE Ma_mayVT = N'" + txtMa_mayVT.Text + "'";
            ThucthiSQL.CapNhatDuLieu(sql);
            ResetValues();
            btnHuy.Enabled = true;
        }