using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Web.Http; using WebAPI.Models; namespace WebAPI.Controllers { public class Xt_UserController : ApiController { public DBUtility.ClsPub.Enum_BillStatus BillStatus; private json objJsonResult = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; #region[用户列表查询] [Route("Xt_User/list")] [HttpGet] public object list(string sWhere) { try { if (sWhere == null || sWhere.Equals("")) { ds = oCN.RunProcReturn("select * from h_v_IF_UserList " + sWhere, "h_v_IF_UserList"); } else { string sql1 = "select * from h_v_IF_UserList where 1 = 1 "; string sql = sql1 + sWhere; ds = oCN.RunProcReturn(sql, "h_v_IF_UserList"); } if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region [用户列表删除功能] /// /// 用户信息删除功能 /// /// [Route("Xt_User/DeltetUser")] [HttpGet] public object DeltetUser(string HCzybm) { try { //编辑权限 //if (!DBUtility.ClsPub.Security_Log("Gy_UserByUserRelation_Delete", 1, true, DBUtility.ClsPub.CurUserName)) //{ // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "无删除权限!"; // objJsonResult.data = null; // return objJsonResult; //} Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HCzybm); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "用户编码为空!"; objJsonResult.data = null; return objJsonResult; } oCN.BeginTran(); //删除用户信息 oCN.RunProc("delete from Gy_Czygl where Czybm='" + HCzybm + "'"); //删除用户对应的角色信息 oCN.RunProc("delete from System_UserGroupInfo where UserId='" + HCzybm + "'"); DBUtility.ClsPub.Add_Log(DBUtility.ClsPub.CurUserName, "删除用户:" + HCzybm, DBUtility.ClsPub.CurUserName); oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message ="删除信息成功!"; objJsonResult.data = null; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = e.Message; objJsonResult.data = null; } return objJsonResult; } #endregion } }