コード例 #1
0
        private void SaveTruck()
        {
            try
            {
                var truck = new Truck
                {
                    TruckNo   = txtTruckNo.Text.Trim(),
                    Driver    = txtDriver.Text.Trim(),
                    TruckType = new TruckType
                    {
                        TruckTypeId   = (int)comboxTruckType.SelectedValue,
                        TruckTypeDesc = comboxTruckType.Text,
                    },
                    Active   = chkActive.Checked,
                    CreateBy = "system",
                };

                if (truckId == 0)
                {
                    TruckController.Insert(truck);
                }
                else
                {
                    truck.TruckId = Convert.ToInt32(txtTruckId.Text);
                    TruckController.Update(truck);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }