void GetInfo()
        {
            CheckInfo();

            if (_CarModelInfo == null)
            {
                _CarModelInfo = new TCU_CarModelInfo();

                _CarModelInfo.CarModelNo   = txtCarModelNo.Text.ToUpper();
                _CarModelInfo.FactoryCode  = txtFactoryID.Tag.ToString();
                _CarModelInfo.CarModelType = GlobalObject.GeneralFunction.GetRadioButton(plCarModelType);
            }

            _CarModelInfo.IsOff         = chbIsOff.Checked;
            _CarModelInfo.DLLName       = lbDLLName.Text;
            _CarModelInfo.DLLFileUnique = new Guid(lbDLLName.Tag.ToString());

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

            switch (type)
            {
            case CE_CarModelType.统车型:
                _DetailInfo = GetInfo_Tradition();
                break;

            case CE_CarModelType.新能源车型:
                break;

            default:
                break;
            }
        }
        void ShowInfo()
        {
            if (_CarModelInfo == null)
            {
                return;
            }

            foreach (TabPage tp in lstTabPage)
            {
                if (tp.Name == _CarModelInfo.CarModelType)
                {
                    tabControl1.TabPages.Clear();
                    tabControl1.TabPages.Add(tp);
                }
            }

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

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

            case CE_CarModelType.新能源车型:
                break;

            default:
                break;
            }

            txtCarModelNo.Text = _CarModelInfo.CarModelNo;
            txtFactoryID.Tag   = _CarModelInfo.FactoryCode;
            txtFactoryID.Text  = _ServiceTCU.GetFactoryInfo(_CarModelInfo.FactoryCode).FactoryShortName;
            chbIsOff.Checked   = _CarModelInfo.IsOff;

            if (_CarModelInfo.DLLFileUnique != null)
            {
                lbDLLName.Tag  = _CarModelInfo.DLLFileUnique;
                lbDLLName.Text = _CarModelInfo.DLLName;
            }

            GlobalObject.GeneralFunction.SetRadioButton(_CarModelInfo.CarModelType, plCarModelType);

            txtCarModelNo.Enabled  = false;
            txtFactoryID.Enabled   = false;
            plCarModelType.Enabled = false;
        }
Ejemplo n.º 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);
            }
        }