| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Net; |
| | | using System.Net.Http; |
| | | using System.Web; |
| | | using System.Web.Http; |
| | | using WebAPI; |
| | | using WebAPI.Controllers.SCGL.日计划管理; |
| | | using WebAPI.Models; |
| | | using WebAPI.Service; |
| | | using SyntacticSugar.constant; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | //public static string sUrl = "http://183.129.128.86:9090/WEBS-WMSTest/WebService1.asmx"; |
| | | // private POInStockBillServices oclscg_poinstockbillmain = new POInStockBillServices(); |
| | | |
| | | string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; |
| | | |
| | | /// <summary> |
| | | /// 送货单表头信息 |
| | | /// 获取单据号与单据内码 |
| | | /// </summary> |
| | | /// <param name="sMsg"></param> |
| | | /// <returns></returns> |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据时间获取产量汇报单集合 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/GetICMOBillWorkQtyStatus_Tmp")] |
| | | [HttpGet] |
| | | public object GetICMOBillWorkQtyStatus_Tmp() |
| | | { |
| | | DataSet ds = new DataSet(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | ds = oCN.RunProcReturn("exec h_p_Sc_TodayWorkQtySumReport", "h_p_Sc_TodayWorkQtySumReport"); |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "Sucess!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | |
| | | } |
| | | |
| | | [Route("Web/GetMAXNumPDA")] |
| | | [HttpGet] |
| | | public object GetMAXNumPDA(string HBillType) |
| | |
| | | //----------创建虚表------------------------ |
| | | DataTable dt_Main = new DataTable("Json"); |
| | | dt_Main.Columns.Add("HBillNo", typeof(string)); |
| | | dt_Main.Columns.Add("HInterID", typeof(int)); |
| | | dt_Main.Columns.Add("HInterID", typeof(Int64)); |
| | | //---------创建新行------------------------ |
| | | DataRow dr_main = dt_Main.NewRow();//创建新行 |
| | | dt_Main.Rows.Add(dr_main);//将新行加入到表中 |
| | | dr_main["HBillNo"] = DBUtility.ClsPub.isStrNull(HBillNo); |
| | | dr_main["HInterID"] = DBUtility.ClsPub.isLong(HInterID); |
| | | //返回数据 |
| | | objjson.code = "0"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功"; |
| | | objjson.data = dt_Main; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + e.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | [Route("Web/GetMAXNum_ProcExchange")] |
| | | [HttpGet] |
| | | public object GetMAXNum_ProcExchange(string HBillType) |
| | | { |
| | | try |
| | | { |
| | | string HBillNo = ""; |
| | | string sErrMsg = ""; |
| | | Int64 HInterID = 0;//显示的字段 |
| | | HInterID = DBUtility.ClsPub.CreateBillID_Prod(HBillType, ref sErrMsg); |
| | | //HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref sErrMsg, true); |
| | | |
| | | DataSet ds; |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | ds = oCN.RunProcReturn("exec h_p_IF_CheckBillIDExists_WMS " + HInterID + ",'" + HBillNo + "'", "h_p_IF_CheckBillIDExists_WMS"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | sErrMsg = "存在重复单据内码或单据号的单据,不允许新增,请退出后重新登录!"; |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = sErrMsg; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0][0]) == "1") |
| | | { |
| | | sErrMsg = "存在重复单据内码或单据号的单据,不允许新增,请退出后重新登录!"; |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = sErrMsg; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | //----------创建虚表------------------------ |
| | | DataTable dt_Main = new DataTable("Json"); |
| | | dt_Main.Columns.Add("HBillNo", typeof(string)); |
| | | dt_Main.Columns.Add("HInterID", typeof(Int64)); |
| | | //---------创建新行------------------------ |
| | | DataRow dr_main = dt_Main.NewRow();//创建新行 |
| | | dt_Main.Rows.Add(dr_main);//将新行加入到表中 |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetMAXNumber")] |
| | | [HttpGet] |
| | | public object GetMAXNumber(string HBillType,string HName,string TableName) |
| | | public object GetMAXNumber(string HBillType, string HName, string TableName) |
| | | { |
| | | try |
| | | { |
| | | string HNumber = ""; |
| | | HNumber = DBUtility.ClsPub.CreateHNumber(HBillType,HName, TableName, ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | HNumber = DBUtility.ClsPub.CreateHNumber(HBillType, HName, TableName, ref DBUtility.ClsPub.sExeReturnInfo, true); |
| | | //----------创建虚表------------------------ |
| | | DataTable dt_Main = new DataTable("Json"); |
| | | dt_Main.Columns.Add("HNumber", typeof(string)); |
| | | |
| | | |
| | | //---------创建新行------------------------ |
| | | DataRow dr_main = dt_Main.NewRow();//创建新行 |
| | | dt_Main.Rows.Add(dr_main);//将新行加入到表中 |
| | | dr_main["HNumber"] = DBUtility.ClsPub.isStrNull(HNumber); |
| | | |
| | | |
| | | |
| | | if (HNumber == null) |
| | | { |
| | |
| | | public object GetUser(string UserName, string PassWord, string HOrgName) |
| | | { |
| | | try |
| | | { |
| | | { |
| | | DataSet ds = null; |
| | | ClsCN oCnLoc = new ClsCN(); |
| | | DAL.ClsUser oUser = new DAL.ClsUser(); |
| | |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "密码错误!"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | //判断用户数是否大于客户账号数 |
| | | DataSet ds1 = oCN.RunProcReturn("Exec h_p_Xt_BaseInfo ", "h_p_Xt_BaseInfo"); |
| | | if (DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HBack"]) != "0") |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = ds1.Tables[0].Rows[0]["HBackRemark"].ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 登录根据ic卡获取信息 |
| | | /// </summary> |
| | | /// <param name="HBarCode"></param> |
| | | /// <returns></returns> |
| | | [Route("Web/GetUserByICCard")] |
| | | [HttpGet] |
| | | public object GetUserByICCard(string HBarCode) |
| | | { |
| | | try |
| | | { |
| | | DataSet ds = null; |
| | | ClsCN oCnLoc = new ClsCN(); |
| | | DAL.ClsUser oUser = new DAL.ClsUser(); |
| | | string sql = string.Format(@" select a.* from h_v_Gy_Czygl_Login a |
| | | where a.HICNumber = '{0}'", HBarCode); |
| | | ds = oCnLoc.RunProcReturn(sql, "h_v_Gy_Czygl_Login"); |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "无此ic卡对应员工信息!"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "信息获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "登录异常!" + e.Message; |
| | | objjson.data = null; |
| | | return objjson; ; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 菜单栏 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | |
| | | return objjson; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | objjson.code = "0"; |
| | | objjson.count = 1; |
| | | objjson.Message = "展开成功!"; |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetXGPassword")] |
| | | [HttpGet] |
| | | public object GetXGPassword(string UserName, string oldPassword, string PassWord, string Repassword) |
| | | public object GetXGPassword(string UserName, string oldPassword, string PassWord, string Repassword,string HCloudUserName,string HCloudUserPsd) |
| | | { |
| | | try |
| | | { |
| | | ClsCN oCn = new ClsCN(); |
| | | DataSet oDs = new DataSet(); |
| | | //========== |
| | | oDs = oCn.RunProcReturn("select Czmm from Gy_Czygl where Czybm='" + UserName + "'", "Gy_Czygl"); |
| | | if (PassWord.Trim() != Repassword.Trim()) |
| | | |
| | | if(PassWord!=null) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "2次密码不一致!"; |
| | | objjson.data = oDs.Tables[0]; |
| | | return objjson; ; |
| | | } |
| | | //=========== |
| | | if (oDs == null || oDs.Tables[0].Rows.Count == 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "没有这个用户,不能修改密码!"; |
| | | objjson.data = null; |
| | | return objjson; ; |
| | | } |
| | | else |
| | | { |
| | | oCn.RunProc("update Gy_Czygl set Czmm='" + ClsPub.StrToPsd(PassWord.Trim()) + "' where Czybm='" + UserName.Trim() + "'"); |
| | | oDs = oCn.RunProcReturn("select Czmm from Gy_Czygl where Czybm='" + UserName + "'", "Gy_Czygl"); |
| | | if (PassWord.Trim() != Repassword.Trim()) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "2次密码不一致!"; |
| | | objjson.data = oDs.Tables[0]; |
| | | return objjson; ; |
| | | } |
| | | //=========== |
| | | if (oDs == null || oDs.Tables[0].Rows.Count == 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "没有这个用户,不能修改密码!"; |
| | | objjson.data = null; |
| | | return objjson; ; |
| | | } |
| | | oCn.RunProc("update Gy_Czygl set Czmm='" + ClsPub.StrToPsd(PassWord.Trim()) + "',HCloudUserName = '" + HCloudUserName+ "',HCloudUserPsd = '" + HCloudUserPsd+ "' where Czybm='" + UserName.Trim() + "'"); |
| | | objjson.code = "0"; |
| | | objjson.count = 1; |
| | | objjson.Message = "* 密码修改成功!"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | oCn.RunProc("update Gy_Czygl set HCloudUserName = '" + HCloudUserName + "',HCloudUserPsd = '" + HCloudUserPsd + "' where Czybm='" + UserName.Trim() + "'"); |
| | | objjson.code = "0"; |
| | | objjson.count = 1; |
| | | objjson.Message = "* 金蝶云账号修改成功!"; |
| | | objjson.data = null; |
| | | return objjson; ; |
| | | } |
| | | } |
| | | catch (Exception) |
| | | catch (Exception e) |
| | | { |
| | | |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "修改密码异常!"; |
| | | objjson.Message = "修改密码异常!" + e.ToString(); |
| | | objjson.data = null; |
| | | return objjson; ; |
| | | } |
| | |
| | | // return objJsonResult; |
| | | //} |
| | | |
| | | string sql = "update Gy_Czygl set " + |
| | | "HWhID = " + HWhID + |
| | | string sql = "update Gy_Czygl set " + |
| | | "HWhID = " + HWhID + |
| | | ", HWhName = '" + HWhName + |
| | | "', HSecManagerID = " + HSecManagerID + |
| | | ", HSecManager = '" + HSecManager + |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetSouceList_Json")] |
| | | [HttpGet] |
| | | public object GetSouceList_Json(string HMaterID,string Value, Int64 HOrgID) |
| | | public object GetSouceList_Json(string HMaterID, string Value, Int64 HOrgID) |
| | | { |
| | | sWhere = " and HStopFlag=0 and HUSEORGID =" + HOrgID + ""; |
| | | if (Value != "" && Value != null) |
| | |
| | | } |
| | | try |
| | | { |
| | | string sql = "EXEC h_p_Gy_SouceViewList " + HMaterID+",'"+ sWhere + "'"; |
| | | string sql = "EXEC h_p_Gy_SouceViewList " + HMaterID + ",'" + sWhere + "'"; |
| | | ds = oCN.RunProcReturn(sql, "h_p_Gy_SouceViewList"); |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取班次列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/GetGy_ShiftsList_Json")] |
| | | [HttpGet] |
| | | public object GetGy_ShiftsList_Json(string Shifts) |
| | | { |
| | | sWhere = " 禁用标记!='Y'"; |
| | | if (Shifts != "") |
| | | { |
| | | sWhere = " Where 禁用标记!='Y' and ( 班次代码 like '%" + Shifts + "%' or 班次名称 like '%" + Shifts + "%' ) "; |
| | | } |
| | | else |
| | | { |
| | | sWhere = " Where 禁用标记!='Y' "; |
| | | } |
| | | try |
| | | { |
| | | string sql = $"Select * from h_v_Gy_ShiftsList {sWhere} Order by 班次代码"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_ShiftsList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + ex.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取异常反馈类型列表 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/GetGy_ErrMsgBackTypeList_Json")] |
| | | [HttpGet] |
| | | public object GetGy_ErrMsgBackTypeList_Json(string ErrMsg) |
| | | { |
| | | sWhere = " 禁用标志 ='否'"; |
| | | if (ErrMsg != "") |
| | | { |
| | | sWhere = " Where 禁用标志 ='否' and ( 异常反馈类型代码 like '%" + ErrMsg + "%' or 异常反馈类型名称 like '%" + ErrMsg + "%' ) "; |
| | | } |
| | | else |
| | | { |
| | | sWhere = " Where 禁用标志 ='否' "; |
| | | } |
| | | try |
| | | { |
| | | string sql = $"Select * from h_v_Gy_ErrMsgBackType {sWhere} Order by 异常反馈类型代码"; |
| | | ds = oCN.RunProcReturn(sql, "h_v_Gy_ErrMsgBackType"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + ex.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 获取班组列表 |
| | | ///参数:string sql。 |
| | |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | ds = oCN.RunProcReturn("Select HItemID,班组代码 班组代码,班组名称 班组 from h_v_GroupList where 1=1 " + sWhere + " Order by HItemID ", "h_v_GroupList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + e.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取班组列表 根据用户对应班组关系,获取用户对应的班组 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Web/GetGroupListByUser_Json")] |
| | | [HttpGet] |
| | | public object GetGroupListByUser_Json(string sWhere, string user) |
| | | { |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | |
| | | //根据用户对应班组的关系,过滤条件中增加只显示对应的班组 |
| | | DataSet dsHitemID = oCN.RunProcReturn("exec h_p_Gy_GetSQLGroupByUser '" + user + "'", "h_p_Gy_GetSQLGroupByUser"); |
| | | sWhere = sWhere + DBUtility.ClsPub.isStrNull(dsHitemID.Tables[0].Rows[0]["HBack"]); |
| | | |
| | | DataSet ds = oCN.RunProcReturn("Select HItemID,班组代码 班组代码,班组名称 班组 from h_v_GroupList where 1=1 " + sWhere + " Order by HItemID ", "h_v_GroupList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | |
| | | string sql1 = "Select HItemID,HNumber ,HName from Gy_SellStyle where HStopflag=0 and HEndFlag=1 "; |
| | | string sql = sql1 + sWhere; |
| | | ds = oCN.RunProcReturn(sql, "Gy_SellStyle"); |
| | | } |
| | | } |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | |
| | | objjson.Message = "获取失败" + ex.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | } |
| | | |
| | | #region 不良原因 文件导入保存 |
| | | #region 不良原因 文件上传 |
| | | [Route("Gy_BadReason/Gy_BadReason_Excel")] |
| | | [HttpPost] |
| | | public object Gy_BadReason_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | tb2.Columns.Add("HDeptID", typeof(Int32));//部门ID |
| | | tb2.Columns.Add("HProcID", typeof(Int32));//工序ID |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("不良原因代码")) |
| | | error += "没有找到【不良原因代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("不良原因")) |
| | | error += "没有找到【不良原因】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("默认部门代码")) |
| | | error += "没有找到【默认部门代码】的标题,"; |
| | | if (!tb2.Columns.Contains("默认部门")) |
| | | error += "没有找到【默认部门】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("默认工序代码")) |
| | | error += "没有找到【默认工序代码】的标题,"; |
| | | if (!tb2.Columns.Contains("默认工序")) |
| | | error += "没有找到【默认工序】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | string HDeptNumber = ""; |
| | | string HDeptName = ""; |
| | | string HProcNumber = ""; |
| | | string HProcName = ""; |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良原因"].ToString()); |
| | | HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良原因代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | HDeptNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认部门代码"].ToString()); |
| | | HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认部门"].ToString()); |
| | | HProcNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认工序代码"].ToString()); |
| | | HProcName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认工序"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | if (HDeptNumber != "") |
| | | { |
| | | //查询部门 |
| | | ds = oCN.RunProcReturn("select * from Gy_Department where HNumber='" + HDeptNumber + "' and Hname='" + HDeptName + "'", "Gy_Department"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,部门不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HDeptID"] = 0; |
| | | } |
| | | if (HProcNumber != "") |
| | | { |
| | | //查询部门 |
| | | ds = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HProcNumber + "' and Hname='" + HProcName + "'", "Gy_Process"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,工序不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HProcID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HProcID"] = 0; |
| | | } |
| | | |
| | | //不良原因名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良原因名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //不良原因代码 |
| | | if (HNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良原因代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 不良原因项目 导入(保存) |
| | | [Route("Gy_BadReason/Gy_BadReason_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_BadReason_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_BadReason_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HDeptID = item["HDeptID"].ToString();//部门ID |
| | | string HProcID = item["HProcID"].ToString();//工序ID |
| | | string HName = item["不良原因"].ToString(); |
| | | string HNumber = item["不良原因代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_BadReason where HNumber='" + HNumber + "'", "Gy_BadReason"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_BadReason " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HDeptID,HProcID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HBadTypeID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HDeptID.ToString() + "," + HProcID.ToString() + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "'," + 0 + ")", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update Gy_BadReason"+ " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + sShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HLevel=" + HLevel.ToString() + |
| | | ",HDeptID=" + HDeptID.ToString() + |
| | | ",HProcID=" + HProcID.ToString() + |
| | | ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 保存不良类型 |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 不良类型 文件导入保存 |
| | | #region 不良类型 文件上传 |
| | | [Route("Gy_BadType/Gy_BadType_Excel")] |
| | | [HttpPost] |
| | | public object Gy_BadType_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | tb2.Columns.Add("HGroupID", typeof(Int32));//班组ID |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("不良类型代码")) |
| | | error += "没有找到【不良类型代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("不良类型")) |
| | | error += "没有找到【不良类型】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("默认班组代码")) |
| | | error += "没有找到【默认班组代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("默认班组名称")) |
| | | error += "没有找到【默认班组名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | string HGroupNumber = ""; |
| | | string HGroupName = ""; |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良类型"].ToString()); |
| | | HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良类型代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | HGroupNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认班组代码"].ToString()); |
| | | HGroupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["默认班组名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | if(HGroupNumber != "") |
| | | { |
| | | //查询班组 |
| | | ds = oCN.RunProcReturn("select * from Gy_Group where HNumber='" + HGroupNumber + "' and Hname='" + HGroupName + "'", "Gy_Group"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,班组不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HGroupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HGroupID"] = 0; |
| | | } |
| | | |
| | | |
| | | //不良类型名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良类型名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //不良类型代码 |
| | | if (HNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良类型代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 不良类型项目 导入(保存) |
| | | [Route("Gy_BadType/Gy_BadType_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_BadType_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_BadType_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HGroupID = item["HGroupID"].ToString();//班组ID |
| | | string HName = item["不良类型"].ToString(); |
| | | string HNumber = item["不良类型代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_BadType where HNumber='" + HNumber + "'", "Gy_BadType"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into Gy_BadType" + " " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HGroupID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HUSEORGID,HCREATEORGID,HUseFlag,HMakeEmp,HMakeTime) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HGroupID.ToString() + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "'," + HOrgID + "," + HOrgID + ",'" + "未检测" + "','" + user + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_BadType " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HGroupID= '" + HGroupID + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | } |
| | | |
| | | |
| | | |
| | | oCN.RunProc("delete Gy_ErrType where HItemID=" + HItemID); |
| | | oCN.Commit();//提交事务 |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 异常类型 文件导入保存 |
| | | #region 异常类型 文件上传 |
| | | [Route("Gy_ErrType/Gy_ErrType_Excel")] |
| | | [HttpPost] |
| | | public object Gy_ErrType_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询工艺路线没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("异常类型")) |
| | | error += "没有找到【异常类型名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("异常类型代码")) |
| | | error += "没有找到【异常类型代码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HProcessName = ""; |
| | | string HProcessNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["异常类型"].ToString()); |
| | | HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["异常类型代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | |
| | | //异常类型名称 |
| | | if (HProcessName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,异常类型名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //异常类型代码 |
| | | if (HProcessNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,异常类型代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 异常类型项目 导入(保存) |
| | | [Route("Gy_ErrType/Gy_ErrType_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_ErrType_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_ErrType_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HProcessName = item["异常类型"].ToString(); |
| | | string HProcessNum = item["异常类型代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//短代码 |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HProcessNum); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HProcessNum.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_ErrType where HNumber='" + HProcessNum + "'", "Gy_ErrType"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | |
| | | oCN.RunProc("Insert into " + "Gy_ErrType" + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HBarCode,HUSEORGID,HCREATEORGID,HUseFlag) " + |
| | | " Values('" + HProcessNum + "','" + HProcessName + "','" + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + "'," + HOrgID + "," + HOrgID + ",'" + "未检测" + "')"); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("update Gy_ErrType set HUSEORGID=" + HOrgID + ",HRemark='" + HRemark + "' where HNumber='" + HProcessNum + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | /// <summary> |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 不良后果 文件导入保存 |
| | | #region 不良后果 文件上传 |
| | | [Route("Gy_BadResult/Gy_BadResult_Excel")] |
| | | [HttpPost] |
| | | public object Gy_BadResult_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("不良后果代码")) |
| | | error += "没有找到【不良后果代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("不良后果")) |
| | | error += "没有找到【不良后果】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良后果"].ToString()); |
| | | HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良后果代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | //不良后果名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良后果名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //不良后果代码 |
| | | if (HNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良后果代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 不良后果项目 导入(保存) |
| | | [Route("Gy_BadResult/Gy_BadResult_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_BadResult_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_BadResult_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HName = item["不良后果"].ToString(); |
| | | string HNumber = item["不良后果代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_BadResult where HNumber='" + HNumber + "'", "Gy_BadResult"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into Gy_BadResult" + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HISsystemSet,HCREATEORGID,HERPItemID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + 0 + "','" + HOrgID + "','" + 0 + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_BadResult " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | |
| | |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "删除失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 检测值列表 文件上传 |
| | | [Route("Gy_Inspect/Gy_Process_Excel")] |
| | | [HttpPost] |
| | | public json Gy_Inspect_Excel() |
| | | { |
| | | json res = new json(); |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable provisional = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | provisional.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = provisional.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | provisional.Rows.Add(row); |
| | | } |
| | | |
| | | //判断列 |
| | | string error = JudgmentColumns(provisional); |
| | | if (error.Length > 0) |
| | | { |
| | | res.code = "0"; |
| | | res.count = 0; |
| | | res.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | res.data = null; |
| | | return res; |
| | | } |
| | | |
| | | for (int i = 0; i <= provisional.Rows.Count - 1; i++) |
| | | { |
| | | string HNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["检测值代码"].ToString()); |
| | | string HName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["检测值名称"].ToString()); |
| | | string HHelpCode = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["助记码"]); |
| | | string HRemark = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["备注"].ToString()); |
| | | //获取真实行数 |
| | | int line = i + 1; |
| | | } |
| | | |
| | | res.code = "1"; |
| | | res.count = 1; |
| | | res.Message = error; |
| | | res.data = provisional; |
| | | return res; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | res.code = "0"; |
| | | res.count = 0; |
| | | res.Message = "Exception!" + e.ToString(); |
| | | res.data = null; |
| | | return res; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 判断列 |
| | | /// </summary> |
| | | /// <param name="provisional"></param> |
| | | /// <returns></returns> |
| | | private static string JudgmentColumns(DataTable provisional) |
| | | { |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!provisional.Columns.Contains("检测值代码")) |
| | | error += "没有找到【检测值代码】的标题,"; |
| | | |
| | | if (!provisional.Columns.Contains("检测值名称")) |
| | | error += "没有找到【检测值名称】的标题,"; |
| | | return error; |
| | | } |
| | | #endregion |
| | | |
| | | #region 检测值列表 导入(保存) |
| | | [Route("Gy_Inspect/Gy_Process_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_Inspect_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | string organ = sArray[2].ToString(); |
| | | |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_Group_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HNumber = item["检测值代码"].ToString(); |
| | | string HName = item["检测值名称"].ToString(); |
| | | string HHelpCode = item["助记码"]; |
| | | string HRemark = item["备注"].ToString(); |
| | | |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_InspectValue where HNumber='" + HNumber + "'", "Gy_InspectValue"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | |
| | | string sql = "insert into Gy_InspectValue (HName,HNumber,HShortNumber,HLevel,HHelpCode,HParentID,HStopflag,HEndFlag,HRemark,HUseFlag, HUSEORGID, HCREATEORGID, HMakeTime,HMakeEmp)" + |
| | | $"values('{HName}', '{HNumber}', '{sShortNumber}',{HLevel},'',0,'0','0','{HRemark}', '未使用', '{organ}', '{organ}', '{System.DateTime.Now.ToString("G")}', '{user}')"; |
| | | oCN.RunProc(sql); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("update Gy_InspectValue set HName='" + HName + "', HHelpCode='" + HHelpCode + "', HModifyEmp = '" + user + "', HModifyTime = '" + System.DateTime.Now.ToString("G") + "'where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 文件上传 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Gy_InspectInstruMent_UploadFile")] |
| | | [HttpPost] |
| | | public object Gy_InspectInstruMent_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/Gy_InspectInstruMent/" + 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/Gy_InspectInstruMent/" + 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/Gy_InspectInstruMent/" + 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; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据单据号查找上传文件列表 |
| | | /// </summary> |
| | | /// <param name="sWhere"></param> |
| | | /// <returns></returns> |
| | | [Route("Gy_InspectInstruMent_Filelist")] |
| | | [HttpGet] |
| | | public object Gy_InspectInstruMent_Filelist(string HBillNo) |
| | | { |
| | | var url = fileip + "/files/Gy_InspectInstruMent/" + 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; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据ID,单据号,文件名 删除文件 |
| | | /// </summary> |
| | | /// <param name="sWhere"></param> |
| | | /// <returns></returns> |
| | | [Route("Gy_InspectInstruMent_DeleteFilelist")] |
| | | [HttpGet] |
| | | public object Gy_InspectInstruMent_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/EquipTechParamFolder/" + 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 检验依据 设置列表/保存/编辑/删除方法 |
| | |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | } |
| | | |
| | | |
| | | |
| | | oCN.RunProc("delete Gy_PostSkill where HItemID=" + HItemID); |
| | | oCN.Commit();//提交事务 |
| | |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 岗位技能 文件导入保存 |
| | | #region 岗位技能 文件上传 |
| | | [Route("Gy_PostSkill/Gy_PostSkill_Excel")] |
| | | [HttpPost] |
| | | public object Gy_PostSkill_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | tb2.Columns.Add("HPostID", typeof(Int32));//岗位id |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("岗位技能")) |
| | | error += "没有找到【岗位技能】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("岗位技能代码")) |
| | | error += "没有找到【岗位技能代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("岗位")) |
| | | error += "没有找到【岗位】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("岗位代码")) |
| | | error += "没有找到【岗位代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HProcessName = ""; |
| | | string HProcessNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | string HPostName = ""; |
| | | string HPostNumber = ""; |
| | | |
| | | |
| | | HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位技能"].ToString()); |
| | | HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位技能代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | HPostName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位"].ToString()); |
| | | HPostNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位代码"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | //查询岗位 |
| | | ds = oCN.RunProcReturn("select * from Gy_Post where HNumber='" + HPostNumber + "' and Hname='" + HPostName + "' and HUSEORGID = "+ HORGid, "Gy_Post"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,岗位不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HPostID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | |
| | | |
| | | //岗位技能名称 |
| | | if (HProcessName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,岗位技能不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //岗位技能代码 |
| | | if (HProcessNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,岗位技能代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 岗位技能项目 导入(保存) |
| | | [Route("Gy_PostSkill/Gy_PostSkill_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_PostSkill_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_PostSkill_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HPostID = item["HPostID"].ToString();//组织ID |
| | | string HName = item["岗位技能"].ToString(); |
| | | string HNumber = item["岗位技能代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string HUseFlag = "未检测"; |
| | | string HShortNumber; |
| | | HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (HShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_PostSkill where HNumber='" + HNumber + "'", "Gy_PostSkill"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_PostSkill" + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID,HPostID,HProcID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + 0 + |
| | | "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + HUseFlag + "','" + user + "','" + HOrgID + "','" + HPostID + "','" + 0 + "')"); |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_PostSkill" + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + HShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HModifyTime='" + DateTime.Now + "'" + |
| | | ",HUSEORGID='" + HOrgID + "'" + |
| | | ",HModifyEmp ='" + user + "'" + |
| | | ",HPostID ='" + HPostID + "'" + |
| | | ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 岗位 设置列表/保存/编辑/删除方法 |
| | | /// <summary> |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 岗位 文件导入保存 |
| | | #region 岗位 文件上传 |
| | | [Route("Gy_Post/Gy_Post_Excel")] |
| | | [HttpPost] |
| | | public object Gy_Post_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("岗位")) |
| | | error += "没有找到【岗位名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("岗位代码")) |
| | | error += "没有找到【岗位代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HProcessName = ""; |
| | | string HProcessNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位"].ToString()); |
| | | HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["岗位代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | |
| | | //岗位名称 |
| | | if (HProcessName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,岗位名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //岗位代码 |
| | | if (HProcessNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,岗位代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 岗位项目 导入(保存) |
| | | [Route("Gy_Post/Gy_Post_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_Post_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_Post_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HName = item["岗位"].ToString(); |
| | | string HNumber = item["岗位代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string HUseFlag = "未检测"; |
| | | string HShortNumber; |
| | | HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (HShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_Post where HNumber='" + HNumber + "'", "Gy_Post"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_Post" + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + 0 + |
| | | "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + HUseFlag + "','" + user + "','" + HOrgID + "')"); |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_Post" + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + HShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HModifyTime='" + DateTime.Now + "'" + |
| | | ",HUSEORGID='" + HOrgID + "'" + |
| | | ",HModifyEmp ='" + user + "'" + |
| | | ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 调拨类型 设置列表/保存/编辑/删除方法 |
| | | /// <summary> |
| | | /// 保存调拨类型 |
| | |
| | | WebAPI.DLL.ClsGy_StockMoveStyle_Ctl oBill = new WebAPI.DLL.ClsGy_StockMoveStyle_Ctl(); |
| | | List<Model.ClsGy_StockMoveStyle_Model> lsmain = new List<Model.ClsGy_StockMoveStyle_Model>(); |
| | | msg1 = msg1.Replace("\\", ""); |
| | | msg1 = msg1.Replace("\n", ""); |
| | | msg1 = msg1.Replace("\n", ""); |
| | | lsmain = oListModels.getObjectByJson_Gy_StockMoveStyle(msg1); |
| | | foreach (Model.ClsGy_StockMoveStyle_Model oItem in lsmain) |
| | | { |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 供应商分类 文件导入保存 |
| | | #region 供应商分类 文件上传 |
| | | [Route("Gy_SupType/Gy_SupType_Excel")] |
| | | [HttpPost] |
| | | public object Gy_SupType_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("供应商分类代码")) |
| | | error += "没有找到【供应商分类代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("供应商分类")) |
| | | error += "没有找到【供应商分类】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["供应商分类"].ToString()); |
| | | HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["供应商分类代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | //供应商分类名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,供应商分类名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //供应商分类代码 |
| | | if (HNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,供应商分类代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 供应商分类项目 导入(保存) |
| | | [Route("Gy_SupType/Gy_SupType_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_SupType_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_SupType_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HName = item["供应商分类"].ToString(); |
| | | string HNumber = item["供应商分类代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_SupType where HNumber='" + HNumber + "'", "Gy_SupType"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_SupType " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_SupType " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + sShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region 工艺参数分类 设置列表/保存/编辑/删除方法 |
| | | /// <summary> |
| | | /// 工艺参数分类 保存 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | /// <returns></returns> |
| | | [Route("SaveGy_TechnologyTypeList")] |
| | | [HttpPost] |
| | | public object SaveGy_TechnologyTypeList([FromBody] JObject msg) |
| | | { |
| | | DataSet ds; |
| | | var _value = msg["msg"].ToString(); |
| | | string msg3 = _value.ToString(); |
| | | string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg1 = sArray[0].ToString(); |
| | | string msg2 = sArray[1].ToString(); |
| | | |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_Technology_Edit", 1, false, msg2)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | Int64 HItemID = 0; |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | //获取最大ID值赋值 |
| | | DataSet Maxds = oCN.RunProcReturn("select isNull(MAX(HItemID),0) HItemID from Gy_TechnologyParameterClass ", "Gy_TechnologyParameterClass"); |
| | | if (Maxds != null || Maxds.Tables[0].Rows.Count > 0) |
| | | { |
| | | //HItemID= Maxds.Tables[0].Rows[0]["HItemID"] |
| | | var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]); |
| | | maxid += 1; |
| | | HItemID = maxid; |
| | | } |
| | | ListModels oListModels = new ListModels(); |
| | | try |
| | | { |
| | | WebAPI.DLL.ClsGy_TechnologyParameterType_Ctl oBill = new WebAPI.DLL.ClsGy_TechnologyParameterType_Ctl(); |
| | | List<Model.ClsGy_TechnologyParameterType_Model> lsmain = new List<Model.ClsGy_TechnologyParameterType_Model>(); |
| | | msg1 = msg1.Replace("\\", ""); |
| | | msg1 = msg1.Replace("\n", ""); |
| | | lsmain = oListModels.getObjectByJson_Gy_TechnologyParameterType(msg1); |
| | | foreach (Model.ClsGy_TechnologyParameterType_Model oItem in lsmain) |
| | | { |
| | | if (oItem.HNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码不能为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | if (oItem.HName.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!名称不能为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //查询数据中是否存在重复代码 |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_TechnologyParameterClass where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_TechnologyParameterClass"); |
| | | if (oItem.HNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //新增时判断 |
| | | if (oItem.HItemID == 0) |
| | | { |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码重复!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //检查父级是否存在 |
| | | string sParent; |
| | | sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim()); |
| | | if (sParent.Trim() == "") |
| | | { |
| | | oBill.oModel.HParentID = 0; |
| | | } |
| | | else |
| | | { |
| | | if (oBill.HavParentCode(sParent.Trim(), HItemID)) |
| | | { |
| | | oBill.oModel.HParentID = oBill.oModel.HItemID; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!上级代码不存在或被禁用!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else//编辑时判断 |
| | | { |
| | | //检查父级是否存在 |
| | | string sParent; |
| | | sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim()); |
| | | if (sParent.Trim() == "") |
| | | { |
| | | oBill.oModel.HParentID = 0; |
| | | } |
| | | else |
| | | { |
| | | if (oBill.HavParentCode(sParent.Trim(), oItem.HItemID)) |
| | | { |
| | | oBill.oModel.HParentID = oBill.oModel.HItemID; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!上级代码不存在或被禁用!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | //得到短代码 |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim()); |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | oItem.HShortNumber = sShortNumber;//短代码 |
| | | oItem.HEndFlag = true;//末级标志 |
| | | oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //等级 |
| | | oItem.HMakeEmp = msg2; //创建人 |
| | | |
| | | oBill.oModel = oItem; |
| | | } |
| | | |
| | | //保存 |
| | | //保存完毕后处理 |
| | | bool bResult; |
| | | if (oBill.oModel.HItemID == 0) |
| | | { |
| | | // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | bResult = oBill.AddNew(); |
| | | } |
| | | else |
| | | { |
| | | bResult = oBill.ModifyByID(oBill.oModel.HItemID); |
| | | } |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 工艺参数分类删除功能 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("DeltetGy_TechnologyType")] |
| | | [HttpGet] |
| | | public object DeltetGy_TechnologyType(string HItemID, string user) |
| | | { |
| | | DataSet ds; |
| | | //string ModRightNameCheck = "Sc_ProcessReport_check"; |
| | | try |
| | | { |
| | | //删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_Technology_Drop", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无删除权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | if (string.IsNullOrWhiteSpace(HItemID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HItemID为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.BeginTran();//开始事务 |
| | | ds = oCN.RunProcReturn("select * from Gy_TechnologyParameterClass where HItemID=" + HItemID, "Gy_TechnologyParameterClass"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "没有数据,无法删除!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | } |
| | | |
| | | |
| | | oCN.RunProc("delete Gy_TechnologyParameterClass where HItemID=" + HItemID); |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 工艺品参数分类获取信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("GetGy_TechnologyTypeDetail")] |
| | | [HttpGet] |
| | | public ApiResult<DataSet> GetGy_TechnologyType(string HID) |
| | | { |
| | | var model = LuBaoSevice.GetGy_TechnologyType(HID); |
| | | return model; |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region 客户分类 设置列表/保存/编辑/删除方法 |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | |
| | | #region 客户分类 文件导入保存 |
| | | #region 客户分类 文件上传 |
| | | [Route("Gy_CusType/Gy_CusType_Excel")] |
| | | [HttpPost] |
| | | public object Gy_CusType_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("客户分类代码")) |
| | | error += "没有找到【客户分类代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("客户分类")) |
| | | error += "没有找到【客户分类】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户分类"].ToString()); |
| | | HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["客户分类代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | //客户分类名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,客户分类名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //客户分类代码 |
| | | if (HNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,客户分类代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 客户分类项目 导入(保存) |
| | | [Route("Gy_CusType/Gy_CusType_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_CusType_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_CusType_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HName = item["客户分类"].ToString(); |
| | | string HNumber = item["客户分类代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_CusType where HNumber='" + HNumber + "'", "Gy_CusType"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + " Gy_CusType" + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_CusType " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + sShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #endregion |
| | | |
| | | #region 盘点方案 设置列表/保存/编辑/删除方法 |
| | |
| | | ListModels oListModels = new ListModels(); |
| | | try |
| | | { |
| | | |
| | | |
| | | WebAPI.DLL.ClsGy_ProjectMoney_Ctl oBill = new WebAPI.DLL.ClsGy_ProjectMoney_Ctl(); |
| | | List<Model.ClsGy_ProjectMoney_Model> lsmain = new List<Model.ClsGy_ProjectMoney_Model>(); |
| | | msg1 = msg1.Replace("\\", ""); |
| | |
| | | return objJsonResult; |
| | | } |
| | | oCN.BeginTran();//开始事务 |
| | | |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_ProjectMoney where HItemID=" + HItemID, "Gy_ProjectMoney"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | |
| | | ListModels oListModels = new ListModels(); |
| | | try |
| | | { |
| | | |
| | | |
| | | WebAPI.DLL.ClsGy_ErrMsgBackType_Ctl oBill = new WebAPI.DLL.ClsGy_ErrMsgBackType_Ctl(); |
| | | List<Model.ClsGy_ErrMsgBackType_Model> lsmain = new List<Model.ClsGy_ErrMsgBackType_Model>(); |
| | | msg1 = msg1.Replace("\\", ""); |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 异常反馈类型 文件导入保存 |
| | | #region 异常反馈类型 文件上传 |
| | | [Route("Gy_ErrMsgBackType/Gy_ErrMsgBackType_Excel")] |
| | | [HttpPost] |
| | | public object Gy_ErrMsgBackType_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询工艺路线没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("异常反馈类型")) |
| | | error += "没有找到【异常反馈类型名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("异常反馈类型代码")) |
| | | error += "没有找到【异常反馈类型代码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HProcessName = ""; |
| | | string HProcessNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["异常反馈类型"].ToString()); |
| | | HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["异常反馈类型代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | |
| | | //异常类型名称 |
| | | if (HProcessName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,异常反馈类型名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //异常类型代码 |
| | | if (HProcessNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,异常反馈类型代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 异常反馈项目 导入(保存) |
| | | [Route("Gy_ErrMsgBackType/Gy_ErrMsgBackType_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_ErrMsgBackType_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_ErrType_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HProcessName = item["异常反馈类型"].ToString(); |
| | | string HProcessNum = item["异常反馈类型代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//短代码 |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HProcessNum); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HProcessNum.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_ErrMsgBackType where HNumber='" + HProcessNum + "'", "Gy_ErrMsgBackType"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_ErrMsgBackType " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + |
| | | " Values('" + HProcessNum + "','" + HProcessName + "','" + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')"); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("update Gy_ErrMsgBackType set HUSEORGID=" + HOrgID + ",HRemark='" + HRemark + "' where HNumber='" + HProcessNum + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 不良现象 设置列表/保存/编辑/删除方法 |
| | |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | #region 不良现象 文件导入保存 |
| | | #region 不良现象 文件上传 |
| | | [Route("Gy_BadPhenomena/Gy_BadPhenomena_Excel")] |
| | | [HttpPost] |
| | | public object Gy_BadPhenomena_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("不良现象代码")) |
| | | error += "没有找到【不良现象代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("不良现象")) |
| | | error += "没有找到【不良现象】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HName = ""; |
| | | string HNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良现象"].ToString()); |
| | | HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["不良现象代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | |
| | | //不良现象名称 |
| | | if (HName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良现象名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //不良现象代码 |
| | | if (HNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,不良现象代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 不良现象项目 导入(保存) |
| | | [Route("Gy_BadPhenomena/Gy_BadPhenomena_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_BadPhenomena_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_BadPhenomena_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HName = item["不良现象"].ToString(); |
| | | string HNumber = item["不良现象代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_BadPhenomena where HNumber='" + HNumber + "'", "Gy_BadPhenomena"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_BadPhenomena " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_BadPhenomena " + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + sShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HRemark= '" + HRemark + "'" + |
| | | ",HModifyEmp= '" + user + "'" + |
| | | ",HModifyTime=getdate()" + |
| | | ",HUSEORGID=" + HOrgID + |
| | | " where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | |
| | | #endregion |
| | | |
| | | #region 项目类别 设置列表/保存/编辑/删除方法 |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 防错装置 文件导入保存 |
| | | #region 防错装置 文件上传 |
| | | [Route("Gy_PreventErrMould/Gy_PreventErrMould_Excel")] |
| | | [HttpPost] |
| | | public object Gy_PreventErrMould_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("防错装置名称")) |
| | | error += "没有找到【防错装置名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("防错装置代码")) |
| | | error += "没有找到【防错装置代码】的标题,"; |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HProcessName = ""; |
| | | string HProcessNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["防错装置名称"].ToString()); |
| | | HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["防错装置代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | |
| | | //防错装置名称 |
| | | if (HProcessName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,防错装置名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //防错装置代码 |
| | | if (HProcessNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,防错装置代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 防错装置项目 导入(保存) |
| | | [Route("Gy_PreventErrMould/Gy_PreventErrMould_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_PreventErrMould_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_PreventErrMould_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HName = item["防错装置名称"].ToString(); |
| | | string HNumber = item["防错装置代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string HShortNumber; |
| | | HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (HShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_PreventErrMould where HNumber='" + HNumber + "'", "Gy_PreventErrMould"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_PreventErrMould" + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + 0 + |
| | | "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "未检测" + "','" + user + "','" + HOrgID + "')"); |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_PreventErrMould" + " set " + |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + HShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HModifyTime='" + DateTime.Now + "'" + |
| | | ",HUSEORGID='" + HOrgID + "'" + |
| | | ",HModifyEmp ='" + user + "'" + |
| | | ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 防错装置 设置列表/保存/编辑/删除方法 |
| | | /// <summary> |
| | | /// 防错装置 保存 |
| | |
| | | } |
| | | oCN.BeginTran();//开始事务 |
| | | |
| | | |
| | | |
| | | oCN.RunProc("delete Gy_PreventErrMould where HItemID=" + HItemID); |
| | | oCN.Commit();//提交事务 |
| | | objJsonResult.code = "0"; |
| | |
| | | try |
| | | { |
| | | //删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_CheckNoteItem_Drop", 1, false, user)) |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_CheckNoteItem_Delete", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 启动检查项目 文件导入保存 |
| | | #region 启动检查项目 文件上传 |
| | | [Route("Gy_CheckNoteItem/Gy_CheckNoteItem_Excel")] |
| | | [HttpPost] |
| | | public object Gy_CheckNoteItem_Excel() |
| | | { |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | |
| | | NpoiHelper np = new NpoiHelper(); |
| | | DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable tb2 = new DataTable("dt2"); |
| | | |
| | | //添加列名 |
| | | for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) |
| | | { |
| | | tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); |
| | | } |
| | | |
| | | //模板缺少列 但需要从数据库中查询出来显示在页面的字段 |
| | | tb2.Columns.Add("HOrgID", typeof(Int32));//组织ID |
| | | |
| | | //添加数据 |
| | | for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) |
| | | { |
| | | DataRow row = tb2.NewRow(); |
| | | for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | { |
| | | row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); |
| | | } |
| | | tb2.Rows.Add(row); |
| | | } |
| | | |
| | | |
| | | var error = ""; |
| | | |
| | | //查询没有的列 |
| | | if (!tb2.Columns.Contains("组织代码")) |
| | | error += "没有找到【组织代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("组织名称")) |
| | | error += "没有找到【组织名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("启动检查项目名称")) |
| | | error += "没有找到【启动检查项目名称】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("启动检查项目代码")) |
| | | error += "没有找到【启动检查项目代码】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("备注")) |
| | | error += "没有找到【备注】的标题,"; |
| | | |
| | | if (!tb2.Columns.Contains("助记码")) |
| | | error += "没有找到【助记码】的标题,"; |
| | | |
| | | if (error.Length > 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = $"Excel模板存在错误,{error}\r\n"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | for (int i = 0; i <= tb2.Rows.Count - 1; i++) |
| | | { |
| | | string HProcessName = ""; |
| | | string HProcessNum = ""; |
| | | string HORGNumber = ""; |
| | | string HORGName = ""; |
| | | |
| | | |
| | | HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["启动检查项目名称"].ToString()); |
| | | HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["启动检查项目代码"].ToString()); |
| | | HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织代码"].ToString()); |
| | | HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["组织名称"].ToString()); |
| | | |
| | | //检查物料 |
| | | int index = i + 1; |
| | | |
| | | if (HORGNumber != "") |
| | | { |
| | | |
| | | //查询组织 |
| | | ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织不存在!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | } |
| | | string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | |
| | | //启动检查项目名称 |
| | | if (HProcessName == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,启动检查项目名称不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | //启动检查项目代码 |
| | | if (HProcessNum == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,启动检查项目代码不能为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "第" + index + "行,组织代码为空"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = error; |
| | | objJsonResult.data = tb2; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | #region 启动检查项目项目 导入(保存) |
| | | [Route("Gy_CheckNoteItem/Gy_CheckNoteItem_btnSave")] |
| | | [HttpPost] |
| | | public object Gy_CheckNoteItem_btnSave([FromBody] JObject sMainSub) |
| | | { |
| | | var _value = sMainSub["sMainSub"].ToString(); |
| | | string msg1 = _value.ToString(); |
| | | string[] sArray = msg1.Split(new string[] { "&和" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg2 = sArray[0].ToString(); |
| | | string user = sArray[1].ToString(); |
| | | try |
| | | { |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_CheckNoteItem_Edit", 1, false, user)) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2); |
| | | List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); |
| | | |
| | | foreach (JObject item in Excel) |
| | | { |
| | | Dictionary<string, string> dic = new Dictionary<string, string>(); |
| | | foreach (var itm in item.Properties()) |
| | | { |
| | | dic.Add(itm.Name, itm.Value.ToString()); |
| | | } |
| | | list.Add(dic); |
| | | } |
| | | |
| | | oCN.BeginTran(); |
| | | int i = 1; |
| | | foreach (Dictionary<string, string> item in list) |
| | | { |
| | | string HOrgID = item["HOrgID"].ToString();//组织ID |
| | | string HName = item["启动检查项目名称"].ToString(); |
| | | string HNumber = item["启动检查项目代码"].ToString(); |
| | | string HRemark = item["备注"].ToString(); |
| | | string HHelpCode = item["助记码"].ToString(); |
| | | string HShortNumber; |
| | | HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//短代码 |
| | | if (HShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | int HEndFlag = 1;//末级标志 |
| | | int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //等级 |
| | | string HUseFlag = "未检测"; |
| | | |
| | | if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_CheckNoteItem where HNumber='" + HNumber + "'", "Gy_CheckNoteItem"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | oCN.RunProc("Insert into " + "Gy_CheckNoteItem" + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID,HCheckPostID) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + 0 + |
| | | "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + HUseFlag + "','" + user + "','" + HOrgID + "','" + 0 + "')"); |
| | | |
| | | |
| | | } |
| | | else |
| | | { |
| | | oCN.RunProc("Update " + "Gy_CheckNoteItem" + " set " + |
| | | |
| | | "HName='" + HName + "'" + |
| | | ",HShortNumber='" + HShortNumber + "'" + |
| | | ",HHelpCode='" + HHelpCode + "'" + |
| | | ",HModifyTime='" + DateTime.Now + "'" + |
| | | ",HUSEORGID='" + HOrgID + "'" + |
| | | ",HModifyEmp ='" + user + "'" + |
| | | ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'"); |
| | | } |
| | | |
| | | i++; |
| | | } |
| | | |
| | | oCN.Commit(); |
| | | |
| | | objJsonResult.code = CodeConstant.SUCCEED; |
| | | objJsonResult.count = CountConstant.SUCCEED; |
| | | objJsonResult.Message = "导入成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | LogService.Write(e); |
| | | objJsonResult.code = CodeConstant.FAIL; |
| | | objJsonResult.count = CountConstant.FAIL; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 休息日 设置列表/保存/编辑/删除方法 |
| | | /// <summary> |
| | | /// 休息日 保存 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | /// <returns></returns> |
| | | [Route("SaveGy_RestDayList")] |
| | | [HttpPost] |
| | | public object SaveGy_RestDayList([FromBody] JObject msg) |
| | | { |
| | | DataSet ds; |
| | | var _value = msg["msg"].ToString(); |
| | | string msg3 = _value.ToString(); |
| | | string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg1 = sArray[0].ToString(); |
| | | string msg2 = sArray[1].ToString(); |
| | | |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_RestDay_Edit", 1, false, msg2)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | Int64 HItemID = 0; |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | //获取最大ID值赋值 |
| | | DataSet Maxds = oCN.RunProcReturn("select isNull(MAX(HItemID),0) HItemID from Gy_RestDay ", "Gy_RestDay"); |
| | | if (Maxds != null || Maxds.Tables[0].Rows.Count > 0) |
| | | { |
| | | //HItemID= Maxds.Tables[0].Rows[0]["HItemID"] |
| | | var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]); |
| | | maxid += 1; |
| | | HItemID = maxid; |
| | | } |
| | | ListModels oListModels = new ListModels(); |
| | | try |
| | | { |
| | | |
| | | WebAPI.DLL.ClsGy_RestDay_Ctl oBill = new WebAPI.DLL.ClsGy_RestDay_Ctl(); |
| | | List<Model.ClsGy_RestDay_Model> lsmain = new List<Model.ClsGy_RestDay_Model>(); |
| | | msg1 = msg1.Replace("\\", ""); |
| | | msg1 = msg1.Replace("\n", ""); |
| | | lsmain = oListModels.getObjectByJson_Gy_RestDay(msg1); |
| | | foreach (Model.ClsGy_RestDay_Model oItem in lsmain) |
| | | { |
| | | if (oItem.HNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码不能为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | if (oItem.HName.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!名称不能为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //得到短代码 |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim()); |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | oItem.HShortNumber = sShortNumber;//短代码 |
| | | oItem.HEndFlag = true;//末级标志 |
| | | oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //等级 |
| | | oItem.HMakeEmp = msg2; //创建人 |
| | | DayOfWeek dayOfWeek = oItem.HRestDay.DayOfWeek; |
| | | |
| | | // 定义星期几的中文映射关系 |
| | | Dictionary<DayOfWeek, string> chineseDayOfWeek = new Dictionary<DayOfWeek, string> |
| | | { |
| | | { DayOfWeek.Sunday, "星期日" }, |
| | | { DayOfWeek.Saturday, "星期六" } |
| | | }; |
| | | |
| | | // 获取中文星期几名称 |
| | | oItem.HWeekDay = chineseDayOfWeek[dayOfWeek]; |
| | | oBill.oModel = oItem; |
| | | } |
| | | |
| | | //保存 |
| | | //保存完毕后处理 |
| | | bool bResult; |
| | | if (oBill.oModel.HItemID == 0) |
| | | { |
| | | // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo); |
| | | bResult = oBill.AddNew(); |
| | | } |
| | | else |
| | | { |
| | | bResult = oBill.ModifyByID(oBill.oModel.HItemID); |
| | | } |
| | | if (bResult) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "保存成功!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!数据已存在!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!" + e.ToString(); |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 休息日 保存 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | /// <returns></returns> |
| | | [Route("SaveSumGy_RestDayList")] |
| | | [HttpPost] |
| | | public object SaveSumGy_RestDayList([FromBody] JObject msg) |
| | | { |
| | | DataSet ds; |
| | | var _value = msg["msg"].ToString(); |
| | | string msg3 = _value.ToString(); |
| | | string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg1 = sArray[0].ToString(); |
| | | string msg2 = sArray[1].ToString(); |
| | | |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_RestDay_Edit", 1, false, msg2)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | |
| | | JObject msgObj = JObject.Parse(msg1); |
| | | string HYear = msgObj["HYear"].ToString(); |
| | | string HNumber1 = msgObj["HDeptNumber"].ToString()+'-' + msgObj["HOrgNumber"].ToString(); |
| | | string HName1 = msgObj["HDeptName"].ToString()+'-'+msgObj["HOrgName"].ToString(); |
| | | string HOrgID = msgObj["HOrgID"].ToString(); |
| | | string HDeptID = msgObj["HDeptID"].ToString(); |
| | | bool HStopflag = bool.Parse(msgObj["HStopflag"].ToString()); |
| | | string HRemark= msgObj["HRemark"].ToString(); |
| | | string HUSEORGID= msgObj["HUSEORGID"].ToString(); |
| | | string HHelpCode= msgObj["HHelpCode"].ToString(); |
| | | string HMakeEmp = msg2; //创建人 |
| | | bool Sunday = Convert.ToBoolean(msgObj["Sunday"]); |
| | | bool Saturday = Convert.ToBoolean(msgObj["Saturday"]); |
| | | List<Tuple<DateTime, string>> sundaysInYear = GetSundaysInYear(Convert.ToInt32(HYear), Sunday, Saturday); |
| | | |
| | | foreach (var oItem in sundaysInYear) |
| | | { |
| | | Int64 HItemID = 0; |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | //获取最大ID值赋值 |
| | | DataSet Maxds = oCN.RunProcReturn("select isNull(MAX(HItemID),0) HItemID from Gy_RestDay ", "Gy_RestDay"); |
| | | if (Maxds != null || Maxds.Tables[0].Rows.Count > 0) |
| | | { |
| | | //HItemID= Maxds.Tables[0].Rows[0]["HItemID"] |
| | | var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]); |
| | | maxid += 1; |
| | | HItemID = maxid; |
| | | } |
| | | DateTime HRestDay = oItem.Item1; |
| | | string HWeekDay = oItem.Item2; // 获取星期字符串 |
| | | string HDate = oItem.Item1.ToString("yyyyMMdd"); |
| | | string HNumber = ""; |
| | | string HName = ""; |
| | | HNumber = HNumber1 + '-' + HDate; |
| | | |
| | | HName = HName1 + '-' + HDate; |
| | | //先查看数据库有没有 |
| | | ds = oCN.RunProcReturn("select * from Gy_RestDay where HRestDay='" + HRestDay + "' and HOrgID='" + HOrgID + "' and HDeptID='" + HDeptID + "'", "Gy_RestDay"); |
| | | if (ds.Tables[0].Rows.Count<1) |
| | | { |
| | | oCN.RunProc("Insert into Gy_RestDay " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID," + |
| | | "HOrgID,HDeptID,HRestDay,HWeekDay) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "',''," + 0 + |
| | | "," + 0 + "," + 0 + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "','" + DateTime.Now + "','" + HUSEORGID + "',' 未检测','" + HMakeEmp + "','" + HUSEORGID + "'" + |
| | | ",'" + HOrgID.ToString() + "','" + HDeptID.ToString() + "','" + HRestDay.ToString() + "','" + HWeekDay.ToString() + "')"); |
| | | } |
| | | } |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "保存成功!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 休息日 获取信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("GetGy_RestDayDetailEdit")] |
| | | [HttpGet] |
| | | public ApiResult<DataSet> GetGy_RestDayDetailEdit(string HID) |
| | | { |
| | | var model = LuBaoSevice.GetGy_RestDayDetailEdit(HID); |
| | | return model; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 休息日 获取信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("GetGy_RestDayDetail")] |
| | | [HttpGet] |
| | | public ApiResult<DataSet> GetGy_RestDayDetail(string HName) |
| | | { |
| | | var model = LuBaoSevice.GetGy_RestDayDetail(HName); |
| | | return model; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 休息日 删除功能 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("DeltetGy_RestDay")] |
| | | [HttpGet] |
| | | public object DeltetGy_RestDay(string HItemID, string user) |
| | | { |
| | | DataSet ds; |
| | | try |
| | | { |
| | | //删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_RestDay_Delete", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无删除权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | if (string.IsNullOrWhiteSpace(HItemID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HItemID为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.BeginTran();//开始事务 |
| | | |
| | | |
| | | oCN.RunProc("delete Gy_RestDay where HItemID=" + HItemID); |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | //获取一年中的周六,周日或者两个同时获取 |
| | | public List<Tuple<DateTime, string>> GetSundaysInYear(int HYear, bool Sunday,bool Saturday) |
| | | { |
| | | List<Tuple<DateTime, string>> Days = new List<Tuple<DateTime, string>>(); |
| | | DateTime startDate = new DateTime(HYear, 1, 1); |
| | | DateTime endDate = new DateTime(HYear, 12, 31); |
| | | //星期天勾选 |
| | | if (Sunday && !Saturday) |
| | | { |
| | | while (startDate <= endDate) |
| | | { |
| | | if (startDate.DayOfWeek == DayOfWeek.Sunday) |
| | | { |
| | | Days.Add(Tuple.Create(startDate, "星期天")); |
| | | } |
| | | startDate = startDate.AddDays(1); |
| | | } |
| | | } |
| | | //星期六 勾选 |
| | | else if (!Sunday && Saturday) |
| | | { |
| | | while (startDate <= endDate) |
| | | { |
| | | if (startDate.DayOfWeek == DayOfWeek.Saturday) |
| | | { |
| | | Days.Add(Tuple.Create(startDate, "星期六")); |
| | | } |
| | | startDate = startDate.AddDays(1); |
| | | } |
| | | } |
| | | else if (Sunday && Saturday) |
| | | { |
| | | while (startDate <= endDate) |
| | | { |
| | | if (startDate.DayOfWeek == DayOfWeek.Saturday || startDate.DayOfWeek == DayOfWeek.Sunday) |
| | | { |
| | | string weekdayChinese; |
| | | if (startDate.DayOfWeek == DayOfWeek.Sunday) |
| | | { |
| | | weekdayChinese = "星期天"; |
| | | Days.Add(Tuple.Create(startDate, weekdayChinese)); |
| | | } |
| | | else if (startDate.DayOfWeek == DayOfWeek.Saturday) |
| | | { |
| | | weekdayChinese = "星期六"; |
| | | Days.Add(Tuple.Create(startDate, weekdayChinese)); |
| | | } |
| | | } |
| | | startDate = startDate.AddDays(1); |
| | | } |
| | | } |
| | | return Days; |
| | | } |
| | | |
| | | //返回的字段 |
| | | public class DayOfWeekInfo |
| | | { |
| | | public DateTime Date { get; set; } |
| | | public string DayOfWeekText { get; set; } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | #region 环境检测单 设置列表/保存/编辑/删除方法 |
| | | /// <summary> |
| | | /// 保存环境检测单 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | /// <returns></returns> |
| | | [Route("SaveGy_EnvironmentTestItem")] |
| | | [HttpPost] |
| | | public object SaveGy_EnvironmentTestItem([FromBody] JObject msg) |
| | | { |
| | | DataSet ds; |
| | | var _value = msg["msg"].ToString(); |
| | | string msg3 = _value.ToString(); |
| | | string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); |
| | | string msg1 = sArray[0].ToString(); |
| | | string msg2 = sArray[1].ToString(); |
| | | |
| | | //查看权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_EnvironmentTestItem_Edit", 1, false, msg2)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无保存权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | Int64 HItemID = 0; |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | //获取最大ID值赋值 |
| | | DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Gy_EnvironmentTestItem ", "Gy_EnvironmentTestItem"); |
| | | if (Maxds != null || Maxds.Tables[0].Rows.Count > 0) |
| | | { |
| | | //HItemID= Maxds.Tables[0].Rows[0]["HItemID"] |
| | | var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]); |
| | | maxid += 1; |
| | | HItemID = maxid; |
| | | } |
| | | ListModels oListModels = new ListModels(); |
| | | try |
| | | { |
| | | WebAPI.DLL.ClsGy_EnvironmentTestItem_Ctl oBill = new WebAPI.DLL.ClsGy_EnvironmentTestItem_Ctl(); |
| | | List<Model.ClsGy_EnvironmentTestItem_Model> lsmain = new List<Model.ClsGy_EnvironmentTestItem_Model>(); |
| | | msg1 = msg1.Replace("\\", ""); |
| | | msg1 = msg1.Replace("\n", ""); //\n |
| | | lsmain = oListModels.getObjectByJson_Gy_EnvironmentTestItem(msg1); |
| | | foreach (Model.ClsGy_EnvironmentTestItem_Model oItem in lsmain) |
| | | { |
| | | if (oItem.HNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码不能为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | if (oItem.HName.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!名称不能为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim())) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码中不能出现连续‘.’并且首位末位不能为‘.’!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //查询数据中是否存在重复代码 |
| | | |
| | | ds = oCN.RunProcReturn("select * from Gy_EnvironmentTestItem where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_EnvironmentTestItem"); |
| | | if (oItem.HNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //新增时判断 |
| | | if (oItem.HItemID == 0) |
| | | { |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码重复!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //检查父级是否存在 |
| | | string sParent; |
| | | sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim()); |
| | | if (sParent.Trim() == "") |
| | | { |
| | | oBill.oModel.HParentID = 0; |
| | | } |
| | | else |
| | | { |
| | | if (oBill.HavParentCode(sParent.Trim(), HItemID)) |
| | | { |
| | | oBill.oModel.HParentID = oBill.oModel.HItemID; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!上级代码不存在或被禁用!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | else//编辑时判断 |
| | | { |
| | | //检查父级是否存在 |
| | | string sParent; |
| | | sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim()); |
| | | if (sParent.Trim() == "") |
| | | { |
| | | oBill.oModel.HParentID = 0; |
| | | } |
| | | else |
| | | { |
| | | if (oBill.HavParentCode(sParent.Trim(), oItem.HItemID)) |
| | | { |
| | | oBill.oModel.HParentID = oBill.oModel.HItemID; |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!上级代码不存在或被禁用!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | } |
| | | //得到短代码 |
| | | string sShortNumber; |
| | | sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim()); |
| | | if (sShortNumber.Trim() == "") |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!短代码为空!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | oItem.HShortNumber = sShortNumber;//短代码 |
| | | oItem.HEndFlag = true;//末级标志 |
| | | oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //等级 |
| | | oItem.HMakeEmp = msg2; //创建人 |
| | | |
| | | oBill.oModel = oItem; |
| | | } |
| | | |
| | | //保存 |
| | | //保存完毕后处理 |
| | | bool bResult; |
| | | if (oBill.oModel.HItemID == 0) |
| | | { |
| | | bResult = oBill.AddNew(); |
| | | } |
| | | else |
| | | { |
| | | bResult = oBill.ModifyByID(oBill.oModel.HItemID); |
| | | } |
| | | 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; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 环境检测单取信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("GetGy_EnvironmentTestItem_Edit")] |
| | | [HttpGet] |
| | | public ApiResult<DataSet> GetGy_EnvironmentTestItem_Edit(string HID) |
| | | { |
| | | var model = LuBaoSevice.GetGy_EnvironmentTestItemEdit(HID); |
| | | return model; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 环境检测单删除功能 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("DeltetGy_EnvironmentTestItem")] |
| | | [HttpGet] |
| | | public object DeltetGy_EnvironmentTestItem(string HItemID, string user) |
| | | { |
| | | DataSet ds; |
| | | try |
| | | { |
| | | //删除权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_EnvironmentTestItem_Delete", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无删除权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | if (string.IsNullOrWhiteSpace(HItemID)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "HItemID为空!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | oCN.BeginTran();//开始事务 |
| | | ds = oCN.RunProcReturn("select * from Gy_EnvironmentTestItem where HItemID=" + HItemID, "Gy_EnvironmentTestItem"); |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "没有数据,无法删除!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | } |
| | | |
| | | oCN.RunProc("delete Gy_EnvironmentTestItem where HItemID=" + HItemID); |
| | | oCN.Commit();//提交事务 |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "数据删除成功!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; ; |
| | | |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "删除失败!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | /// <summary> |
| | | /// 用关联工序获取信息 |
| | |
| | | return objjson; ; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 获取基本信息 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/BaseInfo")] |
| | | [HttpGet] |
| | | public object GetBaseInfo() |
| | | { |
| | | try |
| | | { |
| | | ds = oCN.RunProcReturn("select * from xt_BaseInfo", "xt_BaseInfo"); |
| | | if (ds is null) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | }catch(Exception e) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + e.Message; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取职务列表 |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetSc_ICMOBillListView3")] |
| | | [HttpGet] |
| | | public object GetSc_ICMOBillListView3(string ICMOBill, int OrganizationID,int HSourceID) |
| | | public object GetSc_ICMOBillListView3(string ICMOBill, int OrganizationID, int HSourceID) |
| | | { |
| | | if (ICMOBill != "") |
| | | { |
| | |
| | | [HttpGet] |
| | | public object GetSc_ProcessExchangeBillListView(string ICMOBill, int OrganizationID) |
| | | { |
| | | if (ICMOBill != "") |
| | | if (ICMOBill != "" & ICMOBill != null) |
| | | { |
| | | sWhere = " where 1=1 and 单据号 like '%" + ICMOBill + "%' "; |
| | | } |
| | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("select * from h_v_Sc_ProcessExchangeBillList where 1=1 order by 单据号 desc,hsubid ", "h_v_Sc_ProcessExchangeBillList"); |
| | | ds = oCN.RunProcReturn("select top 500 * from h_v_Sc_ProcessExchangeBillList where 1=1 order by 单据号 desc,hsubid", "h_v_Sc_ProcessExchangeBillList"); |
| | | } |
| | | else |
| | | { |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据物料+工序获取检验方案 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/GetCheckItemID")] |
| | | [HttpGet] |
| | | public object GetCheckItemID(string HName,string HProName,string HSourceID) |
| | | { |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Main where 物料名称='"+HName+ "' and 工序名称='" + HProName + "' and HSourceID='" + HSourceID + "' order by 日期 desc ", "h_v_Gy_QCCheckProjectList_Main"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Main where 物料名称='" + HName + "' and 工序名称='" + HProName + "' order by 日期 desc ", "h_v_Gy_QCCheckProjectList_Main"); |
| | | } |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + ex.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据检验方案主内码获取检验项目 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/GetCheckItemByCheckProjectID")] |
| | | [HttpGet] |
| | | public object GetCheckItemByCheckProjectID(int CheckProjectID,int HBatchQty) |
| | | public object GetCheckItemByCheckProjectID(int CheckProjectID, int HBatchQty) |
| | | { |
| | | if (CheckProjectID <= 0) |
| | | { |
| | |
| | | DataSet ds2; |
| | | DataSet ds1; |
| | | |
| | | // string sql1 = string.Format(@"select t.HMaintainItemID ,m.HNumber HMaintainItemNumber,t.HMaintainItem,t.HMaintainPart,t.HClaim,t.HManagerID,e.HNumber HManagerNumber,e.HName HManagerName,a.HRemark |
| | | // from Sc_MouldMaintainRuleBillMain a left join Sc_MouldMaintainRuleBillSub_Item t on a.HInterID=t.HInterID |
| | | // left join Gy_Maintain m on m.HItemID=t.HMaintainItemID |
| | | // left join Gy_Employee e on e.HItemID=t.HManagerID |
| | | // where a.HInterID=" + MouldMaintainRuleID); |
| | | // string sql1 = string.Format(@"select t.HMaintainItemID ,m.HNumber HMaintainItemNumber,t.HMaintainItem,t.HMaintainPart,t.HClaim,t.HManagerID,e.HNumber HManagerNumber,e.HName HManagerName,a.HRemark |
| | | // from Sc_MouldMaintainRuleBillMain a left join Sc_MouldMaintainRuleBillSub_Item t on a.HInterID=t.HInterID |
| | | // left join Gy_Maintain m on m.HItemID=t.HMaintainItemID |
| | | // left join Gy_Employee e on e.HItemID=t.HManagerID |
| | | // where a.HInterID=" + MouldMaintainRuleID); |
| | | |
| | | // string sql2 = string.Format(@"select b.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName, m.HModel HMaterSpec,b.HUnitID,u.HNumber HUnitNumber,u.HName HUnitName,b.HQty,b.HQtyMust,b.HRemark from Sc_MouldMaintainRuleBillMain a |
| | | //left join Sc_MouldMaintainRuleBillSub b on a.HInterID=b.HInterID |
| | | // left join h_v_IF_Material m on b.HMaterID=m.HItemID |
| | | //left join h_v_IF_Unit u on b.HUnitID=u.HItemID |
| | | // where a.HInterID=" + MouldMaintainRuleID); |
| | | // string sql2 = string.Format(@"select b.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName, m.HModel HMaterSpec,b.HUnitID,u.HNumber HUnitNumber,u.HName HUnitName,b.HQty,b.HQtyMust,b.HRemark from Sc_MouldMaintainRuleBillMain a |
| | | //left join Sc_MouldMaintainRuleBillSub b on a.HInterID=b.HInterID |
| | | // left join h_v_IF_Material m on b.HMaterID=m.HItemID |
| | | //left join h_v_IF_Unit u on b.HUnitID=u.HItemID |
| | | // where a.HInterID=" + MouldMaintainRuleID); |
| | | |
| | | string sql1 = string.Format(@"select * from h_v_Sc_MouldMaintainRuleBillSub_Item where hmainid=" + MouldMaintainRuleID); |
| | | string sql2 = string.Format(@"select * from h_v_Sc_MouldMaintainRuleBillSub where hmainid=" + MouldMaintainRuleID); |
| | |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | #region 条码主档分页列表 |
| | | [Route("Gy_BarCodeBillList/page")] |
| | | [HttpGet] |
| | | public json Gy_BarCodeBillListPage(string sWhere, string user, int page, int size) |
| | | { |
| | | DataSet ds; |
| | | json res = new json(); |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //判断是否有查询权限 |
| | | if (!DBUtility.ClsPub.Security_Log("Gy_BarCodeBill_Query", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无权限查询!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_IF_BarCodeBillList " + page + "," + size + ",''", "h_p_IF_BarCodeBillList"); |
| | | } |
| | | else |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_IF_BarCodeBillList " + page + "," + size + ",'" + sWhere + "'", "h_p_IF_BarCodeBillList"); |
| | | } |
| | | |
| | | //添加列名 |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | res.code = CodeConstant.SUCCEED; |
| | | res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); |
| | | res.Message = "Sucess!"; |
| | | res.list = columnNameList; |
| | | res.data = ds.Tables[0]; |
| | | return res; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | res.code = CodeConstant.FAIL; |
| | | res.count = CountConstant.FAIL; |
| | | res.Message = "Exception!" + e.ToString(); |
| | | res.data = null; |
| | | return res; |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | /// <summary> |
| | | /// 根据设备保养规程显示设备保养规程项目 |
| | | /// </summary> |
| | |
| | | List<object> list = new List<object>(); |
| | | DataSet ds2; |
| | | DataSet ds1; |
| | | // string sql1 = string.Format(@"select t.HMaintainItemID HMaintainItemID,m.HNumber HMaintainItemNumber,t.HMaintainItem HMaintainItem,t.HMaintainPart HMaintainPart,t.HClaim HClaim,t.HManagerID HManagerID,e.HNumber HManagerNumber,e.HName HManagerName,a.HRemark |
| | | // from Sb_EquipMaintainRuleBillMain a left join Sb_EquipMaintainRuleBillSub_Item t on a.HInterID=t.HInterID |
| | | // left join Gy_Maintain m on m.HItemID=t.HMaintainItemID |
| | | // left join Gy_Employee e on e.HItemID=t.HManagerID |
| | | // where a.HInterID=" + EquipProjectID); |
| | | // string sql2 = string.Format(@"select b.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName,b.HUnitID,u.HNumber HUnitNumber,u.HName HUnitName,b.HQty,b.HRemark from Sb_EquipMaintainRuleBillMain a |
| | | //left join Sb_EquipMaintainRuleBillSub b on a.HInterID=b.HInterID |
| | | // left join h_v_IF_Material m on b.HMaterID=m.HItemID |
| | | //left join h_v_IF_Unit u on b.HUnitID=u.HItemID |
| | | // where a.HInterID=" + EquipProjectID); |
| | | // string sql1 = string.Format(@"select t.HMaintainItemID HMaintainItemID,m.HNumber HMaintainItemNumber,t.HMaintainItem HMaintainItem,t.HMaintainPart HMaintainPart,t.HClaim HClaim,t.HManagerID HManagerID,e.HNumber HManagerNumber,e.HName HManagerName,a.HRemark |
| | | // from Sb_EquipMaintainRuleBillMain a left join Sb_EquipMaintainRuleBillSub_Item t on a.HInterID=t.HInterID |
| | | // left join Gy_Maintain m on m.HItemID=t.HMaintainItemID |
| | | // left join Gy_Employee e on e.HItemID=t.HManagerID |
| | | // where a.HInterID=" + EquipProjectID); |
| | | // string sql2 = string.Format(@"select b.HMaterID,m.HNumber HMaterNumber,m.HName HMaterName,b.HUnitID,u.HNumber HUnitNumber,u.HName HUnitName,b.HQty,b.HRemark from Sb_EquipMaintainRuleBillMain a |
| | | //left join Sb_EquipMaintainRuleBillSub b on a.HInterID=b.HInterID |
| | | // left join h_v_IF_Material m on b.HMaterID=m.HItemID |
| | | //left join h_v_IF_Unit u on b.HUnitID=u.HItemID |
| | | // where a.HInterID=" + EquipProjectID); |
| | | |
| | | string sql1 = string.Format(@"select * from h_v_Sb_EquipMaintainRuleBillList where HInterID=" + EquipProjectID); |
| | | string sql2 = string.Format(@"select * from h_v_Sb_EquipMaintainRuleSub where hmainid=" + EquipProjectID); |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetItemByEquipFile")] |
| | | [HttpGet] |
| | | public object GetItemByEquipFile(int EquipProjectID,string Type,string HDate) |
| | | public object GetItemByEquipFile(int EquipProjectID, string Type, string HDate) |
| | | { |
| | | if (EquipProjectID <= 0) |
| | | { |
| | |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败,查无数据" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "该设备有多个计划单或点检规程,手动选着" ; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | |
| | | switch (Type) |
| | | { |
| | | case "DJ": |
| | | HView = "h_v_QJ_GetDotCheckItemList"; |
| | | break; |
| | | HView = "h_v_Sc_MouldDotCheckPlanBillList"; |
| | | break; |
| | | case "BY": |
| | | HView = "h_v_Sc_MouldMaintainPlanBillList"; |
| | | break; |
| | | default: |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "设备模块类型错误!"; |
| | | objjson.Message = "模具模块类型错误!"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | //string sql = string.Format(@"select * from " + HView + " where HInterID = " + EquipProjectID); |
| | | string sql = string.Format(@"Exec h_p_Sb_GetCheckItem_PDA '" + MouldProjectID + "','" + Type + "','" + HDate + "'"); |
| | | string sql = string.Format(@"Exec h_p_Sb_GetCheckItemMouldFile_PDA '" + MouldProjectID + "','" + Type + "','" + HDate + "'"); |
| | | ds = oCN.RunProcReturn(sql, HView); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败,查无数据" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 1; |
| | | objjson.Message = "该模具有多个计划单,手动选着"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | |
| | | } |
| | | try |
| | | { |
| | | |
| | | string sql = string.Format(@"select * from h_v_QJ_GetDotCheckItemList where 点检计划ID = " + HInterID ); |
| | | |
| | | string sql = string.Format(@"select * from h_v_QJ_GetDotCheckItemList where 点检计划ID = " + HInterID); |
| | | ds = oCN.RunProcReturn(sql, "h_v_QJ_GetDotCheckItemList"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetEquipmentBillsList")] |
| | | [HttpGet] |
| | | public object GetEquipmentBillsList(string sWhere, string Type,string user) |
| | | { |
| | | public object GetEquipmentBillsList(string sWhere, string Type, string user) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | |
| | | break; |
| | | case "YS": |
| | | HView = "h_v_Sb_EquipRepairCheckBillList"; |
| | | break; |
| | | case "QD": |
| | | HView = "h_v_Sb_EquipRepairSignBillList"; |
| | | break; |
| | | default: |
| | | objjson.code = "0"; |
| | |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | string sql = string.Format(@"select b.HDotCheckItemID HDotCheckItemID,c.HNumber HDotCheckCode,b.HDotCheckItem,b.HDotCheckPart,b.HClaim, |
| | | b.HManagerID,e.HNumber HManagerCode,e.HName HManagerName,b.HRemark from Sb_EquipDotCheckRuleBillMain a |
| | | left join Sb_EquipDotCheckRuleBillSub b on a.HInterID=b.HInterID |
| | | left join Gy_DotCheck c on c.HItemID=b.HDotCheckItemID |
| | | left join Gy_Employee e on e.HItemID=b.HManagerID |
| | | where a.HInterID=" + HDotCheckRuleInterID); |
| | | ds = oCN.RunProcReturn(sql, "Sb_EquipDotCheckRuleBillMain"); |
| | | string sql = string.Format(@"select * from h_v_Sb_EquipDotCheckRuleBillList_PDA where HInterID=" + HDotCheckRuleInterID); |
| | | ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipDotCheckRuleBillList_PDA"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据设备保养规程显示设备保养程项目 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/GetMaintainItemByMaintainRuleID")] |
| | | [HttpGet] |
| | | public object GetMaintainItemByMaintainRuleID(int HEquipMaintainRuleInterID) |
| | | { |
| | | if (HEquipMaintainRuleInterID <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "设备保养规程未选择"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | string sql = string.Format(@"select * from h_v_Sb_EquipMaintainRuleBillList_PDA where HInterID=" + HEquipMaintainRuleInterID); |
| | | ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipMaintainRuleBillList_PDA"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + ex.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据器具点检规程显示器具点检程项目 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/GetDotCheckRuleItemByDotCheckRuleID/Mould")] |
| | | [HttpGet] |
| | | public object GetDotCheckRuleItemByDotCheckRuleIDForMould(int HDotCheckRuleInterID) |
| | | { |
| | | if (HDotCheckRuleInterID <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "器具点检规程未选择"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | string sql = string.Format(@"select * from h_v_Sc_MouldDotCheckRuleBillList_PDA where HInterID=" + HDotCheckRuleInterID); |
| | | ds = oCN.RunProcReturn(sql, "h_v_Sc_MouldDotCheckRuleBillList_PDA"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + ex.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据器具保养规程显示器具保养程项目 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/GetMaintainItemByMaintainRuleID/Mould")] |
| | | [HttpGet] |
| | | public object GetMaintainItemByMaintainRuleIDForMould(int HMouldMaintainRuleInterID) |
| | | { |
| | | if (HMouldMaintainRuleInterID <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "器具保养规程未选择"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | string sql = string.Format(@"select * from h_v_Sb_MouldMaintainRuleBillList_PDA where HInterID=" + HMouldMaintainRuleInterID); |
| | | ds = oCN.RunProcReturn(sql, "h_v_Sb_MouldMaintainRuleBillList_PDA"); |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + ex.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取维修项目列表 |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetHSourceBillType")] |
| | | [HttpGet] |
| | | public object GetHSourceBillType(string HName,int Num) |
| | | public object GetHSourceBillType(string HName, int Num) |
| | | { |
| | | try |
| | | { |
| | | ClsCN oCn = new ClsCN(); |
| | | DataSet oDs = new DataSet(); |
| | | //有的单子源单分为红蓝单 0代表蓝单 1代表红单 |
| | | if (Num==0) |
| | | if (Num == 0) |
| | | { //源单为蓝单 |
| | | oDs = oCn.RunProcReturn("select * from Xt_BillSourceSet where HName='" + HName + "'and HRedBlueFlag ='"+ Num+"' ", "Xt_BillSourceSet"); |
| | | oDs = oCn.RunProcReturn("select * from Xt_BillSourceSet where HName='" + HName + "'and HRedBlueFlag ='" + Num + "' ", "Xt_BillSourceSet"); |
| | | } |
| | | else if (Num==1) |
| | | else if (Num == 1) |
| | | { //源单为红单 |
| | | oDs = oCn.RunProcReturn("select * from Xt_BillSourceSet where HName='" + HName + "' and HRedBlueFlag ='" + Num + "' ", "Xt_BillSourceSet"); |
| | | } |
| | | else if(Num==2) |
| | | else if (Num == 2) |
| | | { //不分红蓝单 |
| | | oDs = oCn.RunProcReturn("select * from Xt_BillSourceSet where HName='" + HName + "'", "Xt_BillSourceSet"); |
| | | } |
| | | |
| | | |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | |
| | | public int HLevel { get; set; } |
| | | public string Hurl { get; set; } |
| | | public string HPicNum { get; set; } |
| | | public string HShowMode { get; set; } |
| | | public List<MenuLoad> childMenus { get; set; } |
| | | } |
| | | |
| | |
| | | { |
| | | List<MenuLoad> mu = new List<MenuLoad>(); //以父子级结构存放菜单清单信息 |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); //数据库操作工具 |
| | | string sql = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum from Gy_MenuDefineSet where HMakeName = '" + HMakeName + "' and HType = '" + HType + "' order by HPosition"; |
| | | string sql = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum,HShowMode from Gy_MenuDefineSet where HMakeName = '" + HMakeName + "' and HType = '" + HType + "' order by HPosition"; |
| | | ds = oCn.RunProcReturn(sql, "Gy_MenuDefineSet"); //查询当前用户的自定义菜单数据 |
| | | if (ds.Tables[0]==null || ds.Tables[0].Rows.Count == 0) //判断当前用户是否有设置过自定义信息,若记录数为0,则没有设置过,加载所有的菜单信息 |
| | | if (ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0) //判断当前用户是否有设置过自定义信息,若记录数为0,则没有设置过,加载所有的菜单信息 |
| | | { |
| | | sql = "Select * from Gy_Menu_1 where HType = '" + HType + "' Order by HPosition,len(HitemID),HitemID "; |
| | | ds = oCn.RunProcReturn(sql, "Gy_Menu"); |
| | | string sql1 = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum,HShowMode from Gy_MenuDefineSet where HMakeName=" + |
| | | "(select top 1 c.GroupName from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId " + |
| | | "left join System_UserGroup c on b.GroupId = c.GroupID where a.Czymc ='"+HMakeName+"' order by len(c.GroupName ))"; |
| | | ds = oCn.RunProcReturn(sql1, "Gy_MenuDefineSet"); //查询用户绑定的角色 是否设置菜单信息 取角色名称最短的一个 |
| | | if ((ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0)) |
| | | { |
| | | sql = "Select * from Gy_Menu_1 where HType = '" + HType + "' Order by HPosition,len(HitemID),HitemID "; |
| | | ds = oCn.RunProcReturn(sql, "Gy_Menu_1"); |
| | | } |
| | | } |
| | | |
| | | for (int i = 0; i < ds.Tables[0].Rows.Count; i++) //将菜单的根节点保存到列表menu中 |
| | |
| | | tbj.HPartentID = ds.Tables[0].Rows[i]["HPartentID"].ToString(); |
| | | tbj.HLevel = int.Parse(ds.Tables[0].Rows[i]["HLevel"].ToString()); |
| | | tbj.Hurl = ds.Tables[0].Rows[i]["Hurl"].ToString(); |
| | | tbj.HShowMode = ds.Tables[0].Rows[i]["HShowMode"].ToString(); |
| | | if (ds.Tables[0].Rows[i]["HPicNum"] != null) |
| | | { |
| | | tbj.HPicNum = ds.Tables[0].Rows[i]["HPicNum"].ToString(); |
| | |
| | | tbjson.HName = dt.Rows[i]["HName"].ToString(); |
| | | tbjson.HLevel = tree[m].HLevel; |
| | | tbjson.Hurl = dt.Rows[i]["Hurl"].ToString(); |
| | | tbjson.HShowMode = dt.Rows[i]["HShowMode"].ToString(); |
| | | if (dt.Rows[i]["HPicNum"] != null) |
| | | { |
| | | tbjson.HPicNum = dt.Rows[i]["HPicNum"].ToString(); |
| | |
| | | List<MenuInit> menuInitList = new List<MenuInit>(); //用以获取Gy_Menu_1中的所有菜单信息,以及对应节点是否被选中需要加载显示 |
| | | |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | ds = oCn.RunProcReturn("Select * from Gy_Menu_1 where HType = '" +HType + "' Order by HItemID ", "Gy_Menu"); //获取Gy_Menu_1中的所有菜单信息,用于为menuInitList列表充实数据 |
| | | ds = oCn.RunProcReturn("Select * from Gy_Menu_1 where HType = '" + HType + "' Order by HItemID ", "Gy_Menu"); //获取Gy_Menu_1中的所有菜单信息,用于为menuInitList列表充实数据 |
| | | |
| | | DataSet ds1 = new DataSet(); |
| | | for (int i = 0; i < ds.Tables[0].Rows.Count; i++) //将Gy_Menu_1中的菜单信息及选中情况保存到menuInitList列表中, |
| | |
| | | |
| | | //设置数据库操作的回滚点,若在提交前报错,则回滚到该点,期间操作取消 |
| | | oCN.BeginTran(); |
| | | |
| | | |
| | | //删除当前用户的自定义数据 |
| | | string sql = "delete from Gy_MenuDefineSet where HMakeName = '" + HMakeName + "' and HType = '" + HTypes + "'"; |
| | | oCN.RunProc(sql); |
| | | |
| | | //插入当前用户最新的自定义数据 |
| | | for(int i=0;i< saveDataList.Count; i++) |
| | | for (int i = 0; i < saveDataList.Count; i++) |
| | | { |
| | | sql = "select * from Gy_Menu_1 where HItemID = '" + saveDataList[i].HItemID + "'"; |
| | | ds = oCn.RunProcReturn(sql,"Gy_Menu_1"); |
| | | ds = oCn.RunProcReturn(sql, "Gy_Menu_1"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | string HPartentID = ds.Tables[0].Rows[0]["HPartentID"].ToString(); |
| | |
| | | string HType = ds.Tables[0].Rows[0]["HType"].ToString(); |
| | | string HPicNum = ds.Tables[0].Rows[0]["HPicNum"].ToString(); |
| | | |
| | | if(HPartentID == "0" || HPartentID == ds.Tables[0].Rows[0]["HItemID"].ToString()) |
| | | if (HPartentID == "0" || HPartentID == ds.Tables[0].Rows[0]["HItemID"].ToString()) |
| | | { |
| | | string HPosition = ds.Tables[0].Rows[0]["HPosition"].ToString(); |
| | | sql = "insert into Gy_MenuDefineSet(HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HMakeName,HPicNum,HPosition) values('" + saveDataList[i].HItemID + "','" + HPartentID + "','" + HNumber + "','" + saveDataList[i].HName + "'," + HLevel + ",'" + Hurl + "','" + HType + "','" + HMakeName + "','" + HPicNum + "','" + HPosition + "')"; |
| | |
| | | sql = "insert into Gy_MenuDefineSet(HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HMakeName,HPicNum,HPosition) values('" + saveDataList[i].HItemID + "','" + HPartentID + "','" + HNumber + "','" + saveDataList[i].HName + "'," + HLevel + ",'" + Hurl + "','" + HType + "','" + HMakeName + "','" + HPicNum + "','z')"; |
| | | oCN.RunProc(sql); |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | //提交数据库操作 |
| | | oCN.Commit(); |
| | | |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "保存成功!"; |
| | |
| | | SQLHelper.ClsCN oCn = new SQLHelper.ClsCN(); |
| | | string sql = "select a.HSubFuncID, a.HCaption,a.HPicNum,b.Hurl from Xt_UserFastMenu as a join Gy_Menu_1 as b on a.HSubFuncID = b.HItemID where a.HUserID = '" + HMakeName + "' and b.HType = '" + HType + "' Order by a.HItemID"; |
| | | ds = oCn.RunProcReturn(sql, "Xt_UserFastMenu"); //获取Xt_UserFastMenu中该用户设置的自定义菜单信息,用于在前端加载 |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count == 0) |
| | | { |
| | | sql = "select a.HSubFuncID, a.HCaption,a.HPicNum,b.Hurl from Xt_UserFastMenu as a join Gy_Menu_1 as b on a.HSubFuncID = b.HItemID where a.HUserID = 'admin' and b.HType = '" + HType + "' Order by a.HItemID"; |
| | | ds = oCn.RunProcReturn(sql, "Xt_UserFastMenu"); //获取Xt_UserFastMenu中该用户设置的自定义菜单信息,用于在前端加载 |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetOtherInBillMain_TempList_New")] |
| | | [HttpGet] |
| | | public object GetOtherInBillMain_TempList_New (string HBillType, string sHMaker, Int64 HOrgID) |
| | | public object GetOtherInBillMain_TempList_New(string HBillType, string sHMaker, Int64 HOrgID) |
| | | { |
| | | WebS.WebService1 oWebs = new WebS.WebService1(); |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | |
| | | |
| | | DataSet ds = oCN.RunProcReturn("exec h_p_KF_GetPonderationBillMain_TempList_New1 '" + HBillType + "','" + sHMaker + "'," + HOrgID.ToString(), "h_p_KF_GetPonderationBillMain_TempList_New1"); |
| | | |
| | | |
| | | //添加列名 |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | |
| | | /// <returns></returns> |
| | | [Route("Web/GetProcNoList")] |
| | | [HttpGet] |
| | | public object GetProcNoList(int HInterID,string sWhere,string UserID) |
| | | public object GetProcNoList(int HInterID, string sWhere, string UserID) |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | try |
| | | { |
| | | ds = oCN.RunProcReturn("exec h_p_Sc_ProcNoList '" + HInterID + "','" + sWhere + "','" + UserID + "'" , "h_p_Sc_ProcNoList"); |
| | | ds = oCN.RunProcReturn("exec h_p_Sc_ProcNoList '" + HInterID + "','" + sWhere + "','" + UserID + "'", "h_p_Sc_ProcNoList"); |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 金帅WMS接口 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | [Route("Web/WMSBarcodeQuery")] |
| | | [HttpGet] |
| | | public object WMSBarcodeQuery(DateTime dateTime, string UserName, string PassWord) |
| | | { |
| | | try |
| | | { |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | //权限判定 |
| | | DAL.ClsUser oUser = new DAL.ClsUser(); |
| | | DataSet DS; |
| | | DS = oCN.RunProcReturn("select * from Gy_Czygl where Czymc='" + UserName.Trim() + "' and Czmm='" + DBUtility.ClsPub.StrToPsd(PassWord.Trim()) + "' ", "Gy_Czygl"); |
| | | if (UserName == "" || UserName != "售后条码查询") |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "用户不对!"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | if (DS == null || DS.Tables[0].Rows.Count == 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "密码错误!"; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | ds = oCN.RunProcReturn("exec h_p_WMSBarcodeQuery '" + dateTime + "'", "h_p_WMSBarcodeQuery"); |
| | | |
| | | if (ds == null || ds.Tables[0].Rows.Count <= 0) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + DBUtility.ClsPub.sErrInfo; |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | else |
| | | { |
| | | objjson.code = "1"; |
| | | objjson.count = 1; |
| | | objjson.Message = "获取成功!"; |
| | | objjson.data = ds.Tables[0]; |
| | | return objjson; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | objjson.code = "0"; |
| | | objjson.count = 0; |
| | | objjson.Message = "获取失败" + ex.ToString(); |
| | | objjson.data = null; |
| | | return objjson; |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |