public bool UpdateSysConfig(string modulecode, string controlcode, Bse_CheckValue val) { Sys_Config_Fieled field = cfInstance.GetListByWhere(string.Format("AND D_ModuleCode='{0}' AND D_Index='{1}'", modulecode, controlcode)).FirstOrDefault(); if (field != null) { field.D_Name = val.SC_Bak1; if (val.SC_Stat == "UnValid") { field.D_Hidden = "true"; } else { field.D_Hidden = "false"; } cfInstance.Update(field); if (string.IsNullOrEmpty(val.SC_Warn)) { var f1 = cfInstance.GetListByWhere(string.Format("AND D_ModuleCode='{0}' AND D_Index='{1}'", modulecode, "Data_W" + val.SC_Position)).FirstOrDefault(); f1.D_Hidden = "true"; cfInstance.Update(f1); } else { var f1 = cfInstance.GetListByWhere(string.Format("AND D_ModuleCode='{0}' AND D_Index='{1}'", modulecode, "Data_W" + val.SC_Position)).FirstOrDefault(); f1.D_Hidden = "false"; cfInstance.Update(f1); } if (string.IsNullOrEmpty(val.SC_Alarm)) { var f1 = cfInstance.GetListByWhere(string.Format("AND D_ModuleCode='{0}' AND D_Index='{1}'", modulecode, "Data_A" + val.SC_Position)).FirstOrDefault(); f1.D_Hidden = "true"; cfInstance.Update(f1); } else { var f1 = cfInstance.GetListByWhere(string.Format("AND D_ModuleCode='{0}' AND D_Index='{1}'", modulecode, "Data_A" + val.SC_Position)).FirstOrDefault(); f1.D_Hidden = "false"; cfInstance.Update(f1); } return(true); } return(false); }
public static Sys_Config_ListPage GetListConfig(string moduleName, out Sys_Config_ListPage M_Model, out List <Sys_Config_Fieled> D_List) { ADOSys_Config_ListPage ListInstance = new ADOSys_Config_ListPage(); ADOSys_Config_Fieled FieledInstance = new ADOSys_Config_Fieled(); M_Model = null; D_List = null; try { if (!string.IsNullOrEmpty(moduleName)) { //第一步:根据传入模块获取Grid配置 List <Sys_Config_ListPage> _ListPage = ListInstance.GetListByWhere(" AND M_ModuleCode='" + moduleName + "'"); if (_ListPage.Count > 0) { M_Model = _ListPage[0]; } //第二步:根据模块获取所有字段 D_List = FieledInstance.GetListByWhere(" AND D_ModuleCode='" + moduleName + "'"); } else { M_Model = null; D_List = null; } } catch (System.Exception ex) { M_Model = null; D_List = null; } return(M_Model); }
/// <summary> /// 根据条件获取List /// </summary> /// <param name='strCondition'>条件(' AND Code='11'')</param> /// <returns>list</returns> public List <Sys_Config_Fieled> GetListByCode(string strCondition) { return(instance.GetListByWhere(strCondition)); }
public static string JsonForJqgridForRpt(string Module, DataTable dt, int pageIndex, int pageSize, int totalCount) { StringBuilder jsonBuilder = new StringBuilder(); StringBuilder sumBuilder = new StringBuilder(); int total = 0; int page = totalCount / pageSize; total = totalCount > pageSize ? totalCount / pageSize : 1; if (totalCount > pageSize) { if (totalCount % pageSize > 0) { total = total + 1; } } if (totalCount == 0) { total = 0; pageIndex = 0; } jsonBuilder.Append("{\"Page\":" + pageIndex + ",\"Total\":" + total + ",\"Records\":" + totalCount + ",\"Rows\":"); #region 对时间进行格式化 Sys_Config_ListPage M_Model = new Sys_Config_ListPage(); List <Sys_Config_Fieled> listfiled = new List <Sys_Config_Fieled>(); ADOSys_Config_Fieled cfInstance = new ADOSys_Config_Fieled(); ADOSys_Config_ListPage clInstance = new ADOSys_Config_ListPage(); // GetListConfig(Module, out M_Model, out listfiled); M_Model = clInstance.GetListByWhere(string.Format(" AND M_ModuleCode='{0}'", Module)).FirstOrDefault(); listfiled = cfInstance.GetListByWhere(string.Format("AND D_ModuleCode='{0}'", Module)); DataTable newDt = dt.Clone(); //DataTable resultDt = dt.Clone(); //string json = JsonConvert.SerializeObject(dt, new DataTableConverter(), new JsonDateConverter("yyyy-MM-dd")); //for (var x = 0; x < newDt.Columns.Count; x++) //{ // var D_Index = dt.Columns[x].ColumnName; // var tmpModel = listfiled.Where(o => o.D_Index == D_Index); // if (tmpModel.Count() > 0) // { // if (tmpModel.FirstOrDefault().D_EditType == "datetime") // { // newDt.Columns[x].DataType = typeof(string); // } // else if (tmpModel.FirstOrDefault().D_EditType == "date") // { // newDt.Columns[x].DataType = typeof(string); // } // } //} var timelist = listfiled.Where(o => o.D_EditType == "datetime" || o.D_EditType == "date"); foreach (var t in timelist) { newDt.Columns[t.D_Index].DataType = typeof(string); } var D_SumList = listfiled.Where(o => !string.IsNullOrEmpty(o.D_Summary)); newDt.Rows.Clear(); for (var i = 0; i < dt.Rows.Count; i++) { DataRow newRow = newDt.NewRow(); for (var j = 0; j < dt.Columns.Count; j++) { var D_Index = dt.Columns[j].ColumnName; var tmpModel = listfiled.Where(o => o.D_Index == D_Index); var temp = timelist.FirstOrDefault(o => o.D_Index == D_Index); if (temp != null) { if (temp.D_EditType == "datetime") { newRow[D_Index] = dt.Rows[i][D_Index] != null && !string.IsNullOrEmpty(dt.Rows[i][D_Index].ToString()) ? JsonConvert.SerializeObject(DateTime.Parse(dt.Rows[i][D_Index].ToString()), new JsonDateConverter("yyyy-MM-dd HH:mm:ss")).Replace("\"", " ") : ""; } else if (temp.D_EditType == "date") { //newDt.Columns[j].DataType = typeof(string); newRow[D_Index] = dt.Rows[i][D_Index] != null && !string.IsNullOrEmpty(dt.Rows[i][D_Index].ToString()) ? JsonConvert.SerializeObject(DateTime.Parse(dt.Rows[i][D_Index].ToString()), new JsonDateConverter("yyyy-MM-dd")).Replace("\"", " ") : ""; } } else { newRow[D_Index] = dt.Rows[i][D_Index]; } // if (tmpModel.Count() > 0) // { // if (tmpModel.FirstOrDefault().D_EditType == "datetime") // { // newRow[D_Index] = dt.Rows[i][D_Index] != null && !string.IsNullOrEmpty(dt.Rows[i][D_Index].ToString()) // ? JsonConvert.SerializeObject(DateTime.Parse(dt.Rows[i][D_Index].ToString()), new JsonDateConverter("yyyy-MM-dd HH:mm:ss")).Replace("\"", " ") : ""; // } // else if (tmpModel.FirstOrDefault().D_EditType == "date") // { // //newDt.Columns[j].DataType = typeof(string); // newRow[D_Index] = dt.Rows[i][D_Index] != null && !string.IsNullOrEmpty(dt.Rows[i][D_Index].ToString()) // ? JsonConvert.SerializeObject(DateTime.Parse(dt.Rows[i][D_Index].ToString()), new JsonDateConverter("yyyy-MM-dd")).Replace("\"", " ") : ""; // } // else // { // newRow[D_Index] = dt.Rows[i][D_Index]; // } // } } newDt.Rows.Add(newRow); } #endregion if (D_SumList.Count() > 0 && newDt.Rows.Count > 0) { sumBuilder.Append(",\"UserData\":{"); StringBuilder sb = new StringBuilder(); foreach (var item in D_SumList) { if (newDt.Columns.Contains(item.D_Index)) { var val = newDt.Compute(string.Format("Sum({0})", item.D_Index), ""); //var d = decimal.Parse(val.ToString()); sb.AppendFormat("\"{0}\":{1},", item.D_Index, val); } } sumBuilder.Append(sb.ToString().TrimEnd(',')); sumBuilder.Append(" }"); } else { sumBuilder.Append(",\"UserData\":{"); StringBuilder sb = new StringBuilder(); foreach (var item in D_SumList) { //if (newDt.Columns.Contains(item.D_Index)) //{ //var val = newDt.Compute(string.Format("Sum({0})", item.D_Index), ""); //var d = decimal.Parse(val.ToString()); sb.AppendFormat("\"{0}\":{1},", item.D_Index, "0"); //} } sumBuilder.Append(sb.ToString().TrimEnd(',')); sumBuilder.Append(" }"); } jsonBuilder.Append(JsonConvert.SerializeObject(newDt, new DataTableConverter())); if (!string.IsNullOrEmpty(sumBuilder.ToString())) { jsonBuilder.Append(sumBuilder.ToString()); } jsonBuilder.Append("}"); return(jsonBuilder.ToString()); }