Пример #1
0
        private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0 || e.RowIndex < 0)
            {
                return;
            }
            string id     = this.dataGridView.Rows[e.RowIndex].Cells["IdColumn"].Value.ToString();
            string button = this.dataGridView.Columns[e.ColumnIndex].HeaderText;

            if (button.Equals("激活"))
            {
                Vehicletype vehicleType = VehicletypeDao.Get(id);
                vehicleType.Isactive = true;

                VehicletypeDao.UpdateVehicletype(vehicleType);
            }
            else if (button.Equals("删除"))
            {
                Vehicletype vehicleType = VehicletypeDao.Get(id);
                vehicleType.Isactive = false;

                VehicletypeDao.UpdateVehicletype(vehicleType);
            }
            else
            {
                return;
            }
            this.dataGridView.DataSource = VehicletypeDao.Load();
        }
Пример #2
0
 private void id_Leave(object sender, EventArgs e)
 {
     if (Utilities.IsNullOrEmpty(this.id.Text))
     {
         this.id.Text = VehicletypeDao.GetLatestId();
     }
 }
Пример #3
0
        private void dataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            string id = this.dataGridView.Rows[e.RowIndex].Cells["IdColumn"].Value.ToString();

            vehicleType    = VehicletypeDao.Get(id);
            this.name.Text = vehicleType.Name;
            this.id.Text   = id;
        }
Пример #4
0
        public void InitComboBox()
        {
            this.vehicleType.DataSource    = VehicletypeDao.LoadAll();
            this.vehicleType.DisplayMember = "Name";
            this.vehicleType.ValueMember   = "Id";

            this.company.DataSource    = CompanyDao.LoadAll();
            this.company.DisplayMember = "Name";
            this.company.ValueMember   = "Id";
        }
Пример #5
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            if (Utilities.IsNullOrEmpty(this.id.Text) || Utilities.IsNullOrEmpty(this.name.Text))
            {
                MessageUtil.ShowWarning("控件内容不合法!");
                return;
            }
            if (vehicleType != null)
            {
                vehicleType.Name = this.name.Text;
                VehicletypeDao.UpdateVehicletype(vehicleType);
            }
            else
            {
                vehicleType          = new Vehicletype();
                vehicleType.Name     = this.name.Text;
                vehicleType.Isactive = true;

                VehicletypeDao.AddVehicletype(vehicleType);
            }
            this.dataGridView.DataSource = VehicletypeDao.Load();
            this.clear();
        }
Пример #6
0
 private void VehicleTypeForm_Load(object sender, EventArgs e)
 {
     this.dataGridView.DataSource = VehicletypeDao.Load();
 }