1
wtt
2024-12-31 50fceef7f1d136e4992353465ba268e752f68c3a
WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
@@ -9,6 +9,7 @@
using System.Web.Http;
using ViewAPI;
using WebAPI.Models;
using SyntacticSugar.constant;
namespace WebAPI.Controllers
{
    /**
@@ -242,6 +243,63 @@
            }
        }
        /// <summary>
        /// 模具保养记录表分页列表
        /// </summary>
        /// <returns></returns>
        [Route("Sc_MouldMaintainBill/GetMouldMaintainBillListPage")]
        [HttpGet]
        public object GetMouldMaintainBillListPage(string sWhere, string user, int page, int size)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldMaintainList " + page + "," + size + ",''", "h_p_Sc_MouldMaintainList");
                }
                else
                {
                    sWhere = sWhere.Replace("'", "''");
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldMaintainList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldMaintainList");
                }
                //添加列名
                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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception ex)
            {
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #region sql语句
@@ -354,6 +412,63 @@
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        /// <summary>
        /// 模具点检记录表分页列表
        /// </summary>
        /// <returns></returns>
        [Route("Sc_MouldDotCheckBill/GetMouldDotCheckBillListPage")]
        [HttpGet]
        public object GetMouldDotCheckBillListPage(string sWhere, string user, int page, int size)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldDotCheckBillList " + page + "," + size + ",''", "h_p_Sc_MouldDotCheckBillList");
                }
                else
                {
                    sWhere = sWhere.Replace("'", "''");
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldDotCheckBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldDotCheckBillList");
                }
                //添加列名
                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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception ex)
            {
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
@@ -534,6 +649,63 @@
            }
        }
        /// <summary>
        /// 模具故障登记表分页列表
        /// </summary>
        /// <returns></returns>
        [Route("Sc_MouldConkBookBill/GetMouldConkBookBillListPage")]
        [HttpGet]
        public object GetMouldConkBookBillListPage(string sWhere, string user, int page, int size)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldConkBookBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldConkBookBillList");
                }
                else
                {
                    sWhere = sWhere.Replace("'", "''");
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldConkBookBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldConkBookBillList");
                }
                //添加列名
                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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception ex)
            {
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #region 器具故障记录统计分析 
        /// <summary>
        /// 器具维修记录统计分析 列表
@@ -689,6 +861,62 @@
            }
        }
        /// <summary>
        /// 模具维修验收单分页列表
        /// </summary>
        /// <returns></returns>
        [Route("Sc_MouldRepairCheckBill/GetMouldRepairCheckBillListPage")]
        [HttpGet]
        public object GetMouldRepairCheckBillListPage(string sWhere, string user, int page, int size)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sb_EquipRepairCheckBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldRepairCheckBillList " + page + "," + size + ",''", "h_p_Sc_MouldRepairCheckBillList");
                }
                else
                {
                    sWhere = sWhere.Replace("'", "''");
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldRepairCheckBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldRepairCheckBillList");
                }
                //添加列名
                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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #region sql语句
@@ -767,81 +995,7 @@
        //}
        #endregion
        /// <summary>
        /// 模具维修工单表列表
        /// </summary>
        /// <returns></returns>
        [Route("Sb_MouldRepairWorkBill/GetMouldRepairWorkBillList")]
        [HttpGet]
        public object GetMouldRepairWorkBillList(string sWhere,string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = Sc_MouldRepairWorkBillList_s(sWhere);
                //添加列名
                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列对象的列名
                }
                //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;
                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;
            }
        }
        #region sql语句
        public static DataSet Sc_MouldRepairWorkBillList_s(string sWhere)
        {
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairWorkBillList where 1=1 " + sWhere+ " order by hmainid desc", "h_v_Sc_MouldRepairWorkBillList");
            }
            else
            {
                string sql1 = "select * from h_v_Sc_MouldRepairWorkBillList where 1 = 1 ";
                string sql = sql1 + sWhere + "order by hmainid desc";
                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList");
            }
        }
        #endregion
        /// <summary>
@@ -4052,6 +4206,7 @@
        #endregion
        #region 模具维修记录单
        #region 模具维修记录单保存/编辑
        /// <summary>
@@ -4092,7 +4247,7 @@
                lsmain = oListModels.getObjectByJson_Gy_MouldRepairWorkBillMain(msg2);
                foreach (Model.ClsSb_MouldRepairWorkBillMain oItem in lsmain)
                {
                    //oItem.HMaker = "";
                    oItem.HMaker = msg4;
                    UserName = msg4;  //制单人
                    oItem.HBillType = "3807";
                    oItem.HBillSubType = "3807";
@@ -4511,6 +4666,309 @@
        }
        #endregion
        #region 模具维修记录单保存/编辑
        /// <summary>
        /// 保存模具维修单
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        [Route("Sb_MouldRepairWorkBill/SaveGetMouldRepairWorkBill_PDA")]
        [HttpPost]
        public object SaveGetMouldRepairWorkBill_PDA([FromBody] JObject msg)
        {
            var _value = msg["msg"].ToString();
            string msg1 = _value.ToString();
            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string msg4 = sArray[2].ToString();
            string UserName = "";
            ListModels oListModels = new ListModels();
            try
            {
                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Edit", 1, false, msg4))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DAL.ClsSb_MouldRepairWorkBill oBill = new DAL.ClsSb_MouldRepairWorkBill();
                List<Model.ClsSb_MouldRepairWorkBillMain> lsmain = new List<Model.ClsSb_MouldRepairWorkBillMain>();
                msg2 = msg2.Replace("\\", "");
                msg2 = msg2.Replace("\n", "");  //\n
                lsmain = oListModels.getObjectByJson_Gy_MouldRepairWorkBillMain(msg2);
                foreach (Model.ClsSb_MouldRepairWorkBillMain oItem in lsmain)
                {
                    oItem.HMaker = msg4;
                    UserName = msg4;  //制单人
                    oItem.HBillType = "3807";
                    oItem.HBillSubType = "3807";
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "保存失败!没有单据日期,无法保存!";
                        objJsonResult.data = 1;
                        return objJsonResult;
                    }
                    oBill.omodel = oItem;
                }
                //表体数据
                //按 },{来拆分数组 //去掉【和】
                msg3 = msg3.Substring(1, msg3.Length - 2);
                msg3 = msg3.Replace("\\", "");
                msg3 = msg3.Replace("\n", "");  //\n
                //msg2 = msg2.Replace("'", "’");
                List<Model.ClsSb_MouldRepairWorkBillSub> ls = new List<Model.ClsSb_MouldRepairWorkBillSub>();
                ls = oListModels.getObjectByJson_Gy_MouldRepairWorkBillSub(msg3);
                int i = 0;
                foreach (Model.ClsSb_MouldRepairWorkBillSub oItem in ls)
                {
                    i++;
                    oItem.HEntryID = i;
                    oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItem.HCloseType = false;   //关闭类型
                    oItem.HRelationQty = 0;     //关联数量
                    oBill.DetailColl.Add(oItem);
                }
                //保存
                //保存完毕后处理
                bool bResult;
                if (oBill.omodel.HInterID == 0)
                {
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else
                {
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                }
                if (bResult)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "保存失败!" + e.ToString();
                objJsonResult.data = 1;
                return objJsonResult;
            }
        }
        #endregion
        #region 模具维修记录表列表
        [Route("Sb_MouldRepairWorkBill/GetMouldRepairWorkBillList")]
        [HttpGet]
        public object GetMouldRepairWorkBillList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = Sc_MouldRepairWorkBillList_s(sWhere);
                //添加列名
                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列对象的列名
                }
                //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;
                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;
            }
        }
        public static DataSet Sc_MouldRepairWorkBillList_s(string sWhere)
        {
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairWorkBillList where 1=1 " + sWhere + " order by hmainid desc", "h_v_Sc_MouldRepairWorkBillList");
            }
            else
            {
                string sql1 = "select * from h_v_Sc_MouldRepairWorkBillList where 1 = 1 ";
                string sql = sql1 + sWhere + "order by hmainid desc";
                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList");
            }
        }
        #endregion
        #region 模具维修记录表分页列表
        [Route("Sb_MouldRepairWorkBill/GetMouldRepairWorkBillListPage")]
        [HttpGet]
        public object GetMouldRepairWorkBillListPage(string sWhere, string user, int page, int size)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldRepairWorkBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldRepairWorkBillList");
                }
                else
                {
                    sWhere = sWhere.Replace("'", "''");
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldRepairWorkBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldRepairWorkBillList");
                }
                //添加列名
                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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception ex)
            {
                objJsonResult.code = CodeConstant.FAIL;
                objJsonResult.count = CountConstant.FAIL;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 模具维修记录表列表
        [Route("Sb_MouldRepairWorkBill/GetMouldRepairWorkBill_PDA")]
        [HttpGet]
        public object GetMouldRepairWorkBill_PDA(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = Sc_MouldRepairWorkBillList_PDA(sWhere);
                //添加列名
                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 ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public static DataSet Sc_MouldRepairWorkBillList_PDA(string sWhere)
        {
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairWorkBillList_PDA where 1=1 " + sWhere + " order by hmainid desc", "h_v_Sc_MouldRepairWorkBillList_PDA");
            }
            else
            {
                string sql1 = "select * from h_v_Sc_MouldRepairWorkBillList_PDA where 1 = 1 ";
                string sql = sql1 + sWhere + "order by hmainid desc";
                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList_PDA");
            }
        }
        #endregion
        #endregion
        #region 器具维修记录统计分析 
        /// <summary>
        /// 器具维修记录统计分析 列表
@@ -4563,7 +5021,7 @@
        }
        #endregion
        #region 模具验收单
        #region 模具维修验收单保存/编辑
        /// <summary>
@@ -4852,6 +5310,7 @@
        }
        #endregion
        #endregion
        #region 模具故障登记表 
@@ -4901,19 +5360,6 @@
                    //oItem.HInnerBillNo = "";  //  --内部单据号
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));
                    //oItem.HEquipID = 0;    //设备ID(Gy_EquipMent)
                    //oItem.HPeriod = 0;
                    //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));  //  --维修日期
                    //oItem.HCheckResult = "";     //验收结论--(正常,异常)
                    //oItem.HEmpID = 0;           //验收人(Gy_Employee)
                    //oItem.HManagerID = 0;      //负责人(Gy_Employee)
                    //oItem.HDeptID = 0;        //验收部门(Gy_Department)
                    //oItem.HExplanation = "";  //摘要(故障描述)
                    //oItem.HRemark = "";       //备注
                    //oItem.HMainSourceInterID = oItem.HInterID;
                    //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo);
                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
                    {
                        objJsonResult.code = "0";
@@ -4939,22 +5385,11 @@
                    i++;
                    oItemSub.HEntryID = i;
                    //oItemSub.HRepairCheckID = 0;   //验收项目ID
                    //oItemSub.HRepairCheckContent = ""; //验收内容
                    //oItemSub.HManagerID = 0;   //负责人ID
                    //oItemSub.HCloseMan = "";       //行关闭
                    oItemSub.HCloseType = false;   //关闭类型
                    //oItemSub.HRemark = "";         //备注
                    oItemSub.HSourceInterID = 0;     // 源单主内码
                    oItemSub.HSourceEntryID = 0;   //源单子内码
                                                   //oItemSub.HSourceBillNo = "";  //源单单号
                                                   //oItemSub.HSourceBillType = ""; //源单类型
                                                   //oItemSub.HRelationQty = 0;     //关联数量
                                                   //oItemSub.HRelationMoney = 0;   //关联金额
                                                   //oItemSub.HRepairID = 0;       //维修项目
                                                   //oItemSub.HRepairExplanation ="";   //维修要求
                    //oItemSub.HMoney = 0;        //维修费用
                    oBill.DetailColl.Add(oItemSub);
                }
@@ -4963,7 +5398,6 @@
                bool bResult;
                if (oBill.omodel.HInterID == 0)
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                }
                else
@@ -4975,7 +5409,6 @@
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
                    //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单");
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
@@ -5140,6 +5573,68 @@
            }
        }
        #endregion
        #region 模具故障登记单_PDA
        [Route("Sc_MouldConkBookBill/GetMouldConkBookBillList_PDA")]
        [HttpGet]
        public object GetMouldConkBookBillList_PDA(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无保存权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ds = Sc_MouldConkBookBillList_PDA(sWhere);
                //添加列名
                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 ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        public static DataSet Sc_MouldConkBookBillList_PDA(string sWhere)
        {
            DataSet ds;
            if (sWhere == null || sWhere.Equals(""))
            {
                ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldConkBookBillList_PDA where 1=1 " + sWhere + " order by hmainid desc", "h_v_Sc_MouldConkBookBillList_PDA");
            }
            else
            {
                string sql1 = "select * from h_v_Sc_MouldConkBookBillList_PDA where 1 = 1 ";
                string sql = sql1 + sWhere + "order by 日期 desc";
                ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldConkBookBillList_PDA");
            }
            return ds;
        }
        #endregion
        #endregion
@@ -5162,7 +5657,7 @@
            string msg3 = sArray[1].ToString();
            string msg4 = sArray[2].ToString();
            string msg5 = sArray[3].ToString();
            string msg6 = sArray[4].ToString();
            string UserName = "";
            ListModels oListModels = new ListModels();
@@ -5196,6 +5691,7 @@
                    //oItem.HBillNo = "";
                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --日期
                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
                    oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month);
                    //oItem.HMakeDate = "";
                    //oItem.HYear = "";
                    //oItem.HPeriod = "";
@@ -5282,6 +5778,32 @@
                    oBill.DetailColl.Add(oItemSub);
                }
                //表体数据
                //按 },{来拆分数组 //去掉【和】
                //如果是编辑就允许保存,否则不允许
                if (oBill.omodel.HInterID != 0)
                {
                    msg6 = msg6.Substring(1, msg6.Length - 2);
                    msg6 = msg6.Replace("\\", "");
                    msg6 = msg6.Replace("\n", "");
                    List<Model.ClsSc_MouldMaintainPlanBillSub_Plan> lss = new List<Model.ClsSc_MouldMaintainPlanBillSub_Plan>();
                    lss = oListModels.getObjectByJson_Sc_MouldMaintainPlanBillSub_Plan(msg6);
                    int l = 0;
                    foreach (Model.ClsSc_MouldMaintainPlanBillSub_Plan oItem in lss)
                    {
                        l++;
                        oItem.HEntryID = l;
                        oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                        oItem.HCloseType = false;   //关闭类型
                        oItem.HSourceInterID = 0;     // 源单主内码
                        oItem.HSourceEntryID = 0;   //源单子内码
                        oItem.HRelationQty = 0;     //关联数量
                        oBill.DetailCol2.Add(oItem);
                    }
                }
                //保存
                //保存完毕后处理
                bool bResult;
@@ -5597,7 +6119,7 @@
                foreach (Model.ClsSc_MouldMaintainBillMain oItem in lsmain)
                {
                    UserName = oItem.HMaker;  //制单人
                    DBUtility.ClsPub.CurUserName = UserName;
                    DBUtility.ClsPub.CurUserName = msg5;
                    oItem.HBillType = "3819";
                    oItem.HBillSubType = "3819";
@@ -7628,6 +8150,62 @@
        #endregion
        #region 模具处理出库单分页列表
        [Route("Sc_MouldScrapOutHouseBill/page")]
        [HttpGet]
        public object Sc_MouldScrapOutHouseBillPage(string sWhere, string user, int page, int size)
        {
            DataSet ds;
            try
            {
                List<object> columnNameList = new List<object>();
                //权限
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldScrapOutBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                sWhere = sWhere.Replace("'", "''");
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldScrapOutHouseBillList " + page + "," + size + ",''", "h_p_Sc_MouldScrapOutHouseBillList");
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldScrapOutHouseBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_Sc_MouldScrapOutHouseBillList");
                }
                //添加列名
                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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                objJsonResult.Message = "Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = ds.Tables[0];
                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("Sc_MouldScrapOutHouseBill/Sc_MouldScrapOutHouseBillListCheckDetai")]
        [HttpGet]
@@ -8261,6 +8839,22 @@
            DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill();
            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
            {
                if (oBill.omodel.HCloseMan.Trim() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已关闭!不能再次审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oBill.omodel.HDeleteMan.Trim() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已作废!不能再次审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (flag == 1)
                {
                    if (oBill.omodel.HBillStatus == 2)
@@ -8284,7 +8878,7 @@
                }
                else
                {
                    if (oBill.omodel.HBillStatus == 1)
                    if (oBill.omodel.HBillStatus != 2)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
@@ -8315,6 +8909,152 @@
            }
        }
        #endregion
        #region 器具处理出库单 关闭/反关闭
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">关闭(0),反关闭(1)</param>
        /// <param name="CurUserName">关闭人</param>
        /// <returns></returns>
        [Route("Sc_MouldScrapOutHouseBill/CloseSc_MouldScrapOutHouseBill")]
        [HttpGet]
        public object CloseSc_MouldScrapOutHouseBill(int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Sc_MouldScrapOutBill_Close";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "关闭失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsSc_MouldProdOutBill oBill = new DAL.ClsSc_MouldProdOutBill();              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HChecker.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据未审核!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不能再次关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未关闭!不需要反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行需要进行的关闭/反关闭操作
                if (IsAudit == 0) //关闭提交
                {
                    //关闭提交
                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (IsAudit == 1) //反关闭提交
                {
                    //反关闭提交
                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
@@ -8370,6 +9110,68 @@
        }
        #endregion
        #region 模具退库单列表 查询-分页
        /// <summary>
        /// 返回应收单列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Sc_MouldProdBackBill/list_byPage")]
        [HttpGet]
        public object getSc_MouldProdBackBill_byPage(string sWhere, string user, string Organization, int page, int size)
        {
            try
            {
                Log.LogInfo("成功!"); //记录提交数据
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdBackBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Log.LogInfo("有权限");
                LogService.Write(sWhere + ";" + Organization);
                string sql = "";
                if (sWhere == null || sWhere.Equals(""))
                {
                    sWhere = " and 库存组织='" + Organization + "'";
                    sWhere = sWhere.Replace("'", "''");
                    sql = "exec h_p_Sc_MouldProdBackBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'";
                    Log.LogInfo(sql);
                    ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_p_Sc_MouldProdBackBillList_Query");
                }
                else
                {
                    sWhere += " and 库存组织='" + Organization + "'";
                    sWhere = sWhere.Replace("'", "''");
                    sql = "exec h_p_Sc_MouldProdBackBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'";
                    Log.LogInfo(sql);
                    ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_p_Sc_MouldProdBackBillList_Query");
                }
                objJsonResult.code = "1";
                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                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
        #region[模具退库单编辑时获取表头数据]
@@ -8868,6 +9670,22 @@
            DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill();
            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
            {
                if (oBill.omodel.HCloseMan.Trim() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已关闭!不能再次审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oBill.omodel.HDeleteMan.Trim() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已作废!不能再次审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (flag == 1)
                {
                    if (oBill.omodel.HBillStatus == 2)
@@ -8891,7 +9709,7 @@
                }
                else
                {
                    if (oBill.omodel.HBillStatus == 1)
                    if (oBill.omodel.HBillStatus != 2)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
@@ -8922,6 +9740,153 @@
            }
        }
        #endregion
        #region 器具领用退库单 关闭/反关闭
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">关闭(0),反关闭(1)</param>
        /// <param name="CurUserName">关闭人</param>
        /// <returns></returns>
        [Route("Sc_MouldProdBackBill/CloseSc_MouldProdBackBill")]
        [HttpGet]
        public object CloseSc_MouldProdBackBill(int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Sc_MouldProdBackBill_Close";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "关闭失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsSc_MouldProdBackBill oBill = new DAL.ClsSc_MouldProdBackBill();              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HChecker.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据未审核!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不能再次关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未关闭!不需要反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行需要进行的关闭/反关闭操作
                if (IsAudit == 0) //关闭提交
                {
                    //关闭提交
                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (IsAudit == 1) //反关闭提交
                {
                    //反关闭提交
                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region 模具领用单
@@ -8977,6 +9942,63 @@
        }
        #endregion
        #region 模具领用单列表 查询-分页
        /// <summary>
        /// 返回应收单列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Sc_MouldProdOutBill/list_byPage")]
        [HttpGet]
        public object getSc_MouldProdOutBill_byPage(string sWhere, string user, string Organization, int page, int size)
        {
            try
            {
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdOutBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql = "";
                if (sWhere == null || sWhere.Equals(""))
                {
                    sWhere = " and 库存组织='" + Organization + "'";
                    sWhere = sWhere.Replace("'", "''");
                    sql = "exec h_p_Sc_MouldProdOutHouseBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'";
                    Log.LogInfo(sql);
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldProdOutHouseBillList_Query");
                }
                else
                {
                    sWhere += " and 库存组织='" + Organization + "'";
                    sWhere = sWhere.Replace("'", "''");
                    sql = "exec h_p_Sc_MouldProdOutHouseBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'";
                    Log.LogInfo(sql);
                    ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldProdOutHouseBillList_Query");
                }
                objJsonResult.code = "1";
                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
                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
        #region[模具领用单编辑时获取表头数据]
@@ -9509,8 +10531,32 @@
            DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill();
            if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))
            {
                if (oBill.omodel.HCloseMan.Trim() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已关闭!不能再次审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (oBill.omodel.HDeleteMan.Trim() != "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据已作废!不能再次审核!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (flag == 1)
                {
                    if (oBill.omodel.HChecker.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已审核!不能再次审核!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HBillStatus == 2)
                    {
                        objJsonResult.code = "0";
@@ -9532,7 +10578,7 @@
                }
                else
                {
                    if (oBill.omodel.HBillStatus == 1)
                    if (oBill.omodel.HBillStatus != 2)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
@@ -9563,6 +10609,153 @@
            }
        }
        #endregion
        #region 器具领用出库单 关闭/反关闭
        /// <summary>
        /// </summary>
        /// <param name="HInterID">单据ID</param>
        /// <param name="IsAudit">关闭(0),反关闭(1)</param>
        /// <param name="CurUserName">关闭人</param>
        /// <returns></returns>
        [Route("Sc_MouldProdOutBill/CloseSc_MouldProdOutBill")]
        [HttpGet]
        public object CloseSc_MouldProdOutBill(int HInterID, int IsAudit, string CurUserName)
        {
            string ModRightNameCheck = "Sc_MouldProdOutBill_Close";
            DBUtility.ClsPub.CurUserName = CurUserName;
            try
            {
                //检查权限
                if (!DBUtility.ClsPub.Security_Log_second(ModRightNameCheck, 1, false, CurUserName))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "关闭失败!无权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //HInterID数据判断
                if (HInterID <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID小于0!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                Int64 lngBillKey = 0;
                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //对HInterID进行类型的转换
                DAL.ClsSc_MouldProdOutBill oBill = new DAL.ClsSc_MouldProdOutBill();              //实例化单据操作类,用于进行相关操作
                //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作
                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //根据HInterID获取该单据的数据
                {
                    if (oBill.omodel.HDeleteMan.Trim() != "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据已作废!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (oBill.omodel.HChecker.Trim() == "")
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据未审核!不能进行关闭!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (IsAudit == 0)  //关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已关闭!不能再次关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                    if (IsAudit == 1) //反关闭判断
                    {
                        if (oBill.omodel.HCloseMan.Trim() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未关闭!不需要反关闭!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //进行需要进行的关闭/反关闭操作
                if (IsAudit == 0) //关闭提交
                {
                    //关闭提交
                    if (oBill.CloseBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                if (IsAudit == 1) //反关闭提交
                {
                    //反关闭提交
                    if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                    {
                        objJsonResult.code = "1";
                        objJsonResult.count = 1;
                        objJsonResult.Message = "反关闭成功";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    else
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "反关闭失败!原因:" + DBUtility.ClsPub.sExeReturnInfo;
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                }
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "关闭失败或者反关闭失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region 模具寿命调整单
@@ -10644,7 +11837,7 @@
                return objJsonResult;
            }
        }
        #endregion
        #endregion
    }
}