示例#1
0
 protected void btSave_Click(object sender, EventArgs e)
 {
     StyleGuide.API api = new StyleGuide.API();
     try
     {
         foreach (GridViewRow r in this.gvEntTypeList.Rows)
         {
             string Changed = getPostedValue(r, "hfChanged");
             string tbId    = getPostedValue(r, "tbID");
             if (Changed == "1" || tbId == "-1")
             {
                 string tbType = getPostedValue(r, "tbType");
                 StyleGuide.SgEntities.EntityType type;
                 if (tbId == "-1")
                 {
                     type = new StyleGuide.SgEntities.EntityType();
                 }
                 else
                 {
                     type = api.getEntityTypeByID(Convert.ToInt64(tbId));
                 }
                 if (type != null)
                 {
                     type.ID   = Convert.ToInt64(tbId);
                     type.Type = tbType;
                     api.SaveEntityType(type);
                     ShowMessage("Entity Type saved");
                 }
                 else
                 {
                     throw new Exception("Entity Type ID not found.");
                 }
             }
         }
         Refresh(api);
     }
     catch (Exception ex)
     {
         ShowErrorMessage("Error on Save(). " + ex.Message);
     }
     finally
     {
         api.Dispose();
     }
 }