Ejemplo n.º 1
0
        public override void UpdateEntities(PxMetaModel.PcAxisMetabaseEntities context)
        {
            if (!IsNew)
            {
                PxMetaModel.Variable variable = (from v in context.Variables
                                                 where v.Variable1 == Variable
                                                 select v).First();
                variable.PresText = PresText;
                variable.VariableInfo = VariableInfo;
                variable.Footnote = Footnote == null ? "N" : Footnote;
                variable.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                variable.LogDate = DateTime.Now;

                PxMetaModel.Variable_Eng variableEng = (from v in context.Variable_Eng
                                                        where v.Variable == Variable
                                                        select v).First();
                variableEng.PresText = PresTextEnglish;
                variableEng.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                variableEng.LogDate = DateTime.Now;
            }

            PxMetaModel.SubTableVariable subTableVariable = (from st in context.SubTableVariables
                                                             where st.MainTable == MainTable.TableId && st.SubTable == "1" && st.Variable == Variable
                                                             select st).FirstOrDefault();
            if (subTableVariable == null)
            {
                subTableVariable = new PxMetaModel.SubTableVariable();
                subTableVariable.MainTable = MainTable.TableId;
                subTableVariable.SubTable = "1";
                subTableVariable.Variable = Variable;
                context.AddToSubTableVariables(subTableVariable);
            }

            subTableVariable.ValueSet = String.IsNullOrWhiteSpace(ValueSet) ? null : ValueSet;
            subTableVariable.VariableType = VariableType;
            subTableVariable.StoreColumnNo = StoreColumnNo;
            subTableVariable.UserID = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            subTableVariable.LogDate = DateTime.Now;

            foreach (var variableFootnote in VariableFootnotes)
            {
                variableFootnote.Variable = this;
                variableFootnote.Save(context);
            }

            foreach (var removedVariableFootnote in RemovedVariableFootnotes)
            {
                removedVariableFootnote.DeleteEntities(context);
            }
        }
Ejemplo n.º 2
0
        public override void CreateEntities(PxMetaModel.PcAxisMetabaseEntities context)
        {
            if (IsNew)
            {
                PxMetaModel.Variable variable = new PxMetaModel.Variable();
                variable.Variable1 = Variable;
                variable.PresText = PresText;
                variable.VariableInfo = VariableInfo;
                variable.Footnote = Footnote;
                variable.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                variable.LogDate = DateTime.Now;

                context.AddToVariables(variable);

                PxMetaModel.Variable_Eng variableEng = new PxMetaModel.Variable_Eng();
                variableEng.Variable1 = variable;
                variableEng.PresText = PresTextEnglish;
                variableEng.UserId = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
                variableEng.LogDate = DateTime.Now;

                context.AddToVariable_Eng(variableEng);
            }

            PxMetaModel.SubTableVariable subTableVariable = new PxMetaModel.SubTableVariable();
            subTableVariable.MainTable = MainTable.TableId;
            subTableVariable.SubTable =  "1";
            subTableVariable.Variable = Variable;
            subTableVariable.ValueSet = String.IsNullOrWhiteSpace(ValueSet)?null:ValueSet;
            subTableVariable.VariableType = VariableType;
            subTableVariable.StoreColumnNo = StoreColumnNo;
            subTableVariable.UserID = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
            subTableVariable.LogDate = DateTime.Now;

            context.AddToSubTableVariables(subTableVariable);

            foreach (var variableFootnote in VariableFootnotes)
            {
                variableFootnote.Variable = this;
                variableFootnote.Save(context);
            }
        }