| New file |
| | |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | |
| | | namespace WebAPI.Controllers.åºç¡èµæ.åºç¡èµæ |
| | | { |
| | | public class Xt_CheckFlowBillController : ApiController |
| | | { |
| | | private json objJsonResult = new json(); |
| | | public DataSet ds = new DataSet(); |
| | | public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | |
| | | #region å®¡æ ¸æµç¨åå表 |
| | | [Route("Xt_CheckFlowBill/Xt_CheckFlowBillList")] |
| | | [HttpGet] |
| | | public object Xt_CheckFlowBillList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //æ¥è¯¢æé |
| | | if (!DBUtility.ClsPub.Security_Log_second("Xt_CheckFlow_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ æ¥çæéï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | string sql1 = string.Format(@"select * from h_v_Xt_CheckFlowList where 1=1 "); |
| | | |
| | | ds = oCN.RunProcReturn(sql1 + sWhere+ " order by æµç¨åç§°", "h_v_Xt_CheckFlowList"); |
| | | |
| | | //æ·»å åå |
| | | 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("Xt_CheckFlowBill/Xt_CheckFlowBillEdit")] |
| | | [HttpPost] |
| | | public object Xt_CheckFlowBillEdit([FromBody] JObject msg) |
| | | { |
| | | var _value = msg["msg"].ToString(); |
| | | string msg3 = _value.ToString(); |
| | | string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg1 = sArray[0].ToString(); |
| | | string msg2 = sArray[1].ToString(); |
| | | msg3 = sArray[2].ToString(); |
| | | string msg4 = sArray[3].ToString(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | |
| | | //ç¼è¾æé |
| | | if (!DBUtility.ClsPub.Security_Log_second("Xt_CheckFlow_Edit", 1, false, msg4)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ ä¿åæéï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | try |
| | | { |
| | | Models.Xt_CheckFlowMain main = JsonConvert.DeserializeObject<Xt_CheckFlowMain>(msg1); |
| | | List<Models.Xt_CheckFlowSub> lsmain = new List<Models.Xt_CheckFlowSub>(); |
| | | msg2 = msg2.Replace("\\", ""); |
| | | msg2 = msg2.Replace("\n", ""); //\n |
| | | lsmain =JsonConvert.DeserializeObject<List<Xt_CheckFlowSub>>(msg2); |
| | | foreach (Xt_CheckFlowSub oItem in lsmain) |
| | | { |
| | | if (oItem.HCheckItemID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼å®¡æ¹é¡¹ç®ä»£ç ä¸è½ä¸ºç©ºï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | if (oItem.HFlowNo == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿åå¤±è´¥ï¼æµç¨å·ä¸è½ä¸ºç©ºï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | ds = oCN.RunProcReturn("select * from h_v_Xt_CheckFlowList where Hmainid= " + main.HInterID, "h_v_Xt_CheckFlowList"); |
| | | |
| | | //ä¿å |
| | | //ä¿å宿¯åå¤ç |
| | | oCN.BeginTran(); |
| | | if (msg3 == "1" && ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert Into Xt_CheckFlowMain " + |
| | | "(HBillTypeID,HInterID,HDeptID" + |
| | | ",HRemark,HStandard,HName" + ") " + |
| | | " values('" + main.HBillTypeID.ToString() + "'," + main.HInterID.ToString() + "," + main.HDeptID.ToString() + |
| | | ",'" + main.HRemark + "'," + Convert.ToString(main.HStandard ? 1 : 0) + ",'" + main.HName.ToString() + "') "); |
| | | } |
| | | else |
| | | { |
| | | //æ´æ°ä¸»è¡¨ |
| | | oCN.RunProc("UpDate Xt_CheckFlowMain set " + |
| | | "HRemark='" + main.HRemark + "'" + |
| | | ",HName='" + main.HName + "'" + |
| | | ",HDeptID=" + main.HDeptID.ToString() + |
| | | ",HBillTypeID='" + main.HBillTypeID + "'" + |
| | | ",HStandard='" + Convert.ToString(main.HStandard ? 1 : 0) + "'" + |
| | | " where HInterID=" + main.HInterID.ToString()); |
| | | //å é¤å表 |
| | | oCN.RunProc("delete from Xt_CheckFlowSub where HInterID=" + main.HInterID.ToString()); |
| | | } |
| | | AddBillSub(lsmain, main.HInterID); |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "ä¿åæåï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼" + e.ToString(); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | public json AddBillSub(List<Xt_CheckFlowSub> DetailColl, long HInterID) |
| | | { |
| | | int i = 1; |
| | | foreach (Xt_CheckFlowSub oSub in DetailColl) |
| | | { |
| | | |
| | | oCN.RunProc("Insert into Xt_CheckFlowSub " + |
| | | " (HInterID,HEntryID,HCheckMan" + |
| | | ",HFlowNo,HJumpFlag,HMakerSelf,HCheckItemID" + |
| | | " )values(" |
| | | + HInterID + "," + i + ",'" + oSub.HCheckMan + "'" + |
| | | "," + oSub.HFlowNo + "," + Convert.ToString(oSub.HJumpFlag ? 1 : 0) + "," + Convert.ToString(oSub.HMakerSelf ? 1 : 0) + "," + oSub.HCheckItemID + ") "); |
| | | i++; |
| | | } |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region å®¡æ ¸æµç¨å å é¤ |
| | | [Route("Xt_CheckFlowBill/Xt_CheckFlowBillDelete")] |
| | | [HttpGet] |
| | | public object Xt_CheckFlowBillDelete(string HItemID, string user) |
| | | { |
| | | try |
| | | { |
| | | //å 餿é |
| | | if (!DBUtility.ClsPub.Security_Log("Xt_CheckFlow_Drop", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ å 餿é"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | if (string.IsNullOrWhiteSpace(HItemID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HItemID为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.BeginTran();//å¼å§äºå¡ |
| | | |
| | | //å é¤å表 |
| | | oCN.RunProc("Delete From Xt_CheckFlowSub where HInterID=" + HItemID); |
| | | |
| | | //å é¤ä¸»è¡¨ |
| | | oCN.RunProc("Delete From Xt_CheckFlowMain where HInterID=" + HItemID); |
| | | |
| | | oCN.Commit();//æäº¤äºå¡ |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "* æ°æ®å 餿åï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | //åæ» |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "å é¤å¤±è´¥ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 审æ¹ç¨æ·æé设置 |
| | | [Route("Xt_CheckFlowBill/Xt_CheckUserRight")] |
| | | [HttpGet] |
| | | public object Xt_CheckUserRight() |
| | | { |
| | | try |
| | | { |
| | | string sql1 = string.Format(@"select * from Gy_Czygl "); |
| | | |
| | | ds = oCN.RunProcReturn(sql1, "Gy_Czygl"); |
| | | |
| | | string TreeStr = "[{\"title\": \"审æ¹ç¨æ·æé设置\", \"id\": \"1\" ,\"spread\": \"true\",\"children\":["; |
| | | |
| | | foreach (DataRow item in ds.Tables[0].Rows) |
| | | { |
| | | TreeStr+= "{ \"title\": \"" + item["Czymc"].ToString() + "\",\"id\": \"" + item["Czybm"].ToString() + "\"},"; |
| | | } |
| | | TreeStr = TreeStr.Substring(0, TreeStr.Length - 1); |
| | | TreeStr += "]}]"; |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucessï¼"; |
| | | objJsonResult.data = JsonConvert.DeserializeObject(TreeStr); |
| | | 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_CheckFlowBill/Xt_CheckUserRightListMain")] |
| | | [HttpGet] |
| | | public object Xt_CheckUserRightListMain(string sWhere) |
| | | { |
| | | try |
| | | { |
| | | string sql1 = string.Format(@"select *,row_number()over(ORDER BY HInterID ) num from h_v_Xt_CheckUserRightMain where 1=1 "); |
| | | |
| | | ds = oCN.RunProcReturn(sql1+sWhere, "h_v_Xt_CheckUserRightMain"); |
| | | |
| | | 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_CheckFlowBill/Xt_CheckUserRightListMainSource")] |
| | | [HttpGet] |
| | | public object Xt_CheckUserRightListMainSource(string sWhere) |
| | | { |
| | | try |
| | | { |
| | | string sql1 = string.Format(@"select *,row_number()over(ORDER BY HInterID ) num from h_v_Xt_CheckUserRightSource where 1=1 "); |
| | | |
| | | ds = oCN.RunProcReturn(sql1 + sWhere, "h_v_Xt_CheckUserRightSource"); |
| | | |
| | | 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 审æ¹ç¨æ·æé设置 ä¿å |
| | | //åæ®µ |
| | | public class Xt_CheckUserRightsub |
| | | { |
| | | public int hcheckitemid; |
| | | } |
| | | [Route("Xt_CheckFlowBill/Xt_CheckUserRightEdit")] |
| | | [HttpPost] |
| | | public object Xt_CheckUserRightEdit([FromBody] JObject msg) |
| | | { |
| | | var _value = msg["msg"].ToString(); |
| | | string msg3 = _value.ToString(); |
| | | string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg1 = sArray[0].ToString(); |
| | | string msg2 = sArray[1].ToString(); |
| | | msg3 = sArray[2].ToString(); |
| | | string msg4 = sArray[3].ToString(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | |
| | | //ç¼è¾æé |
| | | if (!DBUtility.ClsPub.Security_Log_second("Xt_CheckFlow_Edit", 1, false, msg4)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ ä¿åæéï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | try |
| | | { |
| | | List<Xt_CheckUserRightsub> lsmain = new List<Xt_CheckUserRightsub>(); |
| | | msg1 = msg1.Replace("\\", ""); |
| | | msg1 = msg1.Replace("\n", ""); //\n |
| | | lsmain = JsonConvert.DeserializeObject<List<Xt_CheckUserRightsub>>(msg1); |
| | | |
| | | oCN.BeginTran(); |
| | | //å é¤åè®°å½ |
| | | oCN.RunProc("Delete From Xt_CheckUserRight where HUserID='" + msg2 + "'and HCheckFlowInterID=" + msg3 + ""); |
| | | var HCheckItemID=0; |
| | | //æ°å¢è®°å½ |
| | | for (int i = 0; i <= lsmain.Count - 1; i++) |
| | | { |
| | | if (HCheckItemID != lsmain[i].hcheckitemid) |
| | | { |
| | | oCN.RunProc("insert into Xt_CheckUserRight(HUserID,HCheckFlowInterID,HCheckItemID) values('" + msg2 + "'," + msg3 + "," + lsmain[i].hcheckitemid + ") "); |
| | | HCheckItemID = lsmain[i].hcheckitemid; |
| | | } |
| | | |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "ä¿åæåï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼" + e.ToString(); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | } |
| | | } |