Beispiel #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Code > -1)
            {
                NCCPTien   nc         = cbbSupplier.SelectedItem as NCCPTien;
                PhuongTien exited     = PhuongTien.Single(Code);
                PhuongTien newVehicle = controls_Load();
                if (txtName.Text != exited.TenPT)
                {
                    if (PhuongTien.FindByTen_NCC(txtName.Text, nc.ID).Count > 0)
                    {
                        MessageBox.Show("This vehicle had been exited!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        btnAdd.Enabled = false;
                        return;
                    }
                }

                int affected = PhuongTien.Update(newVehicle);
                if (affected > 0)
                {
                    MessageBox.Show("Updating is sucessful!", "Kim Nguyễn say:", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Updating had been failse!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #2
0
        private void controls_LoadUp()
        {
            PhuongTien pt = PhuongTien.Single(Code);

            txtCode.Text              = pt.ID.ToString();
            txtName.Text              = pt.TenPT;
            txtFacitities.Text        = pt.TienNghi;
            txtMxNbr.Text             = pt.SoChoToiDa.ToString();
            txtMinNbr.Text            = pt.SoChoToiThieu.ToString();
            cbbSupplier.SelectedValue = pt.NhaCungCap;
        }