using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Web; using System.Web.Http; using ViewAPI; using WebAPI.Models; namespace WebAPI.Controllers { /** * 找货单单 */ public class Sc_MouldRepairInBillListController : ApiController { public DBUtility.ClsPub.Enum_BillStatus BillStatus;//单据状态(新增,修改,浏览,更新单价,变更) private json objJsonResult = new json(); 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(); Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); public DAL.ClsSc_MouldScrapInBill BillNew0 = new DAL.ClsSc_MouldScrapInBill(); //模具报废入库对应单据类 public DAL.ClsSc_MouldScrapInBill BillOld0 = new DAL.ClsSc_MouldScrapInBill(); //模具报废入库对应单据类 string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; /// /// 根据包装单 返回此包装单内的相关信息 /// /// /// /// 检具维修工单列表 /// /// [Route("Sc_CheckToolsRepair/GetCheckToolsRepairWorkBillList")] [HttpGet] public object GetCheckToolsRepairWorkBillList(string sWhere) { try { ds = Sc_CheckToolsRepairWorkBillList_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; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_CheckToolsRepairWorkBillList_s(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsRepairWorkBillList order by 日期 desc", "h_v_Sc_CheckToolsRepairWorkBillList"); } /// /// 检具点检计划表列表 /// /// [Route("Sc_CheckToolsDotCheckPlan/GetCheckToolsDotCheckPlanBillList")] [HttpGet] public object GetCheckToolsDotCheckPlanBillList(string sWhere) { try { ds = Sc_CheckToolsDotCheckPlanBillList_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; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_CheckToolsDotCheckPlanBillList_s(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsDotCheckPlanBillList order by 日期 desc", "h_v_Sc_CheckToolsDotCheckPlanBillList"); } #endregion /// /// 检具保养记录表列表 /// /// [Route("Sc_CheckToolsMaintainBill/GetCheckToolsMaintainBillList")] [HttpGet] public object GetCheckToolsMaintainBillList(string sWhere) { try { ds = Sc_CheckToolsMaintainBillList_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; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_CheckToolsMaintainBillList_s(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsMaintainBillList order by 日期 desc", "h_v_Sc_CheckToolsMaintainBillList"); } #endregion /// /// 模具保养记录表列表 /// /// [Route("Sc_MouldMaintainBill/GetMouldMaintainBillList")] [HttpGet] public object GetMouldMaintainBillList(string sWhere,string user) { try { List columnNameList = new List(); if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_MouldMaintainBillList_s(sWhere); //添加列名 foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; //} //else //{ //objJsonResult.code = "0"; //objJsonResult.count = 0; //objJsonResult.Message = "无数据"; //objJsonResult.data = null; //return objJsonResult; //} } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_MouldMaintainBillList_s(string sWhere) { if (sWhere == null || sWhere.Equals("")) { 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 hmainid desc"; return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldMaintain"); } //return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldMaintainBillList ", "h_v_Sc_MouldMaintainBillList"); } #endregion /// /// 模具点检计划表列表 /// /// [Route("Sc_MouldDotCheckPlanBill/GetMouldDotCheckPlanBillList")] [HttpGet] public object GetMouldDotCheckPlanBillList(string sWhere,string user) { try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckPlanBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_MouldDotCheckPlanBillList_s(sWhere); 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; } } #region sql语句 public static DataSet Sc_MouldDotCheckPlanBillList_s(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldDotCheckPlanBillList where 1=1 "+sWhere+ " order by hmainid desc", "h_v_Sc_MouldDotCheckPlanBillList"); } #endregion /// /// 模具点检记录表列表 /// /// [Route("Sc_MouldDotCheckBill/GetMouldDotCheckBillList")] [HttpGet] public object GetMouldDotCheckBillList(string sWhere,string user) { try { List columnNameList = new List(); if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_MouldDotCheckBillList_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) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 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 hmainid desc", "h_v_Sc_MouldDotCheckBillList"); } #endregion /// /// 检具保养计划表列表 /// /// [Route("Sc_CheckToolsMaintainPlanBill/GetCheckToolsMaintainPlanBillList")] [HttpGet] public object GetCheckToolsMaintainPlanBillList(string sWhere) { try { ds = Sc_CheckToolsMaintainPlanBillList_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; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_CheckToolsMaintainPlanBillList_s(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsMaintainPlanBillList order by 日期 desc", "h_v_Sc_CheckToolsMaintainPlanBillList"); } #endregion /// /// 模具保养计划表列表 /// /// [Route("Sc_MouldMaintainPlanBill/GetMouldMaintainPlanBillList")] [HttpGet] public object GetMouldMaintainPlanBillList(string sWhere,string user) { try { List columnNameList = new List(); if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainPlanBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_MouldMaintainPlanBillList_s(sWhere); //添加列名 foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; //} //else //{ //objJsonResult.code = "0"; //objJsonResult.count = 0; //objJsonResult.Message = "无数据"; //objJsonResult.data = null; //return objJsonResult; //} } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_MouldMaintainPlanBillList_s(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldMaintainPlanBillList where 1=1 "+sWhere+ " order by hmainid desc", "h_v_Sc_MouldMaintainPlanBillList"); } #endregion /// /// 模具故障登记表列表 /// /// [Route("Sc_MouldConkBookBill/GetMouldConkBookBillList")] [HttpGet] public object GetMouldConkBookBillList(string sWhere,string user) { try { List columnNameList = new List(); if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_MouldConkBookBillList_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) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region 器具故障记录统计分析 /// /// 器具维修记录统计分析 列表 ///参数:string sql。 ///返回值:object。 /// [Route("Sb_MouldRepairWorkBill/Sc_MouldConkBookBillMain")] [HttpGet] public object Sc_MouldConkBookBillMain(string DateYear, string HType, string user) { try { List columnNameList = new List(); 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语句 public static DataSet Sc_MouldConkBookBillList_s(string sWhere) { DataSet ds; if (sWhere == null || sWhere.Equals("")) { ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldConkBookBillList where 1=1 " + sWhere+ " order by hmainid desc", "h_v_Sc_MouldConkBookBillList"); } else { string sql1 = "select * from h_v_Sc_MouldConkBookBillList where 1 = 1 "; string sql = sql1 + sWhere + "order by 日期 desc"; ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldConkBookBillList"); } return ds; } #endregion #region 器具寿命耗用分析报表 [Route("Sc_MouldRepairInBillList/Get_Sc_MouldLifeUsePicReport")] [HttpGet] public object Get_Sc_MouldLifeUsePicReport(string sWhere) { try { List columnNameList = new List(); if (sWhere == null || sWhere.Equals("")) { ds = oCN.RunProcReturn("select * from h_v_Sc_MouldLifeUsePicReport order by 月份 desc", "h_v_Sc_MouldLifeUsePicReport"); } else { string sql1 = "select * from h_v_Sc_MouldLifeUsePicReport where 1 = 1 "; string sql = sql1 + sWhere + " order by 日期 "; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldLifeUsePicReport"); } //添加列名 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 /// /// 模具维修验收单列表 /// /// [Route("Sc_MouldRepairCheckBill/GetMouldRepairCheckBillList")] [HttpGet] public object GetMouldRepairCheckBillList(string sWhere,string user) { try { if (!DBUtility.ClsPub.Security_Log("Sb_EquipRepairCheckBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_MouldRepairCheckBillList_s(sWhere); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "返回记录成功!"; 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; } } #region sql语句 public static DataSet Sc_MouldRepairCheckBillList_s(string sWhere) { DataSet ds; if (sWhere == null || sWhere.Equals("")) { 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 hmainid desc"; ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairCheckBillList_Edit"); } return ds; } #endregion /// /// 检具维修验收单列表 /// /// [Route("Sc_CheckToolsRepairCheckBill/GetCheckToolsRepairCheckBillList")] [HttpGet] public object GetCheckToolsRepairCheckBillList(string sWhere) { try { ds = Sc_CheckToolsRepairCheckBillList_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; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_CheckToolsRepairCheckBillList_s(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsRepairCheckBillList order by 日期 desc", "h_v_Sc_CheckToolsRepairCheckBillList"); } #endregion #region sql语句 //public static DataSet Sc_MouldRepairCheckBillList_s(string sWhere) //{ // return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairCheckBillList ", "h_v_Sc_MouldRepairCheckBillList"); //} #endregion /// /// 检具故障登记表列表 /// /// [Route("Sc_CheckToolsConkBookBill/GetCheckToolsConkBookBillList")] [HttpGet] public object GetCheckToolsConkBookBillList(string sWhere) { try { ds = Sc_CheckToolsConkBookBillList_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; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_CheckToolsConkBookBillList_s(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsConkBookBillList order by 日期 desc", "h_v_Sc_CheckToolsConkBookBillList"); } #endregion /// /// 检具点检记录表列表 /// /// [Route("Sc_CheckToolsDotCheckBill/GetCheckToolsDotCheckBillList")] [HttpGet] public object GetCheckToolsDotCheckBillList(string sWhere) { try { ds = Sc_CheckToolsDotCheckBillList_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; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_CheckToolsDotCheckBillList_s(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_CheckToolsDotCheckBillList order by 日期 desc", "h_v_Sc_CheckToolsDotCheckBillList"); } #endregion #region 直接调拨单 #region 直接调拨单 保存/编辑 /// /// 直接调拨单 /// /// /// [Route("Kf_MoveStockBill/SaveKf_MoveStockBillMain")] [HttpPost] public object SaveKf_MoveStockBillMain([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); //子表 string refSav = sArray[2].ToString();//操作方式数据类型 1添加 3修改 2 复制 string msg4 = sArray[3].ToString();//用户名 DBUtility.ClsPub.CurUserName = msg4; string UserName = ""; string s = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsKf_MoveStockBill oBill = new DAL.ClsKf_MoveStockBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Kf_MoveStockBillMain(msg2); foreach (Model.ClsKf_MoveStockBillMain oItem in lsmain) { if (refSav == "Add") { //单据号是否重复 if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = 1; return objJsonResult; } } if (refSav == "Update") { if (oBill.ShowBill(oItem.HInterID, ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据有误!"; objJsonResult.data = 1; return objJsonResult; } //判断是否可编辑 if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据已经被审核,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(oBill, ref s)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = s + ",不允许修改"; objJsonResult.data = 1; return objJsonResult; } } oItem.HMaker = msg4; UserName = oItem.HMaker; //制单人 oItem.HBillType = "1207"; oItem.HBillSubType = "1207"; oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Kf_MoveStockBillSub(msg3); int i = 0; oBill.DetailColl.Clear(); foreach (Model.ClsKf_MoveStockBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oItemSub.HCloseType = false; //关闭类型 //oItemSub.HSourceInterID = 0; // 源单主内码 //oItemSub.HSourceEntryID = 0; //源单子内码 oBill.DetailColl.Add(oItemSub); } //进行 会计期间 结账 的判断和控制 int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } //保存 //保存完毕后处理 bool bResult; if (refSav == "Add") { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else if (refSav == "Update") { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = false; } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region 直接调拨单 编辑页面初始化 [Route("Kf_MoveStockBill/Kf_MoveStockBillEdit")] [HttpGet] public object Kf_MoveStockBillEdit(long HInterID) { try { List tableList = new List(); ds = oCN.RunProcReturn("exec h_p_Kf_MoveStockBill_Edit " + HInterID, "h_p_Kf_MoveStockBill_Edit"); tableList.Add(ds.Tables[0]); tableList.Add(ds.Tables[1]); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "false!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = tableList; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 直接调拨单 审核/反审核功能 [Route("Kf_MoveStockBill/CheckKf_MoveStockBill")] [HttpGet] public object CheckKf_MoveStockBill(string HInterID, int Type, string user) { try { Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); DAL.ClsKf_OtherInBill oBill = new DAL.ClsKf_OtherInBill(); //判断是否有删除权限 if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockBill_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; } //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作 if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //根据HInterID获取该单据的数据 { if (oBill.omodel.HCloseMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已关闭!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HDeleteMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } //进行 会计期间 结账 的判断和控制 string s = ""; int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } ClsPub.CurUserName = user; BillOld.MvarItemKey = "Kf_ICStockBillMain"; 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; } } //审核前控制========================================= string sql1 = "exec h_p_Kf_MoveStockBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql1, "h_p_Kf_MoveStockBill_BeforeCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; oCN.RollBack(); 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; oCN.RollBack(); return objJsonResult; } //================================================================================== //审核单据 if (!oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_MoveStockBill_AfterCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true) { 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; } } //反审核前控制========================================= string sql1 = "exec h_p_Kf_MoveStockBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql1, "h_p_Kf_MoveStockBill_BeforeUnCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //=========================================================== //反审核单据 if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_MoveStockBill_AfterUnCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true) { } 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_MoveStockBill/CloseKf_MoveStockBill")] [HttpGet] public object CloseKf_MoveStockBill(string HInterID, int Type, string user) { try { //判断是否有删除权限 if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockBill_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_MoveStockBill/DropKf_MoveStockBill")] [HttpGet] public object DropKf_MoveStockBill(string HInterID, int Type, 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; } 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_MoveStockBill/GetMoveStockBillList")] [HttpGet] public object GetMoveStockBillList(string sWhere,string user) { try { List columnNameList = new List(); //定义声明变量 ,把通过 new List()创建的 实例,赋值给变量 //判断是否有查询权限 if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockBillQuery", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; 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 { string sql = "select * from h_v_IF_MoveStockBillList where 1=1 " + sWhere+ "order by hmainid desc"; ds = oCN.RunProcReturn(sql, "h_v_IF_MoveStockBillList"); } foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用 { Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串 columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 直接调拨单 删除 [Route("Kf_MoveStockBill/DelteteGetMoveStockBill")] [HttpGet] public object DelteteGetMoveStockBill(string HInterID, string user) { try { string s = ""; DAL.ClsKf_MoveStockBill oBill = new DAL.ClsKf_MoveStockBill(); //判断是否有删除权限 if (!DBUtility.ClsPub.Security_Log("Kf_MoveStockBill_Drop", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无权限删除!"; objJsonResult.data = null; return objJsonResult; } //删除前控制========================================= string sql1 = "exec h_p_Kf_MoveStockBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql1, "h_p_Kf_MoveStockBill_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; } //================================================================================== //进行 会计期间 结账 的判断和控制 int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } oCN.BeginTran(); //直接调拨单 删除 撤销 回填 调拨申请单 关联数量 oCN.RunProc("exec h_p_Kf_UpDateRelation_MoveStockRequestToPOStockIn_Del " + HInterID); oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID); oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID); //删除后控制================================================================================== string sql2 = "exec h_p_Kf_MoveStockBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql2, "h_p_Kf_MoveStockBill_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.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_MoveStockBill/loadKf_MoveStockBillMain_Push")] [HttpGet] public object loadKf_MoveStockBillMain_Push(long HInterID, long HSubID) { try { ds = oCN.RunProcReturn("select * from h_v_IF_MoveStockRequestBillList_Litee where hmainid =" + HInterID + " and hsubid = " + HSubID, "h_v_IF_MoveStockRequestBillList_Litee"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "未查询到源单信息!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #endregion /// /// 销售出库单列表 /// /// [Route("Kf_SellOutBill/GetSellOutBillList")] [HttpGet] public object GetSellOutBillList(string sWhere,string user) { try { List columnNameList = new List(); //定义声明变量 ,把通过 new List()创建的 实例,赋值给变量 //判断是否有查询权限 if (!DBUtility.ClsPub.Security_Log("Kf_SellOutBillQuery", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有查询权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_GetSellOutBillList(sWhere); foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用 { Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串 columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; //} //else //{ //objJsonResult.code = "0"; //objJsonResult.count = 0; //objJsonResult.Message = "无数据"; //objJsonResult.data = null; //return objJsonResult; //} } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region 销售出库单列表-分页 /// /// 销售出库单列表 /// /// [Route("Kf_SellOutBill/GetSellOutBillList_byPage")] [HttpGet] public object GetSellOutBillList_byPage(string sWhere, string user, string Organization, int page, int size) { try { List columnNameList = new List(); //定义声明变量 ,把通过 new List()创建的 实例,赋值给变量 //判断是否有查询权限 if (!DBUtility.ClsPub.Security_Log("Kf_SellOutBillQuery", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有查询权限!"; objJsonResult.data = null; return objJsonResult; } sWhere = sWhere.Replace("'", "''"); if (sWhere == null || sWhere.Equals("")) { ds = oCN.RunProcReturn("exec h_p_IF_SellOutBillList " + page + "," + size + ",'" + Organization + "'," + "''", "h_p_IF_SellOutBillList"); } else { ds = oCN.RunProcReturn("exec h_p_IF_SellOutBillList " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_IF_SellOutBillList"); } //添加列名 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 = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); objJsonResult.Message = "Sucess!"; objJsonResult.list = columnNameList; 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 /// ///销售出库单删除功能 /// /// [Route("Kf_SellOutBill/DeltetSellOutBill")] [HttpGet] 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 = 0; objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //================================================================================== //进行 会计期间 结账 的判断和控制 int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } oCN.BeginTran(); //销售出库删除回填销售订单关联数量 oCN.RunProc("exec h_p_Xs_UpDateRelation_SeOrderToSellOut_Delete " + HInterID); //销售出库删除回填收货通知单关联数量 oCN.RunProc("exec h_p_Xs_UpDateRelation_SeOutStockToPOStockIn_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 = 0; 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 = 0; objJsonResult.Message = "删除失败!原因:" + s; objJsonResult.data = null; oCN.RollBack(); return objJsonResult; } //============================================================================================== oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "您已删除单据号为" + BillOld.omodel.HBillNo + "的销售出库单!"; 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; } } #region sql语句 public static DataSet Sc_GetSellOutBillList(string sWhere) { 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 #region 其他出库单 #region 其他出库单保存/编辑 /// /// 其他入库单 /// /// /// [Route("Kf_OtherOutBill/SaveKf_OtherOutBillMain")] [HttpPost] public object SaveKf_OtherOutBillMain([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); //子表 string refSav = sArray[2].ToString();//操作方式数据类型 1添加 3修改 2 复制 string msg4 = sArray[3].ToString();//用户名 DBUtility.ClsPub.CurUserName = msg4; string UserName = ""; string s = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Kf_OtherOutBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsKf_OtherOutBill oBill = new DAL.ClsKf_OtherOutBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Kf_OtherOutBillMain(msg2); foreach (Model.ClsKf_OtherOutBillMain oItem in lsmain) { if (refSav == "Add") { //单据号是否重复 if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = 1; return objJsonResult; } } if (refSav == "Update") { if (oBill.ShowBill(oItem.HInterID, ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据有误!"; objJsonResult.data = 1; return objJsonResult; } //判断是否可编辑 if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据已经被审核,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(oBill, ref s)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = s + ",不允许修改"; objJsonResult.data = 1; return objJsonResult; } } oItem.HMaker = msg4; UserName = oItem.HMaker; //制单人 oItem.HBillType = "1206"; oItem.HBillSubType = "1206"; oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Kf_OtherOutBillSub(msg3); int i = 0; oBill.DetailColl.Clear(); foreach (Model.ClsKf_OtherOutBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oItemSub.HCloseType = false; //关闭类型 oItemSub.HSourceInterID = 0; // 源单主内码 oItemSub.HSourceEntryID = 0; //源单子内码 oBill.DetailColl.Add(oItemSub); } //进行 会计期间 结账 的判断和控制 int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } //保存 //保存完毕后处理 bool bResult; if (refSav == "Add") { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else if (refSav == "Update") { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = false; } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region 其他出库单 编辑页面初始化 [Route("Kf_OtherOutBill/Kf_OtherOutBillEdit")] [HttpGet] public object Kf_OtherOutBillEdit(long HInterID) { try { List tableList = new List(); ds = oCN.RunProcReturn("exec h_p_Kf_OtherOutBill_Edit " + HInterID, "h_p_Kf_OtherOutBill_Edit"); tableList.Add(ds.Tables[0]); tableList.Add(ds.Tables[1]); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "false!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = tableList; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 其他出库单列表 /// /// 其他出库单列表 /// /// [Route("Kf_OtherOutBill/GetOtherOutBillList")] [HttpGet] public object GetOtherOutBillList(string sWhere,string user) { try { List columnNameList = new List(); //定义声明变量 ,把通过 new List()创建的 实例,赋值给变量 //判断是否有查询权限 if (!DBUtility.ClsPub.Security_Log("Kf_OtherOutBillQuery", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查询权限!"; objJsonResult.data = null; return objJsonResult; } if (sWhere == null || sWhere.Equals("")) { 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 hmainid desc"; ds = oCN.RunProcReturn(sql, "h_v_Kf_OtherOutBillList"); } foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用 { Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串 columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0];//代码将第一个DataTable(索引为0)赋值给objJsonResult的data属性 objJsonResult.list = columnNameList;//将columnNameList赋值给objJsonResult的list属性 return objJsonResult; //} //else //{ //objJsonResult.code = "0"; //objJsonResult.count = 0; //objJsonResult.Message = "无数据"; //objJsonResult.data = null; //return objJsonResult; //} } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 其他出库单 删除 [Route("Kf_OtherOutBill/DelteteGetOtherOutBill")] [HttpGet] public object DelteteGetOtherOutBill(string HInterID, string user) { try { string s = ""; DAL.ClsKf_OtherInBill oBill = new DAL.ClsKf_OtherInBill(); //判断是否有删除权限 if (!DBUtility.ClsPub.Security_Log("Kf_OtherOutBill_Drop", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无权限删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.ShowBill(long.Parse(HInterID), ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据有误!"; objJsonResult.data = 1; return objJsonResult; } //判断是否可编辑 if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据已经被审核,不允许删除!"; objJsonResult.data = 1; return objJsonResult; } //删除前控制========================================= string sql1 = "exec h_p_Kf_OtherOutBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql1, "h_p_Kf_ICStockBill_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; } //================================================================================== //进行 会计期间 结账 的判断和控制 int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } oCN.BeginTran(); oCN.RunProc("Delete From Kf_ICStockBillMain where HInterID = " + HInterID); oCN.RunProc("Delete From Kf_ICStockBillSub where HInterID = " + HInterID); //删除后控制================================================================================== string sql2 = "exec h_p_Kf_OtherOutBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql2, "h_p_Kf_ICStockBill_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.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 { Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); DAL.ClsKf_OtherOutBill oBill = new DAL.ClsKf_OtherOutBill() ; //判断是否有删除权限 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; } //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作 if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //根据HInterID获取该单据的数据 { if (oBill.omodel.HCloseMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已关闭!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HDeleteMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } //进行 会计期间 结账 的判断和控制 string s = ""; int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } ClsPub.CurUserName = user; BillOld.MvarItemKey = "Kf_ICStockBillMain"; 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; } } //审核前控制========================================= string sql1 = "exec h_p_Kf_OtherOutBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql1, "h_p_Kf_ICStockBill_BeforeCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; oCN.RollBack(); 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; oCN.RollBack(); return objJsonResult; } //================================================================================== //审核单据 if (!oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_OtherOutBill_AfterCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true) { 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; } } //反审核前控制========================================= string sql1 = "exec h_p_Kf_OtherOutBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql1, "h_p_Kf_ICStockBill_BeforeUnCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //=========================================================== //反审核单据 if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_OtherOutBill_AfterUnCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true) { //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 #region 其它出库单 作废/反作废功能 [Route("Kf_OtherInBill/DropKf_ICStockBill")] [HttpGet] public object DropKf_ICStockBill(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 #endregion /// /// 委外出库单列表 /// /// [Route("Kf_EntrustOutBill/GetEntrustOutBill")] [HttpGet] public object GetEntrustOutBill(string sWhere) { try { ds = Sc_GetEntrustOutBill(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; } } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #region sql语句 public static DataSet Sc_GetEntrustOutBill(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Kf_EntrustOutBillList ", "h_v_Kf_EntrustOutBillList"); } #endregion ///// ///// 采购入库单列表 ///// ///// //[Route("Kf_POStockInBill/GetPOStockInBill")] //[HttpGet] //public object GetPOStockInBill(string sWhere) //{ // try // { // ds = Sc_GetPOStockInBill(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; // } // } // catch (Exception ex) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); // objJsonResult.data = null; // return objJsonResult; // } //} #region sql语句 public static DataSet Sc_GetPOStockInBill(string sWhere) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_IF_POStockInBillList order by 日期 desc", "h_v_IF_POStockInBillList"); } #endregion #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 #region 其他入库单 #region 其他入库单保存/编辑 /// /// 其他入库单 /// /// /// [Route("Kf_OtherInBill/SaveKf_OtherInBillMain")] [HttpPost] public object SaveKf_OtherInBillMain([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); //子表 string refSav = sArray[2].ToString();//操作方式数据类型 1添加 3修改 2 复制 string msg4 = sArray[3].ToString();//用户名 DBUtility.ClsPub.CurUserName = msg4; string UserName = ""; string s = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Kf_OtherInBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsKf_OtherInBill oBill = new DAL.ClsKf_OtherInBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Kf_OtherInBillMain(msg2); foreach (Model.ClsKf_OtherInBillMain oItem in lsmain) { if (refSav == "Add") { //单据号是否重复 if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = 1; return objJsonResult; } } if (refSav == "Update") { if (oBill.ShowBill(oItem.HInterID, ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据有误!"; objJsonResult.data = 1; return objJsonResult; } //判断是否可编辑 if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据已经被审核,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!"; objJsonResult.data = 1; return objJsonResult; } if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(oBill, ref s)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = s + ",不允许修改"; objJsonResult.data = 1; return objJsonResult; } } oItem.HMaker = msg4; UserName = oItem.HMaker; //制单人 oItem.HBillType = "1203"; oItem.HBillSubType = "1203"; oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Kf_OtherInBillSub(msg3); int i = 0; oBill.DetailColl.Clear(); foreach (Model.ClsKf_OtherInBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oItemSub.HCloseType = false; //关闭类型 oItemSub.HSourceInterID = 0; // 源单主内码 oItemSub.HSourceEntryID = 0; //源单子内码 oBill.DetailColl.Add(oItemSub); } //进行 会计期间 结账 的判断和控制 int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } //保存 //保存完毕后处理 bool bResult; if (refSav == "Add") { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else if (refSav == "Update") { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = false; } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region 其他入库单 编辑页面初始化 [Route("Kf_OtherInBill/Kf_OtherInBillEdit")] [HttpGet] public object Kf_OtherInBillEdit(long HInterID) { try { List tableList = new List(); ds = oCN.RunProcReturn("exec h_p_Kf_ICStockBillMain_Edit " + HInterID, "h_p_Kf_ICStockBillMain_Edit"); tableList.Add(ds.Tables[0]); tableList.Add(ds.Tables[1]); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "false!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = tableList; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 其它入库单审核/反审核功能 [Route("Kf_OtherInBill/CheckKf_OtherInBill")] [HttpGet] public object CheckKf_OtherInBill(string HInterID, int Type, string user) { try { Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); DAL.ClsKf_OtherInBill oBill = new DAL.ClsKf_OtherInBill(); //判断是否有删除权限 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; } //针对需要进行的操作,检验当前单据的状态是否支持需要进行的操作 if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) //根据HInterID获取该单据的数据 { if (oBill.omodel.HCloseMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已关闭!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HDeleteMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } //进行 会计期间 结账 的判断和控制 string s = ""; int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } ClsPub.CurUserName = user; BillOld.MvarItemKey = "Kf_ICStockBillMain"; 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; } } //审核前控制========================================= string sql1 = "exec h_p_Kf_ICStockBill_BeforeCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql1, "h_p_Kf_ICStockBill_BeforeCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; oCN.RollBack(); 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; oCN.RollBack(); return objJsonResult; } //================================================================================== //审核单据 if (!oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_ICStockBill_AfterCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true) { 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; } } //反审核前控制========================================= string sql1 = "exec h_p_Kf_ICStockBill_BeforeUnCheckCtrl " + oBill.omodel.HInterID + ",'" + oBill.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql1, "h_p_Kf_ICStockBill_BeforeUnCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //=========================================================== //反审核单据 if (oBill.AbandonCheck(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Kf_ICStockBill_AfterUnCheckCtrl", user, ref DBUtility.ClsPub.sExeReturnInfo) == true) { //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 #region 其他入库单列表 /// /// 其他入库单列表 /// /// [Route("Kf_OtherInBill/GetOtherInBill")] [HttpGet] public object GetOtherInBill(string sWhere,string user) { try { List columnNameList = new List(); //定义声明变量 ,把通过 new List()创建的 实例,赋值给变量 //判断是否有查询权限 if (!DBUtility.ClsPub.Security_Log("Kf_OtherInBillQuery", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查询权限!"; objJsonResult.data = null; return objJsonResult; } if (sWhere == null || sWhere.Equals("")) { 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 hmainid desc"; ds = oCN.RunProcReturn(sql, "h_v_Kf_OtherInBillList"); } foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用 { Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串 columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0];//代码将第一个DataTable(索引为0)赋值给objJsonResult的data属性 objJsonResult.list = columnNameList;//将columnNameList赋值给objJsonResult的list属性 return objJsonResult; //} //else //{ //objJsonResult.code = "0"; //objJsonResult.count = 0; //objJsonResult.Message = "无数据"; //objJsonResult.data = null; //return objJsonResult; //} } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 其他入库单 删除 /// ///参数:string HInterID。 ///返回值:object。 /// [Route("Kf_SellOutBill/DeleteKf_ICStockBillMain")] [HttpGet] public object DeleteKf_ICStockBillMain(string HInterID, string user) { try { string s = ""; DAL.ClsKf_OtherInBill oBill = new DAL.ClsKf_OtherInBill(); //查看权限 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 (HInterID == null || HInterID.Equals("")) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "HInterID不能为空!"; objJsonResult.data = null; return objJsonResult; } if (oBill.ShowBill(long.Parse(HInterID), ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据有误!"; objJsonResult.data = 1; return objJsonResult; } //判断是否可编辑 if (oBill.omodel.HChecker != "" && oBill.omodel.HChecker != null) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "此单据已经被审核,不允许删除!"; objJsonResult.data = 1; return objJsonResult; } //删除前控制========================================= string sql1 = "exec h_p_Kf_ICStockBill_BeforeDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql1, "h_p_Kf_ICStockBill_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; } //================================================================================== //进行 会计期间 结账 的判断和控制 int sYear = 0; int sPeriod = 0; DateTime HDate = DateTime.Now; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.Message = s; return objJsonResult; } oCN.BeginTran(); oCN.RunProc("delete from Kf_ICStockBillMain where HInterID = " + HInterID); oCN.RunProc("delete from Kf_ICStockBillSub where HInterID= " + HInterID); //删除后控制================================================================================== string sql2 = "exec h_p_Kf_ICStockBill_AfterDelCtrl " + BillOld.omodel.HInterID + ",'" + BillOld.omodel.HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql2, "h_p_Kf_ICStockBill_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.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 #endregion /// /// 委外入库单列表 /// /// [Route("Kf_EntrustInBill/GetEntrustInBill")] [HttpGet] public object GetEntrustInBill(string sWhere,string user) { try { List columnNameList = new List(); //定义声明变量 ,把通过 new List()创建的 实例,赋值给变量 //判断是否有查询权限 if (!DBUtility.ClsPub.Security_Log("Kf_EntrustInBillQuery", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无权限查询!"; objJsonResult.data = null; return objJsonResult; } if (sWhere == null || sWhere.Equals("")) { 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+ " order by hmainid desc"; ds = oCN.RunProcReturn(sql, "h_v_Kf_EntrustInBillList"); } foreach (DataColumn col in ds.Tables[0].Columns)//遍历ds中第一个表(Tables[0])的所有列(Columns)每次循环中,col变量会持有当前列的引用 { Type dataType = col.DataType; //获取当前数据类型传入 自定义变量datadataType string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //字符串拼接 // 将列名和数据类型信息拼接成一个JSON格式的字符串 columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0];//代码将第一个DataTable(索引为0)赋值给objJsonResult的data属性 objJsonResult.list = columnNameList;//将columnNameList赋值给objJsonResult的list属性 return objJsonResult; //} //else //{ //objJsonResult.code = "0"; //objJsonResult.count = 0; //objJsonResult.Message = "无数据"; //objJsonResult.data = null; //return objJsonResult; //} } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } //测试专用接口 [Route("LookingFor/Test")] [HttpGet] public object Test(string HbillNo)//Sc_CheckToolsRepair/GetCheckToolsRepairWorkBillList { DataSet ds; ds = new SQLHelper.ClsCN().RunProcReturn("EXEC h_p_Xs_SellOutFindSP '" + HbillNo + "'", "h_p_Xs_SellOutFindSP"); if (Pub_Class.ClsPub.isLong(ds.Tables[0].Rows.Count) >= 0) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "true!"; objJsonResult.data = ds.Tables[0];//ds.Tables[0].Rows[1][0] return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "false!"; objJsonResult.data = null; return objJsonResult; } } #endregion #region 模具维修记录单 #region 模具维修记录单保存/编辑 /// /// 保存模具维修单 /// /// /// [Route("Sb_MouldRepairWorkBill/SaveGetMouldRepairWorkBillList")] [HttpPost] public object SaveGetMouldRepairWorkBillList([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg4 = sArray[2].ToString(); string msg5 = sArray[3].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSb_MouldRepairWorkBill oBill = new DAL.ClsSb_MouldRepairWorkBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Gy_MouldRepairWorkBillMain(msg2); foreach (Model.ClsSb_MouldRepairWorkBillMain oItem in lsmain) { oItem.HMaker = msg4; UserName = msg4; //制单人 oItem.HBillType = "3807"; oItem.HBillSubType = "3807"; //oItem.HBillNo = ""; //单据号 //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); //oItem.HEquipID = 0; //设备ID(Gy_EquipMent) //oItem.HPeriod = 0; //oItem.HRepairBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); // --维修开始日期 //oItem.HRepairEndDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --维修结束日期 //oItem.HRepairContent = ""; //维修内容 //oItem.HCycleUnit = ""; //时间单位(小时,天) //oItem.HPlanTimes = 0; //计划维修工时 //oItem.HTimes = 0; //实际维修工时 //oItem.HEmpID = 0; //维修人(Gy_Employee) //oItem.HManagerID = 0; //主管(Gy_Employee) //oItem.HDeptID = 0; //维修部门(Gy_Department) //oItem.HExplanation = ""; //--维修要求 //oItem.HInnerBillNo = ""; // --内部单据号 //oItem.HMouldID = 0; //成品模具ID //oItem.HSupID = 0; //--供应商(Gy_Supplier) //oItem.HRepairType = ""; //--维修类型(内部维修,委外维修) addnew //oItem.HNewModel = ""; //维修后新规格 //oItem.HNewDesignLife = 0; //新设计寿命 //oItem.HRepairID = 0; //维修项目(Gy_Repair) //oItem.HRemark = ""; //备注 //oItem.HMainSourceInterID = oItem.HInterID; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Gy_MouldRepairWorkBillSub(msg3); int i = 0; foreach (Model.ClsSb_MouldRepairWorkBillSub oItem in ls) { i++; oItem.HEntryID = i; //oItemSub.HCloseMan = ""; //行关闭 oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); oItem.HCloseType = false; //关闭类型 //oItemSub.HRemark = ""; //备注 oItem.HRelationQty = 0; //关联数量 //oItemSub.HRelationMoney = 0; //关联金额 //oItemSub.HRepairID = 0; //维修项目 //oItemSub.HRepairExplanation =""; //维修要求 //oItemSub.HManagerID = 0; //负责人ID //oItemSub.HMoney = 0; //维修费用 oBill.DetailColl.Add(oItem); } //配件数据 //按 },{来拆分数组 //去掉【和】 msg5 = msg5.Substring(1, msg5.Length - 2); msg5 = msg5.Replace("\\", ""); msg5 = msg5.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls1 = new List(); 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; if (oBill.omodel.HInterID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region[模具维修列表编辑时获取表头数据] [Route("Sb_MouldRepairWorkBill/Sb_MouldRepairWorkBillListCheckDetai")] [HttpGet] public ApiResult Sb_MouldRepairWorkBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldRepairWorkBillList_Edit where hmainid= " + HID + " ", "h_v_Sc_MouldRepairWorkBillList_Edit"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在维修单号" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具维修列表编辑时获取表体数据] [Route("Sb_MouldRepairWorkBill/Sb_MouldRepairWorkBillListProjectDetai")] [HttpGet] public object Sb_MouldRepairWorkBillListProjectDetai(string sqlWhere) { DataSet ds, ds1; List list = new List(); try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); 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) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + e.ToString(); objJsonResult.data = null; } return objJsonResult; } #endregion #region [模具维修单删除功能] /// /// 模具维修单删除功能 /// /// [Route("Sb_MouldRepairWorkBill/DeltetMouldRepairWorkBill")] [HttpGet] public object DeltetMouldRepairWorkBill(string HInterID,string user) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSb_MouldRepairWorkBill oBill = new DAL.ClsSb_MouldRepairWorkBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; objJsonResult.data = null; return objJsonResult; } bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); if (IsDete) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #region [模具维修单审核、反审核] /// /// /// /// 单据ID /// 审核(0),反审核(1) /// 审核人 /// [Route("Sb_MouldRepairWorkBill/AuditProcessReportList")] [HttpGet] public object AuditProcessReportList(int HInterID, int IsAudit, string CurUserName) { string ModRightNameCheck = "Sb_MouldRepairWorkBill_Check"; DBUtility.ClsPub.CurUserName = CurUserName; try { //审核权限 if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败!无权限!"; objJsonResult.data = null; return objJsonResult; } if (HInterID <= 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "HInterID小于0!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); DAL.ClsSb_MouldRepairWorkBill oBill = new DAL.ClsSb_MouldRepairWorkBill(); //查看是否已审核,关闭,作废 if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HCloseMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已关闭!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HDeleteMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } if (IsAudit == 0) //审核判断 { if (oBill.omodel.HChecker.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已审核!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 1) //反审核判断 { if (oBill.omodel.HChecker.Trim() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未审核!不需要反审核!"; objJsonResult.data = null; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } if (IsAudit == 0) //审核提交 { //审核提交 if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "审核成功"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 1) //反审核提交 { //反审核提交AbandonCheck if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反审核成功"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 模具维修记录单保存/编辑 /// /// 保存模具维修单 /// /// /// [Route("Sb_MouldRepairWorkBill/SaveGetMouldRepairWorkBill_PDA")] [HttpPost] public object SaveGetMouldRepairWorkBill_PDA([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg4 = sArray[2].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSb_MouldRepairWorkBill oBill = new DAL.ClsSb_MouldRepairWorkBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Gy_MouldRepairWorkBillMain(msg2); foreach (Model.ClsSb_MouldRepairWorkBillMain oItem in lsmain) { oItem.HMaker = msg4; UserName = msg4; //制单人 oItem.HBillType = "3807"; oItem.HBillSubType = "3807"; oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Gy_MouldRepairWorkBillSub(msg3); int i = 0; foreach (Model.ClsSb_MouldRepairWorkBillSub oItem in ls) { i++; oItem.HEntryID = i; oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); oItem.HCloseType = false; //关闭类型 oItem.HRelationQty = 0; //关联数量 oBill.DetailColl.Add(oItem); } //保存 //保存完毕后处理 bool bResult; if (oBill.omodel.HInterID == 0) { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region 模具维修记录表列表 [Route("Sb_MouldRepairWorkBill/GetMouldRepairWorkBillList")] [HttpGet] public object GetMouldRepairWorkBillList(string sWhere, string user) { try { List columnNameList = new List(); if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_MouldRepairWorkBillList_s(sWhere); //添加列名 foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } //if (ds.Tables[0].Rows.Count != 0 || ds != null) //{ objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; //} //else //{ //objJsonResult.code = "0"; //objJsonResult.count = 0; //objJsonResult.Message = "无数据"; //objJsonResult.data = null; //return objJsonResult; //} } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } public static DataSet Sc_MouldRepairWorkBillList_s(string sWhere) { if (sWhere == null || sWhere.Equals("")) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairWorkBillList where 1=1 " + sWhere + " order by hmainid desc", "h_v_Sc_MouldRepairWorkBillList"); } else { string sql1 = "select * from h_v_Sc_MouldRepairWorkBillList where 1 = 1 "; string sql = sql1 + sWhere + "order by hmainid desc"; return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList"); } } #endregion #region 模具维修记录表列表 [Route("Sb_MouldRepairWorkBill/GetMouldRepairWorkBill_PDA")] [HttpGet] public object GetMouldRepairWorkBill_PDA(string sWhere, string user) { try { List columnNameList = new List(); if (!DBUtility.ClsPub.Security_Log("Sb_MouldRepairWorkBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_MouldRepairWorkBillList_PDA(sWhere); //添加列名 foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } public static DataSet Sc_MouldRepairWorkBillList_PDA(string sWhere) { if (sWhere == null || sWhere.Equals("")) { return new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldRepairWorkBillList_PDA where 1=1 " + sWhere + " order by hmainid desc", "h_v_Sc_MouldRepairWorkBillList_PDA"); } else { string sql1 = "select * from h_v_Sc_MouldRepairWorkBillList_PDA where 1 = 1 "; string sql = sql1 + sWhere + "order by hmainid desc"; return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldRepairWorkBillList_PDA"); } } #endregion #endregion #region 器具维修记录统计分析 /// /// 器具维修记录统计分析 列表 ///参数:string sql。 ///返回值:object。 /// [Route("Sb_MouldRepairWorkBill/Sb_MouldRepairWorkBill")] [HttpGet] public object Sb_MouldRepairWorkBill(string DateYear, string HType, string user) { try { List columnNameList = new List(); 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; } } #endregion #region 模具验收单 #region 模具维修验收单保存/编辑 /// /// 保存模具维修单 /// /// /// [Route("Sc_MouldRepairCheckBill/SaveGetMouldRepairCheckBillList")] [HttpPost] public object SaveGetMouldRepairCheckBillList([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg4 = sArray[2].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sb_EquipRepairCheckBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DLL.ClsSc_MouldRepairCheckBill oBill = new DLL.ClsSc_MouldRepairCheckBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Gy_MouldRepairCheckBillMain(msg2); foreach (Model.ClsSc_MouldRepairCheckBillMain oItem in lsmain) { oItem.HMaker = msg4; UserName = oItem.HMaker; //制单人 oItem.HBillType = "3817"; oItem.HBillSubType = "3817"; //oItem.HBillNo = ""; //单据号 //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 //oItem.HInnerBillNo = ""; // --内部单据号 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); //oItem.HEquipID = 0; //设备ID(Gy_EquipMent) //oItem.HPeriod = 0; //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); // --维修日期 //oItem.HCheckResult = ""; //验收结论--(正常,异常) //oItem.HEmpID = 0; //验收人(Gy_Employee) //oItem.HManagerID = 0; //负责人(Gy_Employee) //oItem.HDeptID = 0; //验收部门(Gy_Department) //oItem.HExplanation = ""; //摘要(故障描述) //oItem.HRemark = ""; //备注 //oItem.HMainSourceInterID = oItem.HInterID; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Gy_MouldRepairCheckBillSub(msg3); int i = 0; foreach (Model.ClsSc_MouldRepairCheckBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; //oItemSub.HRepairCheckID = 0; //验收项目ID //oItemSub.HRepairCheckContent = ""; //验收内容 //oItemSub.HManagerID = 0; //负责人ID //oItemSub.HCloseMan = ""; //行关闭 oItemSub.HCloseType = false; //关闭类型 //oItemSub.HRemark = ""; //备注 oItemSub.HSourceInterID = 0; // 源单主内码 oItemSub.HSourceEntryID = 0; //源单子内码 //oItemSub.HSourceBillNo = ""; //源单单号 //oItemSub.HSourceBillType = ""; //源单类型 //oItemSub.HRelationQty = 0; //关联数量 //oItemSub.HRelationMoney = 0; //关联金额 //oItemSub.HRepairID = 0; //维修项目 //oItemSub.HRepairExplanation =""; //维修要求 //oItemSub.HMoney = 0; //维修费用 oBill.DetailColl.Add(oItemSub); } //保存 //保存完毕后处理 bool bResult; if (oBill.omodel.HInterID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region[模具维修验收单编辑时获取表头数据] [Route("Sc_MouldRepairCheckBill/Sb_MouldRepairCheckBillListCheckDetai")] [HttpGet] public ApiResult Sb_MouldRepairCheckBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldRepairCheckBillList_Edit where hmainid= " + HID + " ", "h_v_Sc_MouldRepairCheckBillList_Edit"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在维修单号" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具维修验收单编辑时获取表体数据] [Route("Sc_MouldRepairCheckBill/Sb_MouldRepairCheckBillListProjectDetai")] [HttpGet] public object Sb_MouldRepairCheckBillListProjectDetai(string sqlWhere) { DataSet ds; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { //ds = oCN.RunProcReturn("select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub", "Sc_MouldRepairCheckBillSub"); ds = oCN.RunProcReturn("select * from h_v_Sc_MouldRepairCheckBillList_Edit", "h_v_Sc_MouldRepairCheckBillList_Edit"); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.data = ds.Tables[0]; } else { //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub where 1 = 1 "; string sql1 = "select * from h_v_Sc_MouldRepairCheckBillList_Edit where 1 = 1 "; string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldRepairCheckBillList_Edit"); 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 [模具维修验收单删除功能] /// /// 模具维修单删除功能 /// /// [Route("Sc_MouldRepairCheckBill/DeltetMouldRepairCheckBill")] [HttpGet] public object DeltetMouldRepairCheckBill(string HInterID,string user) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sb_EquipRepairCheckBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldRepairCheckBill oBill = new DAL.ClsSc_MouldRepairCheckBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; objJsonResult.data = null; return objJsonResult; } bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); if (IsDete) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #endregion #region 模具故障登记表 #region 模具故障登记表保存/编辑 /// /// 保存故障登记表 /// /// /// [Route("Sc_MouldConkBookBill/SaveGetMouldConkBookBillList")] [HttpPost] public object SaveGetMouldConkBookBillList([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg4 = sArray[2].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldConkBookBill oBill = new DAL.ClsSc_MouldConkBookBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Gy_MouldConkBookBillMain(msg2); foreach (Model.ClsSc_MouldConkBookBillMain oItem in lsmain) { //oItem.HMaker = ""; UserName = msg4; //制单人 DBUtility.ClsPub.CurUserName = UserName; oItem.HBillType = "3815"; oItem.HBillSubType = "3815"; //oItem.HBillNo = ""; //单据号 //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 //oItem.HInnerBillNo = ""; // --内部单据号 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Gy_MouldConkBookBillSub(msg3); int i = 0; foreach (Model.ClsSc_MouldConkBookBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oItemSub.HCloseType = false; //关闭类型 oItemSub.HSourceInterID = 0; // 源单主内码 oItemSub.HSourceEntryID = 0; //源单子内码 oBill.DetailColl.Add(oItemSub); } //保存 //保存完毕后处理 bool bResult; if (oBill.omodel.HInterID == 0) { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region[模具故障登记表编辑时获取表头数据] [Route("Sc_MouldConkBookBill/Sb_MouldConkBookBillListCheckDetai")] [HttpGet] public ApiResult Sb_MouldConkBookBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldConkBookBillList_Edit where hmainid= " + HID + " ", "h_v_Sc_MouldConkBookBillList_Edit"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在维修单号" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具故障登记表编辑时获取表体数据] [Route("Sc_MouldConkBookBill/Sb_MouldConkBookBillListProjectDetai")] [HttpGet] public object Sb_MouldConkBookBillListProjectDetai(string sqlWhere) { DataSet ds; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { //ds = oCN.RunProcReturn("select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub", "Sc_MouldRepairCheckBillSub"); ds = oCN.RunProcReturn("select HConkReasonID,故障原因代码 HConkReasonCode,故障原因 HConkReasonName,故障原因描述 HConkExplanation,HManagerSonID HManagerID,子负责人代码 HManagerCode,子负责人 HManagerName,备注 HRemark from h_v_Sc_MouldConkBookBillList_Edit", "h_v_Sc_MouldConkBookBillList_Edit"); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.data = ds.Tables[0]; } else { //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub where 1 = 1 "; string sql1 = "select HConkReasonID,故障原因代码 HConkReasonCode,故障原因 HConkReasonName,故障原因描述 HConkExplanation,HManagerSonID HManagerID,子负责人代码 HManagerCode,子负责人 HManagerName,备注 HRemark from h_v_Sc_MouldConkBookBillList_Edit where 1 = 1 "; string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldConkBookBillList_Edit"); 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 [模具故障登记表删除功能] /// /// 模具故障登记表删除功能 /// /// [Route("Sc_MouldConkBookBill/DeltetMouldConkBookBill")] [HttpGet] public object DeltetMouldConkBookBill(string HInterID,string user) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldConkBookBill oBill = new DAL.ClsSc_MouldConkBookBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; objJsonResult.data = null; return objJsonResult; } bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); if (IsDete) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #region 模具故障登记单_PDA [Route("Sc_MouldConkBookBill/GetMouldConkBookBillList_PDA")] [HttpGet] public object GetMouldConkBookBillList_PDA(string sWhere, string user) { try { List columnNameList = new List(); if (!DBUtility.ClsPub.Security_Log("Sc_MouldConkBookBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_MouldConkBookBillList_PDA(sWhere); //添加列名 foreach (DataColumn col in ds.Tables[0].Columns) { Type dataType = col.DataType; string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; objJsonResult.list = columnNameList; return objJsonResult; } catch (Exception ex) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } public static DataSet Sc_MouldConkBookBillList_PDA(string sWhere) { DataSet ds; if (sWhere == null || sWhere.Equals("")) { ds = new SQLHelper.ClsCN().RunProcReturn("select * from h_v_Sc_MouldConkBookBillList_PDA where 1=1 " + sWhere + " order by hmainid desc", "h_v_Sc_MouldConkBookBillList_PDA"); } else { string sql1 = "select * from h_v_Sc_MouldConkBookBillList_PDA where 1 = 1 "; string sql = sql1 + sWhere + "order by 日期 desc"; ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldConkBookBillList_PDA"); } return ds; } #endregion #endregion #region 模具保养计划单 #region 模具保养计划单 保存/编辑 /// /// 保存模具保养计划单 /// /// /// [Route("Sc_MouldMaintainPlanBill/SaveGetMouldMaintainPlanBillList")] [HttpPost] public object SaveGetMouldMaintainPlanBillList([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg4 = sArray[2].ToString(); string msg5 = sArray[3].ToString(); string msg6 = sArray[4].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainPlanBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldMaintainPlanBill oBill = new DAL.ClsSc_MouldMaintainPlanBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Gy_MouldMaintainPlanBillMain(msg2); foreach (Model.ClsSc_MouldMaintainPlanBillMain oItem in lsmain) { //oItem.HMaker = ""; UserName = oItem.HMaker; //制单人 oItem.HBillType = "3818"; oItem.HBillSubType = "3818"; oItem.HMainSourceInterID = oItem.HMouldMaintainRuleID; oItem.HMainSourceBillNo = oItem.HMouldMaintainRuleNo; //oItem.HInterID =0; //oItem.HBillNo = ""; oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); //oItem.HMakeDate = ""; //oItem.HYear = ""; //oItem.HPeriod = ""; //oItem.HRemark = ""; //oItem.HCycleUnit = ""; //oItem.HCheckCycle = ""; //oItem.HBeginDate = ""; //oItem.HEndDate = ""; //oItem.HInnerBillNo = ""; //oItem.HExplanation = ""; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //保养项表体数据 //按 },{来拆分数组 //去掉【和】 msg5 = msg5.Substring(1, msg5.Length - 2); msg5 = msg5.Replace("\\", ""); msg5 = msg5.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls1 = new List(); 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); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Gy_MouldMaintainPlanBillSub(msg3); int i = 0; foreach (Model.ClsSc_MouldMaintainPlanBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; //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.DetailColl.Add(oItemSub); } //表体数据 //按 },{来拆分数组 //去掉【和】 //如果是编辑就允许保存,否则不允许 if (oBill.omodel.HInterID != 0) { msg6 = msg6.Substring(1, msg6.Length - 2); msg6 = msg6.Replace("\\", ""); msg6 = msg6.Replace("\n", ""); List lss = new List(); lss = oListModels.getObjectByJson_Sc_MouldMaintainPlanBillSub_Plan(msg6); int l = 0; foreach (Model.ClsSc_MouldMaintainPlanBillSub_Plan oItem in lss) { l++; oItem.HEntryID = l; oItem.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); oItem.HCloseType = false; //关闭类型 oItem.HSourceInterID = 0; // 源单主内码 oItem.HSourceEntryID = 0; //源单子内码 oItem.HRelationQty = 0; //关联数量 oBill.DetailCol2.Add(oItem); } } //保存 //保存完毕后处理 bool bResult; if (oBill.omodel.HInterID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region[模具保养计划单编辑时获取表头数据] [Route("Sc_MouldMaintainPlanBill/Sc_MouldMaintainPlanBillListCheckDetai")] [HttpGet] public ApiResult Sc_MouldMaintainPlanBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldMaintainPlanBillList where hmainid= " + HID + " ", "h_v_Sc_MouldMaintainPlanBillList"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在保养计划单" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具保养计划单编辑时获取表题数据] [Route("Sc_MouldMaintainPlanBill/Sc_MouldMaintainPlanBillListProjectDetai")] [HttpGet] public object Sc_MouldMaintainPlanBillListProjectDetai(string sqlWhere) { DataSet ds, ds1; List list = new List(); try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); //获取保养项目编辑数据 string sql = "select 保养项目ID HMaintainItemID, 保养项目代码 HMaintainItemNumber,保养项目 HMaintainItem,保养部位 HMaintainPart,具体要求 HClaim,负责人ID HManagerID,负责人代码 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) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + e.ToString(); objJsonResult.data = null; } return objJsonResult; } #endregion #region[器具保养记录表,选保养计划获取保养计划清单信息] [Route("Sc_MouldMaintainPlanBill/Sc_MouldMaintainPlanBill_PlanList")] [HttpGet] public object Sc_MouldMaintainPlanBill_PlanList(string HInterID, string HDate) { DataSet ds, ds1; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); List tableList = new List(); //获取保养项目 ds = oCN.RunProcReturn("exec h_p_Sc_MouldMaintain_GetPlanList " + HInterID + ",'" + HDate + "'", "h_p_Sc_MouldMaintain_GetPlanList"); //获取配件项目编辑数据 string sql1 = "select 配件ID HMaterID, 配件代码 HMaterNumber,配件名称 HMaterName,单位ID HUnitID,计量单位代码 HUnitNumber,计量单位名称 HUnitName,用量 HQty,标准用量 HQtyMust,子备注1 HRemark,规格型号 HMaterSpec from h_v_Sc_MouldMaintainPlanBillSub where hmainid = " + HInterID + ""; ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldMaintainPlanBillSub"); tableList.Add(ds.Tables[0]); tableList.Add(ds1.Tables[0]); if (ds.Tables[0].Rows.Count != 0 || ds != null) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.data = tableList; } else { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "没有查询到数据信息!"; objJsonResult.data = tableList; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "发生异常,没有返回任何计划!" + e.ToString(); objJsonResult.data = null; } return objJsonResult; } #endregion #region [模具保养计划单删除功能] /// /// 模具维修单删除功能 /// /// [Route("Sc_MouldMaintainPlanBill/DeltetMouldMaintainPlanBill")] [HttpGet] public object DeltetMouldMaintainPlanBill(string HInterID,string user) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainPlanBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldMaintainPlanBill oBill = new DAL.ClsSc_MouldMaintainPlanBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; objJsonResult.data = null; return objJsonResult; } bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); if (IsDete) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #region 器具保养记录统计分析 /// /// 器具维修记录统计分析 列表 ///参数:string sql。 ///返回值:object。 /// [Route("Sb_MouldRepairWorkBill/Sc_MouldMaintainBillMain")] [HttpGet] public object Sc_MouldMaintainBillMain(string DateYear, string HType, string user) { try { List columnNameList = new List(); 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 模具保养记录表 #region 模具保养记录表 保存/编辑 /// /// 保存模具维修单 /// /// /// [Route("Sc_MouldMaintainBill/SaveGetMouldMaintainBillList")] [HttpPost] public object SaveGetMouldMaintainBillList([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg4 = sArray[2].ToString(); string msg5 = sArray[3].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBill_Edit", 1, false, msg5)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldMaintainBill oBill = new DAL.ClsSc_MouldMaintainBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Sc_MouldMaintainBillMain(msg2); foreach (Model.ClsSc_MouldMaintainBillMain oItem in lsmain) { UserName = oItem.HMaker; //制单人 DBUtility.ClsPub.CurUserName = msg5; oItem.HBillType = "3819"; oItem.HBillSubType = "3819"; //oItem.HInterID =0; //oItem.HBillNo = ""; oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); //oItem.HMakeDate = ""; //oItem.HYear = ""; //oItem.HPeriod = ""; //oItem.HRemark = ""; //oItem.HCycleUnit = ""; //oItem.HCheckCycle = ""; //oItem.HBeginDate = ""; //oItem.HEndDate = ""; //oItem.HInnerBillNo = ""; //oItem.HExplanation = ""; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //保养项表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Sc_MouldMaintainRuleBillSub_Item(msg3); int i = 0; foreach (Model.ClsSc_MouldMaintainRuleBillSub_Item oItemSub in ls) { i++; oItemSub.HEntryID = i; //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; //关联数量 oBill.DetailCol.Add(oItemSub); } //配件项表体数据 //按 },{来拆分数组 //去掉【和】 msg4 = msg4.Substring(1, msg4.Length - 2); msg4 = msg4.Replace("\\", ""); msg4 = msg4.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls1 = new List(); ls1 = oListModels.getObjectByJson_Sc_MouldMaintainBillSub(msg4); int j = 0; foreach (Model.ClsSc_MouldMaintainBillSub Sub in ls1) { j++; Sub.HEntryID = j; //oItemSub.HCloseMan = ""; //行关闭 Sub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now); Sub.HCloseType = false; //关闭类型 //oItemSub.HRemark = ""; //备注 Sub.HSourceInterID = 0; // 源单主内码 Sub.HSourceEntryID = 0; //源单子内码 //oItemSub.HSourceBillNo = ""; //源单单号 //oItemSub.HSourceBillType = ""; //源单类型 Sub.HRelationQty = 0; //关联数量 //oItemSub.HRelationMoney = 0; //关联金额 //HMaterID = "";//配件代码 //HUnitID = "";//单位代码 //HQty = "";//实际用量 //HQtyMust = "";//单位用量 //HRemark = "";//备注 oBill.DetailColl.Add(Sub); } //保存 //保存完毕后处理 bool bResult; if (oBill.omodel.HInterID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region 模具保养记录表 保存/编辑PDA /// /// 保存模具维修单 /// /// /// [Route("Sc_MouldMaintainBill/SaveGetMouldMaintainBillListPDA")] [HttpPost] public object SaveGetMouldMaintainBillListPDA([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg5 = sArray[2].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBill_Edit", 1, false, msg5)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldMaintainBill oBill = new DAL.ClsSc_MouldMaintainBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Sc_MouldMaintainBillMain(msg2); foreach (Model.ClsSc_MouldMaintainBillMain oItem in lsmain) { UserName = oItem.HMaker; //制单人 DBUtility.ClsPub.CurUserName = UserName; oItem.HBillType = "3819"; oItem.HBillSubType = "3819"; //oItem.HInterID =0; //oItem.HBillNo = ""; oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); //oItem.HMakeDate = ""; //oItem.HYear = ""; //oItem.HPeriod = ""; //oItem.HRemark = ""; //oItem.HCycleUnit = ""; //oItem.HCheckCycle = ""; //oItem.HBeginDate = ""; //oItem.HEndDate = ""; //oItem.HInnerBillNo = ""; //oItem.HExplanation = ""; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //保养项表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Sc_MouldMaintainRuleBillSub_Item(msg3); int i = 0; foreach (Model.ClsSc_MouldMaintainRuleBillSub_Item oItemSub in ls) { i++; oItemSub.HEntryID = i; //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; //关联数量 oBill.DetailCol.Add(oItemSub); } //保存 //保存完毕后处理 bool bResult; if (oBill.omodel.HInterID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region[模具保养记录表编辑时获取表头数据] [Route("Sc_MouldMaintainBill/Sc_MouldMaintainBillListCheckDetai")] [HttpGet] public ApiResult Sc_MouldMaintainBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldMaintain where hmainid= " + HID + " ", "h_v_Sc_MouldMaintain"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在保养记录表" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具保养记录表编辑时获取表题数据] [Route("Sc_MouldMaintainBill/Sc_MouldMaintainBillListProjectDetai")] [HttpGet] public object Sc_MouldMaintainBillListProjectDetai(string sqlWhere) { DataSet ds; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { ds = oCN.RunProcReturn("select HMaterID,HUnitID,HQty,HQtyMust,HRemark,HManagerID from Sc_MouldMaintainBillSub", "Sc_MouldMaintainBillSub"); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.data = ds.Tables[0]; } else { string sql1 = "select HMaterID,HUnitID,HQty,HQtyMust,HRemark,HManagerID from Sc_MouldMaintainBillSub where 1 = 1 "; string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "Sc_MouldMaintainBillSub"); 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[模具保养记录表编辑时获取表体数据新(保养项列表、配件项列表)] [Route("Sc_MouldMaintainBill/Sc_MouldMaintainBillListProjectDetaiNew")] [HttpGet] public object Sc_MouldMaintainBillListProjectDetaiNew(string HInterID) { DataSet ds, ds1; List list = new List(); string Swhere = ""; try { if (HInterID != "" || HInterID != null) { Swhere = " and hmainid='" + HInterID + "'"; } else { Swhere = HInterID; } SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); //获取保养项目编辑数据 string sql = "select HMaintainItemID, 保养项目代码 HMaintainItemNumber,保养项目名称 HMaintainItem,保养部位 HMaintainPart,具体要求 HClaim,HManagerID,负责人代码 HManagerNumber,负责人 HManagerName,表体备注 HRemark,保养结果 HMaintainResult from h_v_Sc_MouldMaintainBillListItem where 1 = 1 " + Swhere + ""; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldMaintainBillListItem"); //获取配件项目编辑数据 string sql1 = "select HMaterID, 配件代码 HMaterNumber,配件名称 HMaterName,规格型号 HMaterSpec,HUnitID,单位代码 HUnitNumber,单位名称 HUnitName,实际用量 HQty,标准用量 HQtyMust,HManagerID,负责人代码 HManagerNumber,负责人 HManagerName,表体备注 HRemark from h_v_Sc_MouldMaintainBillList where 1 = 1 " + Swhere + ""; ds1 = oCN.RunProcReturn(sql1, "h_v_Sc_MouldMaintainBillList"); list.Add(ds.Tables[0]); list.Add(ds1.Tables[0]); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.list = list; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + e.ToString(); objJsonResult.data = null; } return objJsonResult; } #endregion #region [模具保养记录表删除功能] /// /// 模具维修单删除功能 /// /// [Route("Sc_MouldMaintainBill/DeltetSc_MouldMaintainBill")] [HttpGet] public object DeltetSc_MouldMaintainBill(string HInterID,string user) { if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldMaintainBill oBill = new DAL.ClsSc_MouldMaintainBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; objJsonResult.data = null; return objJsonResult; } //=========================================Begin 删除前控制 Begin========================================= string sql1 = "exec h_p_Sc_MouldMaintainBill_BeforeDelCtrl " + HInterID + "," + user; ds = oCN.RunProcReturn(sql1, "h_p_Sc_MouldMaintainBill_BeforeDelCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "删除失败!原因:删除前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //===========================================End 删除前控制 End=========================================== bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); //=========================================Begin 删除后控制 Begin========================================= string sql2 = "exec h_p_Sc_MouldMaintainBill_AfterDelCtrl " + HInterID + "," + user; ds = oCN.RunProcReturn(sql2, "h_p_Sc_MouldMaintainBill_AfterDelCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "删除失败!原因:删除后判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "删除失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //===========================================End 删除后控制 End=========================================== if (IsDete) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #region 模具保养记录单审核/反审核功能 [Route("Sc_MouldMaintainBill/CheckSc_MouldMaintainBill")] [HttpGet] public object CheckSc_MouldMaintainBill(string HInterID, int Type, string user, string HBillSubType) { DAL.ClsSc_MouldMaintainBill BillOld = new DAL.ClsSc_MouldMaintainBill(); try { //判断是否有审核权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainBill_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 = "Sc_MouldMaintainBillMain"; 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; } } //审核前控制 string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); sql = "exec h_p_Sc_MouldMaintainBill_BeforeCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldMaintainBill_BeforeCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //审核单据 if (!BillOld.CheckBill(Int64.Parse(HInterID), HBillNo, "h_p_Sc_MouldMaintainBill_AfterCheckCtrl", user, 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; } } //反审核前控制 string HBillNo = ds.Tables[0].Rows[0]["HBillNo"].ToString(); sql = "exec h_p_Sc_MouldMaintainBill_BeforeUnCheckCtrl " + int.Parse(HInterID) + ",'" + HBillNo + "','" + user + "'"; ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldMaintainBill_BeforeUnCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:反审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //反审核单据 if (!BillOld.AbandonCheck(Int64.Parse(HInterID), HBillNo, "h_p_Sc_MouldMaintainBill_AfterUnCheckCtrl", user, 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 #endregion #region 模具点检记录表 #region 模具点检记录表 保存/编辑 /// /// 保存模具维修单 /// /// /// [Route("Sc_MouldDotCheckBill/SaveGetMouldDotCheckBillList")] [HttpPost] public object SaveGetMouldDotCheckBillList([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg4 = sArray[2].ToString(); //string msg5 = sArray[3].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldDotCheckBill oBill = new DAL.ClsSc_MouldDotCheckBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Sc_MouldDotCheckBillMain(msg2); foreach (Model.ClsSc_MouldDotCheckBillMain oItem in lsmain) { //oItem.HMaker = ""; UserName = oItem.HMaker; //制单人 oItem.HMaker = msg4; oItem.HBillType = "3821"; oItem.HBillSubType = "3821"; //oItem.HInterID =0; //oItem.HBillNo = ""; oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); //oItem.HMakeDate = ""; //oItem.HYear = ""; //oItem.HPeriod = ""; //oItem.HRemark = ""; //oItem.HCycleUnit = ""; //oItem.HCheckCycle = ""; //oItem.HBeginDate = ""; //oItem.HEndDate = ""; //oItem.HInnerBillNo = ""; //oItem.HExplanation = ""; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Sc_MouldDotCheckBillSub(msg3); int i = 0; foreach (Model.ClsSc_MouldDotCheckBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; //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 = "";//备注 oBill.DetailColl.Add(oItemSub); } ////配件项表体数据 ////按 },{来拆分数组 //去掉【和】 //msg5 = msg5.Substring(1, msg5.Length - 2); //msg5 = msg5.Replace("\\", ""); //msg5 = msg5.Replace("\n", ""); //\n // //msg2 = msg2.Replace("'", "’"); //List ls1 = new List(); //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; if (oBill.omodel.HInterID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region[模具点检记录表编辑时获取表头数据] [Route("Sc_MouldDotCheckBill/Sc_MouldDotCheckBillListCheckDetai")] [HttpGet] public ApiResult Sc_MouldDotCheckBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldDotCheckBillList where hmainid= " + HID + " ", "h_v_Sc_MouldDotCheckBillList"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在点检记录表" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具点检记录表编辑时获取表题数据] [Route("Sc_MouldDotCheckBill/Sc_MouldDotCheckBillListProjectDetai")] [HttpGet] public object Sc_MouldDotCheckBillListProjectDetai(string sqlWhere) { DataSet ds, ds1; List list = new List(); string Swhere = ""; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); //获取点检项目编辑数据 ds = oCN.RunProcReturn("select * from h_v_Sc_MouldDotCheckBill_Edit where 1=1 " + sqlWhere, "h_v_Sc_MouldDotCheckBill_Edit"); //获取配件项目编辑数据 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 = ds.Tables[0]; objJsonResult.list = list; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + e.ToString(); objJsonResult.data = null; } 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 [模具点检记录表删除功能] /// /// 模具点检记录删除功能 /// /// [Route("Sc_MouldDotCheckBill/DeltetSc_MouldDotCheckBill")] [HttpGet] public object DeltetSc_MouldDotCheckBill(string HInterID,string user) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldDotCheckBill oBill = new DAL.ClsSc_MouldDotCheckBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; objJsonResult.data = null; return objJsonResult; } bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); if (IsDete) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #endregion #region 模具点检计划表 #region 模具点检计划表 保存/编辑 /// /// 保存模具维修单 /// /// /// [Route("Sc_MouldDotCheckPlanBill/SaveGetMouldDotCheckPlanBillList")] [HttpPost] public object SaveGetMouldDotCheckPlanBillList([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg4 = sArray[2].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckPlanBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DBUtility.ClsPub.CurUserName = msg4; DAL.ClsSc_MouldDotCheckPlanBill oBill = new DAL.ClsSc_MouldDotCheckPlanBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Sc_MouldDotCheckPlanBillMain(msg2); foreach (Model.ClsSc_MouldDotCheckPlanBillMain oItem in lsmain) { UserName = oItem.HMaker; //制单人 oItem.HBillType = "3820"; oItem.HBillSubType = "3820"; oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //点检项目表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Sc_MouldDotCheckPlanBillSub(msg3); int i = 0; foreach (Model.ClsSc_MouldDotCheckPlanBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; 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; //关联数量 oBill.DetailColl.Add(oItemSub); } //保存 //保存完毕后处理 bool bResult; if (oBill.omodel.HInterID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region[模具点检计划表编辑时获取表头数据] [Route("Sc_MouldDotCheckPlanBill/Sc_MouldDotCheckPlanBillListCheckDetai")] [HttpGet] public ApiResult Sc_MouldDotCheckPlanBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldDotCheckPlanBillList where hmainid= " + HID + " ", "h_v_Sc_MouldDotCheckPlanBillList"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在点检计划表" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具点检计划表编辑时获取表题数据] [Route("Sc_MouldDotCheckPlanBill/Sc_MouldDotCheckPlanBillListProjectDetai")] [HttpGet] public object Sc_MouldDotCheckPlanBillListProjectDetai(string sqlWhere) { DataSet ds, ds1; List list = new List(); string Swhere = ""; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); //获取点检项目编辑数据 ds = oCN.RunProcReturn(@"select * from h_v_Sc_MouldDotCheckPlanBill_Edit 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 = ds.Tables[0]; objJsonResult.list = list; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何计划!" + e.ToString(); objJsonResult.data = null; } return objJsonResult; } #endregion #region [模具点检计划表删除功能] /// /// 模具维修单删除功能 /// /// [Route("Sc_MouldDotCheckPlanBill/DeltetSc_MouldDotCheckPlanBillBill")] [HttpGet] public object DeltetSc_MouldDotCheckPlanBillBill(string HInterID,string user) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckPlanBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldDotCheckPlanBill oBill = new DAL.ClsSc_MouldDotCheckPlanBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; objJsonResult.data = null; return objJsonResult; } bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); if (IsDete) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #region 器具点检计划单审核/反审核功能 [Route("Sc_MouldDotCheckPlanBill/CheckSc_MouldDotCheckPlanBill")] [HttpGet] public object CheckSc_MouldDotCheckPlanBill(string HInterID, int Type, string user) { DAL.ClsSc_MouldDotCheckPlanBill BillOld = new DAL.ClsSc_MouldDotCheckPlanBill(); try { //判断是否有审核权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldDotCheckPlanBill_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; oCN.BeginTran();//开始事务 //Type 1 审核 2 反审核 if (Type == 1) { if (!BillOld.CheckBill(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } //自动生成点检计划单 oCN.RunProc("exec h_p_Sc_MouldDotCheckPlan_Auto " + HInterID); } else { if (BillOld.AbandonCheck(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); } else { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } 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("Sc_MouldDotCheckPlanBill/GetPlanList")] [HttpGet] public object GetPlanList_Check(string sqlWhere) { DataSet ds; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { ds = oCN.RunProcReturn("select * from h_v_Sc_MouldDotCheckPlanList", "h_v_Sc_MouldDotCheckPlanList"); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.data = ds.Tables[0]; } else { string sql1 = "select * from h_v_Sc_MouldDotCheckPlanList where 1 = 1 "; string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldDotCheckPlanList"); 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 #endregion #region 根据器具条码查找器具档案信息PDA [Route("QJ_PDA_MouldDotCheckBill/txtHBarCode_KeyDown")] [HttpGet] public object txtHBarCode_KeyDown(string HBarCode) { try { if (HBarCode == null || HBarCode.Equals("")) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "条形码不能为空!"; objJsonResult.data = null; return objJsonResult; } //得到信息 ds = oCN.RunProcReturn("select top 1 * from Gy_MouldFileMain where HBarCode= '" + HBarCode + "'", "Gy_MouldFileMain"); //写入信息 if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "未查询到器具信息!"; objJsonResult.data = null; return objJsonResult; } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 模具报废入库单 #region[模具报废入库单编辑时获取表头数据] [Route("Sc_MouldScrapInHouseBill/Sc_MouldScrapInHouseBillListCheckDetai")] [HttpGet] public ApiResult Sc_MouldScrapInHouseBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldScrapInHouseBillList where hmainid= " + HID + " ", "h_v_Sc_MouldScrapInHouseBillList"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在维修单号" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具报废入库单编辑时获取表体数据] [Route("Sc_MouldScrapInHouseBill/Sc_MouldScrapInHouseBillListProjectDetai")] [HttpGet] public object Sc_MouldScrapInHouseBillListProjectDetai(string sqlWhere) { DataSet ds; DataSet ds1; List list = new List(); try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { 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 FROM h_v_Sc_MouldScrapInHouseBillList"), "h_v_Sc_MouldScrapInHouseBillList"); } else { //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub where 1 = 1 "; 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 FROM h_v_Sc_MouldScrapInHouseBillList where 1 = 1 "); string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldScrapInHouseBillList"); } //查汇总 ds1 = oCN.RunProcReturn(string.Format(@"select 物料代码,max(物料名称)物料名称,规格型号,max(单据号)单据号,批次,sum(实收数量)实收数量, hwhid1,max(收料仓库代码)收料仓库代码,max(收料仓库名称)收料仓库名称,子备注 from h_v_Sc_MouldScrapInHouseBillList where 1=1 " + sqlWhere + " group by 物料代码,规格型号,hwhid1,批次,子备注"), "h_v_Sc_MouldScrapInHouseBillList"); list.Add(ds.Tables[0]); list.Add(ds1.Tables[0]); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.list = list; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + e.ToString(); objJsonResult.data = null; } return objJsonResult; } #endregion #region 模具报废入库单保存/编辑 20240702作废 /// /// 保存模具报废入库单 /// /// /// //[Route("Sc_MouldScrapInHouseBill/SaveGetMouldScrapInHouseBillList")] //[HttpPost] //public object SaveGetMouldScrapInHouseBillList([FromBody] JObject msg) //{ // var _value = msg["msg"].ToString(); // string msg1 = _value.ToString(); // string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); // string msg2 = sArray[0].ToString(); // string msg3 = sArray[1].ToString(); // string refSav = sArray[2].ToString(); // string msg4 = sArray[3].ToString(); // string UserName = ""; // string s = ""; // ListModels oListModels = new ListModels(); // try // { // //编辑权限 // if (!DBUtility.ClsPub.Security_Log("Sc_MouldScrapRequestBill_Edit", 1, false, msg4)) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "无保存权限!"; // objJsonResult.data = null; // return objJsonResult; // } // DLL.ClsSc_MouldScrapInBill oBill = new DLL.ClsSc_MouldScrapInBill(); // List lsmain = new List(); // msg2 = msg2.Replace("\\", ""); // msg2 = msg2.Replace("\n", ""); //\n // lsmain = oListModels.getObjectByJson_Gy_MouldScrapInHouseBillMain(msg2); // foreach (Models.ClsSc_MouldStockBillMain oItem in lsmain) // { // if (refSav == "Add") // { // //单据号是否重复 // if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld0.omodel.HInterID)) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "单据号重复!不允许保存!"; // objJsonResult.data = 1; // return objJsonResult; // } // } // if (refSav == "Update") // { // if (BillOld0.ShowBill(oItem.HInterID, ref s) == false) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "此单据有误!"; // objJsonResult.data = 1; // return objJsonResult; // } // //判断是否可编辑 // if (BillOld0.omodel.HChecker != "" && BillOld0.omodel.HChecker != null) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "此单据已经被审核,不允许修改!"; // objJsonResult.data = 1; // return objJsonResult; // } // if (BillOld0.omodel.HBillStatus > 1) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "此单据处于不可编辑状态,不允许修改!"; // objJsonResult.data = 1; // return objJsonResult; // } // if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld0, ref s)) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = s + ",不允许修改"; // objJsonResult.data = 1; // return objJsonResult; // } // } // //oItem.HMaker = ""; // UserName = oItem.HMaker; //制单人 // oItem.HBillType = "3831"; // oItem.HBillSubType = "3831"; // //oItem.HBillNo = ""; //单据号 // //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 // //oItem.HInnerBillNo = ""; // --内部单据号 // oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); // oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); // //oItem.HEquipID = 0; //设备ID(Gy_EquipMent) // //oItem.HPeriod = 0; // //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); // --维修日期 // //oItem.HCheckResult = ""; //验收结论--(正常,异常) // //oItem.HEmpID = 0; //验收人(Gy_Employee) // //oItem.HManagerID = 0; //负责人(Gy_Employee) // //oItem.HDeptID = 0; //验收部门(Gy_Department) // //oItem.HExplanation = ""; //摘要(故障描述) // //oItem.HRemark = ""; //备注 // //oItem.HMainSourceInterID = oItem.HInterID; // //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); // if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; // objJsonResult.data = 1; // return objJsonResult; // } // oBill.omodel = oItem; // } // //表体数据 // //按 },{来拆分数组 //去掉【和】 // msg3 = msg3.Substring(1, msg3.Length - 2); // msg3 = msg3.Replace("\\", ""); // msg3 = msg3.Replace("\n", ""); //\n // //msg2 = msg2.Replace("'", "’"); // List ls = new List(); // ls = oListModels.getObjectByJson_Gy_MouldScrapInHouseBillSub(msg3); // int i = 0; // foreach (Models.ClsSc_MouldStockBillSub oItemSub in ls) // { // i++; // oItemSub.HEntryID = i; // //oItemSub.HRepairCheckID = 0; //验收项目ID // //oItemSub.HRepairCheckContent = ""; //验收内容 // //oItemSub.HManagerID = 0; //负责人ID // //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; //关联金额 // //oItemSub.HRepairID = 0; //维修项目 // //oItemSub.HRepairExplanation =""; //维修要求 // //oItemSub.HMoney = 0; //维修费用 // oBill.DetailColl.Add(oItemSub); // } // //保存 // //保存完毕后处理 // bool bResult; // if (oBill.omodel.HInterID == 0) // { // // 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) // { // objJsonResult.code = "0"; // objJsonResult.count = 1; // objJsonResult.Message = "保存成功!"; // //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); // objJsonResult.data = 1; // return objJsonResult; // } // else // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; // objJsonResult.data = 1; // return objJsonResult; // } // } // catch (Exception e) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + e.ToString(); // objJsonResult.data = 1; // return objJsonResult; // } //} #endregion #region 模具报废入库单保存/编辑 20240702 /// /// 保存模具报废入库单 /// /// /// [Route("Sc_MouldScrapInHouseBill/SaveGetMouldScrapInHouseBillList")] [HttpPost] public object SaveGetMouldScrapInHouseBillList([FromBody] JObject msg) { DAL.ClsSc_MouldScrapInBill oBill = new DAL.ClsSc_MouldScrapInBill(); var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string sMainStr = sArray[0].ToString(); //主表数据 string sSubStr = sArray[1].ToString(); //子表数据 string OperationType = sArray[2].ToString(); //操作类型(Add新增、Update编辑) string HMaker = sArray[3].ToString(); //制单人 try { //判断权限 if (OperationType == "Add") { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; //判断新增权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldScrapRequestBill", 1, false, HMaker)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "您没有该模块新增权限,请与管理员联系!"; objJsonResult.data = null; return objJsonResult; } } else { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify; //判断编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldScrapRequestBill_Edit", 1, false, HMaker)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "您没有该模块编辑权限,请与管理员联系!"; objJsonResult.data = null; return objJsonResult; } } //表头赋值 sMainStr = sMainStr.Replace("\\", ""); sMainStr = sMainStr.Replace("\n", ""); sMainStr = "[" + sMainStr.ToString() + "]"; List lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject>(sMainStr); foreach (Model.ClsSc_MouldStockBillMain oItem in lsmain) { //单据号是否重复 if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, oItem.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = null; return objJsonResult; } //判断会计期是否合理 string s = ""; int sYear = 0; int sPeriod = 0; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oItem.HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = s; objJsonResult.data = null; return objJsonResult; } oItem.HYear = sYear; oItem.HPeriod = sPeriod; DBUtility.ClsPub.CurUserName = oItem.HMaker; oBill.omodel = oItem; } //表体赋值 //按 },{来拆分数组 //去掉【和】 sSubStr = sSubStr.Substring(1, sSubStr.Length - 2); sSubStr = sSubStr.Replace("\\", ""); sSubStr = sSubStr.Replace("\n", ""); sSubStr = "[" + sSubStr.ToString() + "]"; List ls = Newtonsoft.Json.JsonConvert.DeserializeObject>(sSubStr); int i = 0; foreach (Model.ClsSc_MouldStockBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oBill.DetailColl.Add(oItemSub); } string sErrMsg = ""; bool bResult; //获取系统参数 if (oSystemParameter.ShowBill(ref sErrMsg) == true) { //保存 if (OperationType == "Add") //新增保存 { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); if (oSystemParameter.omodel.WMS_CampanyName == "四维尔") //系统参数 客户定制化名称 空白为通用 { //修改器具档案位置 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); if (oSystemParameter.omodel.WMS_CampanyName == "四维尔") //系统参数 客户定制化名称 空白为通用 { //修改器具档案位置 string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID "); oCn.RunProc(sql); } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "获取系统参数失败! " + sErrMsg; objJsonResult.data = null; return objJsonResult; } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; //成功! objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.Message; objJsonResult.data = null; return objJsonResult; } } #endregion #region 模具报废入库单保存 [Route("Sc_MouldScrapInHouseBill/SaveGetMouldScrapInHouseBillList_PDA")] [HttpPost] public object SaveGetMouldScrapInHouseBillList_PDA([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { DLL.ClsSc_MouldScrapInBill oBill = new DLL.ClsSc_MouldScrapInBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Gy_MouldScrapInHouseBillMain(msg2); foreach (Models.ClsSc_MouldStockBillMain oItem in lsmain) { //单据号是否重复 if (BillNew0.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld0.omodel.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = 1; return objJsonResult; } //oItem.HMaker = ""; UserName = oItem.HMaker; //制单人 oItem.HBillType = "3831"; oItem.HBillSubType = "3831"; //oItem.HBillNo = ""; //单据号 //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 //oItem.HInnerBillNo = ""; // --内部单据号 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); //oItem.HEquipID = 0; //设备ID(Gy_EquipMent) //oItem.HPeriod = 0; //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); // --维修日期 //oItem.HCheckResult = ""; //验收结论--(正常,异常) //oItem.HEmpID = 0; //验收人(Gy_Employee) //oItem.HManagerID = 0; //负责人(Gy_Employee) //oItem.HDeptID = 0; //验收部门(Gy_Department) //oItem.HExplanation = ""; //摘要(故障描述) //oItem.HRemark = ""; //备注 //oItem.HMainSourceInterID = oItem.HInterID; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //子表体数据 List ls = new List(); ls = oListModels.getObjectByJson_Gy_MouldScrapInHouseBillSub(msg2); int i = 0; foreach (Models.ClsSc_MouldStockBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; //oItemSub.HRepairCheckID = 0; //验收项目ID //oItemSub.HRepairCheckContent = ""; //验收内容 //oItemSub.HManagerID = 0; //负责人ID //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; //关联金额 //oItemSub.HRepairID = 0; //维修项目 //oItemSub.HRepairExplanation =""; //维修要求 //oItemSub.HMoney = 0; //维修费用 oBill.DetailColl.Add(oItemSub); } //保存 //保存完毕后处理 bool bResult; if (oBill.omodel.HInterID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #endregion #region 模具处理出库单 #region 模具处理出库单列表 [Route("Sc_MouldScrapOutHouseBill/GetMouldScrapOutHouseBill")] [HttpGet] public object GetMouldScrapOutHouseBill(string sWhere, string user, string Organization) { try { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldScrapOutBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } ds = Sc_GetMouldScrapOutHouseBill(sWhere, Organization); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "返回记录成功!"; 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; } } public static DataSet Sc_GetMouldScrapOutHouseBill(string sWhere, string Organization) { 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"); } else { string sql = sql1 + sWhere + " order by 制单日期 desc"; return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldScrapOutHouseBillList"); } } #endregion #region[模具处理出库单编辑时获取表头数据] [Route("Sc_MouldScrapOutHouseBill/Sc_MouldScrapOutHouseBillListCheckDetai")] [HttpGet] public ApiResult Sc_MouldScrapOutHouseBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldScrapOutHouseBillList where hmainid= " + HID + " ", "h_v_Sc_MouldScrapOutHouseBillList"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在维修单号" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具处理出库单编辑时获取表体数据] [Route("Sc_MouldScrapOutHouseBill/Sc_MouldScrapOutHouseBillListProjectDetai")] [HttpGet] public object Sc_MouldScrapOutHouseBillListProjectDetai(string sqlWhere) { DataSet ds; DataSet ds1; List list = new List(); try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具名称 HMaterName,规格型号 HMaterSpec,HPropertyID,辅助属性代码 HPropertyCode,辅助属性名称 HPropertyName, HSecUnitID, 辅助计量单位代码 HSecUnitCode, 辅助计量单位名称 HSecUnitName, 换算率 HSecUnitRate, HUnitID, 计量单位代码 HUnitCode, 计量单位名称 HUnitName, 批次 HBatchNo, 设计寿命 HDesignLife, 剩余寿命 HLeaveLife, 使用寿命 HUseLife, 实发数量 HQty, 单价 HPrice, 金额 HMoney, HWHID, 发货仓库代码 HWHCode, 发货仓库名称 HWHName, HSPID, 仓位代码 HSPCode, 仓位名称 HSPName, 备注 HRemark,HStockOrgID FROM h_v_Sc_MouldScrapOutHouseBillList"), "h_v_Sc_MouldScrapOutHouseBillList"); } else { //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub where 1 = 1 "; string sql1 = string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具名称 HMaterName,规格型号 HMaterSpec,HPropertyID,辅助属性代码 HPropertyCode,辅助属性名称 HPropertyName, HSecUnitID, 辅助计量单位代码 HSecUnitCode, 辅助计量单位名称 HSecUnitName, 换算率 HSecUnitRate, HUnitID, 计量单位代码 HUnitCode, 计量单位名称 HUnitName, 批次 HBatchNo, 设计寿命 HDesignLife, 剩余寿命 HLeaveLife, 使用寿命 HUseLife, 实发数量 HQty, 单价 HPrice, 金额 HMoney, HWHID, 发货仓库代码 HWHCode, 发货仓库名称 HWHName, HSPID, 仓位代码 HSPCode, 仓位名称 HSPName, 备注 HRemark,HStockOrgID FROM h_v_Sc_MouldScrapOutHouseBillList where 1 = 1 "); string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldScrapOutHouseBillList"); } //查汇总 ds1 = oCN.RunProcReturn(string.Format(@"select 物料代码,max(物料名称)物料名称,规格型号,max(单据号)单据号,批次,sum(实发数量)实发数量, hwhid1,max(发货仓库代码)发货仓库代码,max(发货仓库名称)发货仓库名称,子备注 from h_v_Sc_MouldScrapOutHouseBillList where 1=1 " + sqlWhere + " group by 物料代码,规格型号,hwhid1,批次,子备注"), "h_v_Sc_MouldScrapOutHouseBillList"); list.Add(ds.Tables[0]); list.Add(ds1.Tables[0]); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.list = list; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + e.ToString(); objJsonResult.data = null; } return objJsonResult; } #endregion #region 模具处理出库单保存/编辑 20240702作废 /// /// 保存模具处理出库单 /// /// /// //[Route("Sc_MouldScrapOutHouseBill/SaveGetMouldScrapOutHouseBillList")] //[HttpPost] //public object SaveGetMouldScrapOutHouseBillList([FromBody] JObject msg) //{ // var _value = msg["msg"].ToString(); // string msg1 = _value.ToString(); // string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); // string msg2 = sArray[0].ToString(); // string msg3 = sArray[1].ToString(); // string msg4 = sArray[2].ToString(); // string UserName = ""; // ListModels oListModels = new ListModels(); // try // { // //编辑权限 // if (!DBUtility.ClsPub.Security_Log("Sc_MouldScrapOutBill_Edit", 1, false, msg4)) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "无保存权限!"; // objJsonResult.data = null; // return objJsonResult; // } // DLL.ClsSc_MouldScrapOutBill oBill = new DLL.ClsSc_MouldScrapOutBill(); // List lsmain = new List(); // msg2 = msg2.Replace("\\", ""); // msg2 = msg2.Replace("\n", ""); //\n // lsmain = oListModels.getObjectByJson_Gy_MouldScrapOutHouseBillMain(msg2); // foreach (Model.ClsSc_MouldStockBillMain oItem in lsmain) // { // //oItem.HMaker = ""; // UserName = oItem.HMaker; //制单人 // oItem.HBillType = "3832"; // oItem.HBillSubType = "3832"; // //oItem.HBillNo = ""; //单据号 // //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 // //oItem.HInnerBillNo = ""; // --内部单据号 // oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); // oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); // //oItem.HEquipID = 0; //设备ID(Gy_EquipMent) // //oItem.HPeriod = 0; // //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); // --维修日期 // //oItem.HCheckResult = ""; //验收结论--(正常,异常) // //oItem.HEmpID = 0; //验收人(Gy_Employee) // //oItem.HManagerID = 0; //负责人(Gy_Employee) // //oItem.HDeptID = 0; //验收部门(Gy_Department) // //oItem.HExplanation = ""; //摘要(故障描述) // //oItem.HRemark = ""; //备注 // //oItem.HMainSourceInterID = oItem.HInterID; // //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); // if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; // objJsonResult.data = 1; // return objJsonResult; // } // oBill.omodel = oItem; // } // //表体数据 // //按 },{来拆分数组 //去掉【和】 // msg3 = msg3.Substring(1, msg3.Length - 2); // msg3 = msg3.Replace("\\", ""); // msg3 = msg3.Replace("\n", ""); //\n // //msg2 = msg2.Replace("'", "’"); // List ls = new List(); // ls = oListModels.getObjectByJson_Gy_MouldScrapOutHouseBillSub(msg3); // int i = 0; // foreach (Model.ClsSc_MouldStockBillSub oItemSub in ls) // { // i++; // oItemSub.HEntryID = i; // //oItemSub.HRepairCheckID = 0; //验收项目ID // //oItemSub.HRepairCheckContent = ""; //验收内容 // //oItemSub.HManagerID = 0; //负责人ID // //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; //关联金额 // //oItemSub.HRepairID = 0; //维修项目 // //oItemSub.HRepairExplanation =""; //维修要求 // //oItemSub.HMoney = 0; //维修费用 // oBill.DetailColl.Add(oItemSub); // } // //保存 // //保存完毕后处理 // bool bResult; // if (oBill.omodel.HInterID == 0) // { // // 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) // { // objJsonResult.code = "0"; // objJsonResult.count = 1; // objJsonResult.Message = "保存成功!"; // //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); // objJsonResult.data = 1; // return objJsonResult; // } // else // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; // objJsonResult.data = 1; // return objJsonResult; // } // } // catch (Exception e) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + e.ToString(); // objJsonResult.data = 1; // return objJsonResult; // } //} #endregion #region 模具处理出库单保存/编辑 20240702 /// /// 保存模具处理出库单 /// /// /// [Route("Sc_MouldScrapOutHouseBill/SaveGetMouldScrapOutHouseBillList")] [HttpPost] public object SaveGetMouldScrapOutHouseBillList([FromBody] JObject msg) { DAL.ClsSc_MouldScrapOutBill oBill = new DAL.ClsSc_MouldScrapOutBill(); var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string sMainStr = sArray[0].ToString(); //主表数据 string sSubStr = sArray[1].ToString(); //子表数据 string HMaker = sArray[2].ToString(); //制单人 try { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldScrapOutBill_Edit", 1, false, HMaker)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "您没有该模块新增/编辑权限,请与管理员联系!"; objJsonResult.data = null; return objJsonResult; } //表头赋值 sMainStr = sMainStr.Replace("\\", ""); sMainStr = sMainStr.Replace("\n", ""); sMainStr = "[" + sMainStr.ToString() + "]"; List lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject>(sMainStr); foreach (Model.ClsSc_MouldStockBillMain oItem in lsmain) { if (oItem.HInterID == 0) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; } else { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify; } //单据号是否重复 if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, oItem.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = null; return objJsonResult; } //判断会计期是否合理 string s = ""; int sYear = 0; int sPeriod = 0; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oItem.HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = s; objJsonResult.data = null; return objJsonResult; } oItem.HYear = sYear; oItem.HPeriod = sPeriod; DBUtility.ClsPub.CurUserName = oItem.HMaker; oBill.omodel = oItem; } //表体赋值 //按 },{来拆分数组 //去掉【和】 sSubStr = sSubStr.Substring(1, sSubStr.Length - 2); sSubStr = sSubStr.Replace("\\", ""); sSubStr = sSubStr.Replace("\n", ""); sSubStr = "[" + sSubStr.ToString() + "]"; List ls = Newtonsoft.Json.JsonConvert.DeserializeObject>(sSubStr); int i = 0; foreach (Model.ClsSc_MouldStockBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oBill.DetailColl.Add(oItemSub); } string sErrMsg = ""; bool bResult; //获取系统参数 if (oSystemParameter.ShowBill(ref sErrMsg) == true) { //保存 if (oBill.omodel.HInterID == 0) //新增保存 { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); if (oSystemParameter.omodel.WMS_CampanyName == "四维尔") //系统参数 客户定制化名称 空白为通用 { //修改器具档案位置 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); if (oSystemParameter.omodel.WMS_CampanyName == "四维尔") //系统参数 客户定制化名称 空白为通用 { //修改器具档案位置 string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID "); oCn.RunProc(sql); } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "获取系统参数失败! " + sErrMsg; objJsonResult.data = null; return objJsonResult; } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; //成功! objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.Message; objJsonResult.data = null; return objJsonResult; } } #endregion #region [模具处理出库单删除功能] /// /// 模具处理出库库单删除功能 /// /// [Route("Sc_MouldScrapOutHouseBill/DeltetMouldScrapOutHouseBill")] [HttpGet] public object DeltetMouldScrapOutHouseBill(string HInterID, string user) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldScrapOutBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DAL.ClsSc_MouldScrapInBill oBill = new DAL.ClsSc_MouldScrapInBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; 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; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion //#region [模具处理出库单审核、反审核] ///// ///// ///// ///// 单据ID ///// 审核(0),反审核(1) ///// 审核人 ///// //[Route("Sc_MouldScrapOutHouseBill/AuditMouldScrapOutList")] //[HttpGet] //public object AuditMouldScrapOutList(int HInterID, int IsAudit, string CurUserName) //{ // string ModRightNameCheck = "Sc_MouldScrapOutBill_Check"; // DBUtility.ClsPub.CurUserName = CurUserName; // try // { // //审核权限 // if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "审核失败!无权限!"; // objJsonResult.data = null; // return objJsonResult; // } // if (HInterID <= 0) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "HInterID小于0!"; // objJsonResult.data = null; // return objJsonResult; // } // Int64 lngBillKey = 0; // lngBillKey = DBUtility.ClsPub.isLong(HInterID); // DLL.ClsSc_MouldScrapOutBill oBill = new DLL.ClsSc_MouldScrapOutBill(); // //查看是否已审核,关闭,作废 // if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) // { // if (oBill.omodel.HCloseMan.Trim() != "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "单据已关闭!不能再次审核!"; // objJsonResult.data = null; // return objJsonResult; // } // if (oBill.omodel.HDeleteMan.Trim() != "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "单据已作废!不能再次审核!"; // objJsonResult.data = null; // return objJsonResult; // } // if (IsAudit == 0) //审核判断 // { // if (oBill.omodel.HChecker.Trim() != "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "单据已审核!不能再次审核!"; // objJsonResult.data = null; // return objJsonResult; // } // } // if (IsAudit == 1) //反审核判断 // { // if (oBill.omodel.HChecker.Trim() == "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "单据未审核!不需要反审核!"; // objJsonResult.data = null; // return objJsonResult; // } // } // } // else // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; // objJsonResult.data = null; // return objJsonResult; // } // if (IsAudit == 0) //审核提交 // { // //审核提交 // if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) // { // objJsonResult.code = "1"; // objJsonResult.count = 1; // objJsonResult.Message = "审核成功"; // objJsonResult.data = null; // return objJsonResult; // } // else // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; // objJsonResult.data = null; // return objJsonResult; // } // } // if (IsAudit == 1) //反审核提交 // { // //反审核提交AbandonCheck // if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) // { // objJsonResult.code = "1"; // objJsonResult.count = 1; // objJsonResult.Message = "反审核成功"; // objJsonResult.data = null; // return objJsonResult; // } // else // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; // objJsonResult.data = null; // return objJsonResult; // } // } // return objJsonResult; // } // catch (Exception e) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); // objJsonResult.data = null; // return objJsonResult; // } //} //#endregion #region 器具处理出库单审核/反审核 [Route("Sc_MouldScrapOutHouseBill/AuditMouldScrapOutHouseBill")] [HttpGet] public object AuditMouldScrapOutHouseBill(string HInterID, string user, int flag) { //flag=1 审核; flag=2 反审核 //编辑权限 if (!DBUtility.ClsPub.Security_Log_second("Sc_MouldScrapOutBill_Check", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无审核权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (flag == 1) { if (oBill.omodel.HBillStatus == 2) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "当前单据已审核,无需再次审核"; objJsonResult.data = null; return objJsonResult; } else { string HCheckDate = DateTime.Now.Date.ToString(); oCn.RunProc(" Update Sc_MouldStockBillMain set HChecker ='" + user + "',HCheckDate='" + HCheckDate + "',HBillStatus=2 Where HBillType='3832' and HInterID=" + HInterID); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!"; objJsonResult.data = 1; return objJsonResult; } } else { if (oBill.omodel.HBillStatus == 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "当前单据未审核,无需反审核"; objJsonResult.data = null; return objJsonResult; } else { string HCheckDate = DateTime.Now.Date.ToString(); oCn.RunProc(" Update Sc_MouldStockBillMain set HChecker=' ',HCheckDate=' ',HBillStatus=1 Where HBillType='3832' and HInterID=" + HInterID); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核成功!"; objJsonResult.data = 1; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #endregion #region 模具退库单 #region 模具退库单列表 [Route("Sc_MouldProdBackBill/GetMouldProdBackBill")] [HttpGet] public object GetMouldProdBackBill(string sWhere, string user, string Organization) { try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdBackBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有查看权限"; objJsonResult.data = null; return objJsonResult; } ds = Sc_GetMouldProdBackBill(sWhere, Organization); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "返回记录成功!"; 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; } } public static DataSet Sc_GetMouldProdBackBill(string sWhere, string Organization) { string sql1 = string.Format(@"select * from h_v_Sc_MouldProdBackBillList where 库存组织='" + Organization + "'"); if (sWhere == null || sWhere.Equals("")) { return new SQLHelper.ClsCN().RunProcReturn(sql1 + "order by 制单日期 desc", "h_v_Sc_MouldProdBackBillList"); } else { string sql = sql1 + sWhere + "order by 制单日期 desc"; return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldProdBackBillList"); } } #endregion #region 模具退库单列表 查询-分页 /// /// 返回应收单列表 ///参数:string sql。 ///返回值:object。 /// [Route("Sc_MouldProdBackBill/list_byPage")] [HttpGet] public object getSc_MouldProdBackBill_byPage(string sWhere, string user, string Organization, int page, int size) { try { Log.LogInfo("成功!"); //记录提交数据 //查看权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdBackBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } Log.LogInfo("有权限"); LogService.Write(sWhere + ";" + Organization); string sql = ""; if (sWhere == null || sWhere.Equals("")) { sWhere = " and 库存组织='" + Organization + "'"; sWhere = sWhere.Replace("'", "''"); sql = "exec h_p_Sc_MouldProdBackBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'"; Log.LogInfo(sql); ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_p_Sc_MouldProdBackBillList_Query"); } else { sWhere += " and 库存组织='" + Organization + "'"; sWhere = sWhere.Replace("'", "''"); sql = "exec h_p_Sc_MouldProdBackBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'"; Log.LogInfo(sql); ds = new SQLHelper.ClsCN().RunProcReturn(sql, "h_p_Sc_MouldProdBackBillList_Query"); } objJsonResult.code = "1"; objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region[模具退库单编辑时获取表头数据] [Route("Sc_MouldProdBackBill/Sc_MouldProdBackBillListCheckDetai")] [HttpGet] public ApiResult Sc_MouldProdBackBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldProdBackBillList where hmainid= " + HID + " ", "h_v_Sc_MouldProdBackBillList"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在退库单号" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具退库单编辑时获取表体数据] [Route("Sc_MouldProdBackBill/Sc_MouldProdBackBillListProjectDetai")] [HttpGet] public object Sc_MouldProdBackBillListProjectDetai(string sqlWhere) { DataSet ds; DataSet ds1; List list = new List(); try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { 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,计量单位代码 HUnitCode,计量单位 HUnitName FROM h_v_Sc_MouldProdBackBillList"), "h_v_Sc_MouldProdBackBillList"); } else { //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub where 1 = 1 "; 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,计量单位代码 HUnitCode,计量单位 HUnitName FROM h_v_Sc_MouldProdBackBillList where 1 = 1 "); string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldProdBackBillList"); } //查汇总 ds1 = oCN.RunProcReturn(string.Format(@"select 物料代码,max(物料名称)物料名称,规格型号,max(单据号)单据号,批次,sum(实发数量)实发数量, 收料仓库ID,max(收料仓库代码)收料仓库代码,max(收料仓库)收料仓库,表体备注 from h_v_Sc_MouldProdBackBillList where 1=1 " + sqlWhere + " group by 物料代码,规格型号,收料仓库ID,批次,表体备注"), "h_v_Sc_MouldProdBackBillList"); list.Add(ds.Tables[0]); list.Add(ds1.Tables[0]); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.list = list; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + e.ToString(); objJsonResult.data = null; } return objJsonResult; } #endregion #region 模具退库单保存/编辑 20240702作废 /// /// 保存模具退库单 /// /// /// //[Route("Sc_MouldProdBackBill/SaveGetMouldProdBackBillList")] //[HttpPost] //public object SaveGetMouldProdBackBillList([FromBody] JObject msg) //{ // var _value = msg["msg"].ToString(); // string msg1 = _value.ToString(); // string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); // string msg2 = sArray[0].ToString(); // string msg3 = sArray[1].ToString(); // string msg4 = sArray[2].ToString(); // string UserName = ""; // ListModels oListModels = new ListModels(); // try // { // if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdBackBill_Edit", 1, false, msg4)) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "没有保存权限"; // objJsonResult.data = null; // return objJsonResult; // } // DLL.ClsSc_MouldProdBackBill oBill = new DLL.ClsSc_MouldProdBackBill(); // List lsmain = new List(); // msg2 = msg2.Replace("\\", ""); // msg2 = msg2.Replace("\n", ""); //\n // lsmain = oListModels.getObjectByJson_Gy_MouldProdBackBillMain(msg2); // foreach (Model.ClsSc_MouldProdBackBillMain oItem in lsmain) // { // //oItem.HMaker = ""; // UserName = oItem.HMaker; //制单人 // oItem.HBillType = "3803"; // oItem.HBillSubType = "3803"; // //oItem.HBillNo = ""; //单据号 // //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 // //oItem.HInnerBillNo = ""; // --内部单据号 // oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); // oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); // //oItem.HEquipID = 0; //设备ID(Gy_EquipMent) // //oItem.HPeriod = 0; // //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); // --维修日期 // //oItem.HCheckResult = ""; //验收结论--(正常,异常) // //oItem.HEmpID = 0; //验收人(Gy_Employee) // //oItem.HManagerID = 0; //负责人(Gy_Employee) // //oItem.HDeptID = 0; //验收部门(Gy_Department) // //oItem.HExplanation = ""; //摘要(故障描述) // //oItem.HRemark = ""; //备注 // //oItem.HMainSourceInterID = oItem.HInterID; // //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); // if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; // objJsonResult.data = 1; // return objJsonResult; // } // oBill.omodel = oItem; // } // //表体数据 // //按 },{来拆分数组 //去掉【和】 // msg3 = msg3.Substring(1, msg3.Length - 2); // msg3 = msg3.Replace("\\", ""); // msg3 = msg3.Replace("\n", ""); //\n // //msg2 = msg2.Replace("'", "’"); // List ls = new List(); // ls = oListModels.getObjectByJson_Gy_MouldProdBackBillSub(msg3); // int i = 0; // foreach (Model.ClsSc_MouldProdBackBillSub oItemSub in ls) // { // i++; // oItemSub.HEntryID = i; // //oItemSub.HRepairCheckID = 0; //验收项目ID // //oItemSub.HRepairCheckContent = ""; //验收内容 // //oItemSub.HManagerID = 0; //负责人ID // //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; //关联金额 // //oItemSub.HRepairID = 0; //维修项目 // //oItemSub.HRepairExplanation =""; //维修要求 // //oItemSub.HMoney = 0; //维修费用 // oBill.DetailColl.Add(oItemSub); // } // //保存 // //保存完毕后处理 // bool bResult; // if (oBill.omodel.HInterID == 0) // { // // 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 =string.Format($"exec h_p_Sc_MouldProdBackBillList '{oBill.omodel.HBillNo}' ") ; // oCn.RunProc(sql); // objJsonResult.code = "0"; // objJsonResult.count = 1; // objJsonResult.Message = "保存成功!"; // //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); // objJsonResult.data = 1; // return objJsonResult; // } // else // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; // objJsonResult.data = 1; // return objJsonResult; // } // } // catch (Exception e) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + e.ToString(); // objJsonResult.data = 1; // return objJsonResult; // } //} #endregion #region 模具退库单保存/编辑 20240702 /// /// 保存模具退库单 /// /// /// [Route("Sc_MouldProdBackBill/SaveGetMouldProdBackBillList")] [HttpPost] public object SaveGetMouldProdBackBillList([FromBody] JObject msg) { DAL.ClsSc_MouldProdBackBill oBill = new DAL.ClsSc_MouldProdBackBill(); var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string sMainStr = sArray[0].ToString(); //主表数据 string sSubStr = sArray[1].ToString(); //子表数据 string HMaker = sArray[2].ToString(); //制单人 try { //判断权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdBackBill_Edit", 1, false, HMaker)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "您没有该模块新增/编辑权限,请与管理员联系!"; objJsonResult.data = null; return objJsonResult; } //表头赋值 sMainStr = sMainStr.Replace("\\", ""); sMainStr = sMainStr.Replace("\n", ""); sMainStr = "[" + sMainStr.ToString() + "]"; List lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject>(sMainStr); foreach (Model.ClsSc_MouldProdBackBillMain oItem in lsmain) { if (oItem.HInterID == 0) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; } else { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify; } //单据号是否重复 if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, oItem.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = null; return objJsonResult; } //判断会计期是否合理 string s = ""; int sYear = 0; int sPeriod = 0; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oItem.HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = s; objJsonResult.data = null; return objJsonResult; } oItem.HYear = sYear; oItem.HPeriod = sPeriod; DBUtility.ClsPub.CurUserName = oItem.HMaker; oBill.omodel = oItem; } //表体赋值 //按 },{来拆分数组 //去掉【和】 sSubStr = sSubStr.Substring(1, sSubStr.Length - 2); sSubStr = sSubStr.Replace("\\", ""); sSubStr = sSubStr.Replace("\n", ""); sSubStr = "[" + sSubStr.ToString() + "]"; List ls = Newtonsoft.Json.JsonConvert.DeserializeObject>(sSubStr); int i = 0; foreach (Model.ClsSc_MouldStockBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oBill.DetailColl.Add(oItemSub); } string sErrMsg = ""; bool bResult; //获取系统参数 if (oSystemParameter.ShowBill(ref sErrMsg) == true) { //保存 if (oBill.omodel.HInterID == 0) //新增保存 { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); if (oSystemParameter.omodel.WMS_CampanyName == "四维尔") //系统参数 客户定制化名称 空白为通用 { //修改器具档案位置 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); if (oSystemParameter.omodel.WMS_CampanyName == "四维尔") //系统参数 客户定制化名称 空白为通用 { //修改器具档案位置 string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID "); oCn.RunProc(sql); } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "获取系统参数失败! " + sErrMsg; objJsonResult.data = null; return objJsonResult; } if (bResult) { string sql = string.Format($"exec h_p_Sc_MouldProdBackBillList '{oBill.omodel.HBillNo}' "); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; //成功! objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.Message; objJsonResult.data = null; return objJsonResult; } } #endregion #region [模具处理退库单删除功能] /// /// 模具处理退库单删除功能 /// /// [Route("Sc_MouldProdBackBill/DeltetMouldProdBackBill")] [HttpGet] public object DeltetMouldProdBackBill(string HInterID, string user) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdBackBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DLL.ClsSc_MouldProdBackBill oBill = new DLL.ClsSc_MouldProdBackBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; 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; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #region 器具生产退库单审核/反审核 [Route("Sc_MouldProdBackBill/AuditMouldProdBackBill")] [HttpGet] public object AuditMouldProdBackBill(string HInterID, string user, int flag) { //flag=1 审核; flag=2 反审核 //编辑权限 if (!DBUtility.ClsPub.Security_Log_second("Sc_MouldProdBackBill_Check", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无审核权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (flag == 1) { if (oBill.omodel.HBillStatus == 2) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "当前单据已审核,无需再次审核"; objJsonResult.data = null; return objJsonResult; } else { string HCheckDate = DateTime.Now.Date.ToString(); oCn.RunProc(" Update Sc_MouldStockBillMain set HChecker='" + user + "',HCheckDate='" + HCheckDate + "',HBillStatus=2 Where HBillType='3803' and HInterID=" + HInterID); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!"; objJsonResult.data = 1; return objJsonResult; } } else { if (oBill.omodel.HBillStatus == 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "当前单据未审核,无需反审核"; objJsonResult.data = null; return objJsonResult; } else { string HCheckDate = DateTime.Now.Date.ToString(); oCn.RunProc(" Update Sc_MouldStockBillMain set HChecker=' ',HCheckDate=' ',HBillStatus=1 Where HBillType='3803' and HInterID=" + HInterID); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核成功!"; objJsonResult.data = 1; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #endregion #region 模具领用单 #region 模具领用单列表 [Route("Sc_MouldProdOutBill/GetMouldProdOutBill")] [HttpGet] public object GetMouldProdOutBill(string sWhere, string user, string Organization) { try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdOutBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有查看权限"; objJsonResult.data = null; return objJsonResult; } ds = Sc_GetMouldProdOutBill(sWhere, Organization); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "返回记录成功!"; 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; } } public static DataSet Sc_GetMouldProdOutBill(string sWhere, string Organization) { 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 { string sql = sql1 + sWhere + "order by 制单日期 desc"; return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldProdOutHouseBillList"); } } #endregion #region 模具领用单列表 查询-分页 /// /// 返回应收单列表 ///参数:string sql。 ///返回值:object。 /// [Route("Sc_MouldProdOutBill/list_byPage")] [HttpGet] public object getSc_MouldProdOutBill_byPage(string sWhere, string user, string Organization, int page, int size) { try { //查看权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdOutBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } string sql = ""; if (sWhere == null || sWhere.Equals("")) { sWhere = " and 库存组织='" + Organization + "'"; sWhere = sWhere.Replace("'", "''"); sql = "exec h_p_Sc_MouldProdOutHouseBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'"; Log.LogInfo(sql); ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldProdOutHouseBillList_Query"); } else { sWhere += " and 库存组织='" + Organization + "'"; sWhere = sWhere.Replace("'", "''"); sql = "exec h_p_Sc_MouldProdOutHouseBillList_Query " + page + "," + size + ",'" + Organization + "','" + sWhere + "'"; Log.LogInfo(sql); ds = oCN.RunProcReturn(sql, "h_p_Sc_MouldProdOutHouseBillList_Query"); } objJsonResult.code = "1"; objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region[模具领用单编辑时获取表头数据] [Route("Sc_MouldProdOutBill/Sc_MouldProdOutBillListCheckDetai")] [HttpGet] public ApiResult Sc_MouldProdOutBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldProdOutHouseBillList where hmainid= " + HID + " ", "h_v_Sc_MouldProdOutHouseBillList"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在退库单号" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具领用单编辑时获取表体数据] [Route("Sc_MouldProdOutBill/Sc_MouldProdOutBillListProjectDetai")] [HttpGet] public object Sc_MouldProdOutBillListProjectDetai(string sqlWhere) { DataSet ds; DataSet ds1; List list = new List(); try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { 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,计量单位代码 HUnitCode,计量单位 HUnitName FROM h_v_Sc_MouldProdOutHouseBillList"), "h_v_Sc_MouldProdOutHouseBillList"); } else { //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub where 1 = 1 "; 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,计量单位代码 HUnitCode,计量单位 HUnitName FROM h_v_Sc_MouldProdOutHouseBillList where 1 = 1 "); string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldProdOutHouseBillList"); } //查汇总 ds1 = oCN.RunProcReturn(string.Format(@"select 物料代码,max(物料名称)物料名称,规格型号,max(单据号)单据号,批次,sum(实发数量)实发数量, HWHSonID,max(发料仓库代码)发料仓库代码,max(发料仓库)发料仓库,表体备注 from h_v_Sc_MouldProdOutHouseBillList where 1=1 " + sqlWhere + " group by 物料代码,规格型号,HWHSonID,批次,表体备注"), "h_v_Sc_MouldProdOutHouseBillList"); list.Add(ds.Tables[0]); list.Add(ds1.Tables[0]); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.list = list; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + e.ToString(); objJsonResult.data = null; } return objJsonResult; } #endregion #region 模具领用单保存/编辑 20240702作废 /// /// 保存模具领用单 /// /// /// //[Route("Sc_MouldProdOutBill/SaveGetMouldProdOutBillList")] //[HttpPost] //public object SaveGetMouldProdOutBillList([FromBody] JObject msg) //{ // var _value = msg["msg"].ToString(); // string msg1 = _value.ToString(); // string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); // string msg2 = sArray[0].ToString(); // string msg3 = sArray[1].ToString(); // string msg4 = sArray[2].ToString(); // string UserName = ""; // ListModels oListModels = new ListModels(); // try // { // //模块名,写入日志,报错框,用户名 // if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdOutBill_Edit", 1, false, msg4)) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "没有保存权限"; // objJsonResult.data = null; // return objJsonResult; // } // DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill(); // List lsmain = new List(); // msg2 = msg2.Replace("\\", ""); // msg2 = msg2.Replace("\n", ""); //\n // lsmain = oListModels.getObjectByJson_Gy_MouldProdOutBillMain(msg2); // foreach (Model.ClsSc_MouldProdOutBillMain oItem in lsmain) // { // //oItem.HMaker = ""; // UserName = oItem.HMaker; //制单人 // oItem.HBillType = "3802"; // oItem.HBillSubType = "3802"; // //oItem.HBillNo = ""; //单据号 // //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 // //oItem.HInnerBillNo = ""; // --内部单据号 // oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); // oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); // //oItem.HEquipID = 0; //设备ID(Gy_EquipMent) // //oItem.HPeriod = 0; // //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); // --维修日期 // //oItem.HCheckResult = ""; //验收结论--(正常,异常) // //oItem.HEmpID = 0; //验收人(Gy_Employee) // //oItem.HManagerID = 0; //负责人(Gy_Employee) // //oItem.HDeptID = 0; //验收部门(Gy_Department) // //oItem.HExplanation = ""; //摘要(故障描述) // //oItem.HRemark = ""; //备注 // //oItem.HMainSourceInterID = oItem.HInterID; // //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); // if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; // objJsonResult.data = 1; // return objJsonResult; // } // oBill.omodel = oItem; // } // //表体数据 // //按 },{来拆分数组 //去掉【和】 // msg3 = msg3.Substring(1, msg3.Length - 2); // msg3 = msg3.Replace("\\", ""); // msg3 = msg3.Replace("\n", ""); //\n // //msg2 = msg2.Replace("'", "’"); // List ls = new List(); // ls = oListModels.getObjectByJson_Gy_MouldStockBillSub(msg3); // int i = 0; // foreach (Model.ClsSc_MouldStockBillSub oItemSub in ls) // { // i++; // oItemSub.HEntryID = i; // //oItemSub.HRepairCheckID = 0; //验收项目ID // //oItemSub.HRepairCheckContent = ""; //验收内容 // //oItemSub.HManagerID = 0; //负责人ID // //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; //关联金额 // //oItemSub.HRepairID = 0; //维修项目 // //oItemSub.HRepairExplanation =""; //维修要求 // //oItemSub.HMoney = 0; //维修费用 // oBill.DetailColl.Add(oItemSub); // } // //保存 // //保存完毕后处理 // bool bResult; // if (oBill.omodel.HInterID == 0) // { // // 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) // { // objJsonResult.code = "0"; // objJsonResult.count = 1; // objJsonResult.Message = "保存成功!"; // //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); // objJsonResult.data = 1; // return objJsonResult; // } // else // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; // objJsonResult.data = 1; // return objJsonResult; // } // } // catch (Exception e) // { // objJsonResult.code = "0"; // objJsonResult.count = 0; // objJsonResult.Message = "保存失败!" + e.ToString(); // objJsonResult.data = 1; // return objJsonResult; // } //} #endregion #region 模具领用单保存/编辑 20240702 /// /// 保存模具领用单 /// /// /// [Route("Sc_MouldProdOutBill/SaveGetMouldProdOutBillList")] [HttpPost] public object SaveGetMouldProdOutBillList([FromBody] JObject msg) { DAL.ClsSc_MouldProdOutBill oBill = new DAL.ClsSc_MouldProdOutBill(); var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string sMainStr = sArray[0].ToString(); //主表数据 string sSubStr = sArray[1].ToString(); //子表数据 string HMaker = sArray[2].ToString(); //制单人 try { //模块名,写入日志,报错框,用户名 if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdOutBill_Edit", 1, false, HMaker)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "您没有该模块新增/编辑权限,请与管理员联系!"; objJsonResult.data = null; return objJsonResult; } //表头赋值 sMainStr = sMainStr.Replace("\\", ""); sMainStr = sMainStr.Replace("\n", ""); sMainStr = "[" + sMainStr.ToString() + "]"; List lsmain = Newtonsoft.Json.JsonConvert.DeserializeObject>(sMainStr); foreach (Model.ClsSc_MouldProdOutBillMain oItem in lsmain) { if (oItem.HInterID == 0) { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew; } else { BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_Modify; } //单据号是否重复 if (oBill.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, oItem.HInterID)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据号重复!不允许保存!"; objJsonResult.data = null; return objJsonResult; } //判断会计期是否合理 string s = ""; int sYear = 0; int sPeriod = 0; if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(oItem.HDate, ref sYear, ref sPeriod, ref s) == false) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = s; objJsonResult.data = null; return objJsonResult; } oItem.HYear = sYear; oItem.HPeriod = sPeriod; DBUtility.ClsPub.CurUserName = oItem.HMaker; oBill.omodel = oItem; } //表体赋值 //按 },{来拆分数组 //去掉【和】 sSubStr = sSubStr.Substring(1, sSubStr.Length - 2); sSubStr = sSubStr.Replace("\\", ""); sSubStr = sSubStr.Replace("\n", ""); sSubStr = "[" + sSubStr.ToString() + "]"; List ls = Newtonsoft.Json.JsonConvert.DeserializeObject>(sSubStr); int i = 0; foreach (Model.ClsSc_MouldStockBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; oBill.DetailColl.Add(oItemSub); } string sErrMsg = ""; bool bResult; //获取系统参数 if (oSystemParameter.ShowBill(ref sErrMsg) == true) { //保存 if (oBill.omodel.HInterID == 0) //新增保存 { bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); if (oSystemParameter.omodel.WMS_CampanyName == "四维尔") //系统参数 客户定制化名称 空白为通用 { //修改器具档案位置 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); if (oSystemParameter.omodel.WMS_CampanyName == "四维尔") //系统参数 客户定制化名称 空白为通用 { //修改器具档案位置 string sql = string.Format($"exec h_p_Sc_MouldChangeNowWHID "); oCn.RunProc(sql); } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "获取系统参数失败! " + sErrMsg; objJsonResult.data = null; return objJsonResult; } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; //成功! objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.Message; objJsonResult.data = null; return objJsonResult; } } #endregion //判断用户权限 #region [Route("Sc_MouldProdOutBill/QueryUserRight")] [HttpPost] public object QueryUserRight(string UserName) { try { //模块名,写入日志,报错框,用户名 if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdOutBill_Edit", 1, false, UserName)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有查询权限"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "有权限"; objJsonResult.data = null; return objJsonResult; } } catch(Exception e1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有查询权限," + e1.Message; objJsonResult.data = null; return objJsonResult; } } #endregion #region [模具处理领用单删除功能] /// /// 模具处理领用单删除功能 /// /// [Route("Sc_MouldProdOutBill/DeltetMouldProdOutBill")] [HttpGet] public object DeltetMouldProdOutBill(string HInterID, string user) { //删除权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdOutBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; 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; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #region 器具领用出库单审核/反审核 [Route("Sc_MouldProdOutBill/AuditMouldProdOutBill")] [HttpGet] public object AuditMouldProdOutBill(string HInterID, string user, int flag) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldProdOutBill_Check", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无审核权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DLL.ClsSc_MouldProdOutBill oBill = new DLL.ClsSc_MouldProdOutBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (flag == 1) { if (oBill.omodel.HBillStatus == 2) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "当前单据已审核,无需再次审核"; objJsonResult.data = null; return objJsonResult; } else { string HCheckDate = DateTime.Now.Date.ToString(); oCn.RunProc(" Update Sc_MouldStockBillMain set HChecker='" + user + "',HCheckDate='" + HCheckDate + "',HBillStatus=2 Where HBillType='3802' and HInterID=" + HInterID); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核成功!"; objJsonResult.data = 1; return objJsonResult; } } else { if (oBill.omodel.HBillStatus == 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "当前单据未审核,无需反审核"; objJsonResult.data = null; return objJsonResult; } else { string HCheckDate = DateTime.Now.Date.ToString(); oCn.RunProc(" Update Sc_MouldStockBillMain set HChecker=' ',HCheckDate=' ',HBillStatus=1 Where HBillType='3802' and HInterID=" + HInterID); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "反审核成功!"; objJsonResult.data = 1; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #endregion #region 模具寿命调整单 #region 模具寿命调整表 [Route("Sc_MouldLifeChangeBill/GetMouldLifeChangeBill")] [HttpGet] public object GetMouldLifeChangeBill(string sWhere,string user) { try { List columnNameList = new List(); if (!DBUtility.ClsPub.Security_Log("Sc_MouldLifeChangeBillList", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无查看权限!"; objJsonResult.data = null; return objJsonResult; } 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) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "没有返回任何记录!" + ex.ToString(); objJsonResult.data = null; return objJsonResult; } } public static DataSet Sc_GetMouldLifeChangeBill(string sWhere) { if (sWhere == null || sWhere.Equals("")) { 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 hmainid desc"; return new SQLHelper.ClsCN().RunProcReturn(sql, "h_v_Sc_MouldLifeChangeBillList"); } } #endregion #region[模具寿命调整单编辑时获取表头数据] [Route("Sc_MouldLifeChangeBill/Sc_GetMouldLifeChangeBillListCheckDetai")] [HttpGet] public ApiResult Sc_Sc_GetMouldLifeChangeBillListCheckDetai(string HID) { if (string.IsNullOrEmpty(HID)) return new ApiResult { code = -1, msg = "ID不能为空" }; SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); var dataSet = oCN.RunProcReturn("select top 1 * from h_v_Sc_MouldLifeChangeBillList where hmainid= " + HID + " ", "h_v_Sc_MouldLifeChangeBillList"); if (dataSet == null || dataSet.Tables[0].Rows.Count == 0) return new ApiResult { code = -1, msg = "不存在退库单号" }; return new ApiResult { code = 1, msg = "查询成功", data = dataSet }; } #endregion #region[模具寿命调整单编辑时获取表体数据] [Route("Sc_MouldLifeChangeBill/Sc_MouldLifeChangeBillListProjectDetai")] [HttpGet] public object Sc_MouldLifeChangeBillListProjectDetai(string sqlWhere) { DataSet ds; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { ds = oCN.RunProcReturn(string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具 HMaterName,规格型号 HMaterSpec,HPropertyID,辅助属性代码 HPropertyCode,辅助属性 HPropertyName, HSecUnitID, 辅助计量单位代码 HSecUnitCode, 辅助计量单位 HSecUnitName,换算率 HSecUnitRate, HUnitID, 计量单位代码 HUnitCode, 计量单位 HUnitName, 设计寿命 HDesignLife, 原剩余寿命 HLeaveLife, 新剩余寿命 HNewLeaveLife,表体备注 HRemark FROM h_v_Sc_MouldLifeChangeBillList_Edit"), "h_v_Sc_MouldLifeChangeBillList_Edit"); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.data = ds.Tables[0]; } else { //string sql1 = "select HRepairCheckID,HRepairCheckContent,HManagerID,HRemark from Sc_MouldRepairCheckBillSub where 1 = 1 "; string sql1 = string.Format(@"SELECT HMaterID,模具代码 HMaterCode,模具 HMaterName,规格型号 HMaterSpec,HPropertyID,辅助属性代码 HPropertyCode,辅助属性 HPropertyName, HSecUnitID, 辅助计量单位代码 HSecUnitCode, 辅助计量单位 HSecUnitName,换算率 HSecUnitRate, HUnitID, 计量单位代码 HUnitCode, 计量单位 HUnitName, 设计寿命 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"); 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 模具寿命调整单保存/编辑 /// /// 保存模具领用单 /// /// /// [Route("Sc_MouldLifeChangeBill/SaveGetMouldLifeChangeBillList")] [HttpPost] public object SaveGetMouldLifeChangeBillList([FromBody] JObject msg) { var _value = msg["msg"].ToString(); string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string msg3 = sArray[1].ToString(); string msg4 = sArray[2].ToString(); string UserName = ""; ListModels oListModels = new ListModels(); try { if (!DBUtility.ClsPub.Security_Log("Sc_MouldLifeChangeBill_Edit", 1, false, msg4)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无保存权限!"; objJsonResult.data = null; return objJsonResult; } DLL.ClsSc_MouldLifeChangeBill oBill = new DLL.ClsSc_MouldLifeChangeBill(); List lsmain = new List(); msg2 = msg2.Replace("\\", ""); msg2 = msg2.Replace("\n", ""); //\n lsmain = oListModels.getObjectByJson_Gy_MouldLifeChangeBillMain(msg2); foreach (Model.ClsSc_MouldLifeChangeBillMain oItem in lsmain) { //oItem.HMaker = ""; UserName = oItem.HMaker; //制单人 oItem.HBillType = "3824"; oItem.HBillSubType = "3824"; //oItem.HBillNo = ""; //单据号 //oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));// --日期 //oItem.HInnerBillNo = ""; // --内部单据号 oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year); oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd")); //oItem.HEquipID = 0; //设备ID(Gy_EquipMent) //oItem.HPeriod = 0; //oItem.HCheckBeginDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd")); // --维修日期 //oItem.HCheckResult = ""; //验收结论--(正常,异常) //oItem.HEmpID = 0; //验收人(Gy_Employee) //oItem.HManagerID = 0; //负责人(Gy_Employee) //oItem.HDeptID = 0; //验收部门(Gy_Department) //oItem.HExplanation = ""; //摘要(故障描述) //oItem.HRemark = ""; //备注 //oItem.HMainSourceInterID = oItem.HInterID; //oItem.HInterID = DBUtility.ClsPub.CreateBillID_SRMProd("1103", ref DBUtility.ClsPub.sExeReturnInfo); if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!没有单据日期,无法保存!"; objJsonResult.data = 1; return objJsonResult; } oBill.omodel = oItem; } //表体数据 //按 },{来拆分数组 //去掉【和】 msg3 = msg3.Substring(1, msg3.Length - 2); msg3 = msg3.Replace("\\", ""); msg3 = msg3.Replace("\n", ""); //\n //msg2 = msg2.Replace("'", "’"); List ls = new List(); ls = oListModels.getObjectByJson_Gy_MouldLifeChangeBillSub(msg3); int i = 0; foreach (Model.ClsSc_MouldLifeChangeBillSub oItemSub in ls) { i++; oItemSub.HEntryID = i; //oItemSub.HRepairCheckID = 0; //验收项目ID //oItemSub.HRepairCheckContent = ""; //验收内容 //oItemSub.HManagerID = 0; //负责人ID //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; //关联金额 //oItemSub.HRepairID = 0; //维修项目 //oItemSub.HRepairExplanation =""; //维修要求 //oItemSub.HMoney = 0; //维修费用 oBill.DetailColl.Add(oItemSub); } //保存 //保存完毕后处理 bool bResult; if (oBill.omodel.HInterID == 0) { // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); } else { bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); } if (bResult) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "保存成功!"; //WebAPIController.Add_Log("送货单下推", UserName, "生成送货单"); objJsonResult.data = 1; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = 1; return objJsonResult; } } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "保存失败!" + e.ToString(); objJsonResult.data = 1; return objJsonResult; } } #endregion #region [模具寿命调整单删除功能] /// /// 模具处理领用单删除功能 /// /// [Route("Sc_MouldLifeChangeBill/DeltetMouldLifeChangeBill")] [HttpGet] public object DeltetMouldLifeChangeBill(string HInterID,string user) { //编辑权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldLifeChangeBill_Delete", 1, false, user)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "无删除权限!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); if (lngBillKey == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据ID为空!"; objJsonResult.data = null; return objJsonResult; } DLL.ClsSc_MouldLifeChangeBill oBill = new DLL.ClsSc_MouldLifeChangeBill(); if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HBillStatus > 1) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据当前处于不能删除状态,不能删除!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HChecker != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已经审核,不能删除!"; objJsonResult.data = null; return objJsonResult; } bool IsDete = oBill.DeleteBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo); if (IsDete) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未找到"; objJsonResult.data = null; return objJsonResult; } } #endregion #region [模具寿命调整单审核、反审核] /// /// /// /// 单据ID /// 审核(0),反审核(1) /// 审核人 /// [Route("Sc_MouldLifeChangeBill/AuditSc_MouldLifeChangeBillList")] [HttpGet] public object AuditSc_MouldLifeChangeBillList(int HInterID, int IsAudit, string CurUserName) { string ModRightNameCheck = "Sc_MouldLifeChangeBill_Check"; DBUtility.ClsPub.CurUserName = CurUserName; try { //审核权限 if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败!无权限!"; objJsonResult.data = null; return objJsonResult; } if (HInterID <= 0) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "HInterID小于0!"; objJsonResult.data = null; return objJsonResult; } Int64 lngBillKey = 0; lngBillKey = DBUtility.ClsPub.isLong(HInterID); DAL.ClsSc_MouldLifeChangeBill oBill = new DAL.ClsSc_MouldLifeChangeBill(); //查看是否已审核,关闭,作废 if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) { if (oBill.omodel.HCloseMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已关闭!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } if (oBill.omodel.HDeleteMan.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已作废!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } if (IsAudit == 0) //审核判断 { if (oBill.omodel.HChecker.Trim() != "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据已审核!不能再次审核!"; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 1) //反审核判断 { if (oBill.omodel.HChecker.Trim() == "") { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据未审核!不需要反审核!"; objJsonResult.data = null; return objJsonResult; } } } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "单据不存在!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } oCn.BeginTran();//开始事物 if (IsAudit == 0) //审核提交 { //===============================Begin 审核前控制 Begin=============================== string sql = "exec h_p_Sc_MouldLifeChangeBill_BeforeCheckCtrl " + HInterID + ",'" + CurUserName + "'"; ds = oCn.RunProcReturn(sql, "h_p_Sc_MouldLifeChangeBill_BeforeCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { oCn.RollBack();//回滚事物 objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { oCn.RollBack();//回滚事物 objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //=================================End 审核前控制 End================================= //审核提交 if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) { //===============================Begin 审核后控制 Begin=============================== string sql2 = "exec h_p_Sc_MouldLifeChangeBill_AfterCheckCtrl " + HInterID + ",'" + CurUserName + "'"; ds = oCn.RunProcReturn(sql2, "h_p_Sc_MouldLifeChangeBill_AfterCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { oCn.RollBack();//回滚事物 objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:审核后判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { oCn.RollBack();//回滚事物 objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //=================================End 审核后控制 End================================= objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "审核成功"; objJsonResult.data = null; return objJsonResult; } else { oCn.RollBack();//回滚事物 objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } if (IsAudit == 1) //反审核提交 { //===============================Begin 反审核前控制 Begin=============================== string sql = "exec h_p_Sc_MouldLifeChangeBill_BeforeUnCheckCtrl " + HInterID + ",'" + CurUserName + "'"; ds = oCn.RunProcReturn(sql, "h_p_Sc_MouldLifeChangeBill_BeforeUnCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { oCn.RollBack();//回滚事物 objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:反审核前判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { oCn.RollBack();//回滚事物 objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //=================================End 反审核前控制 End================================= //反审核提交AbandonCheck if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) { //===============================Begin 反审核后控制 Begin=============================== string sql2 = "exec h_p_Sc_MouldLifeChangeBill_AfterUnCheckCtrl " + HInterID + ",'" + CurUserName + "'"; ds = oCn.RunProcReturn(sql2, "h_p_Sc_MouldLifeChangeBill_AfterUnCheckCtrl"); if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) { oCn.RollBack();//回滚事物 objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:反审核后判断失败,请与网络管理人员联系"; objJsonResult.data = null; return objJsonResult; } if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { oCn.RollBack();//回滚事物 objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ; objJsonResult.data = null; return objJsonResult; } //=================================End 反审核后控制 End================================= objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反审核成功"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "反审核失败!原因:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } oCn.Commit();//提交事物 return objJsonResult; } catch (Exception e) { oCn.RollBack();//回滚事物 objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "审核失败或者反审核失败!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #endregion #region 器具保养计划单审核/反审核功能 [Route("Sc_MouldMaintainPlanBill/CheckSc_MouldMaintainPlanBill")] [HttpGet] public object CheckSc_MouldMaintainPlanBill(string HInterID, int Type, string user) { DAL.ClsSc_MouldMaintainPlanBill BillOld = new DAL.ClsSc_MouldMaintainPlanBill(); try { //判断是否有审核权限 if (!DBUtility.ClsPub.Security_Log("Sc_MouldMaintainPlanBill_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; oCN.BeginTran();//开始事务 //Type 1 审核 2 反审核 if (Type == 1) { if (!BillOld.CheckBill(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } //自动生成点检计划单 oCN.RunProc("exec h_p_Sc_MouldMaintainPlan_Auto " + HInterID); } else { if (BillOld.AbandonCheck(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) { SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); } else { objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "审核失败!原因:" + ClsPub.sExeReturnInfo; objJsonResult.data = null; return objJsonResult; } } 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("Sc_MouldMaintainPlanBill/GetPlanList")] [HttpGet] public object GetPlanList(string sqlWhere) { DataSet ds; try { SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); if (sqlWhere == null || sqlWhere.Equals("")) { ds = oCN.RunProcReturn("select * from h_v_Sc_MouldMaintainPlanList", "h_v_Sc_MouldMaintainPlanList"); objJsonResult.code = "0"; objJsonResult.count = 1; objJsonResult.Message = "获取信息成功!"; objJsonResult.data = ds.Tables[0]; } else { string sql1 = "select * from h_v_Sc_MouldMaintainPlanList where 1 = 1 "; string sql = sql1 + sqlWhere; ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldMaintainPlanList"); 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 器具点检记录拍照上传 [Route("Sc_MouldDotCheckBill/UploadFile")] [HttpPost] public object UploadFile() { string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //单据号 string HRemark = HttpContext.Current.Request.Params["HRemark"]; //备注 string HUserName = HttpContext.Current.Request.Params["HUserName"]; //创建人 HttpPostedFile files = HttpContext.Current.Request.Files["file"]; string path = HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HBillNo); //string path = @"D:\\Files\\"+ HBillNo; dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName); if (dyResult != null && dyResult.result == 1) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "上传成功!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = dyResult.returnval; objJsonResult.data = null; return objJsonResult; } } public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) { dynamic Result_Ob = new { result = 1, returnval = "上传成功!" }; string filePath = Path.GetFullPath(files.FileName);//文件上传路径 string fileExtension = Path.GetExtension(files.FileName);// 文件扩展名 string filename = files.FileName;//文件名 string fileSavePath = path;// 上传保存路径 int filesize = files.ContentLength;//获取上传文件的大小单位为字节byte int Maxsize = 40000 * 1024;//定义上传文件的最大空间大小为40M try { if (files == null || files.ContentLength <= 0) { Result_Ob = new { result = 0, returnval = "文件不能为空!" }; return Result_Ob; } if (filesize >= Maxsize) { Result_Ob = new { result = 0, returnval = "上传文件超过40M,不能上传!" }; return Result_Ob; } string fileurl = Path.Combine(fileSavePath, filename); if (Directory.Exists(fileurl) == true) //如果存在重名文件就提示 { Result_Ob = new { result = 0, returnval = "存在同名文件!" }; return Result_Ob; } //删除数据表数据 ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); if (Directory.Exists(path)) { File.Delete(fileurl); //删除指定文件 files.SaveAs(fileurl); string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //这里可以执行一些其它的操作,比如更新数据库 //写入数据表 oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" }; } } else { Directory.CreateDirectory(fileSavePath); //添加文件夹 files.SaveAs(fileurl); string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //这里可以执行一些其它的操作,比如更新数据库 //写入数据表 oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" }; } } } catch (Exception e) { Result_Ob = new { result = 0, returnval = e.Message }; } return Result_Ob; } /// /// 根据单据号查找上传文件列表 /// /// /// [Route("Sc_MouldDotCheckBill/Filelist")] [HttpGet] public object Filelist(string HBillNo) { var url = fileip + "/files/MouldFolder/" + HBillNo + "/"; //@"C:\\files\\" try { ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } /// /// 根据ID,单据号,文件名 删除文件 /// /// /// [Route("Sc_MouldDotCheckBill/DeleteFilelist")] [HttpGet] public object DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName) { try { oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HSourceBillNo), HFileName); File.Delete(fileurl); //删除指定文件 objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "删除成功!"; objJsonResult.data = null; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion #region 器具保养记录拍照上传 [Route("Sc_MouldMaintainBill/UploadFile")] [HttpPost] public object UploadFile_Maintain() { string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //单据号 string HRemark = HttpContext.Current.Request.Params["HRemark"]; //备注 string HUserName = HttpContext.Current.Request.Params["HUserName"]; //创建人 HttpPostedFile files = HttpContext.Current.Request.Files["file"]; string path = HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HBillNo); //string path = @"D:\\Files\\"+ HBillNo; dynamic dyResult = UpLoadFile_Maintain(files, path, HBillNo, HRemark, HUserName); if (dyResult != null && dyResult.result == 1) { objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "上传成功!"; objJsonResult.data = null; return objJsonResult; } else { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = dyResult.returnval; objJsonResult.data = null; return objJsonResult; } } public dynamic UpLoadFile_Maintain(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) { dynamic Result_Ob = new { result = 1, returnval = "上传成功!" }; string filePath = Path.GetFullPath(files.FileName);//文件上传路径 string fileExtension = Path.GetExtension(files.FileName);// 文件扩展名 string filename = files.FileName;//文件名 string fileSavePath = path;// 上传保存路径 int filesize = files.ContentLength;//获取上传文件的大小单位为字节byte int Maxsize = 40000 * 1024;//定义上传文件的最大空间大小为40M try { if (files == null || files.ContentLength <= 0) { Result_Ob = new { result = 0, returnval = "文件不能为空!" }; return Result_Ob; } if (filesize >= Maxsize) { Result_Ob = new { result = 0, returnval = "上传文件超过40M,不能上传!" }; return Result_Ob; } string fileurl = Path.Combine(fileSavePath, filename); if (Directory.Exists(fileurl) == true) //如果存在重名文件就提示 { Result_Ob = new { result = 0, returnval = "存在同名文件!" }; return Result_Ob; } //删除数据表数据 ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); if (Directory.Exists(path)) { File.Delete(fileurl); //删除指定文件 files.SaveAs(fileurl); string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //这里可以执行一些其它的操作,比如更新数据库 //写入数据表 oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" }; } } else { Directory.CreateDirectory(fileSavePath); //添加文件夹 files.SaveAs(fileurl); string StrPath = "/files/MouldFolder/" + HBillNo + "/" + filename; if (File.Exists(fileurl)) { //这里可以执行一些其它的操作,比如更新数据库 //写入数据表 oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + ",HFileClsID,HSourceBillNo" + ") values('" + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + "','" + 0 + "','" + HBillNo + "') "); } else { Result_Ob = new { result = 0, returnval = "上传失败!此文件为恶意文件" }; } } } catch (Exception e) { Result_Ob = new { result = 0, returnval = e.Message }; } return Result_Ob; } /// /// 根据单据号查找上传文件列表 /// /// /// [Route("Sc_MouldMaintainBill/Filelist")] [HttpGet] public object Filelist_Maintain(string HBillNo) { var url = fileip + "/files/MouldFolder/" + HBillNo + "/"; //@"C:\\files\\" try { ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess!"; objJsonResult.data = ds.Tables[0]; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } /// /// 根据ID,单据号,文件名 删除文件 /// /// /// [Route("Sc_MouldMaintainBill/DeleteFilelist")] [HttpGet] public object DeleteFilelist_Maintain(string HItemID, string HSourceBillNo, string HFileName) { try { oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/MouldFolder/" + HSourceBillNo), HFileName); File.Delete(fileurl); //删除指定文件 objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "删除成功!"; objJsonResult.data = null; return objJsonResult; } catch (Exception e) { objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception!" + e.ToString(); objJsonResult.data = null; return objJsonResult; } } #endregion } }