| | |
| | | using System.Data.SqlClient; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | using Newtonsoft.Json; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | | public class Gy_WorkCenterController : ApiController |
| | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 返回工作中心列表 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// 工作中心动态列 |
| | | /// </summary> |
| | | [Route("Gy_WorkCenter/list")] |
| | | /// <param name="sWhere"></param> |
| | | /// <param name="user"></param> |
| | | /// <returns></returns> |
| | | [Route("Gy_WorkCenter/Gy_WorkCenterDyCollist")] |
| | | [HttpGet] |
| | | public object list(string sWhere,string user) |
| | | public object Gy_WorkCenterDyCollist(string sWhere,string user) |
| | | { |
| | | try |
| | | { |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | ds = oCN.RunProcReturn("select * from h_v_WorkCenterList where 1 = 1 " + sWhere + " order by 工作中心代码 ", "h_v_WorkCenterList"); |
| | | List<object> listCol = new List<object>(); |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_WorkCenterList order by 工作中心代码 ", "h_v_WorkCenterList"); |
| | | } |
| | | else |
| | | { |
| | | string sql1 = "select * from h_v_WorkCenterList where 1 = 1 "; |
| | | string sql = sql1 + sWhere+ " order by 工作中心代码 "; |
| | | ds = oCN.RunProcReturn(sql, "h_v_WorkCenterList"); |
| | | Type dataType = col.DataType; |
| | | string str = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | listCol.Add(JsonConvert.DeserializeObject(str)); |
| | | } |
| | | |
| | | //if (ds.Tables[0].Rows.Count != 0 || ds != null) |
| | | //{ |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = listCol; |
| | | return objJsonResult; |
| | | //} |
| | | //else |
| | | //{ |
| | | //objJsonResult.code = "0"; |
| | | //objJsonResult.count = 0; |
| | | //objJsonResult.Message = "无数据"; |
| | | //objJsonResult.data = null; |
| | | //return objJsonResult; |
| | | //} |
| | | } |
| | | catch (Exception e) |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 返回工作中心列表 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Gy_WorkCenter/list")] |
| | | [HttpGet] |
| | | public object list(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_WorkCenter", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_WorkCenterList where 1 = 1 " + sWhere + " order by 工作中心代码 ", "h_v_WorkCenterList"); |
| | | |
| | | //添加列名 |
| | | 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));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据基础资料ID 查找记录 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |