yangle
2024-02-02 c0cee04d997030777bd85d198d82cc2567f4773f
WebAPI/Controllers/Sc_MouldRepairInBillListController.cs
@@ -1,9 +1,11 @@
using Newtonsoft.Json.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections.Generic;
using System.Data;
using System.Web.Http;
using ViewAPI;
using WebAPI.Models;
namespace WebAPI.Controllers
{
@@ -18,6 +20,7 @@
        public DataSet ds = new DataSet();
        public WebServer webserver = new WebServer();
        public SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
        public DAL.ClsSc_ICMOBill BillOld = new DAL.ClsSc_ICMOBill();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        public DAL.ClsSc_MouldScrapInBill BillNew0 = new DAL.ClsSc_MouldScrapInBill();   //模具报废入库对应单据类
@@ -187,6 +190,8 @@
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
@@ -197,22 +202,31 @@
                }
                ds = Sc_MouldMaintainBillList_s(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                //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)
            {
@@ -231,12 +245,12 @@
        {
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn("select *  from h_v_Sc_MouldMaintain order by 日期 desc", "h_v_Sc_MouldMaintain");
                return new SQLHelper.ClsCN().RunProcReturn("select *  from h_v_Sc_MouldMaintain order by hmainid desc", "h_v_Sc_MouldMaintain");
            }
            else
            {
                string sql1 = "select * from h_v_Sc_MouldMaintain where 1 = 1 ";
                string sql = sql1 + sWhere + "order by 日期 desc";
                string sql = sql1 + sWhere + "order by hmainid desc";
                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldMaintain");
            }
@@ -266,22 +280,14 @@
                }
                ds = Sc_MouldDotCheckPlanBillList_s(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception ex)
            {
@@ -298,7 +304,7 @@
        public static DataSet Sc_MouldDotCheckPlanBillList_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldDotCheckPlanBillList order by 日期 desc", "h_v_Sc_MouldDotCheckPlanBillList");
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldDotCheckPlanBillList where 1=1 "+sWhere+ " order by hmainid desc", "h_v_Sc_MouldDotCheckPlanBillList");
        }
        #endregion
@@ -312,6 +318,7 @@
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
@@ -321,22 +328,23 @@
                    return objJsonResult;
                }
                ds = Sc_MouldDotCheckBillList_s(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception ex)
            {
@@ -353,7 +361,7 @@
        public static DataSet Sc_MouldDotCheckBillList_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldDotCheckBillList where 1=1 " + sWhere + "order by 日期 desc", "h_v_Sc_MouldDotCheckBillList");
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldDotCheckBillList where 1=1 " + sWhere + "order by hmainid desc", "h_v_Sc_MouldDotCheckBillList");
        }
        #endregion
@@ -427,22 +435,23 @@
                }
                ds = Sc_MouldMaintainPlanBillList_s(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
                //}
                //else
                //{
                //objJsonResult.code = "0";
                //objJsonResult.count = 0;
                //objJsonResult.Message = "无数据";
                //objJsonResult.data = null;
                //return objJsonResult;
                //}
            }
            catch (Exception ex)
            {
@@ -459,7 +468,7 @@
        public static DataSet Sc_MouldMaintainPlanBillList_s(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldMaintainPlanBillList where 1=1 "+sWhere+" order by 日期 desc", "h_v_Sc_MouldMaintainPlanBillList");
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldMaintainPlanBillList where 1=1 "+sWhere+ " order by hmainid desc", "h_v_Sc_MouldMaintainPlanBillList");
        }
        #endregion
@@ -474,6 +483,7 @@
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
@@ -484,10 +494,20 @@
                }
                ds = Sc_MouldConkBookBillList_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列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception ex)
