WebAPI/Controllers/ReportPlatFormController.cs
@@ -1,4 +1,5 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
@@ -71,6 +72,17 @@
            try
            {
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log_second("IpadIndex_Edit", 1, false, HUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "新增产线失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = oCN.RunProcReturn("select * from Gy_SourceRelationSet where HSourceID='" + HSourceID + "' and HUserName='" + HUserName + "'", "Gy_SourceRelationSet");
              
                if (ds.Tables[0].Rows.Count > 0)
@@ -165,6 +177,17 @@
        {
            try
            {
                //编辑权限
                if (!DBUtility.ClsPub.Security_Log_second("IpadIndex_Delete", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "删除产线失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                //更新切换状态值
                string sql = string.Format(@"delete Gy_SourceRelationSet  where HSourceID='" + HSourceID + "' and HUserName = '" + user + "'");
@@ -257,5 +280,159 @@
            return objJsonResult;
        }
        #endregion
        #region 报工平台按钮查询
        [Route("ReportPlatForm/getButtonlist")]
        [HttpGet]
        public object getButtonlist(string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                ds = oCN.RunProcReturn("select * from h_v_Gy_UserButton where 用户名称='" + user+ "' order by 按钮排序", "h_v_Gy_UserButton");
                //添加列名
                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;
            }
        }
        #endregion
        #region 报工平台按钮添加
        [Route("ReportPlatForm/AddButtonlist")]
        [HttpGet]
        public object AddButtonlist(string HUserName,string HButtonID, string HButtonName, string HButtonSize, string HButtonOrder)
        {
            try
            {
                ds = oCN.RunProcReturn("select * from Gy_UserButtons where HButtonID='" + HButtonID + "' and HUserName='" + HUserName + "'", "Gy_UserButtons");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "当前人员已创建改按钮,不允许重复创建!";
                    objJsonResult.data = null;
                }
                else
                {
                    oCN.BeginTran();
                    //写入按钮绑定
                    oCN.RunProc("insert into Gy_UserButtons(HUserName,HButtonID,HButtonName,HButtonSize,HButtonOrder)values('" + HUserName+"','"+HButtonID+ "','" + HButtonName + "','" + HButtonSize + "','" + HButtonOrder + "')");
                    oCN.Commit();
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    objJsonResult.data = null;
                }
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
        #region 报工平台按钮删除
        [Route("ReportPlatForm/DeleteButtonlist")]
        [HttpGet]
        public object DeleteButtonlist(int HItemID)
        {
            try
            {
                oCN.BeginTran();
                oCN.RunProc("delete from Gy_UserButtons where HItemID ='" + HItemID + "'");
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除按钮成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = e.Message.ToString();
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
        #region 报工平台按钮基础资料查询
        [Route("ReportPlatForm/GetGy_BGButtons")]
        [HttpGet]
        public object GetGy_BGButtons(string sWhere)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select HItemID 按钮id,HNumber 按钮代码,HName 按钮名称 from Gy_BGButtons", "Gy_BGButtons");
                }
                else
                {
                    string sql1 = "select HItemID 按钮id,HNumber 按钮代码,HName 按钮名称 from Gy_BGButtons where 1 = 1 ";
                    string sql = sql1 + sWhere;
                    ds = oCN.RunProcReturn(sql, "Gy_BGButtons");
                }
                //添加列名
                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;
            }
        }
        #endregion
    }
}