예제 #1
0
        private void toolstripThem_Click(object sender, EventArgs e)
        {
            FormThemSP them = new FormThemSP();

            them.ShowDialog();
            if (them.DialogResult == DialogResult.Cancel)
            {
                load();
            }
        }
예제 #2
0
        private void toolStripSửa_Click(object sender, EventArgs e)
        {
            if (dataGridView1.CurrentRow == null)
            {
                MessageBox.Show("Bạn phải chọn một dòng để sửa");
                return;
            }
            int        malsp = Int16.Parse(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            FormThemSP them  = new FormThemSP(malsp);

            them.ShowDialog();
            if (them.DialogResult == DialogResult.Cancel)
            {
                load();
            }
        }
예제 #3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            int kieusp = Int16.Parse(cbbKieuSP.SelectedValue.ToString());
            int loaisp = Int16.Parse(cbbLoaiSP.SelectedValue.ToString());
            int sopm   = Int16.Parse(cbbSoPhieuMua.Text);

            if (txtDonGiaMua.Text == "" || txtSoLuong.Text == "")
            {
                MessageBox.Show("Bạn còn dữ liệu chưa nhập");
                return;
            }
            int masp = 0;

            if (ct.KiemTraSP(kieusp, loaisp) == -1)
            {
                DialogResult dr = MessageBox.Show("Sản phẩm này chưa được lưu trong cơ sở dữ liệu, bạn có muốn thêm sản phẩm mới không?", "Cảnh Báo", MessageBoxButtons.OKCancel);
                if (dr == DialogResult.OK)
                {
                    FormThemSP them = new FormThemSP();
                    them.ShowDialog();
                    if (them.DialogResult == DialogResult.Cancel)
                    {
                        cbbKieuSP.DataSource    = ct.LayKieuSP();
                        cbbKieuSP.DisplayMember = "TenKieuSP";
                        cbbKieuSP.ValueMember   = "MaKieuSP";
                        cbbLoaiSP.DataSource    = ct.LayLoaiSP();
                        cbbLoaiSP.DisplayMember = "TenLoaiSP";
                        cbbLoaiSP.ValueMember   = "MaLoaiSP";
                    }
                    if (ct.KiemTraSP(kieusp, loaisp) == -1)
                    {
                        return;
                    }
                    masp = ct.KiemTraSP(kieusp, loaisp);
                }
                else
                {
                    return;
                }
            }
            else
            {
                masp = ct.KiemTraSP(kieusp, loaisp);
            }
            CTPhieuMua_DTO ctpm = new CTPhieuMua_DTO();

            ctpm.SoPhieuMua = sopm;
            ctpm.MaSP       = masp;
            ctpm.SoLuong    = Int16.Parse(txtSoLuong.Text);
            ctpm.DonGia     = Int16.Parse(txtDonGiaMua.Text);
            ctpm.ThanhTien  = ctpm.DonGia * ctpm.SoLuong;
            if (ctpm.SoLuong == 0)
            {
                MessageBox.Show("Số lượng phải lớn hơn 0");
                return;
            }
            if (ctpm.DonGia == 0)
            {
                MessageBox.Show("Đơn giá phải lớn hơn 0");
                return;
            }
            ct.ThemChiTietMua(ctpm);
            MessageBox.Show("Thêm thành công");
            RefToMom.load();
        }