| | |
| | | using System.Data.SqlClient; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | using SyntacticSugar.constant; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | |
| | | #region 应付单分页列表 |
| | | [Route("Cg_PayableBill/page")] |
| | | [HttpGet] |
| | | public object Cg_PayableBillPage(string sWhere, string user, int page, int size) |
| | | { |
| | | DataSet ds; |
| | | json res = new json(); |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断权限 |
| | | //if (!DBUtility.ClsPub.Security_Log("Kf_POStockInBillList", 1, false, user)) |
| | | //{ |
| | | // objJsonResult.code = CodeConstant.FAIL; |
| | | // objJsonResult.count = CountConstant.FAIL; |
| | | // objJsonResult.Message = "您没有该模块权限,请与管理员联系!"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | sWhere = sWhere.Replace("'", "''"); |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_Cg_PayableBillList " + page + "," + size + ",''", "h_p_Cg_PayableBillList"); |
| | | } |
| | | else |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_Cg_PayableBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Cg_PayableBillList"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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列对象的列名 |
| | | } |
| | | |
| | | res.code = CodeConstant.SUCCEED; |
| | | res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); |
| | | res.Message = "Sucess!"; |
| | | res.list = columnNameList; |
| | | res.data = ds.Tables[0]; |
| | | return res; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | res.code = CodeConstant.FAIL; |
| | | res.count = CountConstant.FAIL; |
| | | res.Message = "Exception!" + e.ToString(); |
| | | res.data = null; |
| | | return res; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 应付单列表 查询 |
| | | /// <summary> |
| | |
| | | { |
| | | bResult = false; |
| | | } |
| | | |
| | | //自动审核设置 |
| | | if (refSav == "Add") |
| | | { |
| | | objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //返回主ID |
| | | //系统参数 自动审核 |
| | | string sReturn = ""; |
| | | if (oSystemParameter.ShowBill(ref sReturn) == true) |
| | | { |
| | | if (oSystemParameter.omodel.Cg_PayableBill_AutoCheck == "Y") //系统参数 自动审核 |
| | | { |
| | | objJsonResult.Verify = "Y"; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.Verify = "N"; |
| | | } |
| | | } |
| | | } |
| | | else if (refSav == "Update") |
| | | { |
| | | objJsonResult.HInterID = oBill.omodel.HInterID.ToString(); //返回主ID |
| | | objJsonResult.Verify = "N"; |
| | | } |
| | | |
| | | if (bResult) |
| | | { |
| | | objJsonResult.code = "0"; |
| | |
| | | [HttpGet] |
| | | public object AuditCg_PayableBill_Flow(int HInterID, int IsAudit, string CurUserName, string CurUserID) |
| | | { |
| | | //string ModRightNameCheck = "Cg_POOrderBill_Check"; |
| | | //string ModRightNameCheck = "Cg_PayableBill_Check"; |
| | | DBUtility.ClsPub.CurUserName = CurUserName; |
| | | try |
| | | { |
| | |
| | | { |
| | | #region 审核前的相关判断 |
| | | //审核前控制========================================= |
| | | //string sql1 = "exec h_p_Cg_POOrderBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; |
| | | //ds = oCN.RunProcReturn(sql1, "h_p_Cg_POOrderBill_BeforeCheckCtrl"); |
| | | //string sql1 = "exec h_p_Cg_PayableBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'"; |
| | | //ds = oCN.RunProcReturn(sql1, "h_p_Cg_PayableBill_BeforeCheckCtrl"); |
| | | //if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | |
| | | oCN.RunProc(sql04); |
| | | |
| | | //更新单据的单据状态 |
| | | if (oBill.CheckBill(oCN, oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Cg_POOrderBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | if (oBill.CheckBill(oCN, oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Cg_PayableBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true) |
| | | { |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | { |
| | | #region 反审核前的相关判断 |
| | | //反审核前控制========================================= |
| | | //DataSet ds = oCN.RunProcReturn("Exec h_p_Cg_POOrderBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'", "h_p_Cg_POOrderBill_BeforeUnCheckCtrl"); |
| | | //DataSet ds = oCN.RunProcReturn("Exec h_p_Cg_PayableBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + CurUserName + "'", "h_p_Cg_PayableBill_BeforeUnCheckCtrl"); |
| | | //if (ds == null) |
| | | //{ |
| | | // objJsonResult.code = "0"; |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 应付单列表 查询供应商付款计划表 |
| | | /// <summary> |
| | | /// 返回应收单列表 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Cg_PayableBill/SupplierPayPlanList")] |
| | | [HttpGet] |
| | | public object SupplierPayPlanList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Gy_SupplierPayPlanList order by 单据号 desc", "h_v_Gy_SupplierPayPlanList"); |
| | | } |
| | | else |
| | | { |
| | | string sql1 = "select * from h_v_Gy_SupplierPayPlanList where 1 = 1 "; |
| | | string sql = sql1 + sWhere + " order by 单据号 desc"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_SupplierPayPlanList"); |
| | | } |
| | | |
| | | //添加列名 |
| | | 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_PayableBill/QueryList")] |
| | | [HttpGet] |
| | | public object QueryList(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断是否有查询权限 |
| | | |
| | | //if (!DBUtility.ClsPub.Security_Log("Cg_PayableBillQuery", 1, false, user)) |
| | | //{ |
| | | // objJsonResult.code = CodeConstant.FAIL; |
| | | // objJsonResult.count = CountConstant.FAIL; |
| | | // objJsonResult.Message = "无权限查看!"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | string sql = "select * from h_v_Cg_PayableBillQuery where 1 = 1 "; |
| | | |
| | | if (sWhere == "" || sWhere == null) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Cg_PayableBillQuery order by hmainid desc", "h_v_Cg_PayableBillQuery"); |
| | | } |
| | | else |
| | | { |
| | | ds = oCN.RunProcReturn(sql + sWhere + " order by hmainid desc", "h_v_Cg_PayableBillQuery"); |
| | | } |
| | | |
| | | |
| | | |
| | | 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 = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 应付单查询子列表 |
| | | [Route("Cg_PayableBill/QuerySubList")] |
| | | [HttpGet] |
| | | public object QuerySubList(string hmainid, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断是否有查询权限 |
| | | |
| | | //if (!DBUtility.ClsPub.Security_Log("Cg_PayableBillQuery", 1, false, user)) |
| | | //{ |
| | | // objJsonResult.code = CodeConstant.FAIL; |
| | | // objJsonResult.count = CountConstant.FAIL; |
| | | // objJsonResult.Message = "无权限查看!"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | string sql = "select * from h_v_Cg_PayableBillQuerySub where hmainid = " + hmainid; |
| | | |
| | | ds = oCN.RunProcReturn(sql + " order by hsubid ASC", "h_v_Cg_PayableBillQuerySub"); |
| | | |
| | | |
| | | 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 = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 应付单需要我审批流审批的 |
| | | [Route("Cg_PayableBill/NeedChecklist")] |
| | | [HttpGet] |
| | | public object NeedChecklist(string user, string userid) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断是否有查询权限 |
| | | |
| | | //if (!DBUtility.ClsPub.Security_Log("Cg_PayableBillQuery", 1, false, user)) |
| | | //{ |
| | | // objJsonResult.code = CodeConstant.FAIL; |
| | | // objJsonResult.count = CountConstant.FAIL; |
| | | // objJsonResult.Message = "无权限查看!"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | //搜索需要审核的 |
| | | string sql = "select * from h_v_Cg_PayableBillQuery_NeedCheck where HCheckUserID = '" + userid + "' ORDER BY hmainid DESC,hsubid ASC"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Cg_PayableBillQuery_NeedCheck"); |
| | | 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 = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 应付单已经审批流审批的 |
| | | [Route("Cg_PayableBill/Checkedlist")] |
| | | [HttpGet] |
| | | public object Checkedlist(string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断是否有查询权限 |
| | | |
| | | //if (!DBUtility.ClsPub.Security_Log("Cg_PayableBillQuery", 1, false, user)) |
| | | //{ |
| | | // objJsonResult.code = CodeConstant.FAIL; |
| | | // objJsonResult.count = CountConstant.FAIL; |
| | | // objJsonResult.Message = "无权限查看!"; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | //搜索需要审核的 |
| | | string sql = "select TOP 1000 * from h_v_Cg_PayableBillQuery_Checked where 项目审核人 = '" + user + "'" + |
| | | " ORDER BY hmainid DESC,hsubid ASC"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Cg_PayableBillList_Query"); |
| | | 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 = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = ds.Tables[0]; |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 应付单 批量多级审核 |
| | | [Route("Cg_PayableBill/CheckAllFlow")] |
| | | [HttpGet] |
| | | public object CheckAll(string HInterIDS, int IsAudit, string CurUserName, string CurUserID) |
| | | { |
| | | try |
| | | { |
| | | //处理字符串 |
| | | if (!string.IsNullOrEmpty(HInterIDS)) |
| | | { |
| | | int[] idArray = Array.ConvertAll(HInterIDS.Split(','), int.Parse); |
| | | // 处理idArray... |
| | | for (int i = 0; i < idArray.Length; i++) |
| | | { |
| | | objJsonResult = (json)AuditCg_PayableBill_Flow(idArray[i], IsAudit, CurUserName, CurUserID);//审核执行 |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | objJsonResult.Message += "第" + (i + 1) + "行出现问题无法继续完成"; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "请选择正确行"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | 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("Cg_PayableBill/RejectAllCheckFlow")] |
| | | [HttpGet] |
| | | public object RejectAllCheckFlow(string HInterIDS, string CurUserID) |
| | | { |
| | | try |
| | | { |
| | | //处理字符串 |
| | | if (!string.IsNullOrEmpty(HInterIDS)) |
| | | { |
| | | int[] idArray = Array.ConvertAll(HInterIDS.Split(','), int.Parse); |
| | | // 处理idArray... |
| | | for (int i = 0; i < idArray.Length; i++) |
| | | { |
| | | objJsonResult = (json)RejectCheckFlow_POOrderBill(idArray[i].ToString(), CurUserID);//审核执行 |
| | | if (objJsonResult.count == 0) |
| | | { |
| | | objJsonResult.Message += "第" + (i + 1) + "行出现问题无法继续完成"; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "请选择正确行"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | 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 |
| | | |
| | | } |
| | | } |