|  |  |  | 
|---|
|  |  |  | using Newtonsoft.Json.Linq; | 
|---|
|  |  |  | using Newtonsoft.Json; | 
|---|
|  |  |  | using Newtonsoft.Json.Linq; | 
|---|
|  |  |  | using Pub_Class; | 
|---|
|  |  |  | using System; | 
|---|
|  |  |  | using System.Collections; | 
|---|
|  |  |  | 
|---|
|  |  |  | using System.Data; | 
|---|
|  |  |  | using System.Data.SqlClient; | 
|---|
|  |  |  | using System.Web.Http; | 
|---|
|  |  |  | using System.Windows.Forms; | 
|---|
|  |  |  | using WebAPI.Models; | 
|---|
|  |  |  | namespace WebAPI.Controllers | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private json objJsonResult = new json(); | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); | 
|---|
|  |  |  | public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill(); | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 返回进站扫描列表|工序进站接收单列表 | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  | //判断是否有查询权限 | 
|---|
|  |  |  | //if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Query", 1, false, user)) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //    objJsonResult.code = "0"; | 
|---|
|  |  |  | //    objJsonResult.count = 0; | 
|---|
|  |  |  | //    objJsonResult.Message = "无查询权限!"; | 
|---|
|  |  |  | //    objJsonResult.data = null; | 
|---|
|  |  |  | //    return objJsonResult; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Sc_ProcessExchangeBill_Query", 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无查询权限!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取系统参数 | 
|---|
|  |  |  | string Ret = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref Ret)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断客户为龙山汽配 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取需要拼接的字符串 | 
|---|
|  |  |  | string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "工序派工单列表"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sWhere += sql_splice; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillQuery where 1 = 1 " + sWhere + " order by hmainid desc ", "h_v_Sc_ProcessExchangeBillQuery"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //if (ds.Tables[0].Rows.Count != 0 || ds != null) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //添加列名 | 
|---|
|  |  |  | 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.list = columnNameList; | 
|---|
|  |  |  | objJsonResult.data = ds.Tables[0]; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | //else | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //objJsonResult.code = "0"; | 
|---|
|  |  |  | //objJsonResult.count = 0; | 
|---|
|  |  |  | //objJsonResult.Message = "无数据"; | 
|---|
|  |  |  | //objJsonResult.data = null; | 
|---|
|  |  |  | //return objJsonResult; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | string sql = "select * from h_v_Sc_ProcessExchangeBillQuerySub where hmainid = "; | 
|---|
|  |  |  | string sql1 = sql + sWhere; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql1 + " order by cast(工序号 as int)", "h_v_Sc_ProcessExchangeBillQuerySub"); | 
|---|
|  |  |  | return GetObjectJson(ds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return GetObjectJson(ds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 工序流转卡(下达) | 
|---|
|  |  |  | 
|---|
|  |  |  | //    objJsonResult.data = null; | 
|---|
|  |  |  | //    return objJsonResult; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取系统参数 | 
|---|
|  |  |  | string Ret = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref Ret)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断客户为龙山汽配 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取需要拼接的字符串 | 
|---|
|  |  |  | string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "工序派工单明细列表"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sWhere += sql_splice; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeIssueBillQuery where 1 = 1 " + sWhere + " order by hmainid desc ", "h_v_Sc_ProcessExchangeIssueBillQuery"); | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否有查询权限 | 
|---|
|  |  |  | //if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Query", 1, false, user)) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //    objJsonResult.code = "0"; | 
|---|
|  |  |  | //    objJsonResult.count = 0; | 
|---|
|  |  |  | //    objJsonResult.Message = "无权限查询!"; | 
|---|
|  |  |  | //    objJsonResult.data = null; | 
|---|
|  |  |  | //    return objJsonResult; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Query", 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无权限查询!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取系统参数 | 
|---|
|  |  |  | string Ret = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref Ret)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断客户为龙山汽配 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取需要拼接的字符串 | 
|---|
|  |  |  | string sql_splice = DBUtility.ClsPub.SpliceSQL(user,"工艺路线列表"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sWhere += sql_splice; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | if (sWhere == null || sWhere.Equals("")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select top 1000 * from h_v_Gy_RoutingBillList order by hmainid desc", "h_v_Gy_RoutingBillList"); | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList where 1 = 1" + sWhere + " order by hmainid desc", "h_v_Gy_RoutingBillList"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sql1 = "select  top 1000 * from h_v_Gy_RoutingBillList where 1 = 1 "; | 
|---|
|  |  |  | string sql1 = "select * from h_v_Gy_RoutingBillList where 1 = 1 "; | 
|---|
|  |  |  | //客户自定义 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "瑞与祺") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql1 = "select top 1000 * from h_v_Gy_RoutingBillList where 1 = 1 "; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | string sql = sql1 + sWhere + " order by hmainid desc,cast(工序号 as int)"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_RoutingBillList"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 工艺路线历史列表 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 返回工艺路线历史列表 | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("LEMS/MES_Gy_RoutingBillList_His")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object MES_Gy_RoutingBillList_His(string sWhere, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否有查询权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Query", 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无权限查询!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //获取系统参数 | 
|---|
|  |  |  | string Ret = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref Ret)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断客户为龙山汽配 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取需要拼接的字符串 | 
|---|
|  |  |  | string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "工艺路线列表"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sWhere += sql_splice; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | if (sWhere == null || sWhere.Equals("")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList_His where 1 = 1" + sWhere + " order by hmainid desc", "h_v_Gy_RoutingBillList"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sql1 = "select * from h_v_Gy_RoutingBillList_His where 1 = 1 "; | 
|---|
|  |  |  | //客户自定义 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "瑞与祺") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | sql1 = "select top 1000 * from h_v_Gy_RoutingBillList_His where 1 = 1 "; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | string sql = sql1 + sWhere + " order by hmainid desc,cast(工序号 as int)"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_RoutingBillList_His"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "没有返回任何记录!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return GetObjectJson(ds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 查看工艺路线列表工价权限 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 判断有无查看工价权限 | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Web/CheckProcPrice")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object CheckProcPrice(string UserName) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取系统参数 | 
|---|
|  |  |  | string Ret = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref Ret)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断客户为龙山汽配 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否有查询工价权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_CheckProcPrice", 1, false, UserName)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无查看工价权限!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "查看成功!"; | 
|---|
|  |  |  | objJsonResult.data = 1; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "异常!" + e.Message; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 修改工艺路线工价权限 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 判断有无修改工价权限 | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("Web/EditProcPrice")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object EditProcPrice(string UserName) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取系统参数 | 
|---|
|  |  |  | string Ret = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref Ret)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断客户为龙山汽配 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否有查询工价权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_EditProcPrice", 1, false, UserName)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无修改工价权限!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | objJsonResult.Message = "修改成功!"; | 
|---|
|  |  |  | objJsonResult.data = 1; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "异常!" + e.Message; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 工艺路线  删除 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 工艺路线删除功能 | 
|---|
|  |  |  | 
|---|
|  |  |  | string ModRightNameCheck = "Gy_RoutingBill_Drop"; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string HComputerName = SystemInformation.ComputerName; //设备名称 | 
|---|
|  |  |  | //删除权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | oCN.BeginTran();//开始事务 | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from Gy_RoutingBillmain where HInterID=" + lngBillKey, "Gy_RoutingBillmain"); | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from Gy_RoutingBillMain where HInterID=" + lngBillKey, "Gy_RoutingBillmain"); | 
|---|
|  |  |  | if (ds == null || ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | oCN.RunProc("delete from Gy_RoutingBillmain where HInterID=" + lngBillKey); | 
|---|
|  |  |  | oCN.RunProc("delete from Gy_RoutingBillSub where HInterID=" + lngBillKey); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LogService.Write("用户:" + user + ",日期:" + DateTime.Now + ",删除工艺路线单据:" + ds.Tables[0].Rows[0]["HBillNo"].ToString()); | 
|---|
|  |  |  | oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "删除工艺路线单据:" + ds.Tables[0].Rows[0]["HBillNo"].ToString() + "','LMES-工艺路线模块','" + DBUtility.ClsPub.IPAddress + "','删除单据'", ref DBUtility.ClsPub.sExeReturnInfo); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | oCN.Commit();//提交事务 | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 1; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 工艺路线(维护工价) | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 返回工艺路线列表 | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("LEMS/MES_Gy_RoutingBillMainRates_Json")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object MES_Gy_RoutingBillMainRates_Json(string sWhere, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否有查询权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_Query", 1, false, user)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "无权限查询!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | if (sWhere == null || sWhere.Equals("")) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_Gy_RoutingBillList_MainRate order by hmainid desc", "h_v_Gy_RoutingBillList_MainRate"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string sql1 = "select * from h_v_Gy_RoutingBillList_MainRate where 1 = 1 "; | 
|---|
|  |  |  | string sql = sql1 + sWhere + " order by hmainid desc,cast(工序号 as int)"; | 
|---|
|  |  |  | ds = oCN.RunProcReturn(sql, "h_v_Gy_RoutingBillList_MainRate"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "没有返回任何记录!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return GetObjectJson(ds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 判断物料是否已经存在工艺路线 | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 返回工艺路线列表 | 
|---|
|  |  |  | ///参数:string sql。 | 
|---|
|  |  |  | ///返回值:object。 | 
|---|
|  |  |  | /// </summary> | 
|---|
|  |  |  | [Route("LEMS/IsExistRoutingByMaterial")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object IsExistRoutingByMaterial(int HMaterID, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from Gy_RoutingBillMain where HMaterID = '" + HMaterID + "'", "Gy_RoutingBillMain"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "没有返回任何记录!" + e.ToString(); | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return GetObjectJson(ds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #endregion | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where 1 = 1 " + sWhere + " order by 单据号 desc", "h_v_IF_ICMOBillList"); | 
|---|
|  |  |  | //获取系统参数 | 
|---|
|  |  |  | string Ret = ""; | 
|---|
|  |  |  | if (oSystemParameter.ShowBill(ref Ret)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断客户为龙山汽配 | 
|---|
|  |  |  | if (oSystemParameter.omodel.WMS_CampanyName == "龙山汽配") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //获取需要拼接的字符串 | 
|---|
|  |  |  | string sql_splice = DBUtility.ClsPub.SpliceSQL(user, "生产订单列表"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | sWhere += sql_splice; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where 1 = 1 " + sWhere + " order by 制单日期 desc,单据号 desc", "h_v_IF_ICMOBillList"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return GetObjectJson(ds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 判断下推的生产订单是否审核 | 
|---|
|  |  |  | [Route("LEMS/ICMOBillCheck")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object ICMOBillCheck(string hmainid,string HEntryID,int OrganizationID) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | DataSet ds; | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where 1 = 1  and hmainid=" + hmainid + " and  HEntryID=" + HEntryID + " order by 单据号 desc", "h_v_IF_ICMOBillList"); | 
|---|
|  |  |  | string HNumber = ds.Tables[0].Rows[0]["产品代码"].ToString(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ds.Tables[0].Rows[0]["审核人"].ToString() == "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "所选生产订单为未审核状态,不允许下推生成工序流转卡!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ds.Tables[0].Rows[0]["关闭人"].ToString() != "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "所选生产订单为已关闭状态,不允许下推生成工序流转卡!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ds.Tables[0].Rows[0]["作废人"].ToString() != "") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "所选生产订单为已作废状态,不允许下推生成工序流转卡!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select * from h_v_S_Sc_ICMOBillList where hmainid=" + hmainid + " and HEntryID=" + HEntryID + " and HSTOCKINORGID='" + OrganizationID + "'", "h_v_S_Sc_ICMOBillList"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (double.Parse(ds.Tables[0].Rows[0]["流转卡数量"].ToString()) == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "所选生产订单已全部下推生成工序流转卡,剩余可下推数量为0,不允许下推生成工序流转卡!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ds = oCN.RunProcReturn("select top 1000 * from h_v_Gy_RoutingBillList where 物料代码='" + HNumber + "'", "h_v_Gy_RoutingBillList"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (ds.Tables[0].Rows.Count == 0) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | objJsonResult.code = "0"; | 
|---|
|  |  |  | objJsonResult.count = 0; | 
|---|
|  |  |  | objJsonResult.Message = "所选生产订单对应物料未设置对应的工艺路线,不允许下推生成工序流转卡!"; | 
|---|
|  |  |  | objJsonResult.data = null; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | objJsonResult.code = "1"; | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /// <summary> | 
|---|
|  |  |  | /// 返回工序委外接收单列表 | 
|---|
|  |  |  | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //if (ds.Tables[0].Rows.Count != 0 || ds != null) | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | List<object> columnNameList = new List<object>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //添加列名 | 
|---|
|  |  |  | 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.list = columnNameList; | 
|---|
|  |  |  | objJsonResult.data = ds.Tables[0]; | 
|---|
|  |  |  | return objJsonResult; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | //else | 
|---|
|  |  |  | //{ | 
|---|
|  |  |  | //objJsonResult.code = "0"; | 
|---|
|  |  |  | //objJsonResult.count = 0; | 
|---|
|  |  |  | //objJsonResult.Message = "无数据"; | 
|---|
|  |  |  | //objJsonResult.data = null; | 
|---|
|  |  |  | //return objJsonResult; | 
|---|
|  |  |  | //} | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception e) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | #region 工艺路线审核/反审核功能 | 
|---|
|  |  |  | [Route("Gy_RoutingBill/CheckGy_RoutingBill")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object CheckGy_RoutingBill(string HInterID, int Type, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否有删除权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_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 = "Gy_RoutingBillMain"; | 
|---|
|  |  |  | 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.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 (!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]["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)) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); | 
|---|
|  |  |  | //DataSet DSet = oCn.RunProcReturn("exec h_p_Sc_ICMOBill_AbandonCheckCtrl " + int.Parse(HInterID), "h_p_Sc_ICMOBill_AbandonCheckCtrl"); | 
|---|
|  |  |  | ////if (DBUtility.ClsPub.isInt(DSet.Tables[0].Rows[0]["Hback"]) != 0) | 
|---|
|  |  |  | ////{ | 
|---|
|  |  |  | ////    objJsonResult.code = "0"; | 
|---|
|  |  |  | ////    objJsonResult.count = 1; | 
|---|
|  |  |  | ////    objJsonResult.Message = "该任务单已下推流转卡,不允许反审核" + DBUtility.ClsPub.isStrNull(DSet.Tables[0].Rows[0]["HBackRemark"]); | 
|---|
|  |  |  | ////    objJsonResult.data = null; | 
|---|
|  |  |  | ////    return objJsonResult; | 
|---|
|  |  |  | ////} | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 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("Gy_RoutingBill/CloseGy_RoutingBill_1")] | 
|---|
|  |  |  | [HttpGet] | 
|---|
|  |  |  | public object CloseGy_RoutingBill(string HInterID, int Type, string user) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | //判断是否有删除权限 | 
|---|
|  |  |  | if (!DBUtility.ClsPub.Security_Log("Gy_RoutingBill_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 = "Gy_RoutingBillMain"; | 
|---|
|  |  |  | 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.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 (!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]["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 | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|