Пример #1
0
        private void bt_luu_Click(object sender, EventArgs e)
        {
            if (check_null())
            {
                ThayDoiQuyDinhDTO thaydoi = thaydoiBus.select();
                int line = data_vtpt.RowCount;
                if (line < thaydoi.SoLoaiVTPT1)
                {
                    VatTuPhuTungDTO vtpt = new VatTuPhuTungDTO();
                    vtpt.Maloaivattu  = int.Parse(tb_mavtpt.Text);
                    vtpt.Tenloaivattu = tb_tenvtpt.Text;
                    vtpt.Soluongton   = int.Parse(tb_soluongton.Text);
                    vtpt.Dongia       = int.Parse(tb_dongia.Text);

                    bool kq = vtptBus.them(vtpt);
                    if (kq == false)
                    {
                        MessageBox.Show("Thêm vật tư phụ tùng thất bại. Vui lòng kiểm tra lại dữ liệu");
                    }
                    else
                    {
                        MessageBox.Show("Thêm vật tư phụ tùng thành công");
                        this.loadData_Vao_GridView();
                    }
                    CurrencyManager myCurrencyManager = (CurrencyManager)this.BindingContext[data_vtpt.DataSource];
                    myCurrencyManager.Refresh();
                }
                else
                {
                    MessageBox.Show("Vượt quá số vtpt cho phép");
                }
            }
        }