@@ -500,6 +520,58 @@
            }
        }
        #region 器具故障记录统计分析
        /// <summary>
        /// 器具维修记录统计分析 列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Sb_MouldRepairWorkBill/Sc_MouldConkBookBillMain")]
        [HttpGet]
        public object Sc_MouldConkBookBillMain(string DateYear, string HType, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (DateYear == null || DateYear.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "请选择有效年份";
                    return objJsonResult;
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldConkBookBillMain'" + DateYear + "','" + HType + "'", "h_p_Sc_MouldConkBookBillMain");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region sql语句
@@ -508,7 +580,7 @@
            DataSet ds;
            if (sWhere == null || sWhere.Equals(""))
            {
                ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldConkBookBillList order by 日期 desc" + sWhere, "h_v_Sc_MouldConkBookBillList");
                ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldConkBookBillList where 1=1 " + sWhere+ " order by hmainid desc", "h_v_Sc_MouldConkBookBillList");
            }
            else
            {
@@ -542,6 +614,7 @@
                }
                ds = Sc_MouldRepairCheckBillList_s(sWhere);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "返回记录成功!";
@@ -567,12 +640,12 @@
            DataSet ds;
            if (sWhere == null || sWhere.Equals(""))
            {
                ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairCheckBillList_Edit order by 日期 desc" + sWhere, "h_v_Sc_MouldRepairCheckBillList_Edit");
                ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairCheckBillList_Edit where 1=1" + sWhere+ " order by hmainid desc", "h_v_Sc_MouldRepairCheckBillList_Edit");
            }
            else
            {
                string sql1 = "select * from h_v_Sc_MouldRepairCheckBillList_Edit where 1 = 1 ";
                string sql = sql1 + sWhere + "order by 日期 desc";
                string sql = sql1 + sWhere + "order by hmainid desc";
                ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairCheckBillList_Edit");
            }
            return ds;
@@ -647,6 +720,7 @@
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
@@ -657,22 +731,32 @@
                }
                ds = Sc_MouldRepairWorkBillList_s(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                //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)
            {
@@ -691,12 +775,12 @@
        {
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairWorkBillList order by 日期 desc" + sWhere, "h_v_Sc_MouldRepairWorkBillList");
                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 日期 desc";
                string sql = sql1 + sWhere + "order by hmainid desc";
                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList");
            }
        }
@@ -807,35 +891,36 @@
        /// <returns></returns>
        [Route("Kf_MoveStockBill/GetMoveStockBillList")]
        [HttpGet]
        public object GetMoveStockBillList(string sWhere)
        public object GetMoveStockBillList(string sWhere,string user)
        {
            try
            {
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_IF_MoveStockBillList order by 日期 desc", "h_v_IF_MoveStockBillList");
                }
                else
                {
                    string sql = "select * from h_v_IF_MoveStockBillList where 1=1 " + sWhere+ "order by 日期 desc";
                    ds = oCN.RunProcReturn(sql, "h_v_IF_MoveStockBillList");
                }
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                //判断是否有查询权限
                if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockBillQuery", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.Message = "无查询权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_IF_MoveStockBillList order by hmainid desc", "h_v_IF_MoveStockBillList");
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                    string sql = "select * from h_v_IF_MoveStockBillList where 1=1 " + sWhere+ "order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_IF_MoveStockBillList");
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception ex)
            {
@@ -846,6 +931,46 @@
                return objJsonResult;
            }
        }
        #region 调拨单  删除
        [Route("Kf_MoveStockBill/DelteteGetMoveStockBill")]
        [HttpGet]
        public object DelteteGetMoveStockBill(string HInterID, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        /// 销售出库单列表
@@ -868,22 +993,23 @@
                }
                ds = Sc_GetSellOutBillList(sWhere);
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
                //}
                //else
                //{
                //objJsonResult.code = "0";
                //objJsonResult.count = 0;
                //objJsonResult.Message = "无数据";
                //objJsonResult.data = null;
                //return objJsonResult;
                //}
            }
            catch (Exception ex)
            {
@@ -900,17 +1026,103 @@
        /// <returns></returns>
        [Route("Kf_SellOutBill/DeltetSellOutBill")]
        [HttpGet]
        public object DeltetSeOutStockBackBill(string HInterID)
        public object DeltetSeOutStockBackBill(string HInterID,string user)
        {
            try
            {
                DAL.ClsKf_SellOutBill BillOld = new DAL.ClsKf_SellOutBill();
                string s = "";
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_SellOutBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (BillOld.ShowBill(long.Parse(HInterID), ref s) == false)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "此单据有误!";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                //判断是否可编辑
                if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "此单据已经被审核,不允许删除!";
                    objJsonResult.data = 1;
                    return objJsonResult;
                }
                //删除前控制=========================================
                string sql1 = "exec h_p_Kf_SellOutBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql1, "h_p_Kf_SellOutBill_BeforeDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //==================================================================================
                oCN.BeginTran();
                oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
                //销售出库删除回填销售订单关联数量
                //oCN.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellOut_Delete " + HInterID);
                //oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
                //oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
                string sql = "exec h_p_WMS_ICStockBillAndWMS_Delete " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','1205'";
                oCn.RunProc(sql);
                //删除后控制==================================================================================
                string sql2 = "exec h_p_Kf_SellOutBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'";
                ds = oCN.RunProcReturn(sql2, "h_p_Kf_SellOutBill_AfterDelCtrl");
                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
                {
                    s = "删除后判断失败,请与网络管理人员联系";
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + s;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
                {
                    s = ds.Tables[0].Rows[0]["HRemark"].ToString();
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "删除失败!原因:" + s;
                    objJsonResult.data = null;
                    oCN.RollBack();
                    return objJsonResult;
                }
                //==============================================================================================
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功!";
                objJsonResult.Message = "您已删除单据号为" + BillOld.omodel.HBillNo + "的销售出库单!";
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -929,7 +1141,14 @@
        public static DataSet Sc_GetSellOutBillList(string sWhere)
        {
            return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_SellOutBillList order by 日期 desc", "h_v_IF_SellOutBillList");
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_SellOutBillList order by 制单日期 desc,单据号 desc", "h_v_IF_SellOutBillList");
            }
            else
            {
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_SellOutBillList where 1=1 " + sWhere + " order by 制单日期 desc,单据号 desc", "h_v_IF_SellOutBillList");
            }
        }
        #endregion
@@ -956,30 +1175,30 @@
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Kf_OtherOutBillList where 1=1 order by 日期 desc", "h_v_Kf_OtherOutBillList");
                    ds = oCN.RunProcReturn("select * from h_v_Kf_OtherOutBillList where 1=1 order by hmainid desc", "h_v_Kf_OtherOutBillList");
                }
                else
                {
                    string sql = "select * from h_v_Kf_OtherOutBillList where 1 = 1 " + sWhere+ " order by 日期 desc";
                    string sql = "select * from h_v_Kf_OtherOutBillList where 1 = 1 " + sWhere+ " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Kf_OtherOutBillList");
                }
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
                //}
                //else
                //{
                //objJsonResult.code = "0";
                //objJsonResult.count = 0;
                //objJsonResult.Message = "无数据";
                //objJsonResult.data = null;
                //return objJsonResult;
                //}
            }
            catch (Exception ex)
            {
@@ -990,6 +1209,273 @@
                return objJsonResult;
            }
        }
        #region 其他出库单  删除
        [Route("Kf_OtherOutBill/DelteteGetOtherOutBill")]
        [HttpGet]
        public object DelteteGetOtherOutBill(string HInterID, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_OtherOutBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限删除!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                oCN.BeginTran();
                oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID);
                oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID);
                oCN.Commit();
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "删除成功!";
                objJsonResult.data = null;
                return objJsonResult;
            }
            catch (Exception e)
            {
                oCN.RollBack();
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 其它出库单审核/反审核功能
        [Route("Kf_OtherOutBill/CheckKf_OtherOutBill")]
        [HttpGet]
        public object CheckKf_OtherOutBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_OtherOutBill_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 = "Kf_ICStockBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 审核  2  反审核
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.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("Kf_OtherOutBill/CloseKf_OtherOutBill")]
        [HttpGet]
        public object CloseKf_OtherOutBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_OtherOutBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Kf_ICStockBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 关闭  2  反关闭
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.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
        /// <summary>
