Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 87.73 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Globalization;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11.  
  12. namespace testProjectBCA
  13. {
  14. public partial class OlahanOptiVault : Form
  15. {
  16. Database1Entities en = new Database1Entities();
  17. public OlahanOptiVault()
  18. {
  19. InitializeComponent();
  20. buttonProcessVault.Visible = false;
  21. buttonProcessSetoranCpc.Visible = false;
  22. buttonProsesOrderBlogHistory.Visible = false;
  23. dataGridView1.Visible = false;
  24. dateTimePicker1.Visible = false;
  25. //buttonGeneratePivot.Enabled = false;
  26. //buttonGeneratePivotPerVendor.Enabled = false;
  27. dataGridView2.Visible = false;
  28. dataGridView3.Visible = false;
  29. dataGridView4.Visible = false;
  30. dataGridView5.Visible = false;
  31. dataGridView6.Visible = false;
  32. dataGridView7.Visible = false;
  33. label4.Visible = false;
  34. label5.Visible = false;
  35. label6.Visible = false;
  36. label7.Visible = false;
  37. buttonAll.Visible = false;
  38.  
  39.  
  40.  
  41.  
  42.  
  43. }
  44.  
  45.  
  46. List<VOBH> vobh;
  47. List<VO> vo;
  48. List<OBH> obh;
  49. List<VaultProcessed> vp;
  50. List<SetoranCPC> sc;
  51. List<PivotCPC> pc;
  52. List<PivotCPC_BIBL> bibl;
  53. List<PivotCPC_BIBLD> bibld;
  54. List<PivotCPC_ATMD> atmd;
  55. List<PivotCPC_ATMR> atmr;
  56. List<OBHProcessed> obhp;
  57. List<PivotPerVendor_bon> ppvb;
  58. List<PivotPerVendor_setoran> ppvs;
  59. List<PivotPerVendor_Out> pivotPerVendor_Out;
  60. List<PivotPerVendor_In> pivotPerVendor_In;
  61. List<PivotVault_In> pivotVault_In;
  62. List<PivotVault_Out> pivotVault_Out;
  63.  
  64.  
  65. private void buttonUploadVaultOrderBlogHistory_Click(object sender, EventArgs e)
  66. {
  67. int flagUpVOBH = 0;
  68. OpenFileDialog of = new OpenFileDialog();
  69. of.Filter = Variables.csvFilter;
  70.  
  71. if (of.ShowDialog() == DialogResult.OK)
  72. {
  73. String filename = of.FileName;
  74. DataSet ds = Util.openCsv(filename);
  75. DataTable dt = ds.Tables[0];
  76.  
  77. dataGridView1.DataSource = dt;
  78.  
  79. vobh = new List<VOBH>();
  80.  
  81. for (int i = 1; i < dt.Rows.Count - 1; i++)
  82. {
  83. if (String.IsNullOrWhiteSpace(dt.Rows[i][3].ToString()))
  84. {
  85. continue;
  86. }
  87. Console.WriteLine(i);
  88. Console.WriteLine(dt.Rows[i][7].ToString());
  89. vobh.Add(new VOBH
  90. {
  91. vaultId = dt.Rows[i][0].ToString(),
  92. confId = dt.Rows[i][4].ToString(),
  93. orderDate = Convert.ToDateTime(dt.Rows[i][5].ToString()).Date,
  94. dueDate = Convert.ToDateTime(dt.Rows[i][6].ToString()).Date,
  95. timeStamp = DateTime.ParseExact(dt.Rows[i][7].ToString(), "M/d/yyyy H:mm", System.Globalization.CultureInfo.InvariantCulture),
  96. blogMessage = dt.Rows[i][9].ToString(),
  97. action = dt.Rows[i][2].ToString(),
  98. status = dt.Rows[i][3].ToString(),
  99. currencyAmmount = CurrencyFill(String.IsNullOrWhiteSpace(dt.Rows[i][11].ToString()) ? dt.Rows[i - 1][11].ToString().Replace("IDR:", "") : dt.Rows[i][11].ToString().Replace("IDR:", ""))
  100. //currencyAmmount = String.IsNullOrEmpty(dt.Rows[i][11].ToString()) ? Int64.Parse(dt.Rows[i - 1][11].ToString().Replace("IDR:", "")) : Int64.Parse(dt.Rows[i][11].ToString().Replace("IDR:", ""))
  101. });
  102. }
  103. label1.Text = filename.Substring(filename.LastIndexOf('\\'), filename.Length - filename.LastIndexOf('\\'));
  104. }
  105.  
  106. flagUpVOBH = 1;
  107. }
  108.  
  109. private void buttonUploadVaultOrder_Click(object sender, EventArgs e)
  110. {
  111. int flagUpVO = 0;
  112. OpenFileDialog of = new OpenFileDialog();
  113. of.Filter = Variables.csvFilter;
  114.  
  115. if (of.ShowDialog() == DialogResult.OK)
  116. {
  117. String filename = of.FileName;
  118. DataSet ds = Util.openCsv(filename);
  119. DataTable dt = ds.Tables[0];
  120.  
  121. dataGridView1.DataSource = dt;
  122.  
  123. vo = new List<VO>();
  124.  
  125. for (int i = 1; i < dt.Rows.Count - 1; i++)
  126. {
  127.  
  128. vo.Add(new VO
  129. {
  130. vaultId = dt.Rows[i][0].ToString(),
  131. confId = dt.Rows[i][2].ToString(),
  132. fundingSource = dt.Rows[i][3].ToString(),
  133. orderDate = Convert.ToDateTime(dt.Rows[i][5].ToString()).Date,
  134. dueDate = Convert.ToDateTime(dt.Rows[i][6].ToString()).Date,
  135. action = dt.Rows[i][1].ToString(),
  136. status = dt.Rows[i][4].ToString(),
  137. currencyAmmount = CurrencyFill(String.IsNullOrWhiteSpace(dt.Rows[i][11].ToString()) ? dt.Rows[i - 1][11].ToString().Replace("IDR:", "") : dt.Rows[i][11].ToString().Replace("IDR:", ""))
  138. //currencyAmmount = Int64.Parse(dt.Rows[i][11].ToString())
  139. });
  140. Console.WriteLine("data ke: " + i);
  141. }
  142. label2.Text = filename.Substring(filename.LastIndexOf('\\'), filename.Length - filename.LastIndexOf('\\'));
  143. }
  144. flagUpVO = 1;
  145. }
  146.  
  147.  
  148. private void buttonUploadOrderBlogHistory_Click(object sender, EventArgs e)
  149. {
  150. OpenFileDialog of = new OpenFileDialog();
  151. of.Filter = Variables.csvFilter;
  152. if (of.ShowDialog() == DialogResult.OK)
  153. {
  154. String filename = of.FileName;
  155. DataSet ds = Util.openCsv(filename);
  156. DataTable dt = ds.Tables[0];
  157.  
  158. dataGridView1.DataSource = dt;
  159.  
  160. obh = new List<OBH>();
  161.  
  162. for (int i = 1; i < dt.Rows.Count; i++)
  163. {
  164. if (dt.Rows[i][6].ToString() == "Confirmed" || dt.Rows[i][6].ToString() == "In Transit")
  165. {
  166. String cashpointId = dt.Rows[i][0].ToString();
  167. String confId = dt.Rows[i][5].ToString();
  168. DateTime orderDate = Convert.ToDateTime(dt.Rows[i][3].ToString()).Date;
  169. DateTime dueDate = Convert.ToDateTime(dt.Rows[i][4].ToString()).Date;
  170. DateTime blogTime = DateTime.ParseExact(dt.Rows[i][9].ToString(), "M/d/yyyy H:mm", System.Globalization.CultureInfo.InvariantCulture);
  171. String action = dt.Rows[i][2].ToString();
  172. String status = dt.Rows[i][6].ToString();
  173. String blogMessage = dt.Rows[i][10].ToString();
  174. String tampungan = " ";
  175. for (int z = i; z >= 0; z--)
  176. {
  177. if (String.IsNullOrWhiteSpace(tampungan))
  178. {
  179. tampungan = dt.Rows[z][11].ToString();
  180. }
  181. else
  182. break;
  183. }
  184. Int64 currencyAmmount = CurrencyFill(String.IsNullOrWhiteSpace(dt.Rows[i][11].ToString()) ? dt.Rows[i - 1][11].ToString().Replace("IDR:", "") : dt.Rows[i][11].ToString().Replace("IDR:", ""));
  185.  
  186. obh.Add(new OBH
  187. {
  188. cashpointId = dt.Rows[i][0].ToString(),
  189. confId = dt.Rows[i][5].ToString(),
  190. orderDate = Convert.ToDateTime(dt.Rows[i][3].ToString()).Date,
  191. dueDate = Convert.ToDateTime(dt.Rows[i][4].ToString()).Date,
  192. blogMessage = dt.Rows[i][10].ToString(),
  193. blogTime = DateTime.ParseExact(dt.Rows[i][9].ToString(), "M/d/yyyy H:mm", System.Globalization.CultureInfo.InvariantCulture),
  194. action = dt.Rows[i][2].ToString(),
  195. status = dt.Rows[i][6].ToString(),
  196. currencyAmmount = CurrencyFill(tampungan.Replace("IDR:", "")),
  197. //currencyAmmount = CurrencyFill(String.IsNullOrWhiteSpace(dt.Rows[i][11].ToString()) ? dt.Rows[i - 1][11].ToString().Replace("IDR:", "") : dt.Rows[i][11].ToString().Replace("IDR:", ""))
  198. });
  199. Console.WriteLine("currency yg keluar: " + currencyAmmount);
  200. }
  201.  
  202. }
  203.  
  204. label3.Text = filename.Substring(filename.LastIndexOf('\\'), filename.Length - filename.LastIndexOf('\\'));
  205. dataGridView1.DataSource = obh;
  206.  
  207. }
  208. }
  209.  
  210. private void buttonProsesOrderBlogHistory_Click(object sender, EventArgs e)
  211. {
  212.  
  213. obhp = new List<OBHProcessed>();
  214.  
  215. var cabangs = en.Cabangs.Select(x => x).ToList();
  216.  
  217.  
  218.  
  219. var query = (from x in obh
  220. join y in cabangs on x.cashpointId.TrimStart('B').TrimStart('0') equals y.kodeCabang
  221. select new { x.cashpointId, x.confId, x.orderDate, x.dueDate, x.blogTime, x.action, x.status, x.currencyAmmount, y.kodePkt }
  222. ).ToList();
  223.  
  224. foreach (var item in query)
  225. {
  226. obhp.Add(new OBHProcessed
  227. {
  228. cashpointId = item.cashpointId,
  229. vendor = item.kodePkt,
  230. confId = item.confId,
  231. orderDate = item.orderDate,
  232. dueDate = item.dueDate,
  233. blogTime = item.blogTime,
  234. action = item.action,
  235. status = item.status,
  236. currencyAmmount = item.currencyAmmount,
  237. realDate = item.blogTime.Hour < 21 ? item.blogTime.Date : item.blogTime.AddDays(1).Date,
  238. validation = (item.blogTime.Hour < 21 ? item.blogTime : item.blogTime.AddDays(1)).Date <= item.dueDate.Date ? "VALIDATED" : "NOT VALIDATED"
  239. });
  240. }
  241. dataGridView1.DataSource = obhp;
  242.  
  243. }
  244.  
  245. private void buttonProcessVault_Click(object sender, EventArgs e)
  246. {
  247. var query = (from x in vobh
  248. select new { x.vaultId, x.confId, x.action, x.status, x.orderDate, x.dueDate, x.timeStamp, x.currencyAmmount, fundingSource = vo.Where(y => y.confId == x.confId).Select(y => y.fundingSource).FirstOrDefault() }
  249. ).ToList();
  250.  
  251. vp = new List<VaultProcessed>();
  252.  
  253. foreach (var item in query)
  254. {
  255. vp.Add(new VaultProcessed
  256. {
  257. vaultId = item.vaultId,
  258. confId = item.confId,
  259. action = item.action,
  260. status = item.status,
  261. orderDate = item.orderDate,
  262. dueDate = item.dueDate,
  263. timeStamp = item.timeStamp,
  264. currencyAmmount = item.currencyAmmount,
  265. fundingSource = item.fundingSource,
  266. realDate = item.timeStamp.Hour < 21 ? item.timeStamp.Date : item.timeStamp.AddDays(1).Date,
  267. validation = (item.timeStamp.Hour < 21 ? item.timeStamp : item.timeStamp.AddDays(1)).Date <= item.dueDate.Date ? "VALIDATED" : "NOT VALIDATED"
  268. });
  269. }
  270. Console.WriteLine(vp.Count);
  271. dataGridView1.DataSource = vp;
  272.  
  273. }
  274.  
  275. private void buttonProcessSetoranCpc_Click(object sender, EventArgs e)
  276. {
  277. var query = (from x in vp
  278. where x.status == "Confirmed"
  279. select x
  280. ).ToList();
  281.  
  282. sc = new List<SetoranCPC>();
  283.  
  284. foreach (var item in query)
  285. {
  286. sc.Add(new SetoranCPC
  287. {
  288. vaultId = item.vaultId,
  289. confId = item.confId,
  290. action = item.action,
  291. status = item.status,
  292. orderDate = item.orderDate,
  293. dueDate = item.dueDate,
  294. timeStamp = item.timeStamp,
  295. currencyAmmount = item.currencyAmmount,
  296. fundingSource = item.fundingSource,
  297. realDate = item.timeStamp.Hour < 21 ? item.timeStamp : item.timeStamp.AddDays(1),
  298. validation = (item.timeStamp.Hour < 21 ? item.timeStamp : item.timeStamp.AddDays(1)).Date <= item.dueDate.Date ? "VALIDATED" : "NOT VALIDATED"
  299. });
  300. }
  301. Console.WriteLine(sc.Count);
  302. dataGridView1.DataSource = sc;
  303. }
  304.  
  305. private void buttonGeneratePivotPerVendor_Click(object sender, EventArgs e)
  306. {
  307. //ProsesOrderBlogHistory();
  308. var queryS = (from x in en.RekonSaldoPerVendors.AsEnumerable()
  309. join y in en.Pkts.AsEnumerable() on x.vendor equals y.kodePktCabang
  310. where !String.IsNullOrEmpty(x.vendor) && y.kanwil.Like("Jabotabek")
  311. select x).ToList();
  312.  
  313. //preparing data for pivot pervendor bon
  314. var query = (from x in queryS
  315. join y in en.Pkts.AsEnumerable() on x.vendor equals y.kodePktCabang
  316. where (!String.IsNullOrEmpty(x.vendor) && y.kanwil.Like("Jabotabek") && x.actionRekon.Contains("Delivery") && x.statusRekon.Equals("Confirmed")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  317. select new
  318. {
  319. cashPointId = x.cashPointtId,
  320. confId = x.confId,
  321. orderDate = x.orderDate,
  322. vendor = x.vendor,
  323. actionRekon = x.actionRekon,
  324. statusRekon = x.statusRekon,
  325. dueDate = x.dueDate,
  326. blogTime = x.blogTime,
  327. currencyAmmount = x.currencyAmmount,
  328. realDate = x.realDate,
  329. blogMessage = x.blogMessage,
  330. validation = x.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(x.blogTime.ToString()).Hour < 21 ? x.blogTime : DateTime.Parse(x.blogTime.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  331. // x.realDate <= dateTimePicker2.Value ? "VALIDATED" : "NOT VALIDATED"
  332. //&& x.blogMessage.Contains("GL Processed")
  333. //DateTime.Parse((DateTime.Parse(x.blogTime.ToString()).Hour < 21 ? x.blogTime : DateTime.Parse(x.blogTime.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(x.dueDate.ToString()).Date ? "VALIDATED" : "NOT VALIDATED"
  334. }).ToList();
  335.  
  336. //generating pivotbon
  337. ppvb = new List<PivotPerVendor_bon>();
  338.  
  339. var pivot = query.GroupBy(c => new { c.vendor, c.dueDate, c.realDate }).Select(g => new
  340. {
  341. dueDate = g.Key.dueDate,
  342. valDate = g.Key.realDate,
  343. vendor = g.Key.vendor,
  344. belumValidasi = g.Where(c => c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount),
  345. sudahValidasi = g.Where(c => c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  346. grandTotal = g.Where(c => c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount) +
  347. g.Where(c => c.validation == "VALIDATED").Sum(c => c.currencyAmmount)
  348.  
  349. }).ToList();
  350.  
  351. Console.WriteLine(pivot.Count);
  352.  
  353. foreach (var item in pivot)
  354. {
  355. ppvb.Add(new PivotPerVendor_bon
  356. {
  357. dueDate = ((DateTime)item.dueDate).Date,
  358. valDate = ((DateTime)item.valDate).Date,
  359. vendor = item.vendor,
  360. belumValidasi = (Int64)item.belumValidasi,
  361. sudahValidasi = (Int64)item.sudahValidasi,
  362. grandTotal = (Int64)item.grandTotal
  363. });
  364. }
  365.  
  366. dataGridView6.DataSource = ppvb;
  367.  
  368. //preparing data for pivot pervendor setoran
  369. var querysetoran = (from x in queryS
  370. where (x.actionRekon.Contains("Return") && x.statusRekon.Equals("In Transit")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  371. select new
  372. {
  373. cashPointId = x.cashPointtId,
  374. confId = x.confId,
  375. orderDate = x.orderDate,
  376. vendor = x.vendor,
  377. actionRekon = x.actionRekon,
  378. statusRekon = x.statusRekon,
  379. dueDate = x.dueDate,
  380. blogTime = x.blogTime,
  381. currencyAmmount = x.currencyAmmount,
  382. realDate = x.realDate,
  383. blogMessage = x.blogMessage,
  384. validation = x.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(x.blogTime.ToString()).Hour < 21 ? x.blogTime : DateTime.Parse(x.blogTime.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  385. //DateTime.Parse((DateTime.Parse(x.blogTime.ToString()).Hour < 21 ? x.blogTime : DateTime.Parse(x.blogTime.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(x.dueDate.ToString()).Date ? "VALIDATED" : "NOT VALIDATED"
  386. }).ToList();
  387.  
  388. //generating pivot
  389. ppvs = new List<PivotPerVendor_setoran>();
  390.  
  391. var pivotsetoran = querysetoran.GroupBy(c => new { c.vendor, c.dueDate, c.realDate }).Select(g => new
  392. {
  393. dueDate = g.Key.dueDate,
  394. valDate = g.Key.realDate,
  395. vendor = g.Key.vendor,
  396. belumValidasi = g.Where(c => c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount),
  397. sudahValidasi = g.Where(c => c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  398. grandTotal = g.Where(c => c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount) +
  399. g.Where(c => c.validation == "VALIDATED").Sum(c => c.currencyAmmount)
  400.  
  401. }).ToList();
  402.  
  403. foreach (var item in pivotsetoran)
  404. {
  405. ppvs.Add(new PivotPerVendor_setoran
  406. {
  407. dueDate = ((DateTime)item.dueDate).Date,
  408. valDate = ((DateTime)item.valDate).Date,
  409. vendor = item.vendor,
  410. belumValidasi = (Int64)item.belumValidasi,
  411. sudahValidasi = (Int64)item.sudahValidasi,
  412. grandTotal = (Int64)item.grandTotal
  413. });
  414. }
  415. dataGridView7.DataSource = ppvs;
  416.  
  417. if (dataGridView6.Rows.Count > 0)
  418. {
  419. for (int i = 2; i < dataGridView6.Columns.Count; i++)
  420. {
  421. dataGridView6.Columns[i].DefaultCellStyle.Format = "c";
  422. dataGridView6.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  423. }
  424. }
  425.  
  426. if (dataGridView7.Rows.Count > 0)
  427. {
  428. for (int i = 2; i < dataGridView7.Columns.Count; i++)
  429. {
  430. dataGridView7.Columns[i].DefaultCellStyle.Format = "c";
  431. dataGridView7.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  432. }
  433. }
  434.  
  435. }
  436.  
  437.  
  438. private void buttonGeneratePivot_Click(object sender, EventArgs e)
  439. {
  440. //ProsesVault();
  441. //ProsesSetoranCPC();
  442.  
  443.  
  444. //creating pivotCPC - BI dan BankLain Return
  445. var pivot = pc.GroupBy(c => new { c.vaultId, c.fundingSource, c.dueDate, c.realDate }).Select(g => new
  446. {
  447. dueDate = g.Key.dueDate,
  448. realDate = g.Key.realDate,
  449. vaultID = g.Key.vaultId,
  450. fundingSource = g.Key.fundingSource,
  451. emergencyReturn = g.Where(c => c.action == "Emergency Return").Sum(c => c.currencyAmmount),
  452. emergencyReturnVal = g.Where(c => c.action == "Emergency Return" && c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  453. emergencyReturnNotVal = g.Where(c => c.action == "Emergency Return" && c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount),
  454. plannedReturn = g.Where(c => c.action == "Planned Return").Sum(c => c.currencyAmmount),
  455. plannedReturnVal = g.Where(c => c.action == "Planned Return" && c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  456. plannedReturnNotVal = g.Where(c => c.action == "Planned Return" && c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount)
  457.  
  458. }).ToList();
  459.  
  460. var pivot2 = (from x in pivot
  461. select new { x.dueDate, x.vaultID, x.fundingSource, x.emergencyReturn, x.emergencyReturnVal, x.emergencyReturnNotVal, x.plannedReturn, x.plannedReturnVal, x.plannedReturnNotVal, grandTotal = x.emergencyReturn + x.plannedReturn, x.realDate });
  462.  
  463. bibl = new List<PivotCPC_BIBL>();
  464.  
  465. foreach (var item in pivot2)
  466. {
  467. if (!(item.plannedReturn == 0 && item.emergencyReturn == 0))
  468. {
  469. bibl.Add(new PivotCPC_BIBL
  470. {
  471. dueDate = item.dueDate,
  472. realDate = item.realDate,
  473. vaultId = item.vaultID,
  474. fundingSource = item.fundingSource,
  475. //emergencyReturn = item.emergencyReturn,
  476. emergencyReturnVal = item.emergencyReturnVal,
  477. emergencyReturnNotVal = item.emergencyReturnNotVal,
  478. //plannedReturn = item.plannedReturn,
  479. plannedReturnVal = item.plannedReturnVal,
  480. plannedReturnNotVal = item.plannedReturnNotVal,
  481. grandTotal = item.grandTotal
  482. });
  483. }
  484.  
  485. }
  486.  
  487. dataGridView2.DataSource = bibl;
  488.  
  489. //preparing data for Pivot CPC - BI dan BankLain delivery
  490. var queryd = (from x in en.RekonSaldoVaults.AsEnumerable()
  491. join y in en.Pkts.AsEnumerable() on x.vaultId equals y.kodePktCabang
  492. where !String.IsNullOrEmpty(x.fundingSoure) && y.kanwil.Like("Jabotabek")
  493. select x).ToList();
  494. queryd = (from x in queryd
  495. where (x.fundingSoure == "BI" || x.fundingSoure.Contains("OB")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  496. select x).ToList();
  497.  
  498. pc = new List<PivotCPC>();
  499.  
  500. String bufferVaultId2 = "";
  501.  
  502. foreach (var item in queryd)
  503. {
  504. pc.Add(new PivotCPC
  505. {
  506. vaultId = item.vaultId,
  507. confId = item.confId,
  508. action = item.actionRekon,
  509. status = item.statusRekon,
  510. blogMessage = item.blogMessage,
  511. orderDate = ((DateTime)item.orderDate).Date,
  512. dueDate = ((DateTime)item.dueDate).Date,
  513. timeStamp = (DateTime)item.timeStampRekon,
  514. currencyAmmount = Int64.Parse(item.currencyAmmount.ToString()),
  515. fundingSource = item.fundingSoure,
  516. realDate = ((DateTime)item.timeStampRekon).Hour < 21 ? ((DateTime)item.timeStampRekon).Date : ((DateTime)item.timeStampRekon).AddDays(1).Date,
  517. validation = item.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(item.timeStampRekon.ToString()).Hour < 21 ? item.timeStampRekon : DateTime.Parse(item.timeStampRekon.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  518. });
  519.  
  520. }
  521.  
  522. //creating pivotCPC - BI dan BankLain Delivery
  523. var pivotd = pc.GroupBy(c => new { c.vaultId, c.fundingSource, c.dueDate, c.realDate }).Select(g => new
  524. {
  525. dueDate = g.Key.dueDate,
  526. realDate = g.Key.realDate,
  527. vaultID = g.Key.vaultId,
  528. fundingSource = g.Key.fundingSource,
  529. emergencyDelivery = g.Where(c => c.action == "Emergency Delivery").Sum(c => c.currencyAmmount),
  530. emergencyDeliveryVal = g.Where(c => c.action == "Emergency Delivery" && c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  531. emergencyDeliveryNotVal = g.Where(c => c.action == "Emergency Delivery" && c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount),
  532. plannedDelivery = g.Where(c => c.action == "Planned Delivery").Sum(c => c.currencyAmmount),
  533. plannedDeliveryVal = g.Where(c => c.action == "Planned Delivery" && c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  534. plannedDeliveryNotVal = g.Where(c => c.action == "Planned Delivery" && c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount)
  535. }).ToList();
  536.  
  537. var pivotd2 = (from x in pivotd
  538. select new { x.dueDate, x.vaultID, x.fundingSource, x.emergencyDelivery, x.plannedDelivery, grandTotal = x.emergencyDelivery + x.plannedDelivery, x.plannedDeliveryVal, x.plannedDeliveryNotVal, x.emergencyDeliveryNotVal, x.emergencyDeliveryVal, x.realDate });
  539.  
  540. bibld = new List<PivotCPC_BIBLD>();
  541.  
  542. foreach (var item in pivotd2)
  543. {
  544. if (!(item.emergencyDelivery == 0 && item.plannedDelivery == 0))
  545. {
  546. bibld.Add(new PivotCPC_BIBLD
  547. {
  548. dueDate = item.dueDate,
  549. realDate = item.realDate,
  550. vaultId = item.vaultID,
  551. fundingSource = item.fundingSource,
  552. // emergencyDelivery = item.emergencyDelivery,
  553. emergencyDeliveryVal = item.emergencyDeliveryVal,
  554. emergencyDeliveryNotVal = item.emergencyDeliveryNotVal,
  555. // plannedDelivery = item.plannedDelivery,
  556. plannedDeliveryVal = item.plannedDeliveryVal,
  557. plannedDeliveryNotVal = item.plannedDeliveryNotVal,
  558. grandTotal = item.grandTotal
  559. });
  560. }
  561.  
  562. }
  563.  
  564. dataGridView3.DataSource = bibld;
  565.  
  566. //preparing data for pivot - ATM delivery
  567. var queryad = (from x in en.RekonSaldoVaults.AsEnumerable()
  568. join y in en.Pkts.AsEnumerable() on x.vaultId equals y.kodePktCabang
  569. where !String.IsNullOrEmpty(x.fundingSoure) && y.kanwil.Like("Jabotabek")
  570. select x).ToList();
  571. queryad = (from x in queryad
  572. where (x.fundingSoure != "BI" && !x.fundingSoure.Contains("OB")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  573. select x).ToList();
  574.  
  575. pc = new List<PivotCPC>();
  576.  
  577. String bufferVaultId3 = "";
  578.  
  579. foreach (var item in queryad)
  580. {
  581. pc.Add(new PivotCPC
  582. {
  583. vaultId = item.vaultId,
  584. confId = item.confId,
  585. action = item.actionRekon,
  586. blogMessage = item.blogMessage,
  587. status = item.statusRekon,
  588. orderDate = ((DateTime)item.orderDate).Date,
  589. dueDate = ((DateTime)item.dueDate).Date,
  590. timeStamp = (DateTime)item.timeStampRekon,
  591. currencyAmmount = Int64.Parse(item.currencyAmmount.ToString()),
  592. fundingSource = item.fundingSoure,
  593. realDate = ((DateTime)item.timeStampRekon).Hour < 21 ? ((DateTime)item.timeStampRekon).Date : ((DateTime)item.timeStampRekon).AddDays(1).Date,
  594. validation = item.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(item.timeStampRekon.ToString()).Hour < 21 ? item.timeStampRekon : DateTime.Parse(item.timeStampRekon.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  595. });
  596.  
  597. }
  598.  
  599. //creating pivot - atm delivery
  600. var pivotad = pc.GroupBy(c => new { c.vaultId, c.fundingSource, c.dueDate, c.realDate }).Select(g => new
  601. {
  602. dueDate = g.Key.dueDate,
  603. realDate = g.Key.realDate,
  604. vaultID = g.Key.vaultId,
  605. fundingSource = g.Key.fundingSource,
  606. emergencyDelivery = g.Where(c => c.action == "Emergency Delivery").Sum(c => c.currencyAmmount),
  607. emergencyDeliveryVal = g.Where(c => c.action == "Emergency Delivery" && c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  608. emergencyDeliveryNotVal = g.Where(c => c.action == "Emergency Delivery" && c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount),
  609. plannedDelivery = g.Where(c => c.action == "Planned Delivery").Sum(c => c.currencyAmmount),
  610. plannedDeliveryVal = g.Where(c => c.action == "Planned Delivery" && c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  611. plannedDeliveryNotVal = g.Where(c => c.action == "Planned Delivery" && c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount)
  612. }).ToList();
  613.  
  614. var pivotad2 = (from x in pivotad
  615. select new { x.dueDate, x.vaultID, x.fundingSource, x.emergencyDelivery, x.plannedDelivery, grandTotal = x.emergencyDelivery + x.plannedDelivery, x.plannedDeliveryNotVal, x.plannedDeliveryVal, x.emergencyDeliveryNotVal, x.emergencyDeliveryVal, x.realDate });
  616.  
  617. atmd = new List<PivotCPC_ATMD>();
  618.  
  619. foreach (var item in pivotad2)
  620. {
  621. if (!(item.emergencyDelivery == 0 && item.plannedDelivery == 0))
  622. {
  623. atmd.Add(new PivotCPC_ATMD
  624. {
  625. dueDate = item.dueDate,
  626. realDate = item.realDate,
  627. vaultId = item.vaultID,
  628. fundingSource = item.fundingSource,
  629. // emergencyDelivery = item.emergencyDelivery,
  630. emergencyDeliveryVal = item.emergencyDeliveryVal,
  631. emergencyDeliveryNotVal = item.emergencyDeliveryNotVal,
  632. // plannedDelivery = item.plannedDelivery,
  633. plannedDeliveryVal = item.plannedDeliveryVal,
  634. plannedDeliveryNotVal = item.plannedDeliveryNotVal,
  635. grandTotal = item.grandTotal
  636. });
  637. }
  638.  
  639. }
  640.  
  641. dataGridView4.DataSource = atmd;
  642.  
  643. //preparing data for pivot - atm return
  644. var queryar = (from x in en.RekonSaldoVaults.AsEnumerable()
  645. join y in en.Pkts.AsEnumerable() on x.vaultId equals y.kodePktCabang
  646. where !String.IsNullOrEmpty(x.fundingSoure) && y.kanwil.Like("Jabotabek")
  647. select x).ToList();
  648. queryar = (from x in queryar
  649. where (x.fundingSoure != "BI" && !x.fundingSoure.Contains("OB")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  650. select x).ToList();
  651.  
  652. pc = new List<PivotCPC>();
  653.  
  654. String bufferVaultId4 = "";
  655.  
  656. foreach (var item in queryar)
  657. {
  658. pc.Add(new PivotCPC
  659. {
  660. vaultId = item.vaultId,
  661. confId = item.confId,
  662. action = item.actionRekon,
  663. blogMessage = item.blogMessage,
  664. status = item.statusRekon,
  665. orderDate = ((DateTime)item.orderDate).Date,
  666. dueDate = ((DateTime)item.dueDate).Date,
  667. timeStamp = (DateTime)item.timeStampRekon,
  668. currencyAmmount = Int64.Parse(item.currencyAmmount.ToString()),
  669. fundingSource = item.fundingSoure,
  670. realDate = ((DateTime)item.timeStampRekon).Hour < 21 ? ((DateTime)item.timeStampRekon).Date : ((DateTime)item.timeStampRekon).AddDays(1).Date,
  671. validation = item.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(item.timeStampRekon.ToString()).Hour < 21 ? item.timeStampRekon : DateTime.Parse(item.timeStampRekon.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  672. });
  673.  
  674. }
  675.  
  676. //creating pivotCPC - atm return
  677. var pivotar = pc.GroupBy(c => new { c.vaultId, c.fundingSource, c.dueDate, c.realDate }).Select(g => new
  678. {
  679. dueDate = g.Key.dueDate,
  680. realDate = g.Key.realDate,
  681. vaultID = g.Key.vaultId,
  682. fundingSource = g.Key.fundingSource,
  683. emergencyReturn = g.Where(c => c.action == "Emergency Return").Sum(c => c.currencyAmmount),
  684. emergencyReturnVal = g.Where(c => c.action == "Emergency Return" && c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  685. emergencyReturnNotVal = g.Where(c => c.action == "Emergency Return" && c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount),
  686. plannedReturn = g.Where(c => c.action == "Planned Return").Sum(c => c.currencyAmmount),
  687. plannedReturnVal = g.Where(c => c.action == "Planned Return" && c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  688. plannedReturnNotVal = g.Where(c => c.action == "Planned Return" && c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount)
  689. }).ToList();
  690.  
  691. var pivotar2 = (from x in pivotar
  692. select new { x.dueDate, x.vaultID, x.realDate, x.fundingSource, x.emergencyReturn, x.plannedReturn, grandTotal = x.emergencyReturn + x.plannedReturn, x.plannedReturnVal, x.plannedReturnNotVal, x.emergencyReturnVal, x.emergencyReturnNotVal });
  693.  
  694. atmr = new List<PivotCPC_ATMR>();
  695.  
  696. foreach (var item in pivotar2)
  697. {
  698. if (!(item.plannedReturn == 0 && item.emergencyReturn == 0))
  699. {
  700. atmr.Add(new PivotCPC_ATMR
  701. {
  702. dueDate = item.dueDate,
  703. realDate = item.realDate,
  704. vaultId = item.vaultID,
  705. fundingSource = item.fundingSource,
  706. // emergencyReturn = item.emergencyReturn,
  707. emergencyReturnVal = item.emergencyReturnVal,
  708. emergencyReturnNotVal = item.emergencyReturnNotVal,
  709. // plannedReturn = item.plannedReturn,
  710. plannedReturnVal = item.plannedReturnVal,
  711. plannedReturnNotVal = item.plannedReturnNotVal,
  712. grandTotal = item.grandTotal
  713. });
  714. }
  715.  
  716. }
  717.  
  718. dataGridView5.DataSource = atmr;
  719.  
  720. //formatting
  721. if (dataGridView2.Rows.Count > 0)
  722. {
  723. for (int i = 3; i < dataGridView2.Columns.Count; i++)
  724. {
  725. dataGridView2.Columns[i].DefaultCellStyle.Format = "c";
  726. dataGridView2.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  727. }
  728. }
  729. if (dataGridView3.Rows.Count > 0)
  730. {
  731. for (int i = 3; i < dataGridView3.Columns.Count; i++)
  732. {
  733. dataGridView3.Columns[i].DefaultCellStyle.Format = "c";
  734. dataGridView3.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  735. }
  736. }
  737. if (dataGridView4.Rows.Count > 0)
  738. {
  739. for (int i = 3; i < dataGridView4.Columns.Count; i++)
  740. {
  741. dataGridView4.Columns[i].DefaultCellStyle.Format = "c";
  742. dataGridView4.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  743. }
  744. }
  745. if (dataGridView5.Rows.Count > 0)
  746. {
  747. for (int i = 3; i < dataGridView5.Columns.Count; i++)
  748. {
  749. dataGridView5.Columns[i].DefaultCellStyle.Format = "c";
  750. dataGridView5.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  751. }
  752. }
  753.  
  754.  
  755. }
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763. public Int64 CurrencyFill(String a)
  764. {
  765. Int64 result = 0;
  766. Console.WriteLine("yang masuk: " + a);
  767. if (a.Contains("e") || a.Contains("E"))
  768. {
  769. result = (Int64)Double.Parse(a, System.Globalization.NumberStyles.Float);
  770. }
  771. else
  772. {
  773. if (String.IsNullOrEmpty(a))
  774. { result = 0; }
  775. else
  776. result = (Int64)Double.Parse(a);
  777. }
  778.  
  779. return result;
  780. }
  781.  
  782. public void ProsesVault()
  783. {
  784. {
  785. var query = (from x in vobh
  786. select new { x.vaultId, x.confId, x.action, x.status, x.orderDate, x.dueDate, x.blogMessage, x.timeStamp, x.currencyAmmount, fundingSource = vo.Where(y => y.confId == x.confId).Select(y => y.fundingSource).FirstOrDefault() }
  787. ).ToList();
  788.  
  789. vp = new List<VaultProcessed>();
  790.  
  791. foreach (var item in query)
  792. {
  793. vp.Add(new VaultProcessed
  794. {
  795. vaultId = item.vaultId,
  796. confId = item.confId,
  797. action = item.action,
  798. status = item.status,
  799. orderDate = item.orderDate,
  800. dueDate = item.dueDate,
  801. timeStamp = item.timeStamp,
  802. blogMessage = item.blogMessage,
  803. currencyAmmount = item.currencyAmmount,
  804. fundingSource = item.fundingSource,
  805. realDate = item.timeStamp.Hour < 21 ? item.timeStamp.Date : item.timeStamp.AddDays(1).Date,
  806.  
  807. });
  808. }
  809. Console.WriteLine(vp.Count);
  810. dataGridView1.DataSource = vp;
  811. }
  812. }
  813.  
  814. public void ProsesSetoranCPC()
  815. {
  816. var query = (from x in vp
  817. where x.status == "Confirmed"
  818. select x
  819. ).ToList();
  820.  
  821. sc = new List<SetoranCPC>();
  822.  
  823. foreach (var item in query)
  824. {
  825. sc.Add(new SetoranCPC
  826. {
  827. vaultId = item.vaultId,
  828. confId = item.confId,
  829. action = item.action,
  830. status = item.status,
  831. orderDate = item.orderDate,
  832. dueDate = item.dueDate,
  833. timeStamp = item.timeStamp,
  834. currencyAmmount = item.currencyAmmount,
  835. fundingSource = item.fundingSource,
  836. realDate = item.timeStamp.Hour < 21 ? item.timeStamp.Date : item.timeStamp.AddDays(1).Date,
  837. blogMessage = item.blogMessage
  838.  
  839. });
  840. }
  841. Console.WriteLine(sc.Count);
  842. dataGridView1.DataSource = sc;
  843. }
  844.  
  845. public void ProsesOrderBlogHistory()
  846. {
  847. obhp = new List<OBHProcessed>();
  848.  
  849. var cabangs = en.Cabangs.Select(x => x).ToList();
  850.  
  851.  
  852.  
  853. var query = (from x in obh
  854. join y in cabangs on x.cashpointId.TrimStart('B') equals y.kodeCabang
  855. select new
  856. {
  857. x.cashpointId,
  858. x.confId,
  859. x.orderDate,
  860. x.dueDate,
  861. x.blogTime,
  862. x.action,
  863. x.status,
  864. x.currencyAmmount,
  865. x.blogMessage,
  866. y.kodePkt
  867. }
  868. ).ToList();
  869.  
  870. foreach (var item in query)
  871. {
  872. obhp.Add(new OBHProcessed
  873. {
  874. cashpointId = item.cashpointId,
  875. vendor = item.kodePkt,
  876. confId = item.confId,
  877. orderDate = item.orderDate,
  878. dueDate = item.dueDate,
  879. blogTime = item.blogTime,
  880. blogMessage = item.blogMessage,
  881. action = item.action,
  882. status = item.status,
  883. currencyAmmount = item.currencyAmmount,
  884. realDate = item.blogTime.Hour < 21 ? item.blogTime.Date : item.blogTime.AddDays(1).Date,
  885. validation = (item.blogTime.Hour < 21 ? item.blogTime : item.blogTime.AddDays(1)).Date <= item.dueDate.Date ? "VALIDATED" : "NOT VALIDATED"
  886. });
  887. }
  888. dataGridView1.DataSource = obhp;
  889. }
  890.  
  891. private void buttonSaveToDB_Click(object sender, EventArgs e)
  892. {
  893. loadForm.ShowSplashScreen();
  894. ProsesVault();
  895. ProsesSetoranCPC();
  896. //save to db rs-vault
  897. List<RekonSaldoVault> rsv = (from x in sc
  898. select new RekonSaldoVault()
  899. {
  900. vaultId = x.vaultId,
  901. confId = x.confId,
  902. fundingSoure = x.fundingSource,
  903. actionRekon = x.action,
  904. statusRekon = x.status,
  905. orderDate = x.orderDate,
  906. dueDate = x.dueDate,
  907. timeStampRekon = x.timeStamp,
  908. currencyAmmount = x.currencyAmmount,
  909. realDate = x.realDate,
  910. blogMessage = x.blogMessage
  911. }).ToList();
  912.  
  913.  
  914. DateTime maxdate2 = rsv.Max(x => (DateTime)x.dueDate);
  915. DateTime mindate2 = rsv.Min(x => (DateTime)x.dueDate);
  916.  
  917. var query3 = (from x in en.RekonSaldoVaults
  918. where (DateTime)x.dueDate >= mindate2 && (DateTime)x.dueDate <= maxdate2
  919. select x
  920. ).ToList();
  921.  
  922. List<RekonSaldoVault> rsvToRemove = new List<RekonSaldoVault>();
  923.  
  924. foreach (var item in rsv)
  925. {
  926. var query4 = (from x in query3
  927. where x.confId == item.confId && x.dueDate == item.dueDate
  928. select x).FirstOrDefault();
  929. if (query4 != null)
  930. {
  931. query4.vaultId = item.vaultId;
  932. query4.confId = item.confId;
  933. query4.orderDate = item.orderDate;
  934. query4.fundingSoure = item.fundingSoure;
  935. query4.actionRekon = item.actionRekon;
  936. query4.statusRekon = item.statusRekon;
  937. query4.dueDate = item.dueDate;
  938. query4.timeStampRekon = item.timeStampRekon;
  939. query4.currencyAmmount = item.currencyAmmount;
  940. query4.realDate = item.realDate;
  941. query4.blogMessage = item.blogMessage;
  942. en.SaveChanges();
  943.  
  944. rsvToRemove.Add(item);
  945.  
  946. }
  947. }
  948.  
  949. foreach (var item in rsvToRemove)
  950. {
  951. rsv.Remove(item);
  952. }
  953.  
  954.  
  955. en.RekonSaldoVaults.AddRange(rsv);
  956. en.SaveChanges();
  957. loadForm.CloseForm();
  958.  
  959. //-------------------------=======================---------------------------//
  960.  
  961. }
  962.  
  963. private void dataGridView2_SelectionChanged(object sender, EventArgs e)
  964. {
  965. DataGridViewSelectedCellCollection cells = dataGridView2.SelectedCells;
  966. foreach (DataGridViewCell cell in cells)
  967. {
  968. int rowidx = cell.RowIndex;
  969. int colidx = cell.ColumnIndex;
  970. Console.WriteLine(rowidx + ", " + colidx);
  971. Console.WriteLine(dataGridView2.Rows[rowidx].Cells[colidx].Value.ToString().Replace("Rp.", "").Replace(".", ""));
  972. if (colidx > 2)
  973. {
  974. dataGridView2.Rows[rowidx].Cells[colidx].Style.Format = "F0";
  975. }
  976.  
  977. }
  978. for (int a = 0; a < dataGridView2.Rows.Count; a++)
  979. {
  980. for (int b = 3; b < dataGridView2.Columns.Count; b++)
  981. {
  982. if (!cells.Contains(dataGridView2.Rows[a].Cells[b]))
  983. {
  984. Int64 buf;
  985. dataGridView2.Rows[a].Cells[b].Style.Format = "C0";
  986. dataGridView2.Rows[a].Cells[b].Style.FormatProvider = CultureInfo.GetCultureInfo("id-ID");
  987. }
  988. }
  989. }
  990. }
  991.  
  992. private void dataGridView3_SelectionChanged(object sender, EventArgs e)
  993. {
  994. DataGridViewSelectedCellCollection cells = dataGridView3.SelectedCells;
  995. foreach (DataGridViewCell cell in cells)
  996. {
  997. int rowidx = cell.RowIndex;
  998. int colidx = cell.ColumnIndex;
  999. Console.WriteLine(rowidx + ", " + colidx);
  1000. Console.WriteLine(dataGridView3.Rows[rowidx].Cells[colidx].Value.ToString().Replace("Rp.", "").Replace(".", ""));
  1001. if (colidx > 2)
  1002. {
  1003. dataGridView3.Rows[rowidx].Cells[colidx].Style.Format = "F0";
  1004. }
  1005. }
  1006. for (int a = 0; a < dataGridView3.Rows.Count; a++)
  1007. {
  1008. for (int b = 3; b < dataGridView3.Columns.Count; b++)
  1009. {
  1010. if (!cells.Contains(dataGridView3.Rows[a].Cells[b]))
  1011. {
  1012. Int64 buf;
  1013. dataGridView3.Rows[a].Cells[b].Style.Format = "C0";
  1014. dataGridView3.Rows[a].Cells[b].Style.FormatProvider = CultureInfo.GetCultureInfo("id-ID");
  1015. }
  1016. }
  1017. }
  1018. }
  1019.  
  1020. private void dataGridView6_SelectionChanged(object sender, EventArgs e)
  1021. {
  1022. DataGridViewSelectedCellCollection cells = dataGridView6.SelectedCells;
  1023. foreach (DataGridViewCell cell in cells)
  1024. {
  1025. int rowidx = cell.RowIndex;
  1026. int colidx = cell.ColumnIndex;
  1027. Console.WriteLine(rowidx + ", " + colidx);
  1028. Console.WriteLine(dataGridView6.Rows[rowidx].Cells[colidx].Value.ToString().Replace("Rp.", "").Replace(".", ""));
  1029. if (colidx >= 2)
  1030. {
  1031. dataGridView6.Rows[rowidx].Cells[colidx].Style.Format = "F0";
  1032. }
  1033. }
  1034. for (int a = 0; a < dataGridView6.Rows.Count; a++)
  1035. {
  1036. for (int b = 2; b < dataGridView6.Columns.Count; b++)
  1037. {
  1038. if (!cells.Contains(dataGridView6.Rows[a].Cells[b]))
  1039. {
  1040. Int64 buf;
  1041. dataGridView6.Rows[a].Cells[b].Style.Format = "C0";
  1042. dataGridView6.Rows[a].Cells[b].Style.FormatProvider = CultureInfo.GetCultureInfo("id-ID");
  1043. }
  1044. }
  1045. }
  1046. }
  1047.  
  1048. private void dataGridView5_SelectionChanged(object sender, EventArgs e)
  1049. {
  1050. DataGridViewSelectedCellCollection cells = dataGridView5.SelectedCells;
  1051. foreach (DataGridViewCell cell in cells)
  1052. {
  1053. int rowidx = cell.RowIndex;
  1054. int colidx = cell.ColumnIndex;
  1055. Console.WriteLine(rowidx + ", " + colidx);
  1056. Console.WriteLine(dataGridView5.Rows[rowidx].Cells[colidx].Value.ToString().Replace("Rp.", "").Replace(".", ""));
  1057. if (colidx > 2)
  1058. {
  1059. dataGridView5.Rows[rowidx].Cells[colidx].Style.Format = "F0";
  1060. }
  1061. }
  1062. for (int a = 0; a < dataGridView5.Rows.Count; a++)
  1063. {
  1064. for (int b = 3; b < dataGridView5.Columns.Count; b++)
  1065. {
  1066. if (!cells.Contains(dataGridView5.Rows[a].Cells[b]))
  1067. {
  1068. Int64 buf;
  1069. dataGridView5.Rows[a].Cells[b].Style.Format = "C0";
  1070. dataGridView5.Rows[a].Cells[b].Style.FormatProvider = CultureInfo.GetCultureInfo("id-ID");
  1071. }
  1072. }
  1073. }
  1074. }
  1075.  
  1076. private void dataGridView4_SelectionChanged(object sender, EventArgs e)
  1077. {
  1078. DataGridViewSelectedCellCollection cells = dataGridView4.SelectedCells;
  1079. foreach (DataGridViewCell cell in cells)
  1080. {
  1081. int rowidx = cell.RowIndex;
  1082. int colidx = cell.ColumnIndex;
  1083. Console.WriteLine(rowidx + ", " + colidx);
  1084. Console.WriteLine(dataGridView4.Rows[rowidx].Cells[colidx].Value.ToString().Replace("Rp.", "").Replace(".", ""));
  1085. if (colidx > 2)
  1086. {
  1087. dataGridView4.Rows[rowidx].Cells[colidx].Style.Format = "F0";
  1088. }
  1089. }
  1090. for (int a = 0; a < dataGridView4.Rows.Count; a++)
  1091. {
  1092. for (int b = 3; b < dataGridView4.Columns.Count; b++)
  1093. {
  1094. if (!cells.Contains(dataGridView4.Rows[a].Cells[b]))
  1095. {
  1096. Int64 buf;
  1097. dataGridView4.Rows[a].Cells[b].Style.Format = "C0";
  1098. dataGridView4.Rows[a].Cells[b].Style.FormatProvider = CultureInfo.GetCultureInfo("id-ID");
  1099. }
  1100. }
  1101. }
  1102. }
  1103.  
  1104. private void dataGridView7_SelectionChanged(object sender, EventArgs e)
  1105. {
  1106. DataGridViewSelectedCellCollection cells = dataGridView7.SelectedCells;
  1107. foreach (DataGridViewCell cell in cells)
  1108. {
  1109. int rowidx = cell.RowIndex;
  1110. int colidx = cell.ColumnIndex;
  1111. Console.WriteLine(rowidx + ", " + colidx);
  1112. Console.WriteLine(dataGridView7.Rows[rowidx].Cells[colidx].Value.ToString().Replace("Rp.", "").Replace(".", ""));
  1113. if (colidx >= 2)
  1114. {
  1115. dataGridView7.Rows[rowidx].Cells[colidx].Style.Format = "F0";
  1116. }
  1117. }
  1118. for (int a = 0; a < dataGridView7.Rows.Count; a++)
  1119. {
  1120. for (int b = 2; b < dataGridView7.Columns.Count; b++)
  1121. {
  1122. if (!cells.Contains(dataGridView7.Rows[a].Cells[b]))
  1123. {
  1124. Int64 buf;
  1125. dataGridView7.Rows[a].Cells[b].Style.Format = "C0";
  1126. dataGridView7.Rows[a].Cells[b].Style.FormatProvider = CultureInfo.GetCultureInfo("id-ID");
  1127. }
  1128. }
  1129. }
  1130. }
  1131.  
  1132. private void button1_Click(object sender, EventArgs e)
  1133. {
  1134. loadForm.ShowSplashScreen();
  1135. //save to db rs-pervendor
  1136. ProsesOrderBlogHistory();
  1137. List<RekonSaldoPerVendor> rspv = (from x in obhp
  1138. select new RekonSaldoPerVendor()
  1139. {
  1140. cashPointtId = x.cashpointId,
  1141. confId = x.confId,
  1142. orderDate = x.orderDate,
  1143. vendor = x.vendor,
  1144. actionRekon = x.action,
  1145. statusRekon = x.status,
  1146. dueDate = x.dueDate,
  1147. blogMessage = x.blogMessage,
  1148. blogTime = x.blogTime,
  1149. currencyAmmount = x.currencyAmmount,
  1150. realDate = x.realDate
  1151. }).ToList();
  1152.  
  1153. DateTime maxdate = rspv.Max(x => (DateTime)x.dueDate);
  1154. DateTime mindate = rspv.Min(x => (DateTime)x.dueDate);
  1155.  
  1156. var query = (from x in en.RekonSaldoPerVendors
  1157. where (DateTime)x.dueDate >= mindate && (DateTime)x.dueDate <= maxdate
  1158. select x
  1159. ).ToList();
  1160.  
  1161. List<RekonSaldoPerVendor> rspvToRemove = new List<RekonSaldoPerVendor>();
  1162.  
  1163. foreach (var item in rspv)
  1164. {
  1165. var query2 = (from x in query
  1166. where x.cashPointtId == item.cashPointtId
  1167. && x.confId == item.confId
  1168. && x.orderDate == item.orderDate
  1169. //&& x.vendor == item.vendor
  1170. && x.actionRekon == item.actionRekon
  1171. //&& x.blogMessage == item.blogMessage
  1172. && x.statusRekon == item.statusRekon
  1173. //&& ((DateTime)x.dueDate).Date == item.dueDate
  1174. //&& (DateTime)x.blogTime == item.blogTime
  1175. //&& x.currencyAmmount == item.currencyAmmount
  1176. //&& ((DateTime)x.realDate).Date == item.realDate
  1177. //&& x.validation == item.validation
  1178. select x).ToList();
  1179. /*
  1180. var query3 = (from x in query2
  1181. where x.cashPointtId == item.cashPointtId
  1182. && x.confId == item.confId
  1183. && x.orderDate == item.orderDate
  1184. //&& x.vendor == item.vendor
  1185. && x.actionRekon == item.actionRekon
  1186. && x.statusRekon == item.statusRekon
  1187. //&& ((DateTime)x.dueDate).Date == item.dueDate
  1188. //&& (DateTime)x.blogTime == item.blogTime
  1189. //&& x.currencyAmmount == item.currencyAmmount
  1190. //&& ((DateTime)x.realDate).Date == item.realDate
  1191. //&& x.validation == item.validation
  1192. select x).ToList();
  1193. */
  1194.  
  1195.  
  1196. if (query2 != null)
  1197. {
  1198. for (int i = 0; i < query2.Count; i++)
  1199. {
  1200. Console.WriteLine("UPDATE");
  1201. query2[i].cashPointtId = item.cashPointtId;
  1202. query2[i].confId = item.confId;
  1203. query2[i].orderDate = item.orderDate;
  1204. query2[i].blogMessage = item.blogMessage;
  1205. Console.WriteLine("update blogmessage: " + item.blogMessage);
  1206. query2[i].vendor = item.vendor;
  1207. query2[i].actionRekon = item.actionRekon;
  1208. //query2[i].statusRekon = item.statusRekon;
  1209. //query2[i].dueDate = item.dueDate;
  1210. //query2[i].blogTime = item.blogTime;
  1211. query2[i].currencyAmmount = item.currencyAmmount;
  1212. //query2[i].realDate = item.realDate;
  1213. //query2[i].validation = item.validation;
  1214.  
  1215. en.SaveChanges();
  1216.  
  1217. rspvToRemove.Add(item);
  1218. }
  1219. }
  1220. else
  1221. {
  1222. Console.WriteLine("ELSE RSPV");
  1223. }
  1224. }
  1225.  
  1226. foreach (var item in rspvToRemove)
  1227. {
  1228. rspv.Remove(item);
  1229. }
  1230.  
  1231. en.RekonSaldoPerVendors.AddRange(rspv);
  1232. en.SaveChanges();
  1233. loadForm.CloseForm();
  1234. }
  1235.  
  1236. public void pivotVault()
  1237. {
  1238. //area for BI
  1239. var queryVaultBI = (from x in en.RekonSaldoVaults.AsEnumerable()
  1240. join y in en.Pkts.AsEnumerable() on x.vaultId equals y.kodePktCabang
  1241. where !String.IsNullOrEmpty(x.fundingSoure)
  1242. select x).ToList();
  1243.  
  1244. //area for atm
  1245. var queryVaultATM = (from x in en.RekonSaldoVaults.AsEnumerable()
  1246. join y in en.Pkts.AsEnumerable() on x.vaultId.Substring(0, 4) equals y.kodePktCabang == "CCASA" ? "CCAS" : y.kodePktCabang
  1247. where !String.IsNullOrEmpty(x.fundingSoure) && y.kanwil.Like("Jabotabek")
  1248. select x).ToList();
  1249.  
  1250.  
  1251.  
  1252. //QUERY VAULT IN BI- BUFFER
  1253. var queryInBIBuffer = (from x in queryVaultBI
  1254. where (x.fundingSoure == "BI" || x.fundingSoure.Contains("OB")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  1255. select x).ToList();
  1256.  
  1257. List<PivotCPC> pc = new List<PivotCPC>();
  1258.  
  1259. foreach (var item in queryInBIBuffer)
  1260. {
  1261. pc.Add(new PivotCPC
  1262. {
  1263. vaultId = item.vaultId,
  1264. confId = item.confId,
  1265. action = item.actionRekon,
  1266. status = item.statusRekon,
  1267. blogMessage = item.blogMessage,
  1268. orderDate = ((DateTime)item.orderDate).Date,
  1269. dueDate = ((DateTime)item.dueDate).Date,
  1270. timeStamp = (DateTime)item.timeStampRekon,
  1271. currencyAmmount = Int64.Parse(item.currencyAmmount.ToString()),
  1272. fundingSource = item.fundingSoure,
  1273. realDate = ((DateTime)item.timeStampRekon).Hour < 21 ? ((DateTime)item.timeStampRekon).Date : ((DateTime)item.timeStampRekon).AddDays(1).Date,
  1274. validation = item.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(item.timeStampRekon.ToString()).Hour < 21 ? item.timeStampRekon : DateTime.Parse(item.timeStampRekon.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  1275. });
  1276.  
  1277. }
  1278.  
  1279. //PREPARING PIVOT VAULT IN BI - BUFFER // catatan: pake vaultid //
  1280. if (pc == null)
  1281. {
  1282. Console.WriteLine("pc kosong");
  1283. }
  1284. var pivotInBiBuffer = pc.GroupBy(c => new { c.vaultId }).Select(g => new
  1285. {
  1286. vaultID = g.Key.vaultId,
  1287. sudahValidasi = g.Where(c => c.validation == "VALIDATED" && c.action.ToLower().Contains("delivery")).Sum(c => c.currencyAmmount),
  1288. belumValidasi = g.Where(c => c.validation == "NOT VALIDATED" && c.action.ToLower().Contains("delivery")).Sum(c => c.currencyAmmount),
  1289. total = g.Where(c => c.validation == "NOT VALIDATED" && c.action.ToLower().Contains("delivery")).Sum(c => c.currencyAmmount) + g.Where(c => c.validation == "VALIDATED" && c.action.ToLower().Contains("delivery")).Sum(c => c.currencyAmmount)
  1290.  
  1291. }).ToList();
  1292.  
  1293. var pivotInBiBufferReady = (from x in pivotInBiBuffer
  1294. select new { vaultID = x.vaultID.Substring(0,4), x.sudahValidasi, x.belumValidasi, x.total }).ToList();
  1295. // dataGridViewIn.DataSource = pivotInBiBuffer;
  1296.  
  1297.  
  1298.  
  1299. //QUERY VAULT IN ATM - BUFFER
  1300. var queryInATMBuffer = (from x in queryVaultATM
  1301. where (x.fundingSoure != "BI" || x.fundingSoure.Contains("OB")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  1302. select x).ToList();
  1303.  
  1304.  
  1305. foreach (var item in queryInATMBuffer)
  1306. {
  1307. pc.Add(new PivotCPC
  1308. {
  1309. vaultId = item.vaultId,
  1310. confId = item.confId,
  1311. action = item.actionRekon,
  1312. status = item.statusRekon,
  1313. blogMessage = item.blogMessage,
  1314. orderDate = ((DateTime)item.orderDate).Date,
  1315. dueDate = ((DateTime)item.dueDate).Date,
  1316. timeStamp = (DateTime)item.timeStampRekon,
  1317. currencyAmmount = Int64.Parse(item.currencyAmmount.ToString()),
  1318. fundingSource = item.fundingSoure,
  1319. realDate = ((DateTime)item.timeStampRekon).Hour < 21 ? ((DateTime)item.timeStampRekon).Date : ((DateTime)item.timeStampRekon).AddDays(1).Date,
  1320. validation = item.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(item.timeStampRekon.ToString()).Hour < 21 ? item.timeStampRekon : DateTime.Parse(item.timeStampRekon.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  1321. });
  1322.  
  1323. }
  1324.  
  1325. //PREPARING PIVOT VAULT IN ATM - BUFFER // catatan: pake vaultid //
  1326. var pivotInAtmBuffer = pc.GroupBy(c => new { c.vaultId, }).Select(g => new
  1327. {
  1328. vaultID = g.Key.vaultId,
  1329. sudahValidasi = g.Where(c => c.validation == "VALIDATED" && c.action.ToLower().Contains("delivery")).Sum(c => c.currencyAmmount),
  1330. belumValidasi = g.Where(c => c.validation == "NOT VALIDATED" && c.action.ToLower().Contains("delivery")).Sum(c => c.currencyAmmount),
  1331. total = g.Where(c => c.validation == "NOT VALIDATED" && c.action.ToLower().Contains("delivery")).Sum(c => c.currencyAmmount) + g.Where(c => c.validation == "VALIDATED" && c.action.ToLower().Contains("delivery")).Sum(c => c.currencyAmmount)
  1332.  
  1333. }).ToList();
  1334.  
  1335. var pivotInAtmBufferReady = (from x in pivotInAtmBuffer
  1336. select new { vaultID = x.vaultID.Substring(0,4), x.sudahValidasi, x.belumValidasi, x.total }).ToList();
  1337.  
  1338. //PENGGABUNGAN PIVOT VAULT IN
  1339. var unionIn = pivotInBiBufferReady.Union(pivotInAtmBufferReady).ToList();
  1340.  
  1341. var inReady = unionIn.GroupBy(z => new { z.vaultID }).Select(q => new
  1342. {
  1343. vaultID = q.Key.vaultID,
  1344. sudahValidasi = q.Sum(z => z.sudahValidasi),
  1345. belumValidasi = q.Sum(z => z.belumValidasi),
  1346. total = q.Sum(z => z.total)
  1347. }).ToList();
  1348.  
  1349. List<PivotVault_In> pivotVault_In = new List<PivotVault_In>();
  1350.  
  1351. foreach (var item in inReady)
  1352. {
  1353. pivotVault_In.Add(new PivotVault_In
  1354. {
  1355. vendor = item.vaultID,
  1356. belumValidasi = item.belumValidasi,
  1357. sudahValidasi = item.sudahValidasi,
  1358. total = item.total
  1359. });
  1360. }
  1361.  
  1362.  
  1363. dataGridViewIn.DataSource = pivotVault_In;
  1364.  
  1365. //END OF IN
  1366.  
  1367.  
  1368. //QUERY VAULT OUT BI- BUFFER
  1369. var queryOutBIBuffer = (from x in queryVaultBI
  1370. where (x.fundingSoure == "BI" || x.fundingSoure.Contains("OB")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  1371. select x).ToList();
  1372.  
  1373. List<PivotCPC> cp = new List<PivotCPC>();
  1374.  
  1375. foreach (var item in queryOutBIBuffer)
  1376. {
  1377. cp.Add(new PivotCPC
  1378. {
  1379. vaultId = item.vaultId,
  1380. confId = item.confId,
  1381. action = item.actionRekon,
  1382. status = item.statusRekon,
  1383. blogMessage = item.blogMessage,
  1384. orderDate = ((DateTime)item.orderDate).Date,
  1385. dueDate = ((DateTime)item.dueDate).Date,
  1386. timeStamp = (DateTime)item.timeStampRekon,
  1387. currencyAmmount = Int64.Parse(item.currencyAmmount.ToString()),
  1388. fundingSource = item.fundingSoure,
  1389. realDate = ((DateTime)item.timeStampRekon).Hour < 21 ? ((DateTime)item.timeStampRekon).Date : ((DateTime)item.timeStampRekon).AddDays(1).Date,
  1390. validation = item.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(item.timeStampRekon.ToString()).Hour < 21 ? item.timeStampRekon : DateTime.Parse(item.timeStampRekon.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  1391. });
  1392.  
  1393. }
  1394.  
  1395. //PREPARING PIVOT VAULT OUT BI - BUFFER // catatan: pake vaultid //
  1396. var pivotOutBiBuffer = cp.GroupBy(c => new { c.vaultId }).Select(g => new
  1397. {
  1398. vaultID = g.Key.vaultId,
  1399. sudahValidasi = g.Where(c => c.validation == "VALIDATED" && c.action.ToLower().Contains("return")).Sum(c => c.currencyAmmount),
  1400. belumValidasi = g.Where(c => c.validation == "NOT VALIDATED" && c.action.ToLower().Contains("return")).Sum(c => c.currencyAmmount),
  1401. total = g.Where(c => c.validation == "VALIDATED" && c.action.ToLower().Contains("return")).Sum(c => c.currencyAmmount) + g.Where(c => c.validation == "NOT VALIDATED" && c.action.ToLower().Contains("return")).Sum(c => c.currencyAmmount)
  1402.  
  1403. }).ToList();
  1404.  
  1405. var pivotOutBiBufferReady = (from x in pivotOutBiBuffer
  1406. select new { vaultID = x.vaultID.Substring(0, 4), x.sudahValidasi, x.belumValidasi, x.total }).ToList();
  1407.  
  1408.  
  1409. //QUERY VAULT OUT ATM - BUFFER
  1410. var queryOutAtmBuffer = (from x in queryVaultATM
  1411. where (x.fundingSoure != "BI" || x.fundingSoure.Contains("OB")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  1412. select x).ToList();
  1413.  
  1414.  
  1415. foreach (var item in queryOutAtmBuffer)
  1416. {
  1417. pc.Add(new PivotCPC
  1418. {
  1419. vaultId = item.vaultId,
  1420. confId = item.confId,
  1421. action = item.actionRekon,
  1422. status = item.statusRekon,
  1423. blogMessage = item.blogMessage,
  1424. orderDate = ((DateTime)item.orderDate).Date,
  1425. dueDate = ((DateTime)item.dueDate).Date,
  1426. timeStamp = (DateTime)item.timeStampRekon,
  1427. currencyAmmount = Int64.Parse(item.currencyAmmount.ToString()),
  1428. fundingSource = item.fundingSoure,
  1429. realDate = ((DateTime)item.timeStampRekon).Hour < 21 ? ((DateTime)item.timeStampRekon).Date : ((DateTime)item.timeStampRekon).AddDays(1).Date,
  1430. validation = item.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(item.timeStampRekon.ToString()).Hour < 21 ? item.timeStampRekon : DateTime.Parse(item.timeStampRekon.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  1431. });
  1432.  
  1433. }
  1434.  
  1435. //PREPARING PIVOT VAULT OUT ATM - BUFFER // catatan: pake vaultid //
  1436. var pivotOutAtmBuffer = pc.GroupBy(c => new { c.vaultId, }).Select(g => new
  1437. {
  1438. vaultID = g.Key.vaultId,
  1439. sudahValidasi = g.Where(c => c.validation == "VALIDATED" && c.action.ToLower().Contains("return")).Sum(c => c.currencyAmmount),
  1440. belumValidasi = g.Where(c => c.validation == "NOT VALIDATED" && c.action.ToLower().Contains("return")).Sum(c => c.currencyAmmount),
  1441. total = g.Where(c => c.validation == "VALIDATED" && c.action.ToLower().Contains("return")).Sum(c => c.currencyAmmount) + g.Where(c => c.validation == "NOT VALIDATED" && c.action.ToLower().Contains("return")).Sum(c => c.currencyAmmount)
  1442.  
  1443. }).ToList();
  1444.  
  1445. var pivotOutAtmBufferReady = (from x in pivotOutAtmBuffer
  1446. select new { vaultID = x.vaultID.Substring(0, 4), x.sudahValidasi, x.belumValidasi, x.total }).ToList();
  1447.  
  1448. //PENGGABUNGAN PIVOT VAULT OUT
  1449. var unionOut = pivotOutBiBufferReady.Union(pivotOutAtmBufferReady).ToList();
  1450.  
  1451. var outReady = unionOut.GroupBy(z => new { z.vaultID }).Select(q => new
  1452. {
  1453. vaultID = q.Key.vaultID,
  1454. sudahValidasi = q.Sum(z => z.sudahValidasi),
  1455. belumValidasi = q.Sum(z => z.belumValidasi),
  1456. total = q.Sum(z => z.total)
  1457. }).ToList();
  1458.  
  1459. List<PivotVault_Out> pivotVault_Out = new List<PivotVault_Out>();
  1460.  
  1461. foreach (var item in outReady)
  1462. {
  1463. pivotVault_Out.Add(new PivotVault_Out
  1464. {
  1465. vendor = item.vaultID,
  1466. belumValidasi = item.belumValidasi,
  1467. sudahValidasi = item.sudahValidasi,
  1468. total = item.total
  1469. });
  1470. }
  1471. dataGridViewOut.DataSource = pivotVault_Out;
  1472. //end of test
  1473. }
  1474.  
  1475. public void pivotPerVendor()
  1476. {
  1477. var queryPerVendor = (from x in en.RekonSaldoPerVendors.AsEnumerable()
  1478. join y in en.Pkts.AsEnumerable() on x.vendor.Substring(0, 4) equals y.kodePktCabang == "CCASA" ? "CCAS" : y.kodePktCabang
  1479. where !String.IsNullOrEmpty(x.vendor) && y.kanwil.Like("Jabotabek")
  1480. select x).ToList();
  1481.  
  1482. //QUERY PER VENDOR IN
  1483. var queryIn = (from x in queryPerVendor
  1484. where (x.actionRekon.Contains("Return") && x.statusRekon.Equals("In Transit")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  1485. select new
  1486. {
  1487. cashPointId = x.cashPointtId,
  1488. confId = x.confId,
  1489. orderDate = x.orderDate,
  1490. vendor = x.vendor.Substring(0,4),
  1491. actionRekon = x.actionRekon,
  1492. statusRekon = x.statusRekon,
  1493. dueDate = x.dueDate,
  1494. blogTime = x.blogTime,
  1495. currencyAmmount = x.currencyAmmount,
  1496. realDate = x.realDate,
  1497. blogMessage = x.blogMessage,
  1498. validation = x.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(x.blogTime.ToString()).Hour < 21 ? x.blogTime : DateTime.Parse(x.blogTime.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  1499. }).ToList();
  1500.  
  1501. //GENERATING PIVOT IN
  1502. var pivotIn = queryIn.GroupBy(c => new { c.vendor }).Select(g => new
  1503. {
  1504. vendor = g.Key.vendor,
  1505. belumValidasi = g.Where(c => c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount),
  1506. sudahValidasi = g.Where(c => c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  1507. total = g.Where(c => c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount) +
  1508. g.Where(c => c.validation == "VALIDATED").Sum(c => c.currencyAmmount)
  1509.  
  1510. }).ToList();
  1511.  
  1512. List<PivotPerVendor_In> pivotPerVendor_In = new List<PivotPerVendor_In>();
  1513.  
  1514. foreach (var item in pivotIn)
  1515. {
  1516. pivotPerVendor_In.Add(new PivotPerVendor_In
  1517. {
  1518. vendor = item.vendor,
  1519. belumValidasi = (Int64)item.belumValidasi,
  1520. sudahValidasi = (Int64)item.sudahValidasi,
  1521. total = (Int64)item.total,
  1522. });
  1523. }
  1524.  
  1525. dataGridViewIn.DataSource = pivotPerVendor_In;
  1526.  
  1527. //QUERY PER VENDOR OUT
  1528.  
  1529. var queryOut = (from x in queryPerVendor
  1530. where (x.actionRekon.Contains("Delivery") && x.statusRekon.Equals("Confirmed")) && (((DateTime)x.dueDate).Date == dateTimePicker2.Value.Date || ((DateTime)x.realDate).Date == dateTimePicker2.Value.Date)
  1531. select new
  1532. {
  1533. cashPointId = x.cashPointtId,
  1534. confId = x.confId,
  1535. orderDate = x.orderDate,
  1536. vendor = x.vendor.Substring(0,4),
  1537. actionRekon = x.actionRekon,
  1538. statusRekon = x.statusRekon,
  1539. dueDate = x.dueDate,
  1540. blogTime = x.blogTime,
  1541. currencyAmmount = x.currencyAmmount,
  1542. realDate = x.realDate,
  1543. blogMessage = x.blogMessage,
  1544. validation = x.blogMessage.Contains("GL") ? (DateTime.Parse((DateTime.Parse(x.blogTime.ToString()).Hour < 21 ? x.blogTime : DateTime.Parse(x.blogTime.ToString()).AddDays(1)).ToString()).Date <= DateTime.Parse(dateTimePicker2.Value.ToString()).Date ? "VALIDATED" : "NOT VALIDATED") : "NOT VALIDATED"
  1545. }).ToList();
  1546.  
  1547. //GENERATING PIVOT OUT
  1548. var pivotOut = queryOut.GroupBy(c => new { c.vendor }).Select(g => new
  1549. {
  1550. vendor = g.Key.vendor,
  1551. belumValidasi = g.Where(c => c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount),
  1552. sudahValidasi = g.Where(c => c.validation == "VALIDATED").Sum(c => c.currencyAmmount),
  1553. total = g.Where(c => c.validation == "NOT VALIDATED").Sum(c => c.currencyAmmount) +
  1554. g.Where(c => c.validation == "VALIDATED").Sum(c => c.currencyAmmount)
  1555.  
  1556. }).ToList();
  1557.  
  1558. List<PivotPerVendor_Out> pivotPerVendor_Out = new List<PivotPerVendor_Out>();
  1559.  
  1560. foreach (var item in pivotOut)
  1561. {
  1562. pivotPerVendor_Out.Add(new PivotPerVendor_Out
  1563. {
  1564. vendor = item.vendor,
  1565. belumValidasi = (Int64)item.belumValidasi,
  1566. sudahValidasi = (Int64)item.sudahValidasi,
  1567. total = (Int64)item.total,
  1568. });
  1569. }
  1570. dataGridViewOut.DataSource = pivotPerVendor_Out;
  1571. }
  1572.  
  1573. private void buttonVault_Click(object sender, EventArgs e)
  1574. {
  1575. pivotVault();
  1576. if (dataGridViewIn.Rows.Count > 0)
  1577. {
  1578. for (int i = 1; i < dataGridViewIn.Columns.Count; i++)
  1579. {
  1580. dataGridViewIn.Columns[i].DefaultCellStyle.Format = "c";
  1581. dataGridViewIn.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  1582. }
  1583. }
  1584. if (dataGridViewOut.Rows.Count > 0)
  1585. {
  1586. for (int i = 1; i < dataGridViewOut.Columns.Count; i++)
  1587. {
  1588. dataGridViewOut.Columns[i].DefaultCellStyle.Format = "c";
  1589. dataGridViewOut.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  1590. }
  1591. }
  1592.  
  1593. }
  1594.  
  1595. private void buttonPerVendor_Click(object sender, EventArgs e)
  1596. {
  1597. pivotPerVendor();
  1598. if (dataGridViewIn.Rows.Count > 0)
  1599. {
  1600. for (int i = 1; i < dataGridViewIn.Columns.Count; i++)
  1601. {
  1602. dataGridViewIn.Columns[i].DefaultCellStyle.Format = "c";
  1603. dataGridViewIn.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  1604. }
  1605. }
  1606. if (dataGridViewOut.Rows.Count > 0)
  1607. {
  1608. for (int i = 1; i < dataGridViewOut.Columns.Count; i++)
  1609. {
  1610. dataGridViewOut.Columns[i].DefaultCellStyle.Format = "c";
  1611. dataGridViewOut.Columns[i].DefaultCellStyle.FormatProvider = CultureInfo.GetCultureInfo("ID-id");
  1612. }
  1613. }
  1614. }
  1615.  
  1616. private void buttonAll_Click(object sender, EventArgs e)
  1617. {
  1618. pivotVault();
  1619. pivotPerVendor();
  1620.  
  1621.  
  1622. }
  1623. }
  1624.  
  1625.  
  1626.  
  1627.  
  1628. class VOBH //vault order blog history
  1629. {
  1630. public String vaultId { set; get; }
  1631. public String confId { set; get; }
  1632. public DateTime orderDate { set; get; }
  1633. public DateTime dueDate { set; get; }
  1634. public DateTime timeStamp { set; get; }
  1635. public String blogMessage { set; get; }
  1636. public String action { set; get; }
  1637. public String status { set; get; }
  1638. public Int64 currencyAmmount { set; get; }
  1639. }
  1640.  
  1641. class VO //vault order
  1642. {
  1643. public String vaultId { set; get; }
  1644. public String confId { set; get; }
  1645. public String fundingSource { set; get; }
  1646. public DateTime orderDate { set; get; }
  1647. public DateTime dueDate { set; get; }
  1648. public String action { set; get; }
  1649. public String status { set; get; }
  1650. public Int64 currencyAmmount { set; get; }
  1651. }
  1652.  
  1653. class VaultProcessed //class menampung proses vault
  1654. {
  1655. public String vaultId { set; get; }
  1656. public String confId { set; get; }
  1657. public String fundingSource { set; get; }
  1658. public String action { set; get; }
  1659. public String status { set; get; }
  1660. public DateTime orderDate { set; get; }
  1661. public DateTime dueDate { set; get; }
  1662. public DateTime timeStamp { set; get; }
  1663. public String blogMessage { set; get; }
  1664. public Int64 currencyAmmount { set; get; }
  1665. public DateTime realDate { set; get; }
  1666. public String validation { set; get; }
  1667.  
  1668. }
  1669.  
  1670. class SetoranCPC //class menampung setoran cpc (vaultprocessed yang sudah di proses)
  1671. {
  1672. public String vaultId { set; get; }
  1673. public String confId { set; get; }
  1674. public String fundingSource { set; get; }
  1675. public String action { set; get; }
  1676. public String status { set; get; }
  1677. public DateTime orderDate { set; get; }
  1678. public DateTime dueDate { set; get; }
  1679. public DateTime timeStamp { set; get; }
  1680. public String blogMessage { set; get; }
  1681. public Int64 currencyAmmount { set; get; }
  1682. public DateTime realDate { set; get; }
  1683. public String validation { set; get; }
  1684.  
  1685. }
  1686.  
  1687. class OBH //order blog history
  1688. {
  1689. public String cashpointId { set; get; }
  1690. public String confId { set; get; }
  1691. public DateTime orderDate { set; get; }
  1692. public DateTime dueDate { set; get; }
  1693. public DateTime blogTime { set; get; }
  1694. public String action { set; get; }
  1695. public String status { set; get; }
  1696. public Int64 currencyAmmount { set; get; }
  1697. public String blogMessage { set; get; }
  1698. }
  1699.  
  1700. class OBHProcessed //obh yang di proses
  1701. {
  1702. public String cashpointId { set; get; }
  1703. public String vendor { set; get; }
  1704. public String confId { set; get; }
  1705. public DateTime orderDate { set; get; }
  1706. public DateTime dueDate { set; get; }
  1707. public DateTime blogTime { set; get; }
  1708. public String blogMessage { set; get; }
  1709. public String action { set; get; }
  1710. public String status { set; get; }
  1711. public Int64 currencyAmmount { set; get; }
  1712. public DateTime realDate { set; get; }
  1713. public String validation { set; get; }
  1714. }
  1715.  
  1716. class PivotCPC //class pivotCPC (canvas for detailed pivot)
  1717. {
  1718. public String vaultId { set; get; }
  1719. public String confId { set; get; }
  1720. public String fundingSource { set; get; }
  1721. public String action { set; get; }
  1722. public String status { set; get; }
  1723. public DateTime orderDate { set; get; }
  1724. public DateTime dueDate { set; get; }
  1725. public DateTime timeStamp { set; get; }
  1726. public String blogMessage { set; get; }
  1727. public Int64 currencyAmmount { set; get; }
  1728. public DateTime realDate { set; get; }
  1729. public String validation { set; get; }
  1730.  
  1731. }
  1732.  
  1733. class PivotCPC_BIBL //pivotCPC - BI dan BankLain return
  1734. {
  1735. public DateTime dueDate { set; get; }
  1736. public DateTime realDate { set; get; }
  1737. public String vaultId { set; get; }
  1738. public String fundingSource { set; get; }
  1739. // public Int64 plannedReturn { set; get; }
  1740. public Int64 plannedReturnVal { set; get; }
  1741. public Int64 plannedReturnNotVal { set; get; }
  1742. // public Int64 emergencyReturn { set; get; }
  1743. public Int64 emergencyReturnVal { set; get; }
  1744. public Int64 emergencyReturnNotVal { set; get; }
  1745. public Int64 grandTotal { set; get; }
  1746.  
  1747. }
  1748.  
  1749. class PivotCPC_BIBLD//pivotCPC - BI dan BankLain delivery
  1750. {
  1751. public DateTime dueDate { set; get; }
  1752. public DateTime realDate { set; get; }
  1753. public String vaultId { set; get; }
  1754. public String fundingSource { set; get; }
  1755. // public Int64 plannedDelivery { set; get; }
  1756. public Int64 plannedDeliveryVal { set; get; }
  1757. public Int64 plannedDeliveryNotVal { set; get; }
  1758. // public Int64 emergencyDelivery { set; get; }
  1759. public Int64 emergencyDeliveryVal { set; get; }
  1760. public Int64 emergencyDeliveryNotVal { set; get; }
  1761. public Int64 grandTotal { set; get; }
  1762.  
  1763. }
  1764.  
  1765. class PivotCPC_ATMD //pivotcpc - atm delivery
  1766. {
  1767. public DateTime dueDate { set; get; }
  1768. public DateTime realDate { set; get; }
  1769. public String vaultId { set; get; }
  1770. public String fundingSource { set; get; }
  1771. // public Int64 plannedDelivery { set; get; }
  1772. public Int64 plannedDeliveryVal { set; get; }
  1773. public Int64 plannedDeliveryNotVal { set; get; }
  1774. // public Int64 emergencyDelivery { set; get; }
  1775. public Int64 emergencyDeliveryVal { set; get; }
  1776. public Int64 emergencyDeliveryNotVal { set; get; }
  1777. public Int64 grandTotal { set; get; }
  1778.  
  1779. }
  1780.  
  1781. class PivotCPC_ATMR //pivotcpc - atm return
  1782. {
  1783. public DateTime dueDate { set; get; }
  1784. public DateTime realDate { set; get; }
  1785. public String vaultId { set; get; }
  1786. public String fundingSource { set; get; }
  1787. //public Int64 plannedReturn { set; get; }
  1788. public Int64 plannedReturnVal { set; get; }
  1789. public Int64 plannedReturnNotVal { set; get; }
  1790. //public Int64 emergencyReturn { set; get; }
  1791. public Int64 emergencyReturnVal { set; get; }
  1792. public Int64 emergencyReturnNotVal { set; get; }
  1793. public Int64 grandTotal { set; get; }
  1794.  
  1795. }
  1796.  
  1797. class PivotPerVendor_bon
  1798. {
  1799. public DateTime dueDate { set; get; }
  1800. public DateTime valDate { set; get; }
  1801. public String vendor { set; get; }
  1802. public Int64 belumValidasi { set; get; }
  1803. public Int64 sudahValidasi { set; get; }
  1804. public Int64 grandTotal { set; get; }
  1805.  
  1806. }
  1807.  
  1808. class PivotPerVendor_setoran
  1809. {
  1810. public DateTime dueDate { set; get; }
  1811. public DateTime valDate { set; get; }
  1812. public String vendor { set; get; }
  1813. public Int64 belumValidasi { set; get; }
  1814. public Int64 sudahValidasi { set; get; }
  1815. public Int64 grandTotal { set; get; }
  1816.  
  1817. }
  1818.  
  1819. class PivotPerVendor_In
  1820. {
  1821. public String vendor { set; get; }
  1822. public Int64 belumValidasi { set; get; }
  1823. public Int64 sudahValidasi { set; get; }
  1824. public Int64 total { set; get; }
  1825. }
  1826.  
  1827. class PivotPerVendor_Out
  1828. {
  1829. public String vendor { set; get; }
  1830. public Int64 belumValidasi { set; get; }
  1831. public Int64 sudahValidasi { set; get; }
  1832. public Int64 total { set; get; }
  1833. }
  1834.  
  1835. class PivotVault_In
  1836. {
  1837. public String vendor { set; get; }
  1838. public Int64 belumValidasi { set; get; }
  1839. public Int64 sudahValidasi { set; get; }
  1840. public Int64 total { set; get; }
  1841. }
  1842. class PivotVault_Out
  1843. {
  1844. public String vendor { set; get; }
  1845. public Int64 belumValidasi { set; get; }
  1846. public Int64 sudahValidasi { set; get; }
  1847. public Int64 total { set; get; }
  1848. }
  1849. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement