|  |  | 
 |  |  |         /// </summary> | 
 |  |  |         [Route("Xs_CusBalanceReport/list")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object getXs_CusBalanceReport(string sWhere, string user) | 
 |  |  |         public object getXs_CusBalanceReport(string sWhere, string user, string userid) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  | 
 |  |  |                     return objJsonResult; | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //获取客户 | 
 |  |  |  | 
 |  |  |                 //查询 | 
 |  |  |                 if (sWhere == null || sWhere.Equals("")) | 
 |  |  |                 { | 
 |  |  |                     string sql = "select a.HItemID HCusID,a.HNumber HCusNumber,a.HName HCusName,b.HItemID HCurID,b.HName HCurName " + | 
 |  |  |                         " from Gy_Customer as a " + | 
 |  |  |                         " left join Gy_Currency as b on a.HCurID = b.HItemID " + | 
 |  |  |                         " order by a.HNumber "; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "Gy_Customer"); | 
 |  |  |                     string sql = "exec h_p_Xs_CusBalanceReport_Query '','" + userid + "'"; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "h_p_Xs_CusBalanceReport_Query"); | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     string sql1 = "select a.HItemID HCusID,a.HNumber HCusNumber,a.HName HCusName,b.HItemID HCurID,b.HName HCurName " + | 
 |  |  |                         " from Gy_Customer as a " + | 
 |  |  |                         " inner join Gy_Currency as b on a.HCurID = b.HItemID " + | 
 |  |  |                         " where 1=1  "; | 
 |  |  |                     string sql = sql1 + sWhere + " order by a.HNumber "; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "Gy_Customer"); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //创建临时表 | 
 |  |  |                 DataTable tb2 = new DataTable("dt2"); | 
 |  |  |                 //模板缺少列 但需要从数据库中查询出来显示在页面的字段 | 
 |  |  |                 tb2.Columns.Add("客户内码", typeof(string)); | 
 |  |  |                 tb2.Columns.Add("客户代码", typeof(string)); | 
 |  |  |                 tb2.Columns.Add("客户名称", typeof(string)); | 
 |  |  |                 tb2.Columns.Add("币别内码", typeof(string)); | 
 |  |  |                 tb2.Columns.Add("币别名称", typeof(string)); | 
 |  |  |                 tb2.Columns.Add("客户余额", typeof(string)); | 
 |  |  |                 tb2.Columns.Add("占用额度", typeof(string)); | 
 |  |  |                 tb2.Columns.Add("可用额度", typeof(string)); | 
 |  |  |  | 
 |  |  |                 for(int i = 0; i < ds.Tables[0].Rows.Count; i++) | 
 |  |  |                 { | 
 |  |  |                     string HCusID = ds.Tables[0].Rows[i]["HCusID"].ToString(); | 
 |  |  |                     string HCusNumber = ds.Tables[0].Rows[i]["HCusNumber"].ToString(); | 
 |  |  |                     string HCusName = ds.Tables[0].Rows[i]["HCusName"].ToString(); | 
 |  |  |                     string HCurID = ds.Tables[0].Rows[i]["HCurID"].ToString(); | 
 |  |  |                     string HCurName = ds.Tables[0].Rows[i]["HCurName"].ToString(); | 
 |  |  |  | 
 |  |  |                     //获取对应客户的客户余额、信用额度、可用余额 | 
 |  |  |                     string sql = "exec Xs_CusBalanceReport_Query " + HCusID; | 
 |  |  |                     DataSet ds2 = oCN.RunProcReturn(sql, "Xs_CusBalanceReport_Query"); | 
 |  |  |                     if (ds2 == null||ds2.Tables.Count==0) | 
 |  |  |                     { | 
 |  |  |                         objJsonResult.code = "0"; | 
 |  |  |                         objJsonResult.count = 0; | 
 |  |  |                         objJsonResult.Message = "Exception!未获取到对应客户[" + HCusNumber + "][" + HCusName + "]的余额信息!!"; | 
 |  |  |                         objJsonResult.data = null; | 
 |  |  |                         return objJsonResult; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     if (Double.Parse(ds2.Tables[0].Rows[0]["HCusBalance"].ToString()) <= 0) | 
 |  |  |                     { | 
 |  |  |                         continue; | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |                     //向临时表插入数据 | 
 |  |  |                     DataRow row = tb2.NewRow(); | 
 |  |  |                     row[0] = HCusID; | 
 |  |  |                     row[1] = HCusNumber; | 
 |  |  |                     row[2] = HCusName; | 
 |  |  |                     row[3] = HCurID; | 
 |  |  |                     row[4] = HCurName; | 
 |  |  |                     row[5] = ds2.Tables[0].Rows[0]["HCusBalance"].ToString(); | 
 |  |  |                     row[6] = Double.Parse(ds2.Tables[0].Rows[0]["HCusBalance"].ToString()) + Double.Parse(ds2.Tables[0].Rows[0]["HCreditRating_Now"].ToString()) - Double.Parse(ds2.Tables[0].Rows[0]["HAvailableBalance"].ToString()); | 
 |  |  |                     row[7] = ds2.Tables[0].Rows[0]["HAvailableBalance"].ToString(); | 
 |  |  |                     tb2.Rows.Add(row); | 
 |  |  |                     string sql = "exec h_p_Xs_CusBalanceReport_Query '" + sWhere + "','" + userid + "'"; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "h_p_Xs_CusBalanceReport_Query"); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //添加列名 | 
 |  |  |                 foreach (DataColumn col in tb2.Columns) | 
 |  |  |                 foreach (DataColumn col in ds.Tables[0].Columns) | 
 |  |  |                 { | 
 |  |  |                     Type dataType = col.DataType; | 
 |  |  |                     string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
 |  |  | 
 |  |  |                 objJsonResult.code = "1"; | 
 |  |  |                 objJsonResult.count = 1; | 
 |  |  |                 objJsonResult.Message = "Sucess!"; | 
 |  |  |                 objJsonResult.data = tb2; | 
 |  |  |                 objJsonResult.data = ds.Tables[0]; | 
 |  |  |                 objJsonResult.list = columnNameList; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |             catch (Exception e) | 
 |  |  |             { | 
 |  |  |                 objJsonResult.code = "0"; | 
 |  |  |                 objJsonResult.count = 0; | 
 |  |  |                 objJsonResult.Message = "Exception!" + e.ToString(); | 
 |  |  |                 objJsonResult.data = null; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         #endregion | 
 |  |  |  | 
 |  |  |         #region 客户余额查询报表 占用额度明细 | 
 |  |  |         /// <summary> | 
 |  |  |         ///参数:string sql。 | 
 |  |  |         ///返回值:object。 | 
 |  |  |         /// </summary> | 
 |  |  |         [Route("Xs_CusBalanceReport/getHIsUsingBalanceEntry")] | 
 |  |  |         [HttpGet] | 
 |  |  |         public object getHIsUsingBalanceEntry(string sWhere,Int64 HCusID, string user, string userid) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 List<object> columnNameList = new List<object>(); | 
 |  |  |                 //////查看权限 | 
 |  |  |                 //if (!DBUtility.ClsPub.Security_Log("Xs_CusBalanceReport_Query", 1, false, user)) | 
 |  |  |                 //{ | 
 |  |  |                 //    objJsonResult.code = "0"; | 
 |  |  |                 //    objJsonResult.count = 0; | 
 |  |  |                 //    objJsonResult.Message = "无查看权限!"; | 
 |  |  |                 //    objJsonResult.data = null; | 
 |  |  |                 //    return objJsonResult; | 
 |  |  |                 //} | 
 |  |  |  | 
 |  |  |                 //查询 | 
 |  |  |                 if (sWhere == null || sWhere.Equals("")) | 
 |  |  |                 { | 
 |  |  |                     string sql = "exec h_p_Xs_CusBalanceReport_HIsUsingBalanceEntry_Query '','" + userid + "'," + HCusID; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "h_p_Xs_CusBalanceReport_Query"); | 
 |  |  |                 } | 
 |  |  |                 else | 
 |  |  |                 { | 
 |  |  |                     string sql = "exec h_p_Xs_CusBalanceReport_HIsUsingBalanceEntry_Query '" + sWhere +"','" + userid + "'," + HCusID; | 
 |  |  |                     ds = oCN.RunProcReturn(sql, "h_p_Xs_CusBalanceReport_Query"); | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 //添加列名 | 
 |  |  |                 foreach (DataColumn col in ds.Tables[0].Columns) | 
 |  |  |                 { | 
 |  |  |                     Type dataType = col.DataType; | 
 |  |  |                     string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; | 
 |  |  |                     columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名 | 
 |  |  |                 } | 
 |  |  |  | 
 |  |  |                 objJsonResult.code = "1"; | 
 |  |  |                 objJsonResult.count = 1; | 
 |  |  |                 objJsonResult.Message = "Sucess!"; | 
 |  |  |                 objJsonResult.data = ds.Tables[0]; | 
 |  |  |                 objJsonResult.list = columnNameList; | 
 |  |  |                 return objJsonResult; | 
 |  |  |             } |