Ejemplo n.º 1
0
        private void btnThayDoi_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtTenPT.Text == "")
                {
                    MessageBox.Show("Tên phụ tùng không được để trống", "Thông báo", MessageBoxButtons.OK);
                    return;
                }
                if (txtDonGia.Text == "")
                {
                    MessageBox.Show("Đơn giá không được để trống", "Thông báo", MessageBoxButtons.OK);
                    return;
                }
                PhuTung phuTung = new PhuTung();
                phuTung.MaPhuTung  = txtMaVTPT.Text;
                phuTung.TenPhuTung = txtTenPT.Text;
                phuTung.DonGia     = decimal.Parse(txtDonGia.Text);

                PhuTungBLL.ThayDoiPhuTung(phuTung);
                GetDataGridView();
                MessageBox.Show("Thay đổi phụ tùng thành công", "Thông báo");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 2
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult dialog = MessageBox.Show("Bạn có muốn xóa phụ tùng này không?", "Thông báo", MessageBoxButtons.YesNo);
         if (dialog == DialogResult.Yes)
         {
             if (PhuTungBLL.XoaPhuTung(txtMaVTPT.Text))
             {
                 MessageBox.Show("Xóa phụ tùng thành công!", "Thông báo");
                 GetDataGridView();
                 txtMaVTPT.Clear();
                 txtDonGia.Clear();
                 txtSoLuong.Clear();
                 txtTenPT.Clear();
                 btnXoa.Enabled     = false;
                 btnThayDoi.Enabled = false;
             }
             else
             {
                 MessageBox.Show("Không thể xóa phụ tùng vì nó đang được sử dụng", "Thông báo");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Thông báo");
     }
 }
Ejemplo n.º 3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtTenPT.Text == "")
            {
                MessageBox.Show("Tên phụ tùng không được để trống", "Thông báo", MessageBoxButtons.OK);
                return;
            }
            if (txtDonGia.Text == "")
            {
                MessageBox.Show("Đơn giá không được để trống", "Thông báo", MessageBoxButtons.OK);
                return;
            }
            try
            {
                PhuTung phuTung = new PhuTung();
                phuTung.MaPhuTung  = txtMaVTPT.Text;
                phuTung.TenPhuTung = txtTenPT.Text;
                phuTung.SoLuong    = int.Parse(txtSoLuong.Text);
                phuTung.DonGia     = decimal.Parse(txtDonGia.Text);

                PhuTungBLL.ThemPhuTung(phuTung);
                MessageBox.Show("Thêm phụ tùng thành công!", "Thông báo", MessageBoxButtons.OK);
                GetDataGridView();
                txtMaVTPT.Text  = PhuTungBLL.MakeID();
                txtSoLuong.Text = "0";
                txtTenPT.Clear();
                txtDonGia.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Thông báo", MessageBoxButtons.OK);
            }
        }
Ejemplo n.º 4
0
        //Get list để đổ vào combo box
        private void GetListPhuTung()
        {
            DataTable dt = PhuTungBLL.ListPhuTung();

            cboPhuTung.DataSource    = dt;
            cboPhuTung.DisplayMember = "TENPT";
            cboPhuTung.ValueMember   = "MAPT";
            cboPhuTung.Text          = "";
        }
Ejemplo n.º 5
0
        void GetDataGridView()
        {
            dgvVTPT.DataSource = PhuTungBLL.ListPhuTung();
            string[] columns = { "MAPT", "TENPT", "DONGIA", "SL" };
            Utility.ControlFormat.DataGridViewFormat(dgvVTPT, columns);

            dgvVTPT.Columns[0].HeaderText = "Mã phụ tùng";
            dgvVTPT.Columns[1].HeaderText = "Tên phụ tùng";
            dgvVTPT.Columns[2].HeaderText = "Số lượng";
            dgvVTPT.Columns[3].HeaderText = "Đơn giá";
        }
