protected void gvQuery_SortCommand(object source, Ares.Cimes.IntelliService.Web.UI.CimesSortedArgs e) { try { removeListAddandDeletRow(); gvQuery.SetDataSource(ToolTypeList); gvQuery.EditItemIndex = -1; if (GridViewSortDirection == SortDirection.Ascending) { GridViewSortDirection = SortDirection.Descending; ToolTypeList = ToolTypeList.OrderByDescending(p => p[e.CimesSortField].ToString()).ToList(); } else { GridViewSortDirection = SortDirection.Ascending; ToolTypeList = ToolTypeList.OrderBy(p => p[e.CimesSortField].ToString()).ToList(); } gvQuery.DataBind(); } catch (Exception ex) { HandleError(ex, CurrentUpdatePanel, string.Empty, MessageShowOptions.OnLabel); } }
protected void gvQuery_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { int iIndex = gvQuery.Rows[e.RowIndex].DataItemIndex; //避免新增未按下儲存就按其他資料的編輯 string SID, Tag; if (ToolTypeList[iIndex].ActiveFlag == "T") //ActiveFlag的判斷,若曾經啟用過則不可刪除 { removeListAddandDeletRow(); gvQuery.SetDataSource(ToolTypeList); gvQuery.DataBind(); throw new Exception(TextMessage.Error.T00714()); } else { // Delete Data SID = ToolTypeList[iIndex].ID; //避免若新增模式時,按下刪除的button,不作動作 if (SID.Length == 0) { return; } using (CimesTransactionScope cts = CimesTransactionScope.Create()) { if (ToolTypeList[iIndex].DeleteFromDB() == 0) { throw new Exception(TextMessage.Error.T00710("")); } AttributeAttributeInfo.DeleteByObjectSIDAndDataClass(SID, "ToolTypeAttribute", this.User.Identity.Name, DBCenter.GetSystemTime()); cts.Complete(); } _ProgramInformationBlock.ShowMessage(TextMessage.Hint.T00349(ToolTypeList[iIndex].Type)); ToolTypeList.RemoveAt(iIndex); removeListAddandDeletRow(); gvQuery.SetDataSource(ToolTypeList); gvQuery.EditItemIndex = -1; if (gvQuery.CurrentPageIndex > ((ToolTypeList.Count - 1) / gvQuery.PageSize)) { gvQuery.CurrentPageIndex = (ToolTypeList.Count - 1) / gvQuery.PageSize; } gvQuery.DataBind(); DisableSubControl(); uscAttributeSetupGrid.ClearField(); } } catch (Exception ex) { HandleError(ex, CurrentUpdatePanel, string.Empty, MessageShowOptions.OnLabel); } }
protected void removeListAddandDeletRow() { for (int j = ToolTypeList.Count - 1; j >= 0; j--) { if (ToolTypeList[j].InfoState == InfoState.Deleted || ToolTypeList[j].InfoState == InfoState.NewCreate) { ToolTypeList.RemoveAt(j); } } }
protected void btnAdd_Click(object sender, System.EventArgs e) { try { if (ToolTypeList == null) { ToolTypeList = new List <ToolTypeInfo>(); } //若第一筆資料模式仍是新增,則不再新增空白列 if (ToolTypeList.Count > 0) { if (ToolTypeList[0].InfoState == InfoState.NewCreate) { return; } } //新增一筆空白在第一列 gvQuery.CurrentPageIndex = 0; ToolTypeList.Insert(0, InfoCenter.Create <ToolTypeInfo>()); gvQuery.SetDataSource(ToolTypeList, true); gvQuery.EditItemIndex = 0; gvQuery.DataBind(); uscAttributeSetupGrid.BindData("ToolTypeAttribute", ""); //顯示系統屬性 _SystemAttribute.LoadSystemAttribute(ToolTypeList[0], "ToolDieTypeSystemAttribute"); EnableSubControl(); } catch (Exception ex) { HandleError(ex, CurrentUpdatePanel, string.Empty, MessageShowOptions.OnLabel); } }
public JsonResult Update(ToolTypeList toolType) { return(Json(toolTypeListDB.Insert(toolType), JsonRequestBehavior.AllowGet)); }