using System; using System.Collections.Generic; using System.Data; using System.Linq; using Pub_Class; using System.Web; using System.Web.Http; using WebAPI.Models; using Newtonsoft.Json.Linq; using Model; using Newtonsoft.Json; namespace WebAPI.Controllers.仓存管理.验收入库 { public class Kf_StepFoldinBillController : ApiController { public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更) private json objJsonResult = new json(); //public DAL.ClsCg_POInStockBill BillOld = new DAL.ClsCg_POInStockBill(); public DataSet ds = new DataSet(); public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); public DAL.ClsKf_StepFoldInBill BillOld = new DAL.ClsKf_StepFoldInBill(); #region 分步式调入单 返回列表 [Route("Kf_StepFoldinBill/GetStepFoldinBillList")] [HttpGet] //public object GetStepFoldinBillList(string sWhere, string user, string Organization) //{ // try // { // //判断查询权限 // if (!DBUtility.ClsPub.Security_Log("Fb_StepFoldinBill_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_Kf_MoveStockStepInBillList where (调入组织='" + Organization + "')"); // if (sWhere == null || sWhere.Equals("")) // { // ds = oCN.RunProcReturn(sql1 + " order by hmainid desc", "h_v_Kf_MoveStockStepInBillList"); // } // else // { // string sql = sql1 + sWhere + " order by hmainid desc"; // ds = oCN.RunProcReturn(sql, "h_v_Kf_MoveStockStepInBillList"); // } // //if (ds.Tables[0].Rows.Count != 0 || ds != null) // //{ // objJsonResult.code = "1"; // objJsonResult.count = 1; // objJsonResult.Message = "Sucess!"; // objJsonResult.data = ds.Tables[0]; // return objJsonResult; // //} // //else // //{ // //objJsonResult.code = "0"; // //objJsonResult.count = 0; // //objJsonResult.Message = "无数据"; // //objJsonResult.data = null; // //return objJsonResult; // //} // } // catch (Exception ex) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); // objJsonResult.data = null; // return objJsonResult; // } //} //#endregion public object list(string sWhere) { try { List columnNameList = new List(); //定义声明变量 ,把通过 new List()创建的 实例,赋值给变量 if (sWhere == null || sWhere.Equals("")) { ds = oCN.RunProcReturn("select * from h_v_IF_StepFoldInBillList order by hmainid desc", "h_v_IF_StepFoldInBillList"); } else { string sql1 = "select * from h_v_IF_StepFoldInBillList where 1 = 1 "; string sql = sql1 + sWhere + " order by hmainid desc"; ds = oCN.RunProcReturn(sql, "h_v_IF_StepFoldInBillList"); } foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用 { Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串 columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList;//将columnNameList赋值给objJsonResult的list属性 return objJsonResult; //} //else //{ //objJsonResult.code = "0"; //objJsonResult.count = 0; //objJsonResult.Message = "无数据"; //objJsonResult.data = null; //return objJsonResult; //} } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 分步式调入单 查询 [Route("Kf_StepFoldInBill/cx")] [HttpGet] public object cx(long HInterID) { try { //List columnNameList = new List(); //定义声明变量 ,把通过 new List()创建的 实例,赋值给变量 ds = oCN.RunProcReturn("select * from h_v_IF_StepFoldInBillList where hmainid =" + HInterID, "h_v_IF_StepFoldInBillList"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "false!"; objJsonResult.data = null; return objJsonResult; } else { //foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用 //{ // Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType // string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串 // 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("Kf_StepFoldInBill/Kf_StepFoldInBillEdit")] [HttpPost] public object StepFoldInBillEdit([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 mainList = Newtonsoft.Json.JsonConvert.DeserializeObject>(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 HPSStyleID = mainList[0].HPSStyleID;//采购方式 long HEmpID = mainList[0].HEmpID;//仓管员 long HDeptID = mainList[0].HDeptID;//部门 long HWHID = mainList[0].HWHID;//调入仓库 long HSCWHID = mainList[0].HSCWHID;//调出仓库 long HManagerID = mainList[0].HManagerID;//负责人 long HSecManagerID = mainList[0].HSecManagerID;//验收员 long HKeeperID = mainList[0].HKeeperID;//保管员 string HMaker = user;//制单人 string HExplanation = mainList[0].HExplanation;//摘要 string HInnerBillNo = mainList[0].HInnerBillNo;//内部单据号 string HBillType = mainList[0].HBillType; string HBillSubType = mainList[0].HBillSubType; long HBillStatus = mainList[0].HBillStatus; string HMakeDate = mainList[0].HMakeDate; string HChecker = mainList[0].HChecker; string HCheckDate = mainList[0].HCheckDate; string HUpDater = mainList[0].HUpDater; string HUpDateDate = mainList[0].HUpDateDate; string HDeleteMan = mainList[0].HDeleteMan; string HDeleteDate = mainList[0].HDeleteDate; string HCloseMan = mainList[0].HCloseMan; string HCloseDate = mainList[0].HCloseDate; long HCurID = mainList[0].HCurID; long HProjectID = mainList[0].HProjectID; //-项目 //进行 会计期间 结账 的判断和控制 string s = ""; int sYear = 0; int sPeriod = 0; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } ds = oCN.RunProcReturn("select * from h_v_IF_StepFoldInBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_StepFoldInBillList"); if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//新增 { //主表 oCN.RunProc(@"Insert Into Kf_ICStockBillMain (HInterID,HBillNo,HDate,HBillType,HBillSubType,HBillStatus,HYear,HPeriod ,HSupID,HWHID,HSCWHID,HEmpID,HManagerID,HSecManagerID,HKeeperID,HDeptID ,HMaker,HMakeDate,HChecker,HUpDater ,HDeleteMan,HCloseMan ,HRemark,HExplanation,HInnerBillNo,HCurID,HProjectID) values(" + HInterID + ",'" + HBillNo + "','" + HDate + "','" + 1251 + "','" + 1251 + "'," + HBillStatus + "," + DateTime.Now.Year + "," + DateTime.Now.Month + "," + HSupID + "," + HWHID + "," + HSCWHID + "," + HEmpID + "," + HManagerID + "," + HSecManagerID + "," + HKeeperID + "," + HDeptID + ",'" + HMaker + "','" + HMakeDate + "','" + HChecker + "','" + HUpDater + "','" + HDeleteMan + "','" + HCloseMan + "','" + HRemark + "','" + HExplanation + "','" + HInnerBillNo + "'," + HCurID + "," + HProjectID + "" + ")"); } else if (OperationType == 3 || ds.Tables[0].Rows.Count != 0) { //修改 DataSet dss; dss = oCN.RunProcReturn("select * from h_v_IF_StepFoldInBillList where hmainid=" + HInterID + " and 单据号='" + HBillNo + "'", "h_v_IF_StepFoldInBillList"); //判断是否可编辑 if (dss.Tables[0].Rows[0]["审核人"].ToString() != "" && dss.Tables[0].Rows[0]["审核人"] != null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据已经被审核,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } if (dss.Tables[0].Rows[0]["状态"].ToString() != "创建") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } String sql = "update Kf_ICStockBillMain set " + "HRemark='" + HRemark + "', HUpDater='" + HMaker + "', HUpDateDate=getdate()" + ",HSupID=" + HSupID + ",HWHID=" + HWHID + ",HSCWHID=" + HSCWHID + ", HEmpID=" + HEmpID + ",HManagerID=" + HManagerID + ",HSecManagerID = " + HSecManagerID + ",HKeeperID=" + HKeeperID + ",HDeptID=" + HDeptID + ",HProjectID=" + HProjectID + " where HInterID=" + HInterID; oCN.RunProc(sql); //分布式调入单 编辑 撤销 回填分布式调出单关联数量 oCN.RunProc("exec h_p_Kf_UpDateRelation_ICStockToPOStockIn_Del " + HInterID); //删除子表 oCN.RunProc("delete from Kf_ICStockBillSub where HInterID='" + HInterID + "'"); } //保存子表 objJsonResult = AddBillSub(msg3, HInterID, OperationType); //分布式调入单新增回填分布式调出单关联数量 oCN.RunProc("exec h_p_Kf_UpDateRelation_ICStockToPOStockIn_Add " + HInterID); 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 DetailColl = Newtonsoft.Json.JsonConvert.DeserializeObject>(msg3); int i = 0; foreach (ClsKf_StepFoldInBillSub 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 Kf_ICStockBillSub", "Kf_ICStockBillSub"); 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; } oCN.RunProc($@"Insert into Kf_ICStockBillSub (HInterID,HEntryID,HRemark ,HMaterID,HUnitID,HSecUnitID,HPropertyID,HBatchNo ,HWHID,HSCWHID,HSPID,HSCSPID ,HQtyMust,HQty,HRelationQty,HRelationMoney,HSecUnitRate,HPrice,HMoney,HOrderPrice ,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType ,HPOOrderInterID,HPOOrderEntryID,HPOOrderBillNo,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo) values({HInterID},{NewHEntryID},'{oSub.HRemark}' ,{oSub.HMaterID},{oSub.HUnitID},{oSub.HSecUnitID},{oSub.HPropertyID},'{oSub.HBatchNo}',{oSub.HWHID},{oSub.HSCWHID} ,{oSub.HSPID},{oSub.HSCSPID},{oSub.HQtyMust},{(oSub.HQty == null ? 0 : oSub.HQty)},{oSub.HRelationQty},{oSub.HRelationMoney},{oSub.HSecUnitRate} ,{oSub.HPrice},{oSub.HMoney},{oSub.HOrderPrice} ,{oSub.HSourceInterID},{oSub.HSourceEntryID},'{oSub.HSourceBillNo}','{oSub.HSourceBillType}',{oSub.HPOOrderInterID},{oSub.HPOOrderEntryID} ,'{oSub.HPOOrderBillNo}',{oSub.HSeOrderInterID},{oSub.HSeOrderEntryID},'{oSub.HSeOrderBillNo}')"); } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = null; objJsonResult.data = null; return objJsonResult; } #endregion #region 分步式调入单 删除功能 [Route("Fb_StepFoldInBill/DeltetFb_StepFoldInBill")] [HttpGet] public object DeltetFb_StepFoldInBill(string HInterID) { try { //进行 会计期间 结账 的判断和控制 string s = ""; int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } oCN.BeginTran(); //分布式调入单新增回填分布式调出单关联数量 oCN.RunProc("exec h_p_Kf_UpDateRelation_ICStockToPOStockIn_Del " + HInterID); oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID); oCN.RunProc("Delete From Kf_ICStockBillSub 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; } } #endregion #region 分步式调入单 审核/反审核 /// /// /// /// 单据ID /// 审核(0),反审核(1) /// 审核人 /// [Route("Kf_StepFoldInBill/AuditKf_StepFoldInBill")] [HttpGet] public object AuditKf_StepFoldInBill(string HInterID, int Type, string user) { string sql = ""; //ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey); try { //判断是否有审核权限 if (!DBUtility.ClsPub.Security_Log("Fb_StepFoldinBill_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; } //进行 会计期间 结账 的判断和控制 string s = ""; int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } ClsPub.CurUserName = user; BillOld.MvarItemKey = "Kf_ICStockBillMain"; ds = oCN.RunProcReturn("select * from Kf_ICStockBillMain where HInterID = " + int.Parse(HInterID), "Kf_ICStockBillMain"); string HBillNo = ""; oCN.BeginTran();//开始事务 if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!"; objJsonResult.data = null; return objJsonResult; } else { HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); } //Type 1 审核 2 反审核 if (Type == 1) { //审核前控制 sql = "exec h_p_Cg_POInStockBill_BeforeCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql, "h_p_Cg_POInStockBill_BeforeCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } if (!BillOld.CheckBill(int.Parse(HInterID), HBillNo, "h_p_Cg_POInStockBill_AfterCheckCtrl", user, ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { //反审核前控制 sql = "exec h_p_Cg_POInStockBill_BeforeUnCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql, "h_p_Cg_POInStockBill_BeforeUnCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } if (BillOld.AbandonCheck(int.Parse(HInterID), HBillNo, "h_p_Cg_POInStockBill_AfterUnCheckCtrl", user, ref ClsPub.sExeReturnInfo)) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); } else { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } 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("Kf_StepFoldInBill/CloseKf_StepFoldInBill")] [HttpGet] public object CloseKf_StepFoldInBill(string HInterID, int Type, string user) { try { //判断是否有删除权限 if (!DBUtility.ClsPub.Security_Log("Fb_StepFoldinBill_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 = "Kf_ICStockBillMain"; 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]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].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 (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]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].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 (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 #region 分步式调入单 作废/反作废功能 [Route("Kf_StepFoldInBill/CancellKf_StepFoldInBill")] [HttpGet] public object CancellKf_StepFoldInBill(string HInterID, int Type, string user) { try { //判断是否有删除权限 if (!DBUtility.ClsPub.Security_Log("Fb_StepFoldinBill_Delete", 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; oCN.BeginTran();//开始事务 //Type 1 作废 2 反作废 if (Type == 1) { DataSet ds; string sql = "select * from Kf_ICStockBillMain where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, "Kf_ICStockBillMain"); 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]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不需要再作废!"; objJsonResult.data = null; return objJsonResult; } //作废单据 if (!BillOld.Cancelltion(int.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 Kf_ICStockBillMain where HinterID = " + HInterID; ds = oCN.RunProcReturn(sql, "Kf_ICStockBillMain"); 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]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不需要再作废!"; objJsonResult.data = null; return objJsonResult; } //作废单据 if (!BillOld.AbandonCancelltion(int.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("Kf_StepFoldInBill/loadKf_ICStockBillMain_Push")] [HttpGet] public object loadKf_ICStockBillMain_Push(long HInterID, long HSubID) { try { ds = oCN.RunProcReturn("select * from h_v_IF_StepFoldOutBillList where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_IF_StepFoldOutBillList"); 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 } }