InstallManageService.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. using LeaRun.Application.IService.InstallManage;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. //using LeaRun.Application.Busines.InstallManage;
  8. using LeaRun.Application.Entity.InstallManage;
  9. using LeaRun.Data;
  10. using LeaRun.Util.WebControl;
  11. using System.Data;
  12. using LeaRun.Application.Code;
  13. using LeaRun.Util;
  14. using System.Reflection;
  15. namespace LeaRun.Application.Service.InstallManage
  16. {
  17. public class InstallManageService : IInstallManageService
  18. {
  19. SqlHelper sqlHelper = new SqlHelper("InstallDB");
  20. public String GetInstallApplyData(String st, String et, InstallApplyEntity mt, Pagination pagination)
  21. {
  22. String sql = "";
  23. DataTable dt;
  24. StringBuilder sb = new StringBuilder();
  25. String json = "";
  26. Char c = ',';
  27. String SurveyType = "", DesginType = "", DesginVerfiyType = "", MasterVerifyType = "", budgetType = "", PayMentType = "", ConstructionType = "", AcceptType = "", ThroughWaterType = "", CreateCusInfoType = "";
  28. int total = pagination.records;
  29. sb.Append("SELECT [Apply_ID] ,[Apply_Number],[Dis_ID] ,[CustomerName],[LinkMan],[LinkManMobile],[CustomerAddr],[ApplyHouseHold_Num],[Metercaliber]");
  30. sb.Append(",[ApplyTime],[Operater],[SurveyType],[SurveyTime],[SurveyOperater],[SurveySugget],[DesginType],[DesginTime],[DesginOperater],[DesginImage],[DesginVerfiy]");
  31. sb.Append(",[DesginSugget],[DesginVerfiyName],[DesginVerfiyTime],[DesginVerfiyType],[MasterVerifyType],[MasterVerfiySugget],[MasterVerfiyOperater],[MasterVerfiyTime]");
  32. sb.Append(",[budgetType],[budgetOperater],[PayMentOperater],[PayMentType],[ConstructionOperater],[ConstructionType],[AcceptOperater],[AcceptType],[ThroughWaterOperater]");
  33. sb.Append(",[ThroughWaterType],[CreateCusInfoType],[CreateCusInfoOperater],[budgetTime],[PayMentTime],[ConstructionTime],[AcceptTime],[ThroughWaterTime],[CreateCusInfoTime] FROM INS_Apply WHERE 1=1 ");
  34. if (st != null)
  35. {
  36. if (et != null)
  37. {
  38. sb.Append(" AND ApplyTime BETWEEN '").Append(st).Append("' AND '").Append(et).Append(" 23:59:59' ");
  39. }
  40. }
  41. if (mt == null)
  42. {
  43. sql = sb.ToString();
  44. }
  45. else
  46. {
  47. if (mt.SurveyType != null) // 勘测
  48. {
  49. sb.Append(" AND SurveyType = ").Append(mt.SurveyType);
  50. }
  51. if (mt.DesginType != null) //设计
  52. {
  53. sb.Append(" AND DesginType = ").Append(mt.DesginType);
  54. }
  55. if (mt.DesginVerfiyType != null) // 设计审核
  56. {
  57. sb.Append(" AND DesginVerfiyType = ").Append(mt.DesginVerfiyType);
  58. }
  59. if (mt.MasterVerifyType != null)//经理审核
  60. {
  61. sb.Append(" AND MasterVerifyType = ").Append(mt.MasterVerifyType);
  62. }
  63. if (mt.budgetType != null)//预算
  64. {
  65. sb.Append(" AND budgetType = ").Append(mt.budgetType);
  66. }
  67. if (mt.PayMentType != null)//缴费
  68. {
  69. sb.Append(" AND PayMentType = ").Append(mt.PayMentType);
  70. }
  71. if (mt.ConstructionType != null)//施工
  72. {
  73. sb.Append(" AND ConstructionType = ").Append(mt.ConstructionType);
  74. }
  75. if (mt.AcceptType != null)//验收
  76. {
  77. sb.Append(" AND AcceptType = ").Append(mt.AcceptType);
  78. }
  79. if (mt.ThroughWaterType != null)//通水
  80. {
  81. sb.Append(" AND ThroughWaterType = ").Append(mt.ThroughWaterType);
  82. }
  83. if (mt.CreateCusInfoType != null)//立户
  84. {
  85. sb.Append(" AND CreateCusInfoType = ").Append(mt.CreateCusInfoType);
  86. }
  87. sql = sb.ToString();
  88. }
  89. dt = sqlHelper.ExecuteDataTable(sql, "", false, pagination.rows, pagination.page, out total, null);
  90. pagination.records = total;
  91. if (dt.Rows.Count > 0)
  92. {
  93. //pagination.records = dt.Rows.Count;
  94. //int startNum = pagination.rows * (pagination.page - 1);
  95. //int endNum = pagination.rows * pagination.page;
  96. //if (startNum > pagination.records)
  97. //{
  98. // startNum = 0;
  99. // endNum = dt.Rows.Count;
  100. //}
  101. //if (endNum > pagination.records)
  102. //{
  103. // endNum = dt.Rows.Count;
  104. //}
  105. sb.Clear();
  106. for (int i = 0; i < dt.Rows.Count; i++)
  107. {
  108. DataRow r = dt.Rows[i];
  109. #region 判断各种情况
  110. switch (r["SurveyType"].ToString())//勘测
  111. {
  112. case "0":
  113. SurveyType = "未勘测";
  114. break;
  115. case "1":
  116. SurveyType = "已勘测";
  117. break;
  118. case "2":
  119. SurveyType = "未通过";
  120. break;
  121. }
  122. switch (r["DesginType"].ToString())//设计
  123. {
  124. case "0":
  125. DesginType = "未设计";
  126. break;
  127. case "1":
  128. DesginType = "已设计";
  129. break;
  130. case "2":
  131. DesginType = "未通过";
  132. break;
  133. }
  134. switch (r["DesginVerfiyType"].ToString())//设计审核
  135. {
  136. case "0":
  137. DesginVerfiyType = "未审核";
  138. break;
  139. case "1":
  140. DesginVerfiyType = "已通过";
  141. break;
  142. case "2":
  143. DesginVerfiyType = "未通过";
  144. break;
  145. }
  146. switch (r["MasterVerifyType"].ToString())//经理审核
  147. {
  148. case "0":
  149. MasterVerifyType = "未审核";
  150. break;
  151. case "1":
  152. MasterVerifyType = "已通过";
  153. break;
  154. case "2":
  155. MasterVerifyType = "驳回";
  156. break;
  157. }
  158. switch (r["budgetType"].ToString())//预算审核
  159. {
  160. case "0":
  161. budgetType = "未预算";
  162. break;
  163. case "1":
  164. budgetType = "已预算";
  165. break;
  166. case "2":
  167. budgetType = "";
  168. break;
  169. }
  170. switch (r["PayMentType"].ToString())//缴费审核
  171. {
  172. case "0":
  173. PayMentType = "未缴费";
  174. break;
  175. case "1":
  176. PayMentType = "已缴费";
  177. break;
  178. case "2":
  179. PayMentType = "";
  180. break;
  181. }
  182. switch (r["ConstructionType"].ToString())//设计审核
  183. {
  184. case "0":
  185. ConstructionType = "未施工";
  186. break;
  187. case "1":
  188. ConstructionType = "施工中";
  189. break;
  190. case "2":
  191. ConstructionType = "已完成";
  192. break;
  193. }
  194. switch (r["AcceptType"].ToString())//设计审核
  195. {
  196. case "0":
  197. AcceptType = "未验收";
  198. break;
  199. case "1":
  200. AcceptType = "已验收";
  201. break;
  202. case "2":
  203. AcceptType = "";
  204. break;
  205. }
  206. switch (r["ThroughWaterType"].ToString())//设计审核
  207. {
  208. case "0":
  209. ThroughWaterType = "未通水";
  210. break;
  211. case "1":
  212. ThroughWaterType = "已通水";
  213. break;
  214. case "2":
  215. ThroughWaterType = "";
  216. break;
  217. }
  218. switch (r["CreateCusInfoType"].ToString())//设计审核
  219. {
  220. case "0":
  221. CreateCusInfoType = "未立户";
  222. break;
  223. case "1":
  224. CreateCusInfoType = "已立户";
  225. break;
  226. case "2":
  227. CreateCusInfoType = "";
  228. break;
  229. }
  230. #endregion
  231. #region 拼接sql
  232. sb.Append("{");
  233. sb.Append("\"Apply_ID\":\"").Append(r["Apply_ID"].ToString()).Append("\",");
  234. sb.Append("\"Apply_Number\":\"").Append(r["Apply_Number"].ToString()).Append("\",");
  235. sb.Append("\"Dis_ID\":\"").Append(r["Dis_ID"] != System.DBNull.Value ? r["Dis_ID"].ToString() : "").Append("\",");
  236. sb.Append("\"CustomerName\":\"").Append(r["CustomerName"].ToString()).Append("\",");
  237. sb.Append("\"LinkMan\":\"").Append(r["LinkMan"].ToString()).Append("\",");
  238. sb.Append("\"LinkManMobile\":\"").Append(r["LinkManMobile"].ToString()).Append("\",");
  239. sb.Append("\"CustomerAddr\":\"").Append(r["CustomerAddr"].ToString()).Append("\",");
  240. sb.Append("\"ApplyHouseHold_Num\":\"").Append(r["ApplyHouseHold_Num"].ToString()).Append("\",");
  241. sb.Append("\"Metercaliber\":\"").Append(r["Metercaliber"] != System.DBNull.Value ? r["Metercaliber"].ToString() : "").Append("\",");
  242. sb.Append("\"ApplyTime\":\"").Append(r["ApplyTime"] != System.DBNull.Value ? Convert.ToDateTime(r["ApplyTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  243. sb.Append("\"Operater\":\"").Append(r["Operater"].ToString()).Append("\",");
  244. sb.Append("\"SurveyType\":\"").Append(SurveyType).Append("\",");
  245. sb.Append("\"SurveyTime\":\"").Append(r["SurveyTime"] != System.DBNull.Value ? Convert.ToDateTime(r["SurveyTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  246. sb.Append("\"SurveyOperater\":\"").Append(r["SurveyOperater"].ToString()).Append("\",");
  247. sb.Append("\"SurveySugget\":\"").Append(r["SurveySugget"].ToString()).Append("\",");
  248. sb.Append("\"DesginType\":\"").Append(DesginType).Append("\",");
  249. sb.Append("\"DesginTime\":\"").Append(r["DesginTime"] != System.DBNull.Value ? Convert.ToDateTime(r["DesginTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  250. sb.Append("\"DesginOperater\":\"").Append(r["DesginOperater"].ToString()).Append("\",");
  251. sb.Append("\"DesginImage\":\"").Append(r["DesginImage"].ToString()).Append("\",");
  252. //sb.Append("\"DesginVerfiy\":\"").Append(r[19]).Append("\",");
  253. sb.Append("\"DesginSugget\":\"").Append(r["DesginSugget"].ToString()).Append("\",");
  254. sb.Append("\"DesginVerfiyName\":\"").Append(r["DesginVerfiyName"].ToString()).Append("\",");
  255. sb.Append("\"DesginVerfiyTime\":\"").Append(r["DesginVerfiyTime"] != System.DBNull.Value ? Convert.ToDateTime(r["DesginVerfiyTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  256. sb.Append("\"DesginVerfiyType\":\"").Append(DesginVerfiyType).Append("\",");
  257. sb.Append("\"MasterVerifyType\":\"").Append(MasterVerifyType).Append("\",");
  258. sb.Append("\"MasterVerfiySugget\":\"").Append(r["MasterVerfiySugget"].ToString()).Append("\",");
  259. sb.Append("\"MasterVerfiyOperater\":\"").Append(r["MasterVerfiyOperater"].ToString()).Append("\",");
  260. sb.Append("\"MasterVerfiyTime\":\"").Append(r["MasterVerfiyTime"] != System.DBNull.Value ? Convert.ToDateTime(r["MasterVerfiyTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  261. sb.Append("\"budgetType\":\"").Append(budgetType).Append("\",");
  262. sb.Append("\"budgetOperater\":\"").Append(r["budgetOperater"].ToString()).Append("\",");
  263. sb.Append("\"PayMentOperater\":\"").Append(r["PayMentOperater"].ToString()).Append("\",");
  264. sb.Append("\"PayMentType\":\"").Append(PayMentType).Append("\",");
  265. sb.Append("\"ConstructionOperater\":\"").Append(r["ConstructionOperater"].ToString()).Append("\",");
  266. sb.Append("\"ConstructionType\":\"").Append(ConstructionType).Append("\",");
  267. sb.Append("\"AcceptOperater\":\"").Append(r["AcceptOperater"].ToString()).Append("\",");
  268. sb.Append("\"AcceptType\":\"").Append(AcceptType).Append("\",");
  269. sb.Append("\"ThroughWaterOperater\":\"").Append(r["ThroughWaterOperater"].ToString()).Append("\",");
  270. sb.Append("\"ThroughWaterType\":\"").Append(ThroughWaterType).Append("\",");
  271. sb.Append("\"CreateCusInfoType\":\"").Append(CreateCusInfoType).Append("\",");
  272. sb.Append("\"CreateCusInfoOperater\":\"").Append(r["CreateCusInfoOperater"].ToString()).Append("\",");
  273. sb.Append("\"budgetTime\":\"").Append(r["budgetTime"] != System.DBNull.Value ? Convert.ToDateTime(r["budgetTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  274. sb.Append("\"PayMentTime\":\"").Append(r["PayMentTime"] != System.DBNull.Value ? Convert.ToDateTime(r["PayMentTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  275. sb.Append("\"ConstructionTime\":\"").Append(r["ConstructionTime"] != System.DBNull.Value ? Convert.ToDateTime(r["ConstructionTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  276. sb.Append("\"AcceptTime\":\"").Append(r["AcceptTime"] != System.DBNull.Value ? Convert.ToDateTime(r["AcceptTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  277. sb.Append("\"ThroughWaterTime\":\"").Append(r["ThroughWaterTime"] != System.DBNull.Value ? Convert.ToDateTime(r["ThroughWaterTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  278. sb.Append("\"CreateCusInfoTime\":\"").Append(r["CreateCusInfoTime"] != System.DBNull.Value ? Convert.ToDateTime(r["CreateCusInfoTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\"");
  279. sb.Append("},");
  280. #endregion
  281. json = "[" + sb.ToString().TrimEnd(c) + "]";
  282. }
  283. }
  284. return json;
  285. }
  286. // 保存 申请
  287. public void SaveApply(String applyNumber, String cusName, String linkMan, String linkMobile, String cusAdrr, String applyNum)
  288. {
  289. //定义变量
  290. StringBuilder sb = new StringBuilder();
  291. String sql = "";
  292. String curTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  293. String curOperator = "";
  294. //赋值
  295. curOperator = OperatorProvider.Provider.Current().UserName;
  296. //编写 insert sql
  297. sb.Append("INSERT INTO INS_Apply (Apply_Number,CustomerName,LinkMan,LinkManMobile,CustomerAddr,ApplyHouseHold_Num,ApplyTime,Operater) values ('");
  298. sb.Append(applyNumber).Append("','").Append(cusName).Append("','").Append(linkMan).Append("','").Append(linkMobile).Append("','");
  299. sb.Append(cusAdrr).Append("',").Append(applyNum).Append(",'").Append(curTime).Append("','").Append(curOperator).Append("'");
  300. sb.Append(")");
  301. sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text);
  302. }
  303. // 勘测
  304. public void SaveSurvey(String surveySuggset, Int32 apply_id)
  305. {
  306. String op = OperatorProvider.Provider.Current().UserName;
  307. String sql = "Update INS_Apply SET SurveyType = 1 ,SurveySugget = '" + surveySuggset + "',SurveyTime = GETDATE(),SurveyOperater = '" + op + "' WHERE Apply_ID = " + apply_id.ToString();
  308. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  309. }
  310. //申请的form
  311. public InstallApplyEntity GetFormJson(String keyValue)
  312. {
  313. InstallApplyEntity entity = new InstallApplyEntity();
  314. String sql = "SELECT * FROM INS_Apply WHERE Apply_ID = " + keyValue;
  315. DataTable dt = sqlHelper.ExecuteDataTable(sql, CommandType.Text, null);
  316. List<InstallApplyEntity> list = DataHelper.DataTableToT<InstallApplyEntity>(dt);
  317. if (list.Count > 0)
  318. {
  319. entity = list[0];
  320. }
  321. return entity;
  322. }
  323. public String GetInstallDudgetData(String applyId, InstallDudgetEntity mt, Pagination pagination)
  324. {
  325. //定义变量
  326. String json = "";
  327. DataTable dt;
  328. Int32 total = 0;
  329. StringBuilder sb = new StringBuilder();
  330. Char c = ',';
  331. // 客户地址 型号 类型 费用类型 单位 数量 单价 费用 人工费 审核 审核人 发票表号 开票人 开票时间 打印情况
  332. String sql = "SELECT name,Dudget_ID,Apply_ID,Depot_ID,[Version],[Type],MoneyType,unit,number,price,Creater,CreateDt,PaymentMoney,LabourCost,VerifyType,VerfiyName,InvoiceCode,PaymentName,PaymentTime,PrintType FROM INS_Budget WHERE Apply_ID = " + applyId;
  333. try
  334. {
  335. dt = sqlHelper.ExecuteDataTable(sql, "", false, pagination.rows, pagination.page, out total, null);
  336. pagination.records = total;
  337. if (dt.Rows.Count > 0)
  338. {
  339. for (int i = 0; i < dt.Rows.Count; i++)
  340. {
  341. DataRow r = dt.Rows[i];
  342. sb.Append("{");
  343. sb.Append("\"Apply_ID\":\"").Append(r["Apply_ID"].ToString()).Append("\",");
  344. sb.Append("\"Dudget_ID\":\"").Append(r["Dudget_ID"] != System.DBNull.Value ? r["Dudget_ID"].ToString() : "").Append("\",");
  345. sb.Append("\"Depot_ID\":\"").Append(r["Depot_ID"] != System.DBNull.Value ? r["Depot_ID"].ToString() : "").Append("\",");
  346. sb.Append("\"Version\":\"").Append(r["Version"].ToString()).Append("\",");
  347. sb.Append("\"Type\":\"").Append(r["Type"].ToString()).Append("\",");
  348. sb.Append("\"MoneyType\":\"").Append(r["MoneyType"] != System.DBNull.Value ? r["MoneyType"].ToString() : "").Append("\",");
  349. sb.Append("\"unit\":\"").Append(r["unit"] != System.DBNull.Value ? r["unit"].ToString() : "").Append("\",");
  350. sb.Append("\"number\":\"").Append(r["number"] != System.DBNull.Value ? r["number"].ToString() : "").Append("\",");
  351. sb.Append("\"price\":\"").Append(r["price"] != System.DBNull.Value ? r["price"].ToString() : "").Append("\",");
  352. sb.Append("\"Creater\":\"").Append(r["Creater"] != System.DBNull.Value ? r["Creater"].ToString() : "").Append("\",");
  353. sb.Append("\"CreateDt\":\"").Append(r["CreateDt"] != System.DBNull.Value ? Convert.ToDateTime(r["CreateDt"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  354. sb.Append("\"PaymentMoney\":\"").Append(r["PaymentMoney"] != System.DBNull.Value ? r["PaymentMoney"].ToString() : "").Append("\",");
  355. sb.Append("\"LabourCost\":\"").Append(r["LabourCost"] != System.DBNull.Value ? r["LabourCost"].ToString() : "").Append("\",");
  356. sb.Append("\"VerifyType\":\"").Append(r["VerifyType"] != System.DBNull.Value ? r["VerifyType"].ToString() : "").Append("\",");
  357. sb.Append("\"VerfiyName\":\"").Append(r["VerfiyName"] != System.DBNull.Value ? r["VerfiyName"].ToString() : "").Append("\",");
  358. sb.Append("\"InvoiceCode\":\"").Append(r["InvoiceCode"] != System.DBNull.Value ? r["InvoiceCode"].ToString() : "").Append("\",");
  359. sb.Append("\"PaymentName\":\"").Append(r["PaymentName"] != System.DBNull.Value ? r["PaymentName"].ToString() : "").Append("\",");
  360. sb.Append("\"PaymentTime\":\"").Append(r["PaymentTime"] != System.DBNull.Value ? Convert.ToDateTime(r["PaymentTime"]).ToString("yyyy-MM-dd HH:mm:ss") : "").Append("\",");
  361. sb.Append("\"PrintType\":\"").Append(r["PrintType"] != System.DBNull.Value ? r["PrintType"].ToString() : "").Append("\",");
  362. sb.Append("\"name\":\"").Append(r["name"] != System.DBNull.Value ? r["name"].ToString() : "").Append("\"");
  363. sb.Append("},");
  364. }
  365. json = "[" + sb.ToString().TrimEnd(c) + "]";
  366. }
  367. }
  368. catch (Exception ex)
  369. {
  370. json = ex.Message;
  371. }
  372. return json;
  373. }
  374. /// <summary>
  375. /// 获得预算细节
  376. /// </summary>
  377. /// <returns></returns>
  378. ///
  379. public DataSet GetBudgetDetail()
  380. {
  381. DataSet ds = new DataSet();
  382. string sqlType = "select materialId, Name from dbo.WM_materialtype";
  383. string sqlGoods = "select GoodId,Name,Specifications,Materialid from dbo.WM_Goods";
  384. string sqlUnit = "select UnitId, CalculateUnit from dbo.WM_CalculateUnit";
  385. DataTable dtType = sqlHelper.ExecuteDataTable(sqlType, CommandType.Text, null);
  386. DataTable dtGoods = sqlHelper.ExecuteDataTable(sqlGoods,CommandType.Text,null);
  387. DataTable dtUnit = sqlHelper.ExecuteDataTable(sqlUnit,CommandType.Text,null);
  388. ds.Tables.Add(dtType);
  389. ds.Tables.Add(dtGoods);
  390. ds.Tables.Add(dtUnit);
  391. return ds;
  392. }
  393. public DataTable GetBudgetDetailGoods(string materialID)
  394. {
  395. string sqlGoods = "select GoodId,Name,Specifications,Materialid from dbo.WM_Goods where Materialid=" + materialID ;
  396. DataTable dtGoods = sqlHelper.ExecuteDataTable(sqlGoods, CommandType.Text, null);
  397. return dtGoods;
  398. }
  399. public String GetBudgetDetail110()
  400. {
  401. //定义变量
  402. string json = "";
  403. String json1 = "";
  404. string json2 = "";
  405. string json3 = "";
  406. DataTable dt1;
  407. DataTable dt2;
  408. DataTable dt3;
  409. StringBuilder sb1 = new StringBuilder();
  410. StringBuilder sb2 = new StringBuilder();
  411. StringBuilder sb3= new StringBuilder();
  412. Char c = ',';
  413. string sql1 = "select materialId, Name from dbo.WM_materialtype";
  414. string sql2 = "select GoodId,Name,Specifications from dbo.WM_Goods";
  415. string sql3 = "select UnitId, CalculateUnit from dbo.WM_CalculateUnit";
  416. try
  417. {
  418. dt1 = sqlHelper.ExecuteDataTable(sql1, CommandType.Text, null);
  419. if (dt1.Rows.Count > 0)
  420. {
  421. for (int i = 0; i < dt1.Rows.Count; i++)
  422. {
  423. DataRow r = dt1.Rows[i];
  424. sb1.Append("{");
  425. sb1.Append("\"materialId\":\"").Append(r["materialId"].ToString()).Append("\",");
  426. sb1.Append("\"Name\":\"").Append(r["Name"].ToString()).Append("\"");
  427. sb1.Append("},");
  428. }
  429. json1 = "[" + sb1.ToString().TrimEnd(c) + "]";
  430. }
  431. dt2 = sqlHelper.ExecuteDataTable(sql2, CommandType.Text, null);
  432. if (dt2.Rows.Count > 0)
  433. {
  434. for (int i = 0; i < dt2.Rows.Count; i++)
  435. {
  436. DataRow r = dt2.Rows[i];
  437. sb2.Append("{");
  438. sb2.Append("\"GoodId\":\"").Append(r["GoodId"].ToString()).Append("\",");
  439. sb2.Append("\"Name\":\"").Append(r["Name"].ToString()).Append("\",");
  440. sb2.Append("\"Specifications\":\"").Append(r["Specifications"].ToString()).Append("\"");
  441. sb2.Append("},");
  442. }
  443. json2 = "[" + sb2.ToString().TrimEnd(c) + "]";
  444. }
  445. dt3 = sqlHelper.ExecuteDataTable(sql3, CommandType.Text, null);
  446. if (dt3.Rows.Count > 0)
  447. {
  448. for (int i = 0; i < dt3.Rows.Count; i++)
  449. {
  450. DataRow r = dt3.Rows[i];
  451. sb3.Append("{");
  452. sb3.Append("\"UnitId\":\"").Append(r["UnitId"].ToString()).Append("\",");
  453. sb3.Append("\"CalculateUnit\":\"").Append(r["CalculateUnit"].ToString()).Append("\"");
  454. sb3.Append("},");
  455. }
  456. json3 = "[" + sb3.ToString().TrimEnd(c) + "]";
  457. }
  458. //json = json1 + "*" + json2 + "*" + json3;
  459. json = json1;
  460. }
  461. catch (Exception ex)
  462. {
  463. json = ex.Message;
  464. }
  465. return json;
  466. }
  467. public void SaveBudgetForma(String applyId, InstallDudgetEntity entity)
  468. {
  469. StringBuilder sb = new StringBuilder();
  470. String curOperator = OperatorProvider.Provider.Current().UserName;
  471. sb.Append("INSERT INTO INS_Budget(Apply_ID,[Version],[Type],unit,number,price,PaymentMoney,LabourCost,name,Creater,CreateDt) VALUES (");
  472. sb.Append(applyId).Append(",'").Append(entity.Version).Append("','").Append(entity.Type).Append("','");
  473. sb.Append(entity.unit).Append("',").Append(entity.number).Append(",").Append(entity.price).Append(",");
  474. sb.Append(entity.price * entity.number).Append(",").Append(entity.LabourCost).Append(",'").Append(entity.name).Append("','");
  475. sb.Append(curOperator).Append("',GETDATE()");
  476. sb.Append(")");
  477. try
  478. {
  479. sqlHelper.ExecuteNoParams(sb.ToString(), CommandType.Text);
  480. }
  481. catch (Exception ex)
  482. {
  483. }
  484. }
  485. public void SaveBudgetForm(String applyId)
  486. {
  487. String op = OperatorProvider.Provider.Current().UserName;
  488. String sql = "Update INS_Apply SET budgetType = 1,budgetTime = GETDATE(),budgetOperater = '" + op + "' WHERE Apply_ID = " + applyId;
  489. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  490. try
  491. {
  492. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  493. }
  494. catch (Exception ex)
  495. {
  496. }
  497. }
  498. //经理审核
  499. public void MasterVerify(String applyId)
  500. {
  501. String op = OperatorProvider.Provider.Current().UserName;
  502. String sql = "Update INS_Apply SET MasterVerifyType = 1,MasterVerfiyTime = GETDATE(),MasterVerfiyOperater = '" + op + "' WHERE Apply_ID = " + applyId;
  503. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  504. try
  505. {
  506. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  507. }
  508. catch (Exception ex)
  509. {
  510. }
  511. }
  512. //缴费
  513. public void PaymentForm(String applyId)
  514. {
  515. String op = OperatorProvider.Provider.Current().UserName;
  516. String sql = "Update INS_Apply SET PayMentType = 1,PayMentTime = GETDATE(),PayMentOperater = '" + op + "' WHERE Apply_ID = " + applyId;
  517. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  518. try
  519. {
  520. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  521. sql = "update INS_Budget SET PaymentName = '" + op + "' ,PaymentTime = GETDATE() where Apply_ID =" + applyId;
  522. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  523. }
  524. catch (Exception ex)
  525. {
  526. throw;
  527. }
  528. }
  529. //施工
  530. public void UpdateEngineer(String appId, String type)
  531. {
  532. String op = OperatorProvider.Provider.Current().UserName;
  533. String sql = "Update INS_Apply SET ConstructionType = " + type + ",PayMentTime = GETDATE(),ConstructionOperater = '" + op + "' WHERE Apply_ID = " + appId;
  534. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  535. try
  536. {
  537. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  538. //sql = "update INS_Budget SET PaymentName = '" + op + "' ,PaymentTime = GETDATE() where Apply_ID =" + applyId;
  539. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  540. }
  541. catch (Exception ex)
  542. {
  543. throw;
  544. }
  545. }
  546. //验收
  547. public void UpdateAceept(String appId, String type)
  548. {
  549. String op = OperatorProvider.Provider.Current().UserName;
  550. String sql = "Update INS_Apply SET AcceptType = " + type + ",AcceptTime = GETDATE(),AcceptOperater = '" + op + "' WHERE Apply_ID = " + appId;
  551. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  552. try
  553. {
  554. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  555. //sql = "update INS_Budget SET PaymentName = '" + op + "' ,PaymentTime = GETDATE() where Apply_ID =" + applyId;
  556. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  557. }
  558. catch (Exception ex)
  559. {
  560. throw;
  561. }
  562. }
  563. //通水
  564. public void UpdateThroughWater(String appId, String type)
  565. {
  566. String op = OperatorProvider.Provider.Current().UserName;
  567. String sql = "Update INS_Apply SET ThroughWaterType = " + type + ",ThroughWaterTime = GETDATE(),ThroughWaterOperater = '" + op + "' WHERE Apply_ID = " + appId;
  568. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  569. try
  570. {
  571. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  572. //sql = "update INS_Budget SET PaymentName = '" + op + "' ,PaymentTime = GETDATE() where Apply_ID =" + applyId;
  573. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  574. }
  575. catch (Exception ex)
  576. {
  577. throw;
  578. }
  579. }
  580. //导入
  581. public void UpdateCreateCus(String appId, String type)
  582. {
  583. String op = OperatorProvider.Provider.Current().UserName;
  584. String sql = "Update INS_Apply SET CreateCusInfoType = " + type + ",CreateCusInfoTime = GETDATE(),CreateCusInfoOperater = '" + op + "' WHERE Apply_ID = " + appId;
  585. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  586. try
  587. {
  588. sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  589. //sql = "update INS_Budget SET PaymentName = '" + op + "' ,PaymentTime = GETDATE() where Apply_ID =" + applyId;
  590. //sqlHelper.ExecuteNoParams(sql, CommandType.Text);
  591. }
  592. catch (Exception ex)
  593. {
  594. throw;
  595. }
  596. }
  597. }
  598. }