예제 #1
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(maCTPSC))
     {
         MessageBox.Show("Không có chi tiết phiếu sửa chữa để xóa", "Thông báo", MessageBoxButtons.OK);
     }
     else
     {
         DialogResult dialog = MessageBox.Show("Bạn có muốn xóa chi tiết này không?", "Thông báo", MessageBoxButtons.YesNo);
         if (dialog == DialogResult.Yes)
         {
             try
             {
                 ChiTietPhieuSuaChuaBLL.XoaCTPSC(maCTPSC);
                 MessageBox.Show("Xóa chi tiết thành công!", "Thông báo");
                 tongTien        -= thanhTien;
                 txtTongTien.Text = tongTien.ToString();
                 thanhTien        = 0;
                 maCTPSC          = null;
                 GetDataGridView();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
예제 #2
0
 private void GetDataGridView()
 {
     dgvCTPSC.DataSource = ChiTietPhieuSuaChuaBLL.GetList(txtMaPhieu.Text);
     string[] columns = { "MaPhuTung", "SoLuong", "NoiDung", "ThanhTien" };
     Utility.ControlFormat.DataGridViewFormat(dgvCTPSC, columns);
     dgvCTPSC.Columns[2].HeaderText = "Mã phụ tùng";
     dgvCTPSC.Columns[3].HeaderText = "Số lượng";
     dgvCTPSC.Columns[4].HeaderText = "Thành tiền";
     dgvCTPSC.Columns[5].HeaderText = "Đơn giá";
 }
예제 #3
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 = "";
        }