New file |
| | |
| | | using Model; |
| | | using Newtonsoft.Json; |
| | | 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 |
| | | { |
| | | //éè´è®¢åController |
| | | public class Cg_PORequestBillController : ApiController |
| | | { |
| | | //è·åç³»ç»åæ° |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | public DBUtility.ClsPub.Enum_BillStatus BillStatus; |
| | | public DAL.ClsCg_PORequestBill BillOld = new DAL.ClsCg_PORequestBill(); |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | |
| | | |
| | | |
| | | |
| | | #region éè´ç³è¯·åå表 æ¥è¯¢ |
| | | /// <summary> |
| | | /// è¿å项ç®é¶æ®µå表 |
| | | ///åæ°ï¼string sqlã |
| | | ///è¿åå¼ï¼objectã |
| | | /// </summary> |
| | | [Route("Cg_PORequestBill/list")] |
| | | [HttpGet] |
| | | public object getCg_PORequestBill(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Cg_PORequestBillList order by åæ®å· desc", "h_v_Cg_PORequestBillList"); |
| | | } |
| | | else |
| | | { |
| | | string sql1 = "select * from h_v_Cg_PORequestBillList where 1 = 1 "; |
| | | string sql = sql1 + sWhere + " order by åæ®å· desc"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Cg_PORequestBillList"); |
| | | } |
| | | |
| | | //æ·»å åå |
| | | 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("Cg_PORequestBill/Cg_PORequestBillEdit")] |
| | | [HttpPost] |
| | | public object Cg_PORequestBillEdit([FromBody] JObject sMainSub) |
| | | { |
| | | try |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | oCN.BeginTran(); |
| | | //ä¿å主表 |
| | | objJsonResult = AddBillMain(msg1); |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | public json AddBillMain(string msg1) |
| | | { |
| | | string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); //ä¸»è¡¨æ°æ® |
| | | string msg3 = sArray[1].ToString(); //åè¡¨æ°æ® |
| | | int OperationType = int.Parse(sArray[2].ToString()); // æ°æ®ç±»å 1æ·»å 3ä¿®æ¹ |
| | | string user = sArray[3].ToString(); |
| | | string msg_allVal = sArray[4].ToString(); //主表+åè¡¨æææ°æ® |
| | | |
| | | try |
| | | { |
| | | msg2 = "[" + msg2.ToString() + "]"; |
| | | List<ClsCg_PORequestBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsCg_PORequestBillMain>>(msg2); |
| | | |
| | | long HInterID = mainList[0].HInterID;//éå
¥typeå¾å°çåæ®ID |
| | | string HBillNo = mainList[0].HBillNo;//éå
¥typeå¾å°çåæ®å· |
| | | long HPRDORGID = mainList[0].HPRDORGID;//ç»ç» |
| | | DateTime HDate = mainList[0].HDate;//æ¥æ |
| | | string HRemark = mainList[0].HRemark;//夿³¨ |
| | | long HSupID = mainList[0].HSupID;//ç³è¯·é¨é¨ |
| | | long HEmpID = mainList[0].HEmpID;//ç³è¯·äºº |
| | | long HDeptID = mainList[0].HDeptID;//é¨é¨ |
| | | string HMaker = user;//å¶å人 |
| | | string HAddress = mainList[0].HAddress;//å°å |
| | | string HExplanation = mainList[0].HExplanation;//æè¦ |
| | | string HInnerBillNo = mainList[0].HInnerBillNo;//å
é¨åæ®å· |
| | | string HUse = mainList[0].HUse;//使ç¨ç¨é |
| | | string HLinkPhone = mainList[0].HLinkPhone;//èç³»çµè¯ |
| | | string HLinkMan = mainList[0].HLinkMan;//è系人 |
| | | |
| | | List<ClsCg_PORequestBillMain> mainList2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsCg_PORequestBillMain>>(msg2); |
| | | DateTime dt = DateTime.Now; |
| | | |
| | | long HYear = mainList2[0].HYear == null ? 0 : mainList2[0].HYear; |
| | | long HPeriod = mainList2[0].HPeriod == null ? 0 : mainList2[0].HPeriod; |
| | | string HBillType = mainList2[0].HBillType == null ? "''" : mainList2[0].HBillType; |
| | | string HBillSubType = mainList2[0].HBillSubType == null ? "''" : mainList2[0].HBillSubType; |
| | | long HBillStatus = mainList2[0].HBillStatus == null ? 0 : mainList2[0].HBillStatus; |
| | | string HMakeDate = mainList2[0].HMakeDate == null ? "''" : mainList2[0].HMakeDate; |
| | | string HChecker = mainList2[0].HChecker == null ? "''" : mainList2[0].HChecker; |
| | | string HCheckDate = mainList2[0].HCheckDate == null ? "''" : mainList2[0].HCheckDate; |
| | | string HUpDater = mainList2[0].HUpDater == null ? "''" : mainList2[0].HUpDater; |
| | | string HUpDateDate = mainList2[0].HUpDateDate == null ? "''" : mainList2[0].HUpDateDate; |
| | | string HDeleteMan = mainList2[0].HDeleteMan == null ? "''" : mainList2[0].HDeleteMan; |
| | | string HDeleteDate = mainList2[0].HDeleteDate == null ? "''" : mainList2[0].HDeleteDate; |
| | | string HCloseMan = mainList2[0].HCloseMan == null ? "''" : mainList2[0].HCloseMan; |
| | | string HCloseDate = mainList2[0].HCloseDate == null ? "''" : mainList2[0].HCloseDate; |
| | | |
| | | |
| | | |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_Cg_PORequestBillList where hmainid=" + HInterID + " and åæ®å·='" + HBillNo + "'", "h_v_Cg_PORequestBillList"); |
| | | |
| | | if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//æ°å¢ |
| | | { |
| | | DataSet Ds; |
| | | Int64 NewHInterID = 1; |
| | | Ds = oCN.RunProcReturn("select MAX(HInterID)HInterID from Cg_PORequestBillMain", "Cg_PORequestBillMain"); |
| | | if (Ds.Tables[0].Rows.Count != 0 && ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()) != 0) |
| | | { |
| | | NewHInterID = ClsPub.isLong(Ds.Tables[0].Rows[0]["HInterID"].ToString()); |
| | | NewHInterID += 1; |
| | | } |
| | | //主表 |
| | | string sql = $@"Insert Into Cg_PORequestBillMain |
| | | (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus |
| | | ,HAddress,HSupID,HEmpID,HDeptID,HExplanation,HRemark,HInnerBillNo,HUse,HLinkPhone,HLinkMan |
| | | ,HMaker,HMakeDate) |
| | | values(" + HInterID + "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + 1101 + "','" + |
| | | HBillSubType + "','" + HDate + "','" + HBillNo + "','" + HBillStatus + "','" + HAddress + |
| | | "'," + HSupID + "," + HEmpID + "," + HDeptID + ",'" + HExplanation + "','" + HRemark + "','" + HInnerBillNo + "','" + HUse + "','" + HLinkPhone + "','" + HLinkMan + "','" + HMaker + "'," + |
| | | "getdate()" + ")"; |
| | | |
| | | oCN.RunProc(sql); |
| | | } |
| | | else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) |
| | | { //ä¿®æ¹ |
| | | string sql = $@"update Cg_PORequestBillMain set " + |
| | | "HRemark='" + HRemark + "', HChecker='" + HMaker + "', HCheckDate=getdate()" + |
| | | ",HSupID=" + HSupID + ",HEmpID=" + HEmpID + ",HDeptID=" + HDeptID + ",HAddress='" + HAddress + "',HUse='" + HUse + "',HLinkPhone='" + HLinkPhone + "',HLinkMan='" + HLinkMan + "',HExplanation='" + HExplanation + "',HInnerBillNo='" + HInnerBillNo + "' where HInterID=" + HInterID; |
| | | |
| | | oCN.RunProc(sql); |
| | | //å é¤å表 |
| | | oCN.RunProc("delete from Cg_PORequestBillSub where HInterID='" + HInterID + "'"); |
| | | } |
| | | //ä¿åå表 |
| | | objJsonResult = AddBillSub(msg3, HInterID, OperationType); |
| | | |
| | | if (objJsonResult.code == "0") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = objJsonResult.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | public json AddBillSub(string msg3, long HInterID, int OperationType) |
| | | { |
| | | List<ClsCg_PORequestBillSub> DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsCg_PORequestBillSub>>(msg3); |
| | | List<ClsCg_PORequestBillSub> DetailColl2 = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsCg_PORequestBillSub>>(msg3); |
| | | |
| | | |
| | | string HSourceBillNo = DetailColl2[0].HSourceBillNo == null ? "''" : DetailColl2[0].HSourceBillNo; |
| | | string HSourceBillType = DetailColl2[0].HSourceBillType == null ? "''" : DetailColl2[0].HSourceBillType; |
| | | double HRelationQty = DetailColl2[0].HRelationQty == null ? 0 : DetailColl2[0].HRelationQty; |
| | | double HRelationMoney = DetailColl2[0].HRelationMoney == null ? 0 : DetailColl2[0].HRelationMoney; |
| | | |
| | | string HSeOrderBillNo = DetailColl2[0].HSeOrderBillNo == null ? "''" : DetailColl2[0].HSeOrderBillNo; |
| | | string HRemark = DetailColl2[0].HRemark == null ? "''" : DetailColl2[0].HRemark; |
| | | string HUseSub = DetailColl2[0].HUseSub == null ? "''" : DetailColl2[0].HUseSub; |
| | | long HSourceInterID = DetailColl2[0].HSourceInterID == null ? 0 : DetailColl2[0].HSourceInterID; |
| | | long HSourceEntryID = DetailColl2[0].HSourceEntryID == null ? 0 : DetailColl2[0].HSourceEntryID; |
| | | long HSeOrderInterID = DetailColl2[0].HSeOrderInterID == null ? 0 : DetailColl2[0].HSeOrderInterID; |
| | | long HSeOrderEntryID = DetailColl2[0].HSeOrderEntryID == null ? 0 : DetailColl2[0].HSeOrderEntryID; |
| | | |
| | | |
| | | |
| | | |
| | | int i = 0; |
| | | foreach (ClsCg_PORequestBillSub oSub in DetailColl) |
| | | { |
| | | i++; |
| | | if (oSub.HQty <= 0 || oSub.HQty == null) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + i + "è¡ï¼æ°éä¸è½ä¸º0æè
å°äº0"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (oSub.HMaterID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + i + "è¡ï¼ç©æä¸è½ä¸ºç©º"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (oSub.HUnitID == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "第" + i + "è¡ï¼è®¡éåä½ä¸è½ä¸ºç©º"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | DataSet Cs; |
| | | Int64 NewHEntryID = 1; |
| | | Cs = oCN.RunProcReturn("select MAX(HEntryID)HEntryID from Cg_PORequestBillSub", "Cg_PORequestBillSub"); |
| | | if (Cs.Tables[0].Rows.Count != 0 && ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()) != 0) |
| | | { |
| | | NewHEntryID = ClsPub.isLong(Cs.Tables[0].Rows[0]["HEntryID"].ToString()); |
| | | NewHEntryID += 1; |
| | | } |
| | | |
| | | string sql = $@"Insert into Cg_PORequestBillSub |
| | | (HInterID,HEntryID,HMaterID,HUnitID,HQty,HPrice |
| | | ,HMoney,HDate,HUseSub,HSeOrderBillNo,HSeOrderInterID |
| | | ,HSeOrderEntryID,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo |
| | | ,HSourceBillType,HRelationQty,HRelationMoney) |
| | | values({HInterID},{NewHEntryID},{oSub.HMaterID},{oSub.HUnitID},{(oSub.HQty == null ? 0 : oSub.HQty)} |
| | | ,{oSub.HPrice},{oSub.HMoney},'{oSub.HDate}','{oSub.HUseSub}','{oSub.HSeOrderBillNo}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HRemark}',{oSub.HSourceInterID},{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HRelationQty},{oSub.HRelationMoney})"; |
| | | |
| | | oCN.RunProc(sql); |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = null; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | [Route("Cg_PORequestBill/Cg_PORequestBillSaveApi")] |
| | | [HttpPost] |
| | | public object Cg_PORequestBillSaveApi([FromBody] JObject sMainSub) |
| | | { |
| | | try |
| | | { |
| | | //LogService.Write("éè´è®¢å忥,ä¿åæ¹æ³æ§è¡å®æå¼å¸¸ï¼" + sMainSub.ToString()); |
| | | var model = sMainSub["model"].ToString(); |
| | | var entry = sMainSub["model"]["HENTRY"].ToString(); |
| | | |
| | | model = "[" + model.ToString() + "]"; |
| | | List<ClsCg_PORequestBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsCg_PORequestBillMain>>(model); |
| | | List<ClsCg_PORequestBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsCg_PORequestBillSub>>(entry); |
| | | string sql = string.Empty; |
| | | oCN.BeginTran(); |
| | | sql = $"delete Cg_PORequestBillMain where HinterID = {mainList[0].HInterID}"; |
| | | oCN.RunProc(sql); |
| | | sql = $"delete Cg_PORequestBillSub where HinterID = {mainList[0].HInterID}"; |
| | | oCN.RunProc(sql); |
| | | //主表 |
| | | oCN.RunProc(@"Insert Into Cg_PORequestBillMain |
| | | (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillNo,HBillStatus |
| | | ,HAddress,HSupID,HEmpID,HDeptID,HExplanation,HRemark,HInnerBillNo,HUse,HLinkPhone,HLinkMan |
| | | ,HChecker,HCheckDate,HMaker,HMakeDate,HUpDater,HUpDateDate,HDeleteMan,HDeleteDate,HCloseMan,HCloseDate) |
| | | values(" + mainList[0].HInterID + "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + 1101 + "','" + |
| | | mainList[0].HBillSubType + "','" + mainList[0].HDate + "','" + mainList[0].HBillNo + "','" + mainList[0].HBillStatus + "','" + mainList[0].HAddress + |
| | | "'," + mainList[0].HSupID + "," + mainList[0].HEmpID + "," + mainList[0].HDeptID + ",'" + mainList[0].HExplanation + "','" + mainList[0].HRemark + |
| | | "','" + mainList[0].HInnerBillNo + "','" + mainList[0].HUse + "', '"+ mainList[0].HLinkPhone +"','"+ mainList[0].HLinkMan + |
| | | "','" + mainList[0].HChecker + "','" + mainList[0].HCheckDate + "','" + mainList[0].HMaker + "','" + |
| | | mainList[0].HMakeDate + "','" + mainList[0].HUpDater + "',,'" + mainList[0].HUpDateDate + "',,'" + mainList[0].HDeleteMan + "',,'" + mainList[0].HDeleteDate + "',,'" + mainList[0].HCloseMan + "',,'" + mainList[0].HCloseDate + "',)"); |
| | | //ä¿å主表 |
| | | foreach (var oSub in subList) |
| | | { |
| | | sql = $@"Insert into Cg_PORequestBillSub |
| | | (HInterID,HEntryID,HMaterID,HUnitID,HQty,HPrice |
| | | ,HMoney,HDate,HUseSub,HSeOrderBillNo,HSeOrderInterID |
| | | ,HSeOrderEntryID,HRemark,HSourceInterID,,HSourceEntryID,HSourceBillNo |
| | | ,HSourceBillType,HRelationQtyï¼HRelationMoney) |
| | | values('{oSub.HInterID}','{oSub.HEntryID}','{oSub.HMaterID}','{oSub.HUnitID}','{oSub.HQty}','{oSub.HPrice}, |
| | | '{oSub.HMoney}','{oSub.HDate}','{oSub.HUseSub}','{oSub.HSeOrderBillNo}','{oSub.HSeOrderInterID}', |
| | | '{oSub.HSeOrderEntryID}','{oSub.HRemark}','{oSub.HSourceInterID}','{oSub.HSourceEntryID}','{oSub.HSourceBillNo}', |
| | | '{oSub.HSourceBillType}','{oSub.HRelationQty}','{oSub.HRelationMoney}')"; |
| | | oCN.RunProc(sql); |
| | | } |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åæ®ä¿åæåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write("éè´è®¢å忥å¼å¸¸,ä¿åæ¹æ³æ§è¡å®æå¼å¸¸ï¼" + e.Message.ToString()); |
| | | |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "ä¿å失败ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | ///å é¤åè½ |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Cg_PORequestBill/DeltetCg_PORequestBill")] |
| | | [HttpGet] |
| | | public object DeltetCg_PORequestBill(string HInterID) |
| | | { |
| | | try |
| | | { |
| | | oCN.BeginTran(); |
| | | oCN.RunProc("Delete From Cg_PORequestBillMain where HInterID = " + HInterID); |
| | | oCN.RunProc("Delete From Cg_PORequestBillSub where HInterID = " + HInterID); |
| | | oCN.Commit(); |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å 餿åï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exceptionï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¹æ®åºç¡èµæID æ¥æ¾è®°å½ |
| | | ///åæ°ï¼string sqlã |
| | | ///è¿åå¼ï¼objectã |
| | | /// </summary> |
| | | [Route("Cg_PORequestBill/cx")] |
| | | [HttpGet] |
| | | public object cx(long HInterID) |
| | | { |
| | | try |
| | | { |
| | | |
| | | ds = oCN.RunProcReturn("select * from h_v_Cg_PORequestBillList where hmainid =" + HInterID, "h_v_Cg_PORequestBillList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "falseï¼"; |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | #region æ ¹æ®ç©æå
ç è·åç©æä¿¡æ¯ |
| | | [Route("Cg_PORequestBill/getMaterialByMaterID")] |
| | | [HttpGet] |
| | | public ApiResult<DataTable> getMaterialByMaterID(Int64 HMaterID) |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | |
| | | string sql = "select a.HItemID HMaterID,a.HNumber HMaterNumber,a.HName HMaterName,a.HMaterRuleType,a.HModel HMaterModel,a.HUnitID, b.HNumber HUnitNumber, b.HName HUnitName" + |
| | | " from Gy_Material AS a " + |
| | | " LEFT OUTER JOIN Gy_Unit AS b on a.HUnitID = b.HItemID " + |
| | | " where a.HItemID =" + HMaterID; |
| | | |
| | | var dataSet = oCN.RunProcReturn(sql, "Gy_Material"); |
| | | |
| | | |
| | | if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) |
| | | return new ApiResult<DataTable> { code = -1, msg = "ä¸åå¨è¯¥ç©æ" }; |
| | | |
| | | return new ApiResult<DataTable> { code = 1, msg = "æ¥è¯¢æå", data = dataSet.Tables[0] }; |
| | | } |
| | | #endregion |
| | | |
| | | #region éè´ç³è¯·å å®¡æ ¸/åå®¡æ ¸ |
| | | /// <summary> |
| | | /// |
| | | /// </summary> |
| | | /// <param name="HInterID">忮ID</param> |
| | | /// <param name="IsAudit">å®¡æ ¸(0),åå®¡æ ¸(1)</param> |
| | | /// <param name="CurUserName">å®¡æ ¸äºº</param> |
| | | /// <returns></returns> |
| | | [Route("Cg_PORequestBill/AuditCg_PORequestBill")] |
| | | [HttpGet] |
| | | public object AuditCg_PORequestBill(string HInterID, int Type, string user) |
| | | { |
| | | try |
| | | { |
| | | //夿æ¯å¦æå®¡æ ¸æé |
| | | if (!DBUtility.ClsPub.Security_Log("Cg_PORequestBill_Check", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ æéå®¡æ ¸!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(HInterID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HInterID为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ClsPub.CurUserName = user; |
| | | BillOld.MvarItemKey = "Cg_PORequestBillMain"; |
| | | oCN.BeginTran();//å¼å§äºå¡ |
| | | |
| | | //Type 1 å®¡æ ¸ 2 åå®¡æ ¸ |
| | | if (Type == 1) |
| | | { |
| | | //夿忮æ¯å¦å·²ç»å®¡æ ¸ |
| | | DataSet ds; |
| | | string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; |
| | | ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®ä¸åå¨ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "忮已å
³é!ä¸è½åæ¬¡å®¡æ ¸ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®å·²å®¡æ ¸!ä¸è½åæ¬¡å®¡æ ¸ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //å®¡æ ¸åæ® |
| | | if (!BillOld.CheckBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å®¡æ ¸å¤±è´¥!åå :" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //夿忮æ¯å¦å·²ç»åå®¡æ ¸ |
| | | DataSet ds; |
| | | string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; |
| | | ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); |
| | | if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "忮已å
³é!ä¸è½è¿è¡åå®¡æ ¸ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®æªå®¡æ ¸!ä¸éè¦åå®¡æ ¸!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //åå®¡æ ¸åæ® |
| | | if (!BillOld.AbandonCheck(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åå®¡æ ¸å¤±è´¥!åå :" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | |
| | | oCN.Commit();//æäº¤äºå¡ |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "æ§è¡æåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ§è¡å¤±è´¥ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region éè´ç³è¯·å å
³é/åå
³éåè½ |
| | | [Route("Cg_PORequestBill/CloseCg_PORequestBill")] |
| | | [HttpGet] |
| | | public object CloseCg_PORequestBill(string HInterID, int Type, string user) |
| | | { |
| | | try |
| | | { |
| | | //夿æ¯å¦æå 餿é |
| | | if (!DBUtility.ClsPub.Security_Log("Cg_PORequestBill_Close", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ æéå
³é!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(HInterID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HInterID为空ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ClsPub.CurUserName = user; |
| | | BillOld.MvarItemKey = "Cg_PORequestBillMain"; |
| | | oCN.BeginTran();//å¼å§äºå¡ |
| | | |
| | | //Type 1 å
³é 2 åå
³é |
| | | if (Type == 1) |
| | | { |
| | | //夿忮æ¯å¦å·²ç»å
³é |
| | | DataSet ds; |
| | | string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; |
| | | ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®ä¸åå¨ï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®æªå®¡æ ¸!ä¸è½è¿è¡å
³é!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | if (ds.Tables[0].Rows[0]["HCloseMan"] != null && ds.Tables[0].Rows[0]["HCloseMan"].ToString() != "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "忮已å
³é!ä¸è½å次å
³é!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //å
³éåæ® |
| | | if (!BillOld.CloseBill(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "å
³é失败!åå :" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //夿忮æ¯å¦å·²ç»åå
³é |
| | | DataSet ds; |
| | | string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID; |
| | | ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); |
| | | if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | if (ds.Tables[0].Rows[0]["HChecker"] == null || ds.Tables[0].Rows[0]["HChecker"].ToString() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®æªå®¡æ ¸!ä¸è½è¿è¡å
³é!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (ds.Tables[0].Rows[0]["HCloseMan"] == null || ds.Tables[0].Rows[0]["HCloseMan"].ToString() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ®æªå
³é!ä¸éè¦ååå
³é!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //åå
³éåæ® |
| | | if (!BillOld.CancelClose(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "åå
³é失败!åå :" + ClsPub.sExeReturnInfo; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | |
| | | oCN.Commit();//æäº¤äºå¡ |
| | | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "æ§è¡æåï¼"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "æ§è¡å¤±è´¥ï¼" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | |
| | | } |