| | |
| | | } |
| | | |
| | | |
| | | public class TreeModel |
| | | { |
| | | public string Id { get; set; } |
| | | public string Number { get; set; } |
| | | public string Title { get; set; } |
| | | public List<TreeModel> children = new List<TreeModel>(); |
| | | } |
| | | /// <summary> |
| | | /// 返回仓库列表 |
| | | ///参数:string sql。 |
| | | ///返回值:object。 |
| | | /// </summary> |
| | | [Route("Gy_Warehouse/listTree")] |
| | | [HttpGet] |
| | | public object listTree(string sWhere, string user, string Organization) |
| | | { |
| | | try |
| | | { |
| | | List<object> columnNameList = new List<object>(); |
| | | //编辑权限 |
| | | if (!DBUtility.ClsPub.Security_Log_second("Gy_Warehouse", 1, false, user)) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "无查看权限!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | string sql1 = string.Format(@"select * from h_v_IF_WareHouseList_ExtendWHType where 组织名称='" + Organization + "'"); |
| | | if (sWhere == null || sWhere.Equals("")) |
| | | { |
| | | ds = oCN.RunProcReturn(sql1 + sWhere + " order by 仓库代码 ", "h_v_IF_WareHouseList_ExtendWHType"); |
| | | } |
| | | else |
| | | { |
| | | string sql = sql1 + sWhere + " order by 仓库代码 "; |
| | | ds = oCN.RunProcReturn(sql, "h_v_IF_WareHouseList_ExtendWHType"); |
| | | } |
| | | |
| | | List<TreeModel> treeModels = new List<TreeModel>(); |
| | | TreeModel first = new TreeModel(); |
| | | first.Id = "0"; |
| | | first.Title = "模具仓库"; |
| | | first.Number = "0"; |
| | | treeModels.Add(first); |
| | | |
| | | foreach (DataRow row in ds.Tables[0].Rows) |
| | | { |
| | | var strLen = row["hitemid"].ToString().Split('.'); |
| | | if (strLen.Length == 1) |
| | | { |
| | | TreeModel tree = new TreeModel(); |
| | | tree.Id = row["hitemid"].ToString(); |
| | | tree.Title = row["hname"].ToString(); |
| | | tree.Number = row["HNumber"].ToString(); |
| | | treeModels[0].children.Add(tree); |
| | | } |
| | | } |
| | | digui(ds.Tables[0], treeModels[0].children, 2); |
| | | |
| | | //添加列名 |
| | | foreach (DataColumn col in ds.Tables[0].Columns) |
| | | { |
| | | Type dataType = col.DataType; |
| | | string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; |
| | | columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "Sucess!"; |
| | | objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels); |
| | | objJsonResult.list = columnNameList; |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "Exception!" + e.ToString(); |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据基础资料ID 查找记录 |
| | |
| | | //long HCREATEORGID = list[0].HCREATEORGID; |
| | | string HUpDater = list[0].HUpDater; |
| | | long HSPFlag = list[0].HSPFlag; |
| | | string HWarehouseType = list[0].HWarehouseType; |
| | | //得到短代码 |
| | | string HShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber); |
| | | if (HShortNumber.Trim() == "") |
| | |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | //} |
| | | //查询数据中是否存在重复代码 |
| | | ds = oCN.RunProcReturn("Select HItemID from Gy_Warehouse Where HItemID<>" + HItemID + " and HNumber='" + HNumber + "' and HUSEORGID=" + HUSEORGID, "Gy_Warehouse"); |
| | | |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "保存失败!代码重复!"; |
| | | objJsonResult.data = 1; |
| | | return objJsonResult; |
| | | } |
| | | //保存 |
| | | //保存完毕后处理 |
| | | if (HItemID == 0) |
| | |
| | | oCN.BeginTran(); |
| | | oCN.RunProc("Insert into Gy_Warehouse " + |
| | | " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HEmpID,HAddress,HPhone,HUSEORGID,HSPFlag,HCREATEORGID,HMaker,HMakeTime,HStockCtrlFlag) " + |
| | | ",HLevel,HEndFlag,HStopflag,HRemark,HEmpID,HAddress,HPhone,HUSEORGID,HSPFlag,HCREATEORGID,HMaker,HMakeTime,HStockCtrlFlag" + |
| | | ",HWarehouseType) " + |
| | | " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID.ToString() + |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "'," + HEmpID.ToString() + ",'" + HAddress + "','" + HPhone + "','"+ HUSEORGID + "',"+ HSPFlag + ","+ HUSEORGID + ",'"+msg3+"',getdate(),"+ Convert.ToString(HStockCtrlFlag ? 1 : 0)+")", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | "," + HLevel.ToString() + "," + HEndFlag + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "'," + HEmpID.ToString() + ",'" + HAddress + "','" + HPhone + "','"+ HUSEORGID + "',"+ HSPFlag + ","+ HUSEORGID + ",'"+msg3+"',getdate(),"+ Convert.ToString(HStockCtrlFlag ? 1 : 0)+"" + |
| | | ",'"+ HWarehouseType + "')", ref DBUtility.ClsPub.sExeReturnInfo); |
| | | //修改上级为非末级代码 |
| | | oCN.RunProc("Update Gy_Warehouse set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); |
| | | //启用仓位 |
| | |
| | | else { |
| | | //若MAINDI重复则重新获取 |
| | | oCN.BeginTran(); |
| | | //已审核不允许修改 |
| | | DataSet dss; |
| | | dss = oCN.RunProcReturn("select * from Gy_Warehouse where HItemID=" + HItemID, "Gy_Warehouse"); |
| | | //判断是否可编辑 |
| | | if (dss.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") |
| | | { |
| | | oCN.RollBack(); |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "此单据状态已经审核,不允许修改!"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | //主表 |
| | | oCN.RunProc("Update Gy_Warehouse set " + |
| | | " HNumber='" + HNumber + "'" + |
| | |
| | | ",HAddress='" + HAddress + "'" + |
| | | ",HPhone='" + HPhone + "'" + |
| | | ",HUSEORGID='" + HUSEORGID + "'" + |
| | | ",HWarehouseType='" + HWarehouseType + "'" + |
| | | ",HCREATEORGID='" + HUSEORGID + "'" + |
| | | ",HSPFlag='" + HSPFlag + "'" + |
| | | //",HSPGroupID='" + HSPGroupID + "'" + |
| | |
| | | #region [同步基础资料] |
| | | [Route("Gy_Warehouse/Gy_WarehouseViewApi")] |
| | | [HttpGet] |
| | | public json Gy_WarehouseViewApi(string Number, string Type) |
| | | public json Gy_WarehouseViewApi(string Number, string Type, string HUseOrgID) |
| | | { |
| | | string sql = string.Empty; |
| | | string sReturn = ""; |
| | |
| | | { |
| | | #region [公有云模式,调用WEBAPI的方式进行更新] |
| | | var json = new |
| | | //{ |
| | | // CreateOrgId = 0, |
| | | // Number = Number, |
| | | // Id = "" |
| | | //}; |
| | | { |
| | | CreateOrgId = 0, |
| | | Number = Number, |
| | | Id = "" |
| | | FormId = "BD_STOCK", |
| | | FieldKeys = "FMASTERID,FNUMBER,FNAME,FFORBIDSTATUS,FISOPENLOCATION,FAllowMinusQty,FCREATEDATE,FCREATEORGID,FUSEORGID,FSTOCKPROPERTY,FDefStockStatusId", |
| | | FilterString = $@"FNUMBER='{Number}' AND FUSEORGID={HUseOrgID}", |
| | | OrderString = "", |
| | | TopRowCount = 0, |
| | | StartRow = 0, |
| | | Limit = 0 |
| | | }; |
| | | #region [金蝶部分] |
| | | //登录金蝶 |
| | | var loginRet = InvokeHelper.Login(); |
| | | #region [金蝶部分] |
| | | //登录金蝶 |
| | | var loginRet = InvokeHelper.Login(); |
| | | var isSuccess = JObject.Parse(loginRet)["LoginResultType"].Value<int>(); |
| | | //判断是否登录成功 |
| | | if (isSuccess < 0) |
| | |
| | | return objJsonResult; |
| | | } |
| | | //查看 获取数据 |
| | | var _result = InvokeHelper.View("BD_STOCK", JsonConvert.SerializeObject(json)); |
| | | var _saveObj = JObject.Parse(_result); |
| | | var _result = InvokeHelper.Query("BD_STOCK", JsonConvert.SerializeObject(json)); |
| | | var _saveObj = JArray.Parse(_result); |
| | | //判断数据是否获取成功 |
| | | if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") |
| | | // if (_saveObj["Result"]["ResponseStatus"]["IsSuccess"].ToString().ToUpper() != "TRUE") |
| | | // { |
| | | // objJsonResult.code = "0"; |
| | | // objJsonResult.count = 0; |
| | | // objJsonResult.Message = "金蝶仓库仓位同步失败jsonRoot:" + _result; |
| | | // objJsonResult.data = null; |
| | | // return objJsonResult; |
| | | // } |
| | | if (_saveObj.Count == 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "金蝶仓库仓位同步失败jsonRoot:" + _result; |
| | | objJsonResult.Message = "金蝶客户同步失败,使用组织对应的仓库代码无对应的仓库"; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | |
| | | |
| | | #region [表数据赋值] |
| | | var jsonData = new |
| | | //{ |
| | | // HItemID = _saveObj["Result"]["Result"]["Id"], |
| | | // HERPItemID = _saveObj["Result"]["Result"]["Id"], |
| | | // HNumber = _saveObj["Result"]["Result"]["Number"], |
| | | // HName = _saveObj["Result"]["Result"]["Name"][0]["Value"], |
| | | // HShortNumber = _saveObj["Result"]["Result"]["Number"], |
| | | // HParentID = 0, |
| | | // HLevel = 1, |
| | | // HEndFlag = 1, |
| | | // HStopflag = _saveObj["Result"]["Result"]["ForbidStatus"].ToString() == "A" ? 0 : 1, |
| | | // HRemark = "CLD-ERP导入", |
| | | // HSPFlag = _saveObj["Result"]["Result"]["IsOpenLocation"].ToString() == "false" ? 0 : 1, |
| | | // HSPGroupID = 0, |
| | | // HUnderStock = _saveObj["Result"]["Result"]["AllowMinusQty"].ToString() == "false" ? 0 : 1, |
| | | // HUseFlag = "已使用", |
| | | // HMakeTime = _saveObj["Result"]["Result"]["CreateDate"], |
| | | // HCREATEORGID = _saveObj["Result"]["Result"]["CreateOrgId_Id"], |
| | | // HUSEORGID = _saveObj["Result"]["Result"]["UseOrgId_Id"], |
| | | // HSTOCKPROPERTY = _saveObj["Result"]["Result"]["StockProperty"], |
| | | // HDEFSTOCKSTATUSID = _saveObj["Result"]["Result"]["DefStockStatusId_Id"], |
| | | //}; |
| | | { |
| | | HItemID = _saveObj["Result"]["Result"]["Id"], |
| | | HERPItemID = _saveObj["Result"]["Result"]["Id"], |
| | | HNumber = _saveObj["Result"]["Result"]["Number"], |
| | | HName = _saveObj["Result"]["Result"]["Name"][0]["Value"], |
| | | HShortNumber = _saveObj["Result"]["Result"]["Number"], |
| | | HParentID = 0, |
| | | HLevel = 1, |
| | | HEndFlag = 1, |
| | | HStopflag = _saveObj["Result"]["Result"]["ForbidStatus"].ToString() == "A" ? 0 : 1, |
| | | HRemark = "CLD-ERP导入", |
| | | HSPFlag = _saveObj["Result"]["Result"]["IsOpenLocation"].ToString() == "false" ? 0 : 1, |
| | | HSPGroupID = 0, |
| | | HUnderStock = _saveObj["Result"]["Result"]["AllowMinusQty"].ToString() == "false" ? 0 : 1, |
| | | HUseFlag = "已使用", |
| | | HMakeTime = _saveObj["Result"]["Result"]["CreateDate"], |
| | | HCREATEORGID = _saveObj["Result"]["Result"]["CreateOrgId_Id"], |
| | | HUSEORGID = _saveObj["Result"]["Result"]["UseOrgId_Id"], |
| | | HSTOCKPROPERTY = _saveObj["Result"]["Result"]["StockProperty"], |
| | | HDEFSTOCKSTATUSID = _saveObj["Result"]["Result"]["DefStockStatusId_Id"], |
| | | HItemID = _saveObj[0][0], |
| | | HERPItemID = _saveObj[0][0], |
| | | HNumber = _saveObj[0][1], |
| | | HName = _saveObj[0][2], |
| | | HShortNumber = _saveObj[0][1], |
| | | HParentID = 0, |
| | | HLevel = 1, |
| | | HEndFlag = 1, |
| | | HStopflag = _saveObj[0][3].ToString() == "A" ? 0 : 1, |
| | | HRemark = "CLD-ERP导入", |
| | | HSPFlag = _saveObj[0][4].ToString() == "false" ? 0 : 1, |
| | | HSPGroupID = 0, |
| | | HUnderStock = _saveObj[0][5].ToString() == "false" ? 0 : 1, |
| | | HUseFlag = "已使用", |
| | | HMakeTime = _saveObj[0][6], |
| | | HCREATEORGID = _saveObj[0][7], |
| | | HUSEORGID = _saveObj[0][8], |
| | | HSTOCKPROPERTY = _saveObj[0][9], |
| | | HDEFSTOCKSTATUSID = _saveObj[0][10], |
| | | }; |
| | | #endregion |
| | | // 删除主表对应数据 |
| | |
| | | #endregion |
| | | |
| | | #region 检验依据列表 文件上传 |
| | | [Route("Gy_Warehouse/Gy_Process_Excel")] |
| | | [HttpPost] |
| | | public json Gy_InspectBasis_Excel() |
| | | { |
| | | json res = new json(); |
| | | try |
| | | { |
| | | //获取文件名称 |
| | | var file = HttpContext.Current.Request.Files[0]; |
| | | //获取文件物理路径 |
| | | string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); |
| | | //保存文件 |
| | | file.SaveAs(ExcelPath); |
| | | //[Route("Gy_Warehouse/Gy_Process_Excel")] |
| | | //[HttpPost] |
| | | //public json Gy_InspectBasis_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"); |
| | | // NpoiHelper np = new NpoiHelper(); |
| | | // DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); |
| | | |
| | | //删除文件 |
| | | File.Delete(ExcelPath); |
| | | // //删除文件 |
| | | // File.Delete(ExcelPath); |
| | | |
| | | //创建临时表 |
| | | DataTable provisional = new DataTable("dt2"); |
| | | // //创建临时表 |
| | | // 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 = 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); |
| | | } |
| | | // //添加数据 |
| | | // 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; |
| | | } |
| | | // //判断列 |
| | | // 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 phone = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["联系电话"].ToString()); |
| | | string HEmpNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["职员代码"].ToString()); |
| | | string HEmpName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["职员名称"].ToString()); |
| | | string HHelpCode = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["助记码"]); |
| | | string HRemark = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["备注"].ToString()); |
| | | if(JudgeEmp(HEmpNumber, HEmpName)) |
| | | { |
| | | res.code = CodeConstant.FAIL; |
| | | res.count = CountConstant.FAIL; |
| | | res.Message = "当前职员不存在"; |
| | | res.data = null; |
| | | return res; |
| | | } |
| | | //获取真实行数 |
| | | int line = i + 1; |
| | | } |
| | | // 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 phone = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["联系电话"].ToString()); |
| | | // string HEmpNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["职员代码"].ToString()); |
| | | // string HEmpName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["职员名称"].ToString()); |
| | | // string HHelpCode = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["助记码"]); |
| | | // string HRemark = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["备注"].ToString()); |
| | | // if(JudgeEmp(HEmpNumber, HEmpName)) |
| | | // { |
| | | // res.code = CodeConstant.FAIL; |
| | | // res.count = CountConstant.FAIL; |
| | | // res.Message = "当前职员不存在"; |
| | | // res.data = null; |
| | | // return res; |
| | | // } |
| | | // //获取真实行数 |
| | | // 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; |
| | | } |
| | | } |
| | | // 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="HEmpNumber"></param> |
| | | /// <param name="HEmpName"></param> |
| | | /// <returns></returns> |
| | | private bool JudgeEmp(string HEmpNumber, string HEmpName) |
| | | { |
| | | if (!String.IsNullOrEmpty(HEmpNumber) && !String.IsNullOrEmpty(HEmpName)) |
| | | { |
| | | DataSet emp = oCN.RunProcReturn("select * from Gy_Employee where HNumber = '" + HEmpNumber + "' and HName = '" + HEmpName + "'", "Gy_Employee"); |
| | | return emp.Tables[0].Rows.Count <= EmptyConstant.EMPTY ? true : false; |
| | | } |
| | | return false; |
| | | } |
| | | ///// <summary> |
| | | ///// 判断当前职员是否存在 |
| | | ///// </summary> |
| | | ///// <param name="HEmpNumber"></param> |
| | | ///// <param name="HEmpName"></param> |
| | | ///// <returns></returns> |
| | | //private bool JudgeEmp(string HEmpNumber, string HEmpName) |
| | | //{ |
| | | // if (!String.IsNullOrEmpty(HEmpNumber) && !String.IsNullOrEmpty(HEmpName)) |
| | | // { |
| | | // DataSet emp = oCN.RunProcReturn("select * from Gy_Employee where HNumber = '" + HEmpNumber + "' and HName = '" + HEmpName + "'", "Gy_Employee"); |
| | | // return emp.Tables[0].Rows.Count <= EmptyConstant.EMPTY ? true : false; |
| | | // } |
| | | // return false; |
| | | //} |
| | | |
| | | /// <summary> |
| | | /// 判断列 |
| | |
| | | } |
| | | #endregion |
| | | |
| | | #region 递归生成树状结构 |
| | | /// <summary> |
| | | /// 递归函数 |
| | | /// </summary> |
| | | public void digui(DataTable dt, List<TreeModel> tree, int num) |
| | | { |
| | | for (int m = 0; m < tree.Count; m++) |
| | | { |
| | | tree[m].children = new List<TreeModel>(); |
| | | for (int i = 0; i < dt.Rows.Count; i++)//第一次循环,得到所有根节点的子集 |
| | | { |
| | | var strLen = dt.Rows[i]["hnumber"].ToString().Split('.'); |
| | | if (strLen.Length == num && dt.Rows[i]["hnumber"].ToString().Contains(tree[m].Id + ".")) |
| | | { |
| | | TreeModel tbjson = new TreeModel(); |
| | | tbjson.Id = dt.Rows[i]["hitemid"].ToString(); |
| | | tbjson.Title = dt.Rows[i]["hname"].ToString(); |
| | | tbjson.Number = dt.Rows[i]["HNumber"].ToString(); |
| | | tree[m].children.Add(tbjson); |
| | | } |
| | | } |
| | | var strLens = tree[m].Id.Split('.'); |
| | | for (int i = 0; i < tree[m].children.Count; i++) |
| | | { |
| | | digui(dt, tree[m].children, strLens.Length + 2);//再次用子集去循环,拿出子集的子集 |
| | | } |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | } |
| | | } |