@@ -1114,29 +1600,21 @@
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_IF_ProductInBillList where 1=1  order by 日期 desc", "h_v_IF_ProductInBillList");
                    ds = oCN.RunProcReturn("select * from h_v_IF_ProductInBillList where 1=1  order by hmainid desc", "h_v_IF_ProductInBillList");
                }
                else
                {
                    string sql = "select * from h_v_IF_ProductInBillList where 1 = 1 " + sWhere + " order by 日期 desc";
                    string sql = "select * from h_v_IF_ProductInBillList where 1 = 1 " + sWhere + " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_IF_ProductInBillList");
                }
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception ex)
            {
@@ -1147,7 +1625,37 @@
                return objJsonResult;
            }
        }
        #region 条码明细
        [Route("Kf_ICStockBillSub_WMS/Kf_ICStockBillSub_WMS_List")]
        [HttpGet]
        public object Kf_ICStockBillSub_WMS_List(string sWhere, string user)
        {
            try
            {
                ds = oCN.RunProcReturn(@"Select m.HNumber 物料代码,m.HName 物料名称,m.HModel 规格型号
                                    ,wms.HBarCode 条码,wms.HQty 数量,w.HNumber 仓库代码,w.HName 仓库名称 from Kf_ICStockBillSub_WMS wms
                                    left join h_v_IF_Material m on wms.HMaterID = m.HItemID
                                    left join h_v_IF_Warehouse w on wms.HWhID = w.HItemID where 1=1 "+ sWhere, "Kf_ICStockBillSub_WMS");
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception ex)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + ex.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        /// <summary>
        ///产品入库单删除功能
        /// </summary>
@@ -1178,8 +1686,716 @@
                return objJsonResult;
            }
        }
        #region 生产入库单审核/反审核功能
        [Route("Kf_ProductInBill/CheckKf_ProductInBill")]
        [HttpGet]
        public object CheckKf_ProductInBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_ProductInBill_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 = "Kf_ICStockBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 审核  2  反审核
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.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("Kf_ProductInBill/CloseKf_ProductInBill")]
        [HttpGet]
        public object CloseKf_ProductInBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_ProductInBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Kf_ICStockBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 关闭  2  反关闭
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.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
        #region 生产入库单 作废/反作废功能
        [Route("Kf_ProductInBill/DropKf_ProductInBill")]
        [HttpGet]
        public object DropKf_ProductInBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有作废权限
                if (!DBUtility.ClsPub.Security_Log("Kf_ProductInBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限作废!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Kf_ICStockBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 作废  2  反作废
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据不存在!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不能进行作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不需要再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //作废单据
                        if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不能进行作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未作废!不需要再反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //反作废单据
                        if (!BillOld.AbandonCancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "反作废失败!原因:" + ClsPub.sExeReturnInfo;
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                oCN.Commit();//提交事务
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "执行成功!";
                objJsonResult.data = null;
                return objJsonResult; ;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "执行失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 其它入库单审核/反审核功能
        [Route("Kf_OtherInBill/CheckKf_OtherInBill")]
        [HttpGet]
        public object CheckKf_OtherInBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_OtherInBill_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 = "Kf_ICStockBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 审核  2  反审核
                if (Type == 1)
                {
                    //判断单据是否已经审核
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.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("Kf_OtherInBill/CloseKf_OtherInBill")]
        [HttpGet]
        public object CloseKf_OtherInBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有删除权限
                if (!DBUtility.ClsPub.Security_Log("Kf_OtherInBill_Close", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限关闭!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Kf_ICStockBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 关闭  2  反关闭
                if (Type == 1)
                {
                    //判断单据是否已经关闭
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.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
        #region 其他入库单 作废/反作废功能
        [Route("Kf_OtherInBill/DropKf_OtherInBill")]
        [HttpGet]
        public object DropKf_OtherInBill(string HInterID, int Type, string user)
        {
            try
            {
                //判断是否有作废权限
                if (!DBUtility.ClsPub.Security_Log("Kf_OtherInBill_Drop", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无权限作废!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                if (string.IsNullOrWhiteSpace(HInterID))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "HInterID为空!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                ClsPub.CurUserName = user;
                BillOld.MvarItemKey = "Kf_ICStockBillMain";
                oCN.BeginTran();//开始事务
                //Type 1 作废  2  反作废
                if (Type == 1)
                {
                    //判断单据是否已经作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds == null || ds.Tables[0].Rows.Count == 0)
                    {
                        objJsonResult.code = "0";
                        objJsonResult.count = 0;
                        objJsonResult.Message = "单据不存在!";
                        objJsonResult.data = null;
                        return objJsonResult;
                    }
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不能进行作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] != null && ds.Tables[0].Rows[0]["HDeleteMan"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已作废!不需要再作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //作废单据
                        if (!BillOld.Cancelltion(Int64.Parse(HInterID), ref ClsPub.sExeReturnInfo))
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 1;
                            objJsonResult.Message = "作废失败!原因:" + ClsPub.sExeReturnInfo;
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                    }
                }
                else
                {
                    //判断单据是否已经反作废
                    DataSet ds;
                    string sql = "select * from " + BillOld.MvarItemKey + " where HinterID = " + HInterID;
                    ds = oCN.RunProcReturn(sql, BillOld.MvarItemKey);
                    if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["HChecker"] != null && ds.Tables[0].Rows[0]["HChecker"].ToString() != "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据已审核!不能进行作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        if (ds.Tables[0].Rows[0]["HDeleteMan"] == null || ds.Tables[0].Rows[0]["HDeleteMan"].ToString() == "")
                        {
                            objJsonResult.code = "0";
                            objJsonResult.count = 0;
                            objJsonResult.Message = "单据未作废!不需要再反作废!";
                            objJsonResult.data = null;
                            return objJsonResult;
                        }
                        //反作废单据
                        if (!BillOld.AbandonCancelltion(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
        /// <summary>
        /// 其他入库单列表
@@ -1203,29 +2419,30 @@
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Kf_OtherInBillList where 1=1  order by 日期 desc", "h_v_Kf_OtherInBillList");
                    ds = oCN.RunProcReturn("select * from h_v_Kf_OtherInBillList where 1=1  order by hmainid desc", "h_v_Kf_OtherInBillList");
                }
                else
                {
                    string sql = "select * from h_v_Kf_OtherInBillList where 1 = 1 " + sWhere+ " order by 日期 desc";
                    string sql = "select * from h_v_Kf_OtherInBillList where 1 = 1 " + sWhere+ " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Kf_OtherInBillList");
                }
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
                //}
                //else
                //{
                //objJsonResult.code = "0";
                //objJsonResult.count = 0;
                //objJsonResult.Message = "无数据";
                //objJsonResult.data = null;
                //return objJsonResult;
                //}
            }
            catch (Exception ex)
            {
@@ -1248,7 +2465,7 @@
            try
            {
                //判断是否有查询权限
                if (DBUtility.ClsPub.Security_Log("Kf_EntrustInBillQuery", 1, false, user))
                if (!DBUtility.ClsPub.Security_Log("Kf_EntrustInBillQuery", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
@@ -1258,29 +2475,30 @@
                }
                if (sWhere == null || sWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select * from h_v_Kf_EntrustInBillList where 1=1", "h_v_Kf_EntrustInBillList");
                    ds = oCN.RunProcReturn("select * from h_v_Kf_EntrustInBillList where 1=1 order by hmainid desc", "h_v_Kf_EntrustInBillList");
                }
                else
                {
                    string sql = "select * from h_v_Kf_EntrustInBillList where 1 = 1 " + sWhere;
                    string sql = "select * from h_v_Kf_EntrustInBillList where 1 = 1 " + sWhere+ " order by hmainid desc";
                    ds = oCN.RunProcReturn(sql, "h_v_Kf_EntrustInBillList");
                }
                if (ds == null || ds.Tables[0].Rows.Count <= 0)
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "没有返回任何记录!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                else
                {
                    objJsonResult.code = "1";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "返回记录成功!";
                    objJsonResult.data = ds.Tables[0];
                    return objJsonResult;
                }
                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
                //{
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
                //}
                //else
                //{
                //objJsonResult.code = "0";
                //objJsonResult.count = 0;
                //objJsonResult.Message = "无数据";
                //objJsonResult.data = null;
                //return objJsonResult;
                //}
            }
            catch (Exception ex)
            {
@@ -1323,7 +2541,7 @@
        #endregion
        #region 模具维修单保存/编辑
        #region 模具维修记录单保存/编辑
        /// <summary>
        /// 保存模具维修单
        /// </summary>
@@ -1339,6 +2557,7 @@
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string msg4 = sArray[2].ToString();
            string msg5 = sArray[3].ToString();
            string UserName = "";
@@ -1411,24 +2630,62 @@
                List<Model.ClsSb_MouldRepairWorkBillSub> ls = new List<Model.ClsSb_MouldRepairWorkBillSub>();
                ls = oListModels.getObjectByJson_Gy_MouldRepairWorkBillSub(msg3);
                int i = 0;
                foreach (Model.ClsSb_MouldRepairWorkBillSub oItemSub in ls)
                foreach (Model.ClsSb_MouldRepairWorkBillSub oItem in ls)
                {
                    i++;
                    oItemSub.HEntryID = i;
                    oItem.HEntryID = i;
                    //oItemSub.HCloseMan = "";       //行关闭
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItemSub.HCloseType = false;   //关闭类型
                    oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItem.HCloseType = false;   //关闭类型
                    //oItemSub.HRemark = "";         //备注
                    oItemSub.HRelationQty = 0;     //关联数量
                    oItem.HRelationQty = 0;     //关联数量
                    //oItemSub.HRelationMoney = 0;   //关联金额
                    //oItemSub.HRepairID = 0;       //维修项目
                    //oItemSub.HRepairExplanation ="";   //维修要求
                    //oItemSub.HManagerID = 0;   //负责人ID
                    //oItemSub.HMoney = 0;        //维修费用
                    oBill.DetailColl.Add(oItemSub);
                    oBill.DetailColl.Add(oItem);
                }
                //配件数据
                //按 },{来拆分数组 //去掉【和】
                msg5 = msg5.Substring(1, msg5.Length - 2);
                msg5 = msg5.Replace("\\", "");
                msg5 = msg5.Replace("\n", "");  //\n
                //msg2 = msg2.Replace("'", "’");
                List<Model.ClsSb_MouldRepairWorkBillSub_Item> ls1 = new List<Model.ClsSb_MouldRepairWorkBillSub_Item>();
                ls1 = oListModels.getObjectByJson_Gy_MouldRepairWorkBillSub_Item(msg5);
                int j = 0;
                foreach (Model.ClsSb_MouldRepairWorkBillSub_Item oItemSub in ls1)
                {
                    j++;
                    oItemSub.HEntryID = j;
                    //oItemSub.HCloseMan = "";       //行关闭
                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    oItemSub.HCloseType = false;   //关闭类型
                    //oItemSub.HRemark = "";         //备注
                    oItemSub.HSourceInterID = 0;     // 源单主内码
                    oItemSub.HSourceEntryID = 0;   //源单子内码
                    //oItemSub.HSourceBillNo = "";  //源单单号
                    //oItemSub.HSourceBillType = ""; //源单类型
                    oItemSub.HRelationQty = 0;     //关联数量
                    //oItemSub.HRelationMoney = 0;   //关联金额
                    //HMaterID = "";//配件代码
                    //HUnitID = "";//单位代码
                    //HQty = "";//实际用量
                    //HQtyMust = "";//单位用量
                    //HRemark = "";//备注
                    //oItemSub.HRepairID = 0;       //维修项目
                    //oItemSub.HRepairExplanation ="";   //维修要求
                    //oItemSub.HManagerID = 0;   //负责人ID
                    //oItemSub.HMoney = 0;        //维修费用
                    oBill.DetailCol.Add(oItemSub);
                }
                //保存
                //保存完毕后处理
                bool bResult;
@@ -1490,30 +2747,27 @@
        [HttpGet]
        public object Sb_MouldRepairWorkBillListProjectDetai(string sqlWhere)
        {
            DataSet ds;
            DataSet ds, ds1;
            List<object> list = new List<object>();
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sqlWhere == null || sqlWhere.Equals(""))
                {
                    //ds = oCN.RunProcReturn("select HRepairID,HRepairExplanation,HManagerID,HMoney,HRemark   from Sc_MouldRepairWorkBillSub", "Sc_MouldRepairWorkBillSub");
                    ds = oCN.RunProcReturn("select HRepairID, 子维修项目代码 HRepairCode,子维修项目 HRepairName,子维修要求 HRepairExplanation,HManagerSonID HManagerID,子负责人代码 HManagerCode,子负责人 HManagerName,维修费用 HMoney,表体备注 HRemark,源单主内码 HSourceInterID,源单子内码 HSourceEntryID,源单单号 HSourceBillNo,源单类型 HSourceBillType   from h_v_Sc_MouldRepairWorkBillList_Edit", "h_v_Sc_MouldRepairWorkBillList_Edit");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
                    objJsonResult.data = ds.Tables[0];
                }
                else
                {
                    //string sql1 = "select HRepairID,HRepairExplanation,HManagerID,HMoney,HRemark  from Sc_MouldRepairWorkBillSub where 1 = 1 ";
                    string sql1 = "select HRepairID,子维修项目代码 HRepairCode,子维修项目 HRepairName,子维修要求 HRepairExplanation,HManagerSonID HManagerID,子负责人代码 HManagerCode,子负责人 HManagerName,维修费用 HMoney,表体备注 HRemark,源单主内码 HSourceInterID,源单子内码 HSourceEntryID,源单单号 HSourceBillNo,源单类型 HSourceBillType   from h_v_Sc_MouldRepairWorkBillList_Edit where 1 = 1 ";
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList_Edit");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
                    objJsonResult.data = ds.Tables[0];
                }
                string sql = "select HRepairID,子维修项目代码 HRepairCode,子维修项目 HRepairName,子维修要求 HRepairExplanation,HManagerSonID HManagerID,子负责人代码 HManagerCode,子负责人 HManagerName,维修费用 HMoney,表体备注 HRemark,源单主内码 HSourceInterID,源单子内码 HSourceEntryID,源单单号 HSourceBillNo,源单类型 HSourceBillType   from h_v_Sc_MouldRepairWorkBillList_Edit where 1 = 1 "+ sqlWhere;
                ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList_Edit");
                string sql1 = "select 配件ID HMaterID, 配件代码 HMaterNumber,配件名称 HMaterName,规格型号 HMaterSpec,单位ID HUnitID,计量单位代码 HUnitNumber,计量单位名称 HUnitName,用量 HQty,标准用量 HQtyMust,子备注1 HRemark,规格型号 HMaterSpec  from h_v_Sc_MouldRepairWorkBillSub_Item  where 1 = 1 " + sqlWhere ;
                ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldRepairWorkBillSub_Item");
                list.Add(ds.Tables[0]);
                list.Add(ds1.Tables[0]);
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "获取信息成功!";
                objJsonResult.data = null;
                objJsonResult.list = list;
            }
            catch (Exception e)
            {
@@ -1739,6 +2993,58 @@
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #region 器具维修记录统计分析
        /// <summary>
        /// 器具维修记录统计分析 列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Sb_MouldRepairWorkBill/Sb_MouldRepairWorkBill")]
        [HttpGet]
        public object Sb_MouldRepairWorkBill(string DateYear, string HType, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (DateYear == null || DateYear.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "请选择有效年份";
                    return objJsonResult;
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_Sb_MouldRepairWorkBill'" + DateYear + "','" + HType + "'", "h_p_Sb_MouldRepairWorkBill");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
@@ -2343,6 +3649,7 @@
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string msg4 = sArray[2].ToString();
            string msg5 = sArray[3].ToString();
            string UserName = "";
@@ -2396,6 +3703,34 @@
                    }
                    oBill.omodel = oItem;
                }
                //保养项表体数据
                //按 },{来拆分数组 //去掉【和】
                msg5 = msg5.Substring(1, msg5.Length - 2);
                msg5 = msg5.Replace("\\", "");
                msg5 = msg5.Replace("\n", "");  //\n
                //msg2 = msg2.Replace("'", "’");
                List<Model.ClsSc_MouldMaintainPlanBillSub_Item> ls1 = new List<Model.ClsSc_MouldMaintainPlanBillSub_Item>();
                ls1 = oListModels.getObjectByJson_Gy_MouldMaintainPlanBillSub_Item(msg5);
                int j = 0;
                foreach (Model.ClsSc_MouldMaintainPlanBillSub_Item item in ls1)
                {
                    j++;
                    item.HEntryID = j;
                    //oItemSub.HCloseMan = "";       //行关闭
                    item.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                    item.HCloseType = false;   //关闭类型
                    //oItemSub.HRemark = "";         //备注
                    item.HSourceInterID = 0;     // 源单主内码
                    item.HSourceEntryID = 0;   //源单子内码
                    //oItemSub.HSourceBillNo = "";  //源单单号
                    //oItemSub.HSourceBillType = ""; //源单类型
                    item.HRelationQty = 0;     //关联数量
                    oBill.DetailCol.Add(item);
                }
                //表体数据
                //按 },{来拆分数组 //去掉【和】
                msg3 = msg3.Substring(1, msg3.Length - 2);
@@ -2491,28 +3826,28 @@
        [HttpGet]
        public object Sc_MouldMaintainPlanBillListProjectDetai(string sqlWhere)
        {
            DataSet ds;
            DataSet ds, ds1;
            List<object> list = new List<object>();
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sqlWhere == null || sqlWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select a.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName,a.HUnitID,u.HNumber HUnitNumber,u.HName HUnitName,a.HQty,a.HQtyMust,a.HRemark  from Sc_MouldMaintainPlanBillSub a left join Gy_Unit u on a.HUnitID=u.HItemID left join h_v_IF_Material m on a.HMaterID=m.HItemID", "Sc_MouldMaintainPlanBillSub");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
                    objJsonResult.data = ds.Tables[0];
                }
                else
                {
                    string sql1 = "select a.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName,a.HUnitID,u.HNumber HUnitNumber,u.HName HUnitName,a.HQty,a.HQtyMust,a.HRemark  from Sc_MouldMaintainPlanBillSub a left join Gy_Unit u on a.HUnitID=u.HItemID left join h_v_IF_Material m on a.HMaterID=m.HItemID where 1 = 1 ";
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "Sc_MouldMaintainPlanBillSub");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
                    objJsonResult.data = ds.Tables[0];
                }
                //获取保养项目编辑数据
                string sql = "select 保养项目ID HMaintainItemID, 保养项目代码 HMaintainItemNumber,保养项目 HMaintainItem,保养部位 HMaintainPart,具体要求 HClaim,负责人ID,负责人代码 HManagerNumber,负责人名称 HManagerName,子备注2 HRemark,HMouldMaintainRuleID,HEquipDotCheckNo  from h_v_Sc_MouldMaintainPlanBillSub_Item where 1 = 1 " + sqlWhere + "";
                ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldMaintainPlanBillSub_Item");
                //获取配件项目编辑数据
                string sql1 = "select 配件ID HMaterID, 配件代码 HMaterNumber,配件名称 HMaterName,单位ID HUnitID,计量单位代码 HUnitNumber,计量单位名称 HUnitName,用量 HQty,标准用量 HQtyMust,子备注1 HRemark,规格型号 HMaterSpec  from h_v_Sc_MouldMaintainPlanBillSub  where 1 = 1 " + sqlWhere + "";
                ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldMaintainPlanBillSub");
                list.Add(ds.Tables[0]);
                list.Add(ds1.Tables[0]);
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "获取信息成功!";
                objJsonResult.data = null;
                objJsonResult.list = list;
            }
            catch (Exception e)
            {
@@ -2604,6 +3939,57 @@
        }
        #endregion
        #region 器具保养记录统计分析
        /// <summary>
        /// 器具维修记录统计分析 列表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Sb_MouldRepairWorkBill/Sc_MouldMaintainBillMain")]
        [HttpGet]
        public object Sc_MouldMaintainBillMain(string DateYear, string HType, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (DateYear == null || DateYear.Equals(""))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "请选择有效年份";
                    return objJsonResult;
                }
                else
                {
                    ds = oCN.RunProcReturn("exec h_p_Sc_MouldMaintainBillMain'" + DateYear + "','" + HType + "'", "h_p_Sc_MouldMaintainBillMain");
                }
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
        #endregion
        #region 模具保养记录表
@@ -2973,6 +4359,7 @@
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string msg4 = sArray[2].ToString();
            //string msg5 = sArray[3].ToString();
            string UserName = "";
            ListModels oListModels = new ListModels();
@@ -2996,6 +4383,7 @@
                {
                    //oItem.HMaker = "";
                    UserName = oItem.HMaker;  //制单人
                    oItem.HMaker = msg4;
                    oItem.HBillType = "3821";
                    oItem.HBillSubType = "3821";
@@ -3058,6 +4446,32 @@
                    oBill.DetailColl.Add(oItemSub);
                }
                ////配件项表体数据
                ////按 },{来拆分数组 //去掉【和】
                //msg5 = msg5.Substring(1, msg5.Length - 2);
                //msg5 = msg5.Replace("\\", "");
                //msg5 = msg5.Replace("\n", "");  //\n
                //                                //msg2 = msg2.Replace("'", "’");
                //List<Model.ClsSc_MouldDotCheckBillSub_Item> ls1 = new List<Model.ClsSc_MouldDotCheckBillSub_Item>();
                //ls1 = oListModels.getObjectByJson_Sc_MouldDotCheckBillSub_Item(msg5);
                //int j = 0;
                //foreach (Model.ClsSc_MouldDotCheckBillSub_Item oItemSub in ls1)
                //{
                //    j++;
                //    oItemSub.HEntryID = j;
                //    //oItemSub.HCloseMan = "";       //行关闭
                //    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                //    oItemSub.HCloseType = false;   //关闭类型
                //    oItemSub.HSourceInterID = 0;     // 源单主内码
                //    oItemSub.HSourceEntryID = 0;   //源单子内码
                //    oItemSub.HRelationQty = 0;     //关联数量
                //    oBill.DetailCol.Add(oItemSub);
                //}
                //保存
                //保存完毕后处理
                bool bResult;
@@ -3119,28 +4533,29 @@
        [HttpGet]
        public object Sc_MouldDotCheckBillListProjectDetai(string sqlWhere)
        {
            DataSet ds;
            DataSet ds, ds1;
            List<object> list = new List<object>();
            string Swhere = "";
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sqlWhere == null || sqlWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select HDotCheckItemID,点检项目 HDotCheckItem,点检部位 HDotCheckPart,具体要求 HClaim,表体备注 HRemark,HManagerID,负责人代码 HManagerNumber,负责人 HManagerName from h_v_Sc_MouldDotCheckBillList", "h_v_Sc_MouldDotCheckBillList");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
                    objJsonResult.data = ds.Tables[0];
                }
                else
                {
                    string sql1 = "select HDotCheckItemID,点检项目 HDotCheckItem,点检部位 HDotCheckPart,具体要求 HClaim,表体备注 HRemark,HManagerID,负责人代码 HManagerNumber,负责人 HManagerName from h_v_Sc_MouldDotCheckBillList where 1 = 1 ";
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldDotCheckBillList");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
                    objJsonResult.data = ds.Tables[0];
                }
                //获取点检项目编辑数据
                ds = oCN.RunProcReturn("select HDotCheckItem, HDotCheckPart , HClaim, a.HRemark,a.HManagerID,e.HNumber HManagerCode,e.HName HManagerName from Sc_MouldDotCheckBillSub a left join Gy_Employee e on a.HManagerID=e.HItemID where 1=1 " + sqlWhere, "Sc_MouldDotCheckBillSub");
                //获取配件项目编辑数据
                ds1 = oCN.RunProcReturn(@"select b.HMaterID,  mt.Hnumber HMaterNumber ,mt.HName HMaterName, b.HUnitID
                    ,u2.hnumber HUnitNumber,u2.HName HUnitName,b.HQty,b.HQtyMust,b.HRemark
                    from Sc_MouldDotCheckBillSub_Item b
                    left join Gy_Material mt on b.HMaterID=mt.HItemID
                    left join h_v_IF_Unit u2 on b.HUnitID=u2.HItemID  where 1=1 " + sqlWhere, "Sc_MouldDotCheckBillSub_Item");
                list.Add(ds.Tables[0]);
                list.Add(ds1.Tables[0]);
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "获取信息成功!";
                objJsonResult.data = null;
                objJsonResult.list = list;
            }
            catch (Exception e)
            {
@@ -3152,7 +4567,32 @@
            return objJsonResult;
        }
        #endregion
        #region[模具点检记录表选择点检计划带出表格数据]
        [Route("Sc_MouldDotCheckBill/Sc_MouldDotCheckSubBillListByPlan")]
        [HttpGet]
        public object Sc_MouldDotCheckSubBillListByPlan(string HPlanInterID)
        {
            DataSet ds;
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                string sql1 = "select hsubid HDotCheckItemID,点检项目 HDotCheckItem,点检部位 HDotCheckPart,具体要求 HClaim,表体备注 HRemark,HManagerID,负责人代码 HManagerNumber,负责人 HManagerName from h_v_Sc_MouldDotCheckPlanBillList where hmainid =" + HPlanInterID;
                ds = oCN.RunProcReturn(sql1, "h_v_Sc_MouldDotCheckPlanBillList");
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "获取信息成功!";
                objJsonResult.data = ds.Tables[0];
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "没有返回任何记录!" + e.ToString();
                objJsonResult.data = null;
            }
            return objJsonResult;
        }
        #endregion
        #region [模具点检记录表删除功能]
        /// <summary>
        /// 模具点检记录删除功能
@@ -3254,6 +4694,7 @@
            string msg2 = sArray[0].ToString();
            string msg3 = sArray[1].ToString();
            string msg4 = sArray[2].ToString();
            //string msg5 = sArray[3].ToString();
            string UserName = "";
@@ -3268,7 +4709,7 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                DBUtility.ClsPub.CurUserName = msg4;
                DAL.ClsSc_MouldDotCheckPlanBill oBill = new DAL.ClsSc_MouldDotCheckPlanBill();
                List<Model.ClsSc_MouldDotCheckPlanBillMain> lsmain = new List<Model.ClsSc_MouldDotCheckPlanBillMain>();
                msg2 = msg2.Replace("\\", "");
@@ -3278,8 +4719,8 @@
                {
                    //oItem.HMaker = "";
                    UserName = oItem.HMaker;  //制单人
                    oItem.HBillType = "3821";
                    oItem.HBillSubType = "3821";
                    oItem.HBillType = "3820";
                    oItem.HBillSubType = "3820";
                    //oItem.HInterID =0;
                    //oItem.HBillNo = "";
@@ -3307,7 +4748,7 @@
                    }
                    oBill.omodel = oItem;
                }
                //表体数据
                //点检项目表体数据
                //按 },{来拆分数组 //去掉【和】
                msg3 = msg3.Substring(1, msg3.Length - 2);
                msg3 = msg3.Replace("\\", "");
@@ -3340,6 +4781,32 @@
                    oBill.DetailColl.Add(oItemSub);
                }
                ////配件项表体数据
                ////按 },{来拆分数组 //去掉【和】
                //msg5 = msg5.Substring(1, msg5.Length - 2);
                //msg5 = msg5.Replace("\\", "");
                //msg5 = msg5.Replace("\n", "");  //\n
                //                                //msg2 = msg2.Replace("'", "’");
                //List<Model.ClsSc_MouldDotCheckPlanBillSub_Item> ls1 = new List<Model.ClsSc_MouldDotCheckPlanBillSub_Item>();
                //ls1 = oListModels.getObjectByJson_Sc_MouldDotCheckPlanBillSub_Item(msg5);
                //int j = 0;
                //foreach (Model.ClsSc_MouldDotCheckPlanBillSub_Item oItemSub in ls1)
                //{
                //    j++;
                //    oItemSub.HEntryID = j;
                //    //oItemSub.HCloseMan = "";       //行关闭
                //    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
                //    oItemSub.HCloseType = false;   //关闭类型
                //    oItemSub.HSourceInterID = 0;     // 源单主内码
                //    oItemSub.HSourceEntryID = 0;   //源单子内码
                //    oItemSub.HRelationQty = 0;     //关联数量
                //    oBill.DetailCol.Add(oItemSub);
                //}
                //保存
                //保存完毕后处理
                bool bResult;
@@ -3401,28 +4868,29 @@
        [HttpGet]
        public object Sc_MouldDotCheckPlanBillListProjectDetai(string sqlWhere)
        {
            DataSet ds;
            DataSet ds, ds1;
            List<object> list = new List<object>();
            string Swhere = "";
            try
            {
                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                if (sqlWhere == null || sqlWhere.Equals(""))
                {
                    ds = oCN.RunProcReturn("select HDotCheckItem, HDotCheckPart , HClaim, a.HRemark,a.HManagerID,e.HNumber HManagerCode,e.HName HManagerName from Sc_MouldDotCheckPlanBillSub a left join Gy_Employee e on a.HManagerID=e.HItemID", "Sc_MouldDotCheckPlanBillSub");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
                    objJsonResult.data = ds.Tables[0];
                }
                else
                {
                    string sql1 = "select HDotCheckItem, HDotCheckPart , HClaim, a.HRemark,a.HManagerID,e.HNumber HManagerCode,e.HName HManagerName from Sc_MouldDotCheckPlanBillSub a left join Gy_Employee e on a.HManagerID=e.HItemID where 1 = 1 ";
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "Sc_MouldDotCheckPlanBillSub");
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "获取信息成功!";
                    objJsonResult.data = ds.Tables[0];
                }
                //获取点检项目编辑数据
                ds = oCN.RunProcReturn(@"select a.HDotCheckItemID,HDotCheckItem, HDotCheckPart , HClaim, a.HRemark,a.HManagerID,e.HNumber HManagerCode,e.HName HManagerName from Sc_MouldDotCheckPlanBillSub a
                  left join Gy_Employee e on a.HManagerID=e.HItemID
                        where 1=1 " + sqlWhere, "Sc_MouldDotCheckPlanBillSub");
                ////获取配件项目编辑数据
                //ds1 = oCN.RunProcReturn(@"select b.HMaterID,  mt.Hnumber HMaterNumber ,mt.HName HMaterName, b.HUnitID
                //    ,u2.hnumber HUnitNumber,u2.HName HUnitName,b.HQty,b.HQtyMust,b.HRemark
                //    from Sc_MouldDotCheckPlanBillSub_Item b
                //    left join Gy_Material mt on b.HMaterID=mt.HItemID
                //    left join h_v_IF_Unit u2 on b.HUnitID=u2.HItemID  where 1=1 " + sqlWhere, "Sc_MouldDotCheckPlanBillSub_Item");
                list.Add(ds.Tables[0]);
                //list.Add(ds1.Tables[0]);
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "获取信息成功!";
                objJsonResult.data = null;
                objJsonResult.list = list;
            }
            catch (Exception e)
            {
@@ -3556,7 +5024,7 @@
                    ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具名称 HMaterName,规格型号 HMaterSpec,HPropertyID,辅助属性代码 HPropertyCode,辅助属性名称 HPropertyName,
                                            HSecUnitID, 辅助计量单位代码 HSecUnitCode, 辅助计量单位名称 HSecUnitName, HUnitID, 计量单位代码 HUnitCode, 计量单位名称 HUnitName, 批次 HBatchNo,
                                            设计寿命 HDesignLife, 剩余寿命 HLeaveLife, 使用寿命 HUseLife, 实收数量 HQty, 单价 HPrice, 金额 HMoney, HWHID, 收料仓库代码 HWHCode, 收料仓库名称 HWHName,
                                            HSPID, 仓位代码 HSPCode, 仓位名称 HSPName, 备注 HRemark,HStockOrgID
                                            HSPID, 仓位代码 HSPCode, 仓位名称 HSPName, 子备注 HRemark,HStockOrgID
                                            FROM h_v_Sc_MouldScrapInHouseBillList"), "h_v_Sc_MouldScrapInHouseBillList");
                }
@@ -3567,7 +5035,7 @@
                    string sql1 = string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具名称 HMaterName,规格型号 HMaterSpec,HPropertyID,辅助属性代码 HPropertyCode,辅助属性名称 HPropertyName,
                                            HSecUnitID, 辅助计量单位代码 HSecUnitCode, 辅助计量单位名称 HSecUnitName, HUnitID, 计量单位代码 HUnitCode, 计量单位名称 HUnitName, 批次 HBatchNo,
                                            设计寿命 HDesignLife, 剩余寿命 HLeaveLife, 使用寿命 HUseLife, 实收数量 HQty, 单价 HPrice, 金额 HMoney, HWHID, 收料仓库代码 HWHCode, 收料仓库名称 HWHName,
                                            HSPID, 仓位代码 HSPCode, 仓位名称 HSPName, 备注 HRemark,HStockOrgID
                                            HSPID, 仓位代码 HSPCode, 仓位名称 HSPName, 子备注 HRemark,HStockOrgID
                                            FROM h_v_Sc_MouldScrapInHouseBillList where 1 = 1 ");
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldScrapInHouseBillList");
@@ -3757,15 +5225,19 @@
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    string sql = string.Format($"exec h_p_Sc_MouldChangeFileStatus  'in','{oBill.omodel.HInterID.ToString()}' ");
                    oCn.RunProc(sql);
                }
                else
                {
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //修改成功
                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  1,{oBill.omodel.HInterID.ToString()},' ' ");
                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
                    oCn.RunProc(sql);
                }
                if (bResult)
                {
                    string sql = $"exec h_p_Sc_MouldChangeFileStatus  'in','{oBill.omodel.HInterID.ToString()}' ";
                    oCn.RunProc(sql);
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
@@ -3952,6 +5424,7 @@
                }
                ds = Sc_GetMouldScrapOutHouseBill(sWhere, Organization);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "返回记录成功!";
@@ -3973,11 +5446,11 @@
            string sql1 = string.Format(@"select * from h_v_Sc_MouldScrapOutHouseBillList where 库存组织='" + Organization + "'");
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn(sql1 + "order by 制单日期 desc", "h_v_Sc_MouldScrapOutHouseBillList");
                return new SQLHelper.ClsCN().RunProcReturn(sql1 + " order by 制单日期 desc", "h_v_Sc_MouldScrapOutHouseBillList");
            }
            else
            {
                string sql = sql1 + sWhere + "order by 制单日期 desc";
                string sql = sql1 + sWhere + " order by 制单日期 desc";
                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldScrapOutHouseBillList");
            }
        }
@@ -4166,15 +5639,19 @@
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    string sql = string.Format($"exec h_p_Sc_MouldChangeFileStatus  'out','{oBill.omodel.HInterID.ToString()}' ");
                    oCn.RunProc(sql);
                }
                else
                {
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //修改成功
                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  1,{oBill.omodel.HInterID.ToString()},' ' ");
                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
                    oCn.RunProc(sql);
                }
                if (bResult)
                {
                    string sql = $"exec h_p_Sc_MouldChangeFileStatus  'out','{oBill.omodel.HInterID.ToString()}' ";
                    oCn.RunProc(sql);
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
@@ -4251,10 +5728,21 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //删除前查找当前单据的所有器具ID
                //string swhere = "";
                //DataSet ds = oCn.RunProcReturn("select HMaterID from Sc_MouldStockBillSub where HinterID=" + HInterID, "Sc_MouldStockBillSub");
                //for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
                //{
                //    swhere = swhere + ds.Tables[0].Rows[i]["HMaterID"].ToString()+",";
                //}
                //swhere = swhere.Substring(0, swhere.Length - 1);
                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                if (IsDete)
                {
                    //删除成功修改器具档案位置
                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  0,0,'{swhere}' ");
                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
                    oCn.RunProc(sql);
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
@@ -4527,6 +6015,7 @@
                }
                ds = Sc_GetMouldProdBackBill(sWhere, Organization);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "返回记录成功!";
@@ -4593,7 +6082,7 @@
                    ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具名称 HMaterName,规格型号 HMaterSpec,批次 HBatchNo,
                                                设计寿命 HDesignLife, 剩余寿命 HLeaveLife, 累积使用寿命 HUseLife, 应发数量 HQtyMust, 实发数量 HQty, 
                                                单价 HPrice, 金额 HMoney,收料仓库ID HWHID, 收料仓库代码 HWHCode, 收料仓库 HWHName,HSPID, 
                                                仓位代码 HSPCode, 仓位 HSPName,表体备注 HRemark,HStockOrgID,HUnitID,计量单位代码,计量单位 FROM h_v_Sc_MouldProdBackBillList"), "h_v_Sc_MouldProdBackBillList");
                                                仓位代码 HSPCode, 仓位 HSPName,表体备注 HRemark,HStockOrgID,HUnitID,计量单位代码 HUnitCode,计量单位 HUnitName FROM h_v_Sc_MouldProdBackBillList"), "h_v_Sc_MouldProdBackBillList");
                }
                else
@@ -4603,7 +6092,7 @@
                    string sql1 = string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具名称 HMaterName,规格型号 HMaterSpec,批次 HBatchNo,
                                                设计寿命 HDesignLife, 剩余寿命 HLeaveLife, 累积使用寿命 HUseLife, 应发数量 HQtyMust, 实发数量 HQty, 
                                                单价 HPrice, 金额 HMoney,收料仓库ID HWHID, 收料仓库代码 HWHCode, 收料仓库 HWHName,HSPID, 
                                                仓位代码 HSPCode, 仓位 HSPName,表体备注 HRemark,HStockOrgID,HUnitID,计量单位代码,计量单位 FROM h_v_Sc_MouldProdBackBillList where 1 = 1 ");
                                                仓位代码 HSPCode, 仓位 HSPName,表体备注 HRemark,HStockOrgID,HUnitID,计量单位代码 HUnitCode,计量单位 HUnitName FROM h_v_Sc_MouldProdBackBillList where 1 = 1 ");
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldProdBackBillList");
@@ -4741,18 +6230,21 @@
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    string sql1 = string.Format($"exec h_p_Sc_MouldChangeFileStatus  'in','{oBill.omodel.HInterID.ToString()}' ");
                    oCn.RunProc(sql1);
                }
                else
                {
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //修改成功
                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  1,{oBill.omodel.HInterID.ToString()},' ' ");
                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
                    oCn.RunProc(sql);
                }
                if (bResult)
                {
                    string sql = $"exec h_p_Sc_MouldProdBackBillList '{oBill.omodel.HBillNo}' ";
                    string sql =string.Format($"exec h_p_Sc_MouldProdBackBillList '{oBill.omodel.HBillNo}' ") ;
                    oCn.RunProc(sql);
                    string sql1 = $"exec h_p_Sc_MouldChangeFileStatus  'in','{oBill.omodel.HInterID.ToString()}' ";
                    oCn.RunProc(sql1);
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
@@ -4829,10 +6321,21 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //删除前查找当前单据的所有器具ID
                //string swhere = "";
                //DataSet ds = oCn.RunProcReturn("select HMaterID from Sc_MouldStockBillSub where HinterID=" + HInterID, "Sc_MouldStockBillSub");
                //for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
                //{
                //    swhere = swhere + ds.Tables[0].Rows[i]["HMaterID"].ToString()+",";
                //}
                //swhere = swhere.Substring(0, swhere.Length - 1);
                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                if (IsDete)
                {
                    //删除成功修改器具档案位置
                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  0,0,'{swhere}' ");
                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
                    oCn.RunProc(sql);
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
@@ -4965,6 +6468,7 @@
                }
                ds = Sc_GetMouldProdOutBill(sWhere, Organization);
                objJsonResult.code = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "返回记录成功!";
@@ -4986,6 +6490,7 @@
            string sql1 = string.Format(@"select * from h_v_Sc_MouldProdOutHouseBillList where 库存组织='" + Organization + "'");
            if (sWhere == null || sWhere.Equals(""))
            {
                Log.LogInfo(sql1);
                return new SQLHelper.ClsCN().RunProcReturn(sql1 + "order by 制单日期 desc", "h_v_Sc_MouldProdOutHouseBillList");
            }
            else
@@ -5031,7 +6536,7 @@
                    ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具名称 HMaterName,规格型号 HMaterSpec,批次 HBatchNo,
                                                设计寿命 HDesignLife, 剩余寿命 HLeaveLife, 累积使用寿命 HUseLife, 应发数量 HQtyMust, 实发数量 HQty, 
                                                单价 HPrice, 金额 HMoney,HWHSonID HWHID, 发料仓库代码 HWHCode, 发料仓库 HWHName,HSPID, 
                                                仓位代码 HSPCode, 仓位 HSPName,表体备注 HRemark,HStockOrgID,HUnitID,计量单位代码,计量单位 FROM h_v_Sc_MouldProdOutHouseBillList"), "h_v_Sc_MouldProdOutHouseBillList");
                                                仓位代码 HSPCode, 仓位 HSPName,表体备注 HRemark,HStockOrgID,HUnitID,计量单位代码 HUnitCode,计量单位 HUnitName FROM h_v_Sc_MouldProdOutHouseBillList"), "h_v_Sc_MouldProdOutHouseBillList");
                }
                else
@@ -5041,7 +6546,7 @@
                    string sql1 = string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具名称 HMaterName,规格型号 HMaterSpec,批次 HBatchNo,
                                                设计寿命 HDesignLife, 剩余寿命 HLeaveLife, 累积使用寿命 HUseLife, 应发数量 HQtyMust, 实发数量 HQty, 
                                                单价 HPrice, 金额 HMoney,HWHSonID HWHID, 发料仓库代码 HWHCode, 发料仓库 HWHName,HSPID, 
                                                仓位代码 HSPCode, 仓位 HSPName,表体备注 HRemark,HStockOrgID,HUnitID,计量单位代码,计量单位 FROM h_v_Sc_MouldProdOutHouseBillList where 1 = 1 ");
                                                仓位代码 HSPCode, 仓位 HSPName,表体备注 HRemark,HStockOrgID,HUnitID,计量单位代码 HUnitCode,计量单位 HUnitName FROM h_v_Sc_MouldProdOutHouseBillList where 1 = 1 ");
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldProdOutHouseBillList");
                }
@@ -5179,15 +6684,19 @@
                {
                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    string sql = string.Format($"exec h_p_Sc_MouldChangeFileStatus  'out','{oBill.omodel.HInterID.ToString()}' ");
                    oCn.RunProc(sql);
                }
                else
                {
                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                    //修改成功
                    //string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  1,{oBill.omodel.HInterID.ToString()},' ' ");
                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
                    oCn.RunProc(sql);
                }
                if (bResult)
                {
                    string sql = $"exec h_p_Sc_MouldChangeFileStatus  'out','{oBill.omodel.HInterID.ToString()}' ";
                    oCn.RunProc(sql);
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "保存成功!";
@@ -5302,10 +6811,21 @@
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                //删除前查找当前单据的所有器具ID
                //string swhere = "";
                //DataSet ds = oCn.RunProcReturn("select HMaterID from Sc_MouldStockBillSub where HinterID=" + HInterID, "Sc_MouldStockBillSub");
                //for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
                //{
                //    swhere = swhere + ds.Tables[0].Rows[i]["HMaterID"].ToString() + ",";
                //}
                //swhere = swhere.Substring(0, swhere.Length - 1);
                bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
                if (IsDete)
                {
                    //删除成功修改器具档案位置
                    // string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID  0,0,'{swhere}' ");
                    string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID ");
                    oCn.RunProc(sql);
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo;
@@ -5427,6 +6947,8 @@
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (!DBUtility.ClsPub.Security_Log("Sc_MouldLifeChangeBillList", 1, false, user))
                {
                    objJsonResult.code = "0";
@@ -5437,10 +6959,20 @@
                }
                ds = Sc_GetMouldLifeChangeBill(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 = "返回记录成功!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception ex)
@@ -5457,12 +6989,12 @@
        {
            if (sWhere == null || sWhere.Equals(""))
            {
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldLifeChangeBillList order by 日期 desc", "h_v_Sc_MouldLifeChangeBillList");
                return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldLifeChangeBillList order by hmainid desc", "h_v_Sc_MouldLifeChangeBillList");
            }
            else
            {
                string sql1 = "select * from h_v_Sc_MouldLifeChangeBillList where 1 = 1 ";
                string sql = sql1 + sWhere + "order by 日期 desc";
                string sql = sql1 + sWhere + "order by hmainid desc";
                return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldLifeChangeBillList");
            }
@@ -5501,7 +7033,7 @@
                    ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具 HMaterName,规格型号 HMaterSpec,HPropertyID,辅助属性代码 HPropertyCode,辅助属性 HPropertyName,
                                                           HSecUnitID, 辅助计量单位代码 HSecUnitCode, 辅助计量单位 HSecUnitName,换算率 HSecUnitRate,
                                                           HUnitID, 计量单位代码 HUnitCode, 计量单位 HUnitName,
                                                           设计寿命 HDesignLife, 原剩余寿命 HLeaveLife, 新剩余寿命 HNewLife,表体备注 HRemark
                                                           设计寿命 HDesignLife, 原剩余寿命 HLeaveLife, 新剩余寿命 HNewLeaveLife,表体备注 HRemark
                                                          FROM h_v_Sc_MouldLifeChangeBillList_Edit"), "h_v_Sc_MouldLifeChangeBillList_Edit");
                    objJsonResult.code = "0";
@@ -5516,7 +7048,7 @@
                    string sql1 = string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具 HMaterName,规格型号 HMaterSpec,HPropertyID,辅助属性代码 HPropertyCode,辅助属性 HPropertyName,
                                                  HSecUnitID, 辅助计量单位代码 HSecUnitCode, 辅助计量单位 HSecUnitName,换算率 HSecUnitRate,
                                                  HUnitID, 计量单位代码 HUnitCode, 计量单位 HUnitName,
                                                  设计寿命 HDesignLife, 原剩余寿命 HLeaveLife, 新剩余寿命 HNewLife,表体备注 HRemark
                                                  设计寿命 HDesignLife, 原剩余寿命 HLeaveLife, 新剩余寿命 HNewLeaveLife,表体备注 HRemark
                                                 FROM h_v_Sc_MouldLifeChangeBillList_Edit where 1 = 1 ");
                    string sql = sql1 + sqlWhere;
                    ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldLifeChangeBillList_Edit");