コード例 #1
0
ファイル: View.cs プロジェクト: NALSS/epiinfo-82474
 /// <summary>
 /// Checks and adds records metafieldtype and Metafield tables and also adds fields to datatable
 /// </summary>
 private void VerifyandUpdateViewSystemVars()
 {
     DataTable fieldSysVars = GetMetadata().GetSystemFields(this.id);
     bool FlagColumnExists = false;
     //check table for fields
     foreach (DataRow row in fieldSysVars.Rows)
     {
         if (row[ColumnNames.NAME].ToString() == ColumnNames.RECORD_FIRST_SAVE_TIME)
         {
             FlagColumnExists = true;
             return;
         }
     }
     if (FlagColumnExists == false)
     {
         GetMetadata().SynchronizeMetaFieldtypes(this);
         FirstSaveTimeField firstsavetimeField = new FirstSaveTimeField(this);
         firstsavetimeField.SaveToDb();
         LastSaveTimeField lastsavetimeField = new LastSaveTimeField(this);
         lastsavetimeField.SaveToDb();
     }
 }
コード例 #2
0
        /// <summary>
        /// Creates a view in a specified project
        /// </summary>
        /// <old-param name="isrelatedview">Whether or not this view is a related (child) view</old-param>
        /// <old-param name="viewname">Name of the view</old-param>
        public void InsertView(View view)
        {
            #region Input Validation
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            #endregion Input Validation

            try
            {
                Query insertQuery = db.CreateQuery("insert into metaViews([Name], [IsRelatedView], [CheckCode], [Width], [Height], [Orientation], [LabelAlign] ) values (@Name, @IsRelatedView, @CheckCode, @Width, @Height, @Orientation, @LabelAlign)");
                insertQuery.Parameters.Add(new QueryParameter("@Name", DbType.String, view.Name));
                insertQuery.Parameters.Add(new QueryParameter("@IsRelatedView", DbType.Boolean, view.IsRelatedView));
                insertQuery.Parameters.Add(new QueryParameter("@CheckCode", DbType.String, view.CheckCode));
                insertQuery.Parameters.Add(new QueryParameter("@Width", DbType.Int32, view.PageWidth));
                insertQuery.Parameters.Add(new QueryParameter("@Height", DbType.Int32, view.PageHeight));
                insertQuery.Parameters.Add(new QueryParameter("@Orientation", DbType.String, view.PageOrientation));
                insertQuery.Parameters.Add(new QueryParameter("@LabelAlign", DbType.String, view.PageLabelAlign));
                db.ExecuteNonQuery(insertQuery);
                view.Id = this.GetMaxViewId();

                RecStatusField recStatusField = new RecStatusField(view);
                UniqueKeyField uniqueKeyField = new UniqueKeyField(view);
                GlobalRecordIdField globalRecordIdField = new GlobalRecordIdField(view);

                //---123
                FirstSaveTimeField firstsavetimeField = new FirstSaveTimeField(view);
                firstsavetimeField.SaveToDb();
                LastSaveTimeField lastsavetimeField = new LastSaveTimeField(view);
                lastsavetimeField.SaveToDb();
                //---

                uniqueKeyField.SaveToDb();
                recStatusField.SaveToDb();
                globalRecordIdField.SaveToDb();
                if (view.IsRelatedView)
                {
                    ForeignKeyField foreignKeyField = new ForeignKeyField(view);
                    foreignKeyField.SaveToDb();
                }
            }
            catch (Exception ex)
            {
                throw new GeneralException("Could not create view in the database", ex);
            }
        }