protected void upload_Click(object sender, System.EventArgs e) { if (valid) { if (!file.PostedFile.FileName.EndsWith(".xls")) { Js.Alert( this , "Proses Upload Gagal.\\n" + "File yang boleh di-upload adalah file dengan extension .xls saja." , "" ); } else { string path = Request.PhysicalApplicationPath + "Template\\FP_" + Session.SessionID + ".xls"; Dfc.UploadFile(".xls", path, file); Cek(path); //Hapus file sementara tersebut dari hard-disk server Dfc.DeleteFile(path); } } }
protected void save_Click(object sender, System.EventArgs e) { if (datavalid()) { for (int i = 0; i < rsTagihan.Rows.Count; i++) { TextBox lunas = (TextBox)ph.FindControl("lunas_" + i); TextBox va = (TextBox)ph.FindControl("va_" + i); TextBox tgl = (TextBox)ph.FindControl("tgl_" + i); TextBox nokontrak = (TextBox)ph.FindControl("ref_" + i); TextBox cs = (TextBox)ph.FindControl("cs_" + i); TextBox unit = (TextBox)ph.FindControl("unit_" + i); TextBox tag = (TextBox)ph.FindControl("tag_" + i); //int z = Db.SingleInteger("SELECT COUNT(NoBKM) FROM MS_TTS WHERE NoBKM != '' AND YEAR(TglBKM) = " + Convert.ToDateTime(tgl.Text).Year); string c1 = Db.SingleString("SELECT TOP 1 SUBSTRING(NoBKM,5,6) FROM MS_TTS ORDER BY NoBKM DESC"); int z = Convert.ToInt32(c1); string nobkm = ""; bool hasfound = false; while (!hasfound) { if (!Response.IsClientConnected) { break; } z += 1; //nopjt = c.ToString() + "/" + u + "/" + Convert.ToDateTime(tgl.Text).Year; nobkm = "DMC/" + z.ToString().PadLeft(6, '0') + "/" + Cf.Roman(Convert.ToDateTime(tgl.Text).Month) + "/" + Convert.ToDateTime(tgl.Text).Year + "/RC"; if (isUnique(nobkm)) { hasfound = true; } } string NoBKM2 = nobkm; if (lunas.Text != "") { Db.Execute("EXEC spTTSRegistrasi" + " '" + Convert.ToDateTime(tgl.Text) + "'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'JUAL'" + ",'" + Cf.Str(nokontrak.Text) + "'" + ",'" + Cf.Str(unit.Text) + "'" + ",'" + Cf.Str(cs.Text) + "'" + ",'TR'" + ",'VA: " + Cf.Str(va.Text) + "'" ); int NoTTS = Db.SingleInteger("SELECT TOP 1 NoTTS FROM MS_TTS ORDER BY NoTTS DESC"); Db.Execute("UPDATE MS_TTS" + " SET Acc = '" + Bank + "'" + " WHERE NoTTS = " + NoTTS ); string[] arr = tag.Text.Split(';'); Db.Execute("EXEC spTTSAlokasi " + " " + NoTTS + ", " + arr[0] + ", " + Convert.ToDecimal(lunas.Text) ); Db.Execute("EXEC spPostingTTS " + NoTTS + ", '" + NoBKM2 + "', '" + Convert.ToDateTime(tgl.Text) + "'"); Db.Execute("UPDATE MS_TTS" + " SET ManualBKM = ManualTTS" + ", TanggalUangDiterima = TglBKM" + " WHERE NoTTS = " + NoTTS); //Ambil Stok No. FP DataTable fp = Db.Rs("SELECT * FROM REF_FP WHERE Status = 0"); if (fp.Rows.Count > 0) { Db.Execute("UPDATE MS_TTS SET" + " NoFPS = '" + fp.Rows[0]["NoFPS"].ToString() + "'" + " WHERE NoTTS = " + NoTTS); Db.Execute("UPDATE REF_FP SET" + " Status = 1" + " WHERE NoFPS = '" + fp.Rows[0]["NoFPS"].ToString() + "'"); } string NoBKM3 = Db.SingleString("SELECT NoBKM FROM MS_TTS WHERE NoTTS = " + NoTTS); DataTable rsLog = Db.Rs("SELECT " + " CONVERT(varchar, TglTTS, 106) AS [Tanggal]" + ",Tipe" + ",Ref AS [Ref.]" + ",Unit" + ",Customer" + ",CaraBayar AS [Cara Bayar]" + ",Ket AS [Keterangan]" + ",Total" + ",NoBG AS [No. BG]" + ",CONVERT(varchar, TglBG, 106) AS [Tanggal BG]" + ", Acc AS [Rekening Bank]" + " FROM MS_TTS WHERE NoTTS = " + NoTTS); string KetLog = Cf.LogCapture(rsLog) + "<br>***ALOKASI PEMBAYARAN:<br>" + arr[1] + " (" + arr[2] + ")"; Db.Execute("EXEC spLogTTS" + " 'VA'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'" + KetLog + "'" + ",'" + NoTTS.ToString().PadLeft(7, '0') + "'" ); decimal LogID = Db.SingleDecimal("SELECT TOP 1 LogID FROM MS_TTS_LOG ORDER BY LogID DESC"); string Project = Db.SingleString("SELECT Project FROM " + Mi.DbPrefix + "MARKETINGJUAL..MS_KONTRAK WHERE NoKontrak = (SELECT Ref FROM MS_TTS WHERE NoTTS = '" + NoTTS + "')"); Db.Execute("UPDATE MS_TTS_LOG SET Project = '" + Project + "' WHERE LogID = " + LogID); // Db.Execute("EXEC " + Mi.DbPrefix + "MARKETINGJUAL..spDenda"); //Result TableRow r = new TableRow(); TableCell c; c = new TableCell(); c.Text = va.Text; r.Cells.Add(c); c = new TableCell(); c.Text = Cf.Day(tgl.Text); r.Cells.Add(c); c = new TableCell(); c.Text = "<a href=\"javascript:call('" + NoTTS + "')\">" + NoTTS.ToString().PadLeft(7, '0') + "</a>" + "<br /><i>POST</i>" + "<br />BKM: " + NoBKM3; r.Cells.Add(c); c = new TableCell(); c.Text = "JUAL No. " + nokontrak.Text + "<br />" + unit.Text + "<br />" + cs.Text; r.Cells.Add(c); c = new TableCell(); c.Text = Cf.Num(lunas.Text); c.HorizontalAlign = HorizontalAlign.Right; r.Cells.Add(c); Rpt.Border(r); rpt.Rows.Add(r); } } div1.Visible = false; div2.Visible = true; feed.Text = "<img src='/Media/db.gif' align=absmiddle> " + "Upload Success.." ; Dfc.DeleteFile(FilePath); } }
protected void save_Click(object sender, System.EventArgs e) { string ID = ""; if (datavalid()) { for (int i = 0; i < rsTagihan.Rows.Count; i++) { TextBox lunas = (TextBox)ph.FindControl("lunas_" + i); TextBox bulat = (TextBox)ph.FindControl("pembulatan_" + i); TextBox lebihbayar = (TextBox)ph.FindControl("lebihbayar_" + i); TextBox va = (TextBox)ph.FindControl("va_" + i); TextBox tgl = (TextBox)ph.FindControl("tgl_" + i); TextBox nokontrak = (TextBox)ph.FindControl("ref_" + i); TextBox cs = (TextBox)ph.FindControl("cs_" + i); TextBox unit = (TextBox)ph.FindControl("unit_" + i); TextBox tag = (TextBox)ph.FindControl("tag_" + i); TextBox notag = (TextBox)ph.FindControl("notag_" + i); TextBox namatag = (TextBox)ph.FindControl("namatag_" + i); if (lunas.Text != "") { #region Db.Execute("EXEC spTTSRegistrasi" + " '" + Convert.ToDateTime(tgl.Text) + "'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'JUAL'" + ",'" + Cf.Str(nokontrak.Text) + "'" + ",'" + Cf.Str(unit.Text) + "'" + ",'" + Cf.Str(cs.Text) + "'" + ",'TR'" + ",'VA: " + Cf.Str(va.Text) + "'" ); int NoTTS = Db.SingleInteger("SELECT TOP 1 NoTTS FROM MS_TTS ORDER BY NoTTS DESC"); Db.Execute("UPDATE MS_TTS" + " SET Acc = '" + Bank + "'" + " WHERE NoTTS = " + NoTTS ); string[] arr = tag.Text.Split(';'); Db.Execute("EXEC spTTSAlokasi " + " " + NoTTS + ", " + arr[0] + ", " + Convert.ToDecimal(lunas.Text) ); Db.Execute("EXEC spPostingTTS " + NoTTS + ", '" + Convert.ToDateTime(tgl.Text) + "'"); decimal LB = Convert.ToDecimal(lebihbayar.Text); decimal B = Convert.ToDecimal(bulat.Text); Db.Execute("UPDATE MS_TTS" + " SET ManualBKM = ManualTTS" + ", TanggalUangDiterima = TglBKM" + ", LB = " + LB + ", LebihBayar = " + B + " WHERE NoTTS = " + NoTTS); //Ambil Stok No. FP DataTable fp = Db.Rs("SELECT * FROM REF_FP WHERE Status = 0"); if (fp.Rows.Count > 0) { Db.Execute("UPDATE MS_TTS SET" + " NoFPS = '" + fp.Rows[0]["NoFPS"].ToString() + "'" + " WHERE NoTTS = " + NoTTS); Db.Execute("UPDATE REF_FP SET" + " Status = 1" + " WHERE NoFPS = '" + fp.Rows[0]["NoFPS"].ToString() + "'"); } int NoBKM = Db.SingleInteger("SELECT NoBKM FROM MS_TTS WHERE NoTTS = " + NoTTS); DataTable rsLog = Db.Rs("SELECT " + " CONVERT(varchar, TglTTS, 106) AS [Tanggal]" + ",Tipe" + ",Ref AS [Ref.]" + ",Unit" + ",Customer" + ",CaraBayar AS [Cara Bayar]" + ",Ket AS [Keterangan]" + ",Total" + ",NoBG AS [No. BG]" + ",CONVERT(varchar, TglBG, 106) AS [Tanggal BG]" + ", Acc AS [Rekening Bank]" + " FROM MS_TTS WHERE NoTTS = " + NoTTS); string KetLog = Cf.LogCapture(rsLog) + "<br>***ALOKASI PEMBAYARAN:<br>" + arr[1] + " (" + arr[2] + ")"; Db.Execute("EXEC spLogTTS" + " 'VA'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'" + KetLog + "'" + ",'" + NoTTS.ToString().PadLeft(7, '0') + "'" ); decimal LogID = Db.SingleDecimal("SELECT TOP 1 LogID FROM MS_TTS_LOG ORDER BY LogID DESC"); string Project = Db.SingleString("SELECT Project FROM " + Mi.DbPrefix + "MARKETINGJUAL..MS_KONTRAK WHERE NoKontrak = (SELECT Ref FROM MS_TTS WHERE NoTTS = '" + NoTTS + "')"); Db.Execute("UPDATE MS_TTS_LOG SET Project = '" + Project + "' WHERE LogID = " + LogID); //PEMBULATAN decimal pembulatan = Convert.ToDecimal(bulat.Text); if (pembulatan > 0) { Db.Execute("EXEC spMEMORegistrasi" + " '" + Convert.ToDateTime(tgl.Text) + "'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'JUAL'" + ",'" + Cf.Str(nokontrak.Text) + "'" + ",'" + Cf.Str(unit.Text) + "'" + ",'" + Cf.Str(cs.Text) + "'" + ",'PP'" + ",''" + "," + NoTTS + ",0" ); int NoMEMO = 0; if (Db.SingleInteger("SELECT COUNT(*) FROM MS_MEMO") > 0) { NoMEMO = Db.SingleInteger("SELECT TOP 1 NoMEMO FROM MS_MEMO ORDER BY NoMEMO DESC"); } System.Text.StringBuilder alokasiM = new System.Text.StringBuilder(); decimal NilaiTagihan = Db.SingleDecimal("SELECT ISNULL(SUM(NilaiTagihan),0) FROM ISC064_MARKETINGJUAL..MS_TAGIHAN WHERE NoUrut = " + notag.Text + " AND NoKontrak = '" + nokontrak.Text + "'"); decimal Pelunasan = Db.SingleDecimal("SELECT ISNULL(SUM(NilaiPelunasan),0) FROM ISC064_MARKETINGJUAL..MS_PELUNASAN WHERE NoTagihan = " + notag.Text + " AND NoKontrak = '" + nokontrak.Text + "'"); decimal SisaTag = NilaiTagihan - Pelunasan; decimal n = 0; if (SisaTag > 0) { n = SisaTag < pembulatan ? SisaTag : pembulatan; Db.Execute("EXEC spMEMOAlokasi " + " " + NoMEMO + ", " + notag.Text + ", " + n + ",0" ); Db.Execute("UPDATE ISC064_MARKETINGJUAL..MS_PELUNASAN" + " SET" + " TglPelunasan ='" + Convert.ToDateTime(tgl.Text) + "'" + ", SudahCair='1'" + " WHERE NoKontrak='" + nokontrak.Text + "' AND NoMemo='" + NoMEMO + "' AND NoTagihan='" + notag.Text + "'" ); Db.Execute("UPDATE MS_MEMO SET Status='POST' WHERE NoMemo='" + NoMEMO + "'"); alokasiM.Append(namatag.Text + " " + Cf.Num(lunas.Text) + "<br>"); DataTable rsM = Db.Rs("SELECT " + " CONVERT(varchar, TglMEMO, 106) AS [Tanggal]" + ",Tipe" + ",Ref AS [Ref.]" + ",Unit" + ",Customer" + ",CaraBayar AS [Cara Bayar]" + ",Ket AS [Keterangan]" + ",Total" + ",NoBG AS [No. BG]" + ",CONVERT(varchar, TglBG, 106) AS [Tanggal BG]" + ", Acc AS [Rekening Bank]" + " FROM MS_MEMO WHERE NoMEMO = " + NoMEMO); string KetLogM = Cf.LogCapture(rsM) + "<br>***ALOKASI PEMBAYARAN:<br>" + alokasiM.ToString(); Db.Execute("EXEC spLogMEMO" + " 'REGIS'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'" + KetLogM + "'" + ",'" + NoMEMO.ToString().PadLeft(7, '0') + "'" ); decimal LogID2 = Db.SingleDecimal("SELECT TOP 1 LogID FROM MS_MEMO_LOG ORDER BY LogID DESC"); string Project2 = Db.SingleString("SELECT Project FROM MS_MEMO WHERE NoMEMO = '" + NoMEMO + "'"); Db.Execute("UPDATE MS_MEMO_LOG SET Project = '" + Project2 + "' WHERE LogID = " + LogID2); Db.Execute("EXEC ISC064_MARKETINGJUAL..spProsentasePelunasan '" + nokontrak.Text + "'"); Db.Execute("UPDATE ISC064_MARKETINGJUAL..MS_KONTRAK SET FlagMemo=1 WHERE NoKontrak='" + nokontrak.Text + "'"); } } #endregion ID += NoTTS + ";"; } } //div1.Visible = false; //feed.Text = "<img src='/Media/db.gif' align=absmiddle> " // + "Upload Berhasil.." // ; Dfc.DeleteFile(FilePath); string url = "VAImporBNI3.aspx?id=" + ID; Response.Redirect(url); } }