protected void btNew_Click(object sender, EventArgs e) { StyleGuide.API api = new StyleGuide.API(); try { btSave_Click(this.btSave, null); StyleGuide.SgEntities.EntityType type = new StyleGuide.SgEntities.EntityType(); type.ID = -1; type.Type = "New "; StyleGuide.SgEntities.EntityTypes types = api.getAllEntityTypes(); if (types == null) { types = new StyleGuide.SgEntities.EntityTypes(); } types.Add(type); this.gvEntTypeList.DataSource = types; this.gvEntTypeList.DataBind(); } catch (Exception ex) { ShowErrorMessage("Error on CreateNew(). " + ex.Message); } finally { api.Dispose(); } }
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(); } }
protected void btSave_Click(object sender, EventArgs e) { StyleGuide.API api = new StyleGuide.API(); try { Int32 PgIdx = UcPaging1.CurrentPage; foreach (GridViewRow r in this.gvEntList.Rows) { string Changed = getPostedValue(r, "hfChanged"); string tbId = getPostedValue(r, "tbID"); if (Changed == "1" || tbId == "-1") { string tbName = getPostedValue(r, "tbName"); string tbSuspects = getPostedValue(r, "tbSuspects"); string tbSuggestions = getPostedValue(r, "tbSuggestions"); string ddlEntType = getPostedValue(r, "ddlEntTypes"); string tbNotes = getPostedValue(r, "tbNotes"); StyleGuide.SgEntities.Entity ent; StyleGuide.SgEntities.EntityType entType = api.getEntityTypeByID(Convert.ToInt64(ddlEntType)); if (tbId == "-1") { ent = new StyleGuide.SgEntities.Entity(); } else { ent = api.getEntityByID(Convert.ToInt64(tbId)); } if (ent != null) { ent.Name = tbName; ent.Type.ID = entType.ID; ent.Type.Type = entType.Type; ent.Notes = tbNotes; ent.Suspects = tbSuspects; ent.Suggestions = tbSuggestions; ent.LMBY = StyleGuideUI.App_Code.SgCommon.getLoggedUser(); api.SaveEntity(ent); initHandler(); ShowMessage("Entity saved"); if (tbId == "-1") { Refresh(api, UcPaging1.TotalPages); PgIdx = UcPaging1.TotalPages; } else { PgIdx = UcPaging1.CurrentPage; } } else { throw new Exception("Entity ID not found."); } } } Refresh(api, PgIdx); } catch (Exception ex) { ShowErrorMessage("Error on Save(). " + ex.Message); } finally { api.Dispose(); } }
protected void gvEntList_RowDataBound(object sender, GridViewRowEventArgs e) { bool borderleft = false; int cellIdx = 0; foreach (TableCell tc in e.Row.Cells) { if (e.Row.RowType == DataControlRowType.Header) { if (!borderleft) { if (cellIdx == 1) { tc.Attributes["style"] = "border-left:1px solid #c3cecc;border-right:1px solid #c3cecc;border-bottom:1px solid #c3cecc;display:none;"; } else { tc.Attributes["style"] = "border-left:1px solid #c3cecc;border-right:1px solid #c3cecc;border-bottom:1px solid #c3cecc;"; } borderleft = true; } else { if (cellIdx == 1) { tc.Attributes["style"] = "border-right:1px solid #c3cecc;border-bottom:1px solid #c3cecc;display:none;"; } else { tc.Attributes["style"] = "border-right:1px solid #c3cecc;border-bottom:1px solid #c3cecc;"; } } } else { if (!borderleft) { if (cellIdx == 1) { tc.Attributes["style"] = "border-left:1px solid #c3cecc;border-right:1px solid #c3cecc;display:none;"; } else { tc.Attributes["style"] = "border-left:1px solid #c3cecc;border-right:1px solid #c3cecc;"; } borderleft = true; } else { if (cellIdx == 1) { tc.Attributes["style"] = "border-right:1px solid #c3cecc;display:none;"; } else { tc.Attributes["style"] = "border-right:1px solid #c3cecc;"; } } } cellIdx++; } if (e.Row.RowType == DataControlRowType.DataRow) { DropDownList ddlEntTypes = (e.Row.FindControl("ddlEntTypes") as DropDownList); if (ddlEntTypes != null) { try { StyleGuide.API api = new StyleGuide.API(); try { ddlEntTypes.DataSource = api.getAllEntityTypes(null, true); ddlEntTypes.DataTextField = "Type"; ddlEntTypes.DataValueField = "ID"; ddlEntTypes.DataBind(); ddlEntTypes.Style.Add("-webkit-appearance", "none"); StyleGuide.SgEntities.EntityType entType = (StyleGuide.SgEntities.EntityType)DataBinder.Eval(e.Row.DataItem, "Type"); if (entType != null) { int idx = _Library._Web._Common.FindDdlItemIndex(ddlEntTypes, entType.ID.ToString(), true); ddlEntTypes.SelectedIndex = idx; } else { ddlEntTypes.Items.Insert(0, new ListItem("Please select", "")); } long entID = Convert.ToInt64(DataBinder.Eval(e.Row.DataItem, "ID")); if (entID == -1) { ImageButton btCatNew = (e.Row.FindControl("btCatNew") as ImageButton); if (btCatNew != null) { btCatNew.Visible = false; } (e.Row.FindControl("tbID") as TextBox).ForeColor = System.Drawing.Color.Red; (e.Row.FindControl("tbName") as TextBox).ForeColor = System.Drawing.Color.Red; (e.Row.FindControl("ddlEntTypes") as DropDownList).ForeColor = System.Drawing.Color.Red; (e.Row.FindControl("tbNotes") as TextBox).ForeColor = System.Drawing.Color.Red; } GridView gvEntCats = (e.Row.FindControl("gvEntCats") as GridView); RefreshEntCatGrid(api, gvEntCats, entID); } catch (Exception ex) { throw ex; } finally { api.Dispose(); } } catch (Exception) { } } } }