void ShowInfo_Tradition()
        {
            TCU_CarModelInfo_Tradition tradition = _ServiceTCU.GetCarModelInfo_Tradition(_CarModelInfo.CarModelNo);

            if (tradition == null)
            {
                return;
            }

            txtModelName.Text          = tradition.ModelName;
            txtCVTModel.Text           = tradition.CVTModel;
            txtEngineModel.Text        = tradition.EngineModel;
            txtEngineCC.Text           = tradition.EngineCC;
            txtUseArea.Text            = tradition.UseArea;
            txtEMSProvider.Text        = tradition.EMSProvider;
            txtTCUProvider.Text        = tradition.TCUProvider;
            txtTireSize.Text           = tradition.TireSize;
            txtQRCode_FactoryCode.Text = tradition.QRCode_FactoryCode;
            txtQRCode_PartsCode.Text   = tradition.QRCode_PartsCode;
            txtQRCode_PartsType.Text   = tradition.QRCode_PartsType;
            txtQRCode_Provider.Text    = tradition.QRCode_Provider;

            GlobalObject.GeneralFunction.SetRadioButton(tradition.Diagnostics, plDiagnostics);

            foreach (Control cl in groupBox2.Controls)
            {
                List <string> lstPropertyName = GlobalObject.GeneralFunction.GetItemPropertyName(tradition);

                foreach (string name in lstPropertyName)
                {
                    if (cl.Tag != null && cl.Tag.ToString() == name)
                    {
                        GlobalObject.GeneralFunction.SetRadioButton(GeneralFunction.GetItemValue <TCU_CarModelInfo_Tradition>(tradition, name), cl);
                    }
                }
            }
        }
        object GetInfo_Tradition()
        {
            TCU_CarModelInfo_Tradition result = new TCU_CarModelInfo_Tradition();

            CheckInfo_Tradition();

            result.CarModelNo         = txtCarModelNo.Text;
            result.ModelName          = txtModelName.Text;
            result.CVTModel           = txtCVTModel.Text;
            result.EngineModel        = txtEngineModel.Text;
            result.EngineCC           = txtEngineCC.Text;
            result.UseArea            = txtUseArea.Text;
            result.EMSProvider        = txtEMSProvider.Text;
            result.TCUProvider        = txtTCUProvider.Text;
            result.TireSize           = txtTireSize.Text;
            result.QRCode_FactoryCode = txtQRCode_FactoryCode.Text;
            result.QRCode_PartsCode   = txtQRCode_PartsCode.Text;
            result.QRCode_PartsType   = txtQRCode_PartsType.Text;
            result.QRCode_Provider    = txtQRCode_Provider.Text;
            result.Diagnostics        = GlobalObject.GeneralFunction.GetRadioButton(plDiagnostics);

            foreach (Control cl in groupBox2.Controls)
            {
                List <string> lstPropertyName = GlobalObject.GeneralFunction.GetItemPropertyName(result);

                foreach (string name in lstPropertyName)
                {
                    if (cl.Tag != null && cl.Tag.ToString() == name)
                    {
                        GlobalObject.GeneralFunction.SetValue(result, name, GlobalObject.GeneralFunction.GetRadioButton(cl));
                    }
                }
            }

            return(result);
        }
Exemple #3
0
        public void SaveCarModelInfo(TCU_CarModelInfo carModelInfo, object modelInfo)
        {
            DepotManagementDataContext ctx = CommentParameter.DepotDataContext;

            ctx.Connection.Open();
            ctx.Transaction = ctx.Connection.BeginTransaction();

            try
            {
                if (carModelInfo == null || modelInfo == null)
                {
                    throw new Exception("内容为空,无法执行保存");
                }

                var varData1 = from a in ctx.TCU_CarModelInfo
                               where a.CarModelNo == carModelInfo.CarModelNo
                               select a;

                if (varData1.Count() == 0)
                {
                    ctx.TCU_CarModelInfo.InsertOnSubmit(carModelInfo);
                }
                else if (varData1.Count() == 1)
                {
                    varData1.Single().IsOff = carModelInfo.IsOff;

                    if (varData1.Single().DLLFileUnique != null && varData1.Single().DLLFileUnique != carModelInfo.DLLFileUnique)
                    {
                        UniversalControlLibrary.FileOperationService.File_Delete((Guid)varData1.Single().DLLFileUnique,
                                                                                 GeneralFunction.StringConvertToEnum <CE_CommunicationMode>(BasicInfo.BaseSwitchInfo[(int)CE_SwitchName.文件传输方式]));
                    }

                    varData1.Single().DLLFileUnique = carModelInfo.DLLFileUnique;
                    varData1.Single().DLLName       = carModelInfo.DLLName;
                }

                ctx.SubmitChanges();

                CE_CarModelType type = GlobalObject.GeneralFunction.StringConvertToEnum <CE_CarModelType>(carModelInfo.CarModelType);

                switch (type)
                {
                case CE_CarModelType.统车型:

                    TCU_CarModelInfo_Tradition tempInfo = modelInfo as TCU_CarModelInfo_Tradition;

                    var varData = from a in ctx.TCU_CarModelInfo_Tradition
                                  where a.CarModelNo == tempInfo.CarModelNo
                                  select a;

                    if (varData.Count() == 0)
                    {
                        tempInfo.RecordDate = ServerTime.Time;

                        ctx.TCU_CarModelInfo_Tradition.InsertOnSubmit(tempInfo);
                    }
                    else if (varData.Count() == 1)
                    {
                        TCU_CarModelInfo_Tradition tempSingle = varData.Single();

                        tempSingle.ABS                = tempInfo.ABS;
                        tempSingle.Allods             = tempInfo.Allods;
                        tempSingle.CarModelNo         = tempInfo.CarModelNo;
                        tempSingle.CruiseControl      = tempInfo.CruiseControl;
                        tempSingle.CVTModel           = tempInfo.CVTModel;
                        tempSingle.Diagnostics        = tempInfo.Diagnostics;
                        tempSingle.EMSProvider        = tempInfo.EMSProvider;
                        tempSingle.EngineCC           = tempInfo.EngineCC;
                        tempSingle.EngineModel        = tempInfo.EngineModel;
                        tempSingle.EPB                = tempInfo.EPB;
                        tempSingle.ESP                = tempInfo.ESP;
                        tempSingle.HHC                = tempInfo.HHC;
                        tempSingle.ModelName          = tempInfo.ModelName;
                        tempSingle.QRCode_FactoryCode = tempInfo.QRCode_FactoryCode;
                        tempSingle.QRCode_PartsCode   = tempInfo.QRCode_PartsCode;
                        tempSingle.QRCode_PartsType   = tempInfo.QRCode_PartsType;
                        tempSingle.QRCode_Provider    = tempInfo.QRCode_Provider;
                        tempSingle.RecordDate         = ServerTime.Time;
                        tempSingle.StartAndStop       = tempInfo.StartAndStop;
                        tempSingle.TCUProvider        = tempInfo.TCUProvider;
                        tempSingle.TireSize           = tempInfo.TireSize;
                        tempSingle.UseArea            = tempInfo.UseArea;
                        tempSingle.SnowMode           = tempInfo.SnowMode;
                    }
                    else
                    {
                        throw new Exception("车型代码不唯一");
                    }

                    ctx.SubmitChanges();
                    break;

                case CE_CarModelType.新能源车型:
                    break;

                default:
                    break;
                }

                ctx.Transaction.Commit();
            }
            catch (Exception ex)
            {
                ctx.Transaction.Rollback();
                throw new Exception(ex.Message);
            }
        }