New file |
| | |
| | | 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 Gy_ConkReasonBillController : ApiController |
| | | { |
| | | public DBUtility.ClsPub.Enum_BillStatus BillStatus;//åæ®ç¶æï¼æ°å¢ï¼ä¿®æ¹ï¼æµè§ï¼æ´æ°åä»·ï¼åæ´ï¼ |
| | | private json objJsonResult = new json(); |
| | | public DataSet ds = new DataSet(); |
| | | public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | public Model.ClsGy_ConkReason_Model BillNew0 = new Model.ClsGy_ConkReason_Model(); |
| | | |
| | | |
| | | #region æ
éåå å表 |
| | | [Route("Gy_ConkReasonBill/Get_ConkReasonBillList")] |
| | | [HttpGet] |
| | | public object Get_ConkReasonBillList(string sWhere) |
| | | { |
| | | try |
| | | { |
| | | ds = Sc_GetConkReasonBill(sWhere); |
| | | if (ds == null) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¥è¯¢æ°æ®å¼å¸¸ï¼è¯·ä¸ç®¡çåèç³»ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "è¿åè®°å½æåï¼"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¥è¯¢æ°æ®å¼å¸¸ï¼è¯·ä¸ç®¡çåèç³»ï¼" + ex.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | public static DataSet Sc_GetConkReasonBill(string sWhere) |
| | | { |
| | | string sql1 = string.Format(@"select * from h_v_Gy_ConkReasonList"); |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | return new SQLHelper.ClsCN().RunProcReturn(sql1 + sWhere + " order by hitemid desc", "h_v_Gy_ConkReasonList"); |
| | | } |
| | | else |
| | | { |
| | | string sql = sql1 + sWhere + "order by hitemid desc"; |
| | | return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Gy_ConkReasonList"); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region [æ
éåå å é¤åè½] |
| | | [Route("Gy_ConkReasonBill/set_DeleteBill")] |
| | | [HttpGet] |
| | | public object set_DeleteBill(string HItemID) |
| | | { |
| | | Int64 lngBillKey = 0; |
| | | lngBillKey = DBUtility.ClsPub.isLong(HItemID); |
| | | if (lngBillKey == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®ID为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | ds = oCn.RunProcReturn("select * from Gy_ConkReason where HItemID=" + lngBillKey, "Gy_ConkReason"); |
| | | if (ds != null) |
| | | { |
| | | oCn.RunProc("Delete from Gy_ConkReason where HItemID=" + lngBillKey); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å 餿åï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¤åæ®ä¸åå¨ï¼è¯·æ¥çæ¯å¦éå¤å é¤"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region [ç¼è¾æ¾ç¤ºè¡¨å¤´] |
| | | [Route("Gy_ConkReasonBill/GetConkReasonByID")] |
| | | [HttpGet] |
| | | public object GetConkReasonByID(string HID) |
| | | { |
| | | Int64 lngBillKey = 0; |
| | | lngBillKey = DBUtility.ClsPub.isLong(HID); |
| | | if (lngBillKey == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®ID为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | ds = oCn.RunProcReturn("select * from Gy_ConkReason where HItemID=" + lngBillKey, "Gy_ConkReason"); |
| | | if (ds != null) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = ""; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ¤åæ®ä¸åå¨"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ä¿åæ
éåå |
| | | [Route("Gy_ConkReasonBill/SaveGy_ConkReason")] |
| | | [HttpPost] |
| | | public object SaveGy_ConkReason([FromBody] JObject msg) |
| | | { |
| | | var _value = msg["msg"].ToString(); |
| | | string msg2 = _value.ToString(); |
| | | string[] sArray = msg2.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg1 = sArray[0].ToString(); |
| | | string msg3 = sArray[1].ToString();//å½å人 |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | ListModels oListModels = new ListModels(); |
| | | try |
| | | { |
| | | Model.ClsGy_ConkReason_Model oBill = new Model.ClsGy_ConkReason_Model(); |
| | | List<Model.ClsGy_ConkReason_Model> lsmain = new List<Model.ClsGy_ConkReason_Model>(); |
| | | msg1 = msg1.Replace("\\", ""); |
| | | msg1 = msg1.Replace("\n", ""); //\n |
| | | lsmain = oListModels.getObjectByJson_Gy_ConkReason(msg1); |
| | | foreach (Model.ClsGy_ConkReason_Model oItem in lsmain) |
| | | { |
| | | if (oItem.HNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼ä»£ç ä¸è½ä¸ºç©ºï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | if (oItem.HName.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼åç§°ä¸è½ä¸ºç©ºï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //å¾å°ç代ç |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim()); |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼ç代ç 为空ï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | oItem.HShortNumber = sShortNumber;//ç代ç |
| | | oItem.HEndFlag = true;//æ«çº§æ å¿ |
| | | oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //ç级 |
| | | oBill = oItem; |
| | | } |
| | | |
| | | //ä¿å |
| | | //ä¿å宿¯åå¤ç |
| | | if (oBill.HItemID == 0) |
| | | { |
| | | oCn.RunProc("Insert into Gy_ConkReason " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HUseFlag,HMakeTime,HMakeEmp,HExplanation,HConkTypeID) " + |
| | | " Values('" + oBill.HNumber + "','" + oBill.HName + "','" + oBill.HHelpCode + "','" + oBill.HShortNumber + "'," + oBill.HParentID.ToString() + |
| | | "," + oBill.HLevel.ToString() + "," + Convert.ToString(oBill.HEndFlag ? 1 : 0) + "," + Convert.ToString(oBill.HStopflag ? 1 : 0) + ",'" + oBill.HRemark + |
| | | "','" + oBill.HUseFlag + "',getdate(),'" + msg3 + "','" + oBill.HExplanation + "',0" + |
| | | ")", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | //ä¿®æ¹ä¸çº§ä¸ºéæ«çº§ä»£ç |
| | | oCn.RunProc("Update Gy_ConkReason set HEndflag=0 where HItemID=" + oBill.HParentID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "ä¿åæåï¼"; |
| | | //WebAPIController.Add_Log("éè´§å䏿¨", UserName, "çæéè´§å"); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("UpDate Gy_ConkReason set " + |
| | | " HNumber='" + oBill.HNumber + "'" + //åºå®èµå¼=============== |
| | | ",HName='" + oBill.HName + "'" + |
| | | ",HShortNumber='" + oBill.HShortNumber + "'" + |
| | | ",HHelpCode='" + oBill.HHelpCode + "'" + |
| | | ",HUseFlag='" + oBill.HUseFlag + "'" + |
| | | ",HRemark='" + oBill.HRemark + "'" + |
| | | ",HExplanation='" + oBill.HExplanation + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HModifyEmp='" + msg3 + "'" + |
| | | ",HStopflag=" + Convert.ToString(oBill.HStopflag ? 1 : 0) + |
| | | " where HInterID=" + oBill.HItemID.ToString()); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "ä¿®æ¹æåï¼"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼" + e.ToString(); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | } |