public void RefreshData(Guid _RowID) { try { this.Cursor = Cursors.WaitCursor; using (Database db = new Database()) { DataTable dt = new DataTable(); db.Commands.Add(db.CreateCommand("usp_PembayaranMPM_LIST_FILTER_Tanggal")); db.Commands[0].Parameters.Add(new Parameter("@FromDate", SqlDbType.Date, _fromDate)); db.Commands[0].Parameters.Add(new Parameter("@ToDate", SqlDbType.Date, _toDate)); db.Commands[0].Parameters.Add(new Parameter("@PerusahaanDariRowID", SqlDbType.UniqueIdentifier, GlobalVar.PerusahaanRowID)); dt = db.Commands[0].ExecuteDataTable(); GVHeader.DataSource = dt; dtHeader = dt; } if (GVHeader.Rows.Count > 0) { GVHeader.FindRow("RowID", _RowID.ToString()); refreshDetail(); } } catch (Exception ex) { Error.LogError(ex); } finally { this.Cursor = Cursors.Default; } }
public void RefreshHeader(Guid RowID) { try { DataTable dtHeader = new DataTable(); using (Database db = new Database()) { db.Commands.Add(db.CreateCommand("usp_IdenPengajuanBBN_ListHeader")); db.Commands[0].Parameters.Add(new Parameter("@fromdate", SqlDbType.DateTime, rangeDateBox1.FromDate.Value)); db.Commands[0].Parameters.Add(new Parameter("@todate", SqlDbType.DateTime, rangeDateBox1.ToDate.Value)); dtHeader = db.Commands[0].ExecuteDataTable(); } GVHeader.DataSource = dtHeader; if (dtHeader.Rows.Count > 0) { if (RowID != Guid.Empty) { GVHeader.FindRow("RowID", RowID.ToString()); } } else { GVDetail.DataSource = null; } } catch (Exception ex) { Error.LogError(ex); } }
public void RefreshHeader(Guid RowID) { dtHeader = new DataTable(); using (Database db = new Database()) { db.Commands.Add(db.CreateCommand("usp_PenerimaanLeasingHeader")); db.Commands[0].Parameters.Add(new Parameter("@FromDate", SqlDbType.DateTime, rangeDateBox1.FromDate)); db.Commands[0].Parameters.Add(new Parameter("@ToDate", SqlDbType.DateTime, rangeDateBox1.ToDate)); dtHeader = db.Commands[0].ExecuteDataTable(); } GVHeader.DataSource = dtHeader; if (RowID != Guid.Empty) { GVHeader.FindRow("RowID", RowID.ToString()); } }
private void GetData() { Form thisx = this; if (ipProgress == null) { ipProgress = new InPopup(this, pnlProgress); } if (fpProgress == null) { fpProgress = new FakeProgress(progbProgress); } BackgroundWorker bgw = new BackgroundWorker(); bgw.DoWork += (a, b) => { fpProgress.Start(); JSON opt = new JSON(JSONType.Object); opt.ObjAdd("gudang", new JSON(InitGudang)); opt.ObjAdd("fromdate", new JSON(rangeDateBox1.FromDate.Value.ToString("yyyy-MM-dd"))); opt.ObjAdd("todate", new JSON(rangeDateBox1.ToDate.Value.ToString("yyyy-MM-dd"))); string host = "http://devwiserdc.sas-autoparts.com:8000"; using (var db = new Database()) { db.Commands.Add(db.CreateCommand("[usp_AppSetting_LIST]")); db.Commands[0].Parameters.Add(new Parameter("@Key", SqlDbType.VarChar, "WiserDC_Host")); DataTable dtbl = db.Commands[0].ExecuteDataTable(); if (dtbl.Rows.Count > 0) { host = dtbl.Rows[0]["Value"].ToString(); } else { MessageBox.Show("Wiser belum di setting"); return; } } XNet xn = new XNet(host + "/api/koreksipenjualan/get", XNetMethod.GET); //XNet xn = new XNet("https://postman-echo.com/get", XNetMethod.GET); XNetThread xnt = xn.Send(opt, c => { if (bgw.CancellationPending) { return; } ///return; try { if (c.Error != null) { throw new Exception("Terjadi error: " + c.Error.Message); } else if (c.Output.Length > 0) { JSON jdat = JSON.Parse(c.Output); if (jdat.Type == JSONType.Object) { if (jdat.ObjExists("Result") && jdat["Result"].BoolValue) { if (jdat.ObjExists("Data")) { DataTable dtbl0 = new DataTable(); DataTable dtbl1 = new DataTable(); //return; dtbl0.Columns.Add("check"); foreach (string k in jdat["Data"].ObjKeys) { JSON cur = jdat["Data"][k]; List <object> itm = new List <object>(); itm.Add(true); foreach (string k2 in cur.ObjKeys) { switch (k2) { case "Details": // do nothing break; default: if (dtbl0.Rows.Count <= 0) { dtbl0.Columns.Add(k2); } itm.Add(cur[k2].Value); break; } } dtbl0.Rows.Add(itm.ToArray()); } dset = new DataSet(); mdat = jdat["Data"]; dset.Tables.Add(dtbl0); GVHeader.Invoke(new Action(() => GVHeader.DataSource = dset.Tables[0])); b.Result = true; return; } throw new Exception("Response server is not expected"); } else { if (jdat.ObjExists("Msg")) { throw new Exception("Server error: " + jdat["Msg"]); } else { throw new Exception(jdat.ToString()); } } } else { throw new Exception(c.Output); } } else { throw new Exception("Tidak ada response dari server"); } } catch (Exception ex) { b.Result = ex.Message; } }); while (xnt.OnWorking) { if (bgw.CancellationPending) { b.Cancel = true; xnt.Cancel(); break; } } ; if (b.Result != null && !b.Result.Equals(true)) { MessageBox.Show(b.Result.ToString()); return; } //throw new Exception(b.Result.ToString()); }; bgw.RunWorkerCompleted += (a, b) => { bool r = false; if (b.Cancelled) { MessageBox.Show(thisx, "Operasi di gagalkan"); } else if (b.Error != null) { MessageBox.Show(thisx, b.Error.Message); } else { r = true; } ipProgress.Close(r); }; ipProgress.OpenDialog(this, a => { }, () => bgw.CancelAsync()); bgw.RunWorkerAsync(); }