Ejemplo n.º 6
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            DateTime         today   = DateTime.Now;
            string           maBCT   = BaoCaoTonBLL.GetMaBCT(today.Month, today.Year);
            string           maCTBCT = ChiTietBaoCaoTonBLL.getMaCTBCT(maBCT, cboPhuTung.Text);
            ChiTietBaoCaoTon chitiet = new ChiTietBaoCaoTon();

            chitiet.MaBCT    = maBCT;
            chitiet.MaCTBCT  = maCTBCT;
            chitiet.TenPT    = cboPhuTung.Text;
            chitiet.TonCuoi  = int.Parse(txtSL.Text);
            chitiet.PhatSinh = 0;
            chitiet.TonDau   = 0;
            ChiTietBaoCaoTonBLL.capNhatTonCuoi(chitiet);

            decimal thanhTien = decimal.Parse(txtThanhTien.Text);

            txtTongTien.Text = string.Format("{0:0,0}", decimal.Parse(tongTien.ToString()));

            string maCTPSC            = ChiTietPhieuSuaChuaBLL.AutoMACTSC();
            ChiTietPhieuSuaChua ctpsc = new ChiTietPhieuSuaChua(maCTPSC, txtMaPhieu.Text, cboPhuTung.SelectedValue.ToString(), int.Parse(txtSL.Text), cboNoiDung.Text, decimal.Parse(txtThanhTien.Text));

            int soLuongPTTon = int.Parse(PhuTungBLL.LaySoLuongPhuTung(cboPhuTung.Text));

            try
            {
                if (soLuongPTTon < int.Parse(txtSL.Text))
                {
                    MessageBox.Show("Số lượng phụ tùng trong kho không đủ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    ChiTietPhieuSuaChuaBLL.ThemCTPSC(ctpsc);
                    GetDataGridView();
                    tongTien        += thanhTien;
                    txtTongTien.Text = string.Format("{0:0,0}", decimal.Parse(tongTien.ToString()));
                    MessageBox.Show("Thêm chi tiết thành công!", "Thông báo", MessageBoxButtons.OK);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            txtDonGia.Clear();
            txtSL.Clear();
            txtThanhTien.Clear();
            txtTienCong.Clear();
            cboNoiDung.Text = "";
            cboPhuTung.Text = "";
        }
Ejemplo n.º 7
0
        private void btnNhapMoi_Click(object sender, EventArgs e)
        {
            txtTenPT.Clear();
            txtDonGia.Clear();

            txtTenPT.ReadOnly  = false;
            txtDonGia.ReadOnly = false;

            txtSoLuong.Text = "0";
            txtMaVTPT.Text  = PhuTungBLL.MakeID();

            btnThayDoi.Enabled = false;
            btnXoa.Enabled     = false;
            btnThemSL.Enabled  = false;
            btnThem.Enabled    = true;
        }
Ejemplo n.º 8
0
        private void btnThemSL_Click(object sender, EventArgs e)
        {
            int           soluong = int.Parse(txtSoLuong.Text);
            frmMuaPhuTung form    = new frmMuaPhuTung(txtSoLuong);

            form.ShowDialog();
            if (btnThayDoi.Enabled)
            {
                PhuTung phuTung = new PhuTung();
                phuTung.MaPhuTung  = txtMaVTPT.Text;
                phuTung.TenPhuTung = txtTenPT.Text;
                phuTung.SoLuong    = int.Parse(txtSoLuong.Text);

                //cap nhat phat sinh
                DateTime today = DateTime.Now;
                string   maBCT = BaoCaoTonBLL.GetMaBCT(today.Month, today.Year);

                if (maBCT == "")
                {
                    BaoCaoTon baocao = new BaoCaoTon();

                    baocao.MaBCT = BaoCaoTonBLL.AutoMABCT();
                    maBCT        = baocao.MaBCT;
                    baocao.Thang = today.Month;
                    baocao.Nam   = today.Year;
                    BaoCaoTonBLL.ThemBC(baocao);
                }

                string           maCTBCT = ChiTietBaoCaoTonBLL.getMaCTBCT(maBCT, phuTung.TenPhuTung);
                ChiTietBaoCaoTon chitiet = new ChiTietBaoCaoTon();

                chitiet.MaBCT    = maBCT;
                chitiet.MaCTBCT  = maCTBCT;
                chitiet.TenPT    = phuTung.TenPhuTung;
                chitiet.TonCuoi  = 0;
                chitiet.PhatSinh = int.Parse(txtSoLuong.Text) - soluong;
                chitiet.TonDau   = 0;
                ChiTietBaoCaoTonBLL.capNhatPhatSinh(chitiet);

                PhuTungBLL.ThayDoiSoLuongPhuTung(phuTung);
                GetDataGridView();
            }
        }
Ejemplo n.º 9
0
 private void cboPhuTung_SelectedIndexChanged(object sender, EventArgs e)
 {
     txtDonGia.Text = String.Format("{0:0,0}", PhuTungBLL.GetTienPhuTung(cboPhuTung.SelectedValue.ToString()));
 }