| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | sWhere = sWhere.Replace("'", "''"); |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | sWhere = sWhere?.Replace("'", "''") ?? ""; |
| | | if (string.IsNullOrEmpty(sWhere)) |
| | | { |
| | | ds = oCn.RunProcReturn("exec h_p_Sc_MouldLifeChangeBillList_Query " + page + "," + size + ",''", "h_p_Sc_MouldLifeChangeBillList_Query"); |
| | | } |
| | |
| | | ds = oCn.RunProcReturn("exec h_p_Sc_MouldLifeChangeBillList_Query " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldLifeChangeBillList_Query"); |
| | | } |
| | | |
| | | //添加列名 |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | // 添加空值检查 |
| | | if (ds == null || ds.Tables.Count == 0) |
| | | { |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "查询成功,但无数据!"; |
| | | objJsonResult.list = columnNameList; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | // 检查第一个表 |
| | | if (ds.Tables[0] != null) |
| | | { |
| | | //添加列名 |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString)); |
| | | } |
| | | } |
| | | |
| | | // 检查第二个表和行数据 |
| | | int totalCount = 0; |
| | | if (ds.Tables.Count > 1 && ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0) |
| | | { |
| | | var countRow = ds.Tables[1].Rows[0]["count"]; |
| | | if (countRow != null && countRow != DBNull.Value) |
| | | { |
| | | totalCount = int.Parse(countRow.ToString()); |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.count = totalCount; |
| | | objJsonResult.Message = "Success!"; |
| | | objJsonResult.list = columnNameList; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.data = ds.Tables[0] ?? new DataTable(); // 确保不为null |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |