protected void save_Click(object sender, System.EventArgs e) { if (datavalid()) { DateTime TglST = Convert.ToDateTime(tglst.Text); DateTime TargetST = Db.SingleTime("SELECT TargetST FROM MS_KONTRAK WHERE NoKontrak ='" + NoKontrak + "'"); decimal NilaiKontrak = Db.SingleDecimal("SELECT NilaiKontrak FROM MS_KONTRAK WHERE NoKontrak ='" + NoKontrak + "'"); decimal Luas = Convert.ToDecimal(luas.Text); decimal LuasNett = Convert.ToDecimal(luasnett.Text); decimal Biaya = Convert.ToDecimal(nilaibiaya.Text); decimal LebihBayar = Convert.ToDecimal(lebihbayar.Text); decimal MasaGaransi = Convert.ToDecimal(masagaransi.Text); string status = "D"; // B = Belum, S = Target, D = Serah Terima, T = Tanda Tangan string Project = Db.SingleString("SELECT Project FROM MS_KONTRAK WHERE NoKontrak = '" + NoKontrak + "'"); if (TglST > TargetST) { TimeSpan ts = new TimeSpan(); ts = TglST.Subtract(TargetST); int Telat = ts.Days; decimal dendaST = (decimal)0.001 * NilaiKontrak * Telat; Db.Execute(" UPDATE MS_KONTRAK SET DendaST ='" + dendaST + "' WHERE NoKontrak='" + NoKontrak + "'"); } int c = Db.SingleInteger("SELECT COUNT(*) FROM MS_BAST WHERE NoKontrak = '" + NoKontrak + "'"); if (c == 0) { string NoST = Db.SingleString("SELECT NoST FROM MS_KONTRAK WHERE NoKontrak = '" + NoKontrak + "'"); if (NoST == "") { NoST = Numerator.BAST(TglST.Month, TglST.Year, Project); } Db.Execute("EXEC spST " + " '" + NoKontrak + "'" + ",'" + NoST + "'" + ",'" + TglST + "'" ); Db.Execute("UPDATE MS_BAST SET Project = '" + Project + "' WHERE NoST = '" + NoST + "'"); Db.Execute("UPDATE MS_BAST SET" + " STu=" + stused.SelectedValue + " ,NoSTm='" + nostm.Text + "'" + " ,ST='" + status + "'" + " ,LuasGross= '" + Luas + "'" + " ,LuasNett= '" + LuasNett + "'" + " ,Biaya= '" + Biaya + "'" + " ,LebihBayar= '" + LebihBayar + "'" + " ,MasaGaransi= '" + MasaGaransi + "'" + " ,KetST ='" + keterangan.Text + "'" + " WHERE NoKontrak = '" + NoKontrak + "'" ); if (tglst.Text != "") { Db.Execute("UPDATE MS_BAST SET TglST='" + Convert.ToDateTime(tglst.Text) + "' WHERE NoKontrak = '" + NoKontrak + "'"); } Db.Execute("UPDATE MS_KONTRAK SET ST = '" + status + "',TglST = '" + Convert.ToDateTime(tglst.Text) + "' WHERE NoKontrak = '" + NoKontrak + "'"); decimal NilaiBiaya = Convert.ToDecimal(nilaibiaya.Text); if (NilaiBiaya != 0) { Db.Execute("EXEC spTagihanDaftar " + " '" + NoKontrak + "'" + ",'BIAYA ADM. SERAH TERIMA'" + ",'" + TglST + "'" + ", " + NilaiBiaya + ",'ADM'" ); } DataTable rs = Db.Rs("SELECT" + " A.NoKontrak AS [No. Kontrak]" + ",B.NoUnit AS [Unit]" + ",C.Nama AS [Customer]" + ",A.NoST AS [No. BAST]" + ",A.LuasGross AS [Luas Tanah]" + ",A.LuasNett AS [Luas Bangunan]" + ",CONVERT(varchar, A.TargetST, 106) AS [Tanggal Target BAST]" + ",CONVERT(varchar, A.TglST, 106) AS [Tanggal BAST]" + ",PersenLunas AS [Prosentase Pelunasan]" + ",A.MasaGaransi" + ", case when A.ST='S' then 'Target BAST' when A.ST='D' then 'BAST' when A.ST='B' then 'Belum BAST' else 'Tanda Tangan BAST' end as [Status BAST]" + " FROM MS_BAST A INNER JOIN MS_KONTRAK B" + " ON A.NoKontrak = B.NoKontrak" + " INNER JOIN MS_CUSTOMER C ON B.NoCustomer = C.NoCustomer" + " WHERE A.NoKontrak = '" + NoKontrak + "'"); string ket = Cf.LogCapture(rs) //+ Cf.LogCompare(rsBef,rsAft) + "<br>Biaya Administrasi : " + Cf.Num(NilaiBiaya) ; Db.Execute("EXEC spLogKontrak " + " 'BAST'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'" + ket + "'" + ",'" + NoKontrak + "'" ); decimal LogID = Db.SingleDecimal("SELECT TOP 1 LogID FROM MS_KONTRAK_LOG ORDER BY LogID DESC"); Db.Execute("UPDATE MS_KONTRAK_LOG SET Project = '" + Project + "' WHERE LogID = " + LogID); } else { string NoST = Db.SingleString("SELECT NoST FROM MS_KONTRAK WHERE NoKontrak = '" + NoKontrak + "'"); if (NoST == "") { NoST = Numerator.BAST(TglST.Month, TglST.Year, Project); } Db.Execute("UPDATE MS_BAST SET" + " STu=" + stused.SelectedValue + " ,NoST = '" + NoST + "'" + " ,NoSTm='" + nostm.Text + "'" + " ,ST='" + status + "'" + " ,LuasGross= '" + Luas + "'" + " ,LuasNett= '" + LuasNett + "'" + " ,Biaya= '" + Biaya + "'" + " ,LebihBayar= '" + LebihBayar + "'" + " ,MasaGaransi= '" + MasaGaransi + "'" + " ,KetST ='" + keterangan.Text + "'" + ", Project = '" + Project + "'" + " WHERE NoKontrak = '" + NoKontrak + "'" ); if (tglst.Text != "") { Db.Execute("UPDATE MS_BAST SET TglST='" + Convert.ToDateTime(tglst.Text) + "' WHERE NoKontrak = '" + NoKontrak + "'"); } decimal NilaiBiaya = Convert.ToDecimal(nilaibiaya.Text); if (NilaiBiaya != 0) { Db.Execute("EXEC spTagihanDaftar " + " '" + NoKontrak + "'" + ",'BIAYA ADM. SERAH TERIMA'" + ",'" + TglST + "'" + ", " + NilaiBiaya + ",'ADM'" ); } Db.Execute("UPDATE MS_KONTRAK SET ST = '" + status + "',TglST = '" + Convert.ToDateTime(tglst.Text) + "' WHERE NoKontrak = '" + NoKontrak + "'"); DataTable rs = Db.Rs("SELECT" + " A.NoKontrak AS [No. Kontrak]" + ",B.NoUnit AS [Unit]" + ",C.Nama AS [Customer]" + ",A.NoST AS [No. BAST]" + ",A.LuasGross AS [Luas Tanah]" + ",A.LuasNett AS [Luas Bangunan]" + ",CONVERT(varchar, A.TargetST, 106) AS [Tanggal Target BAST]" + ",CONVERT(varchar, A.TglST, 106) AS [Tanggal BAST]" + ",PersenLunas AS [Prosentase Pelunasan]" + ",A.MasaGaransi" + ", case when A.ST='S' then 'Target BAST' when A.ST='D' then 'BAST' when A.ST='B' then 'Belum BAST' else 'Tanda Tangan BAST' end as [Status BAST]" + " FROM MS_BAST A INNER JOIN MS_KONTRAK B" + " ON A.NoKontrak = B.NoKontrak" + " INNER JOIN MS_CUSTOMER C ON B.NoCustomer = C.NoCustomer" + " WHERE A.NoKontrak = '" + NoKontrak + "'"); string ket = Cf.LogCapture(rs) //+ Cf.LogCompare(rsBef,rsAft) + "<br>Biaya Administrasi : " + Cf.Num(NilaiBiaya) ; Db.Execute("EXEC spLogKontrak " + " 'BAST'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'" + ket + "'" + ",'" + NoKontrak + "'" ); decimal LogID = Db.SingleDecimal("SELECT TOP 1 LogID FROM MS_KONTRAK_LOG ORDER BY LogID DESC"); Db.Execute("UPDATE MS_KONTRAK_LOG SET Project = '" + Project + "' WHERE LogID = " + LogID); } if (dariReminder.Checked) { Response.Redirect("ReminderST.aspx?done=" + NoKontrak); } else { Response.Redirect("KontrakST.aspx?done=" + NoKontrak); } } }
protected void save_Click(object sender, System.EventArgs e) { if (datavalid()) { DateTime TglST = Convert.ToDateTime(tgltarget.Text); DateTime TargetST = Db.SingleTime("SELECT TargetST FROM MS_KONTRAK WHERE NoKontrak ='" + NoKontrak + "'"); string Project = Db.SingleString("SELECT Project FROM MS_KONTRAK WHERE NoKontrak = '" + NoKontrak + "'"); int c = Db.SingleInteger("SELECT COUNT(*) FROM MS_BAST WHERE NoKontrak = '" + NoKontrak + "'"); string status = "S"; // B = Belum, S = Target, D = Serah Terima, T = Tanda Tangan if (c == 0) { string NoST = Db.SingleString("SELECT NoST FROM MS_KONTRAK WHERE NoKontrak = '" + NoKontrak + "'"); if (NoST == "") { NoST = Numerator.BAST(TglST.Month, TglST.Year, Project); } Db.Execute("EXEC spST " + " '" + NoKontrak + "'" + ",'" + NoST + "'" + ",''" ); Db.Execute("UPDATE MS_BAST SET Project = '" + Project + "' WHERE NoST = '" + NoST + "'"); Db.Execute("UPDATE MS_BAST SET" + " ST='" + status + "'" + " WHERE NoKontrak = '" + NoKontrak + "'" ); if (tgltarget.Text != "") { Db.Execute("UPDATE MS_BAST SET TargetST='" + Convert.ToDateTime(tgltarget.Text) + "' WHERE NoKontrak = '" + NoKontrak + "'"); } DataTable rs = Db.Rs("SELECT" + " A.NoKontrak AS [No. Kontrak]" + ",B.NoUnit AS [Unit]" + ",C.Nama AS [Customer]" + ",CONVERT(varchar, A.TargetST, 106) AS [Tanggal Target BAST]" + ",PersenLunas AS [Prosentase Pelunasan]" + ", case when A.ST='S' then 'Target BAST' when A.ST='D' then 'BAST' when A.ST='B' then 'Belum BAST' else 'Tanda Tangan BAST' end as [Status BAST]" + " FROM MS_BAST A INNER JOIN MS_KONTRAK B" + " ON A.NoKontrak = B.NoKontrak" + " INNER JOIN MS_CUSTOMER C ON B.NoCustomer = C.NoCustomer" + " WHERE A.NoKontrak = '" + NoKontrak + "'"); string ket = Cf.LogCapture(rs) ; Db.Execute("EXEC spLogKontrak " + " 'T-BAST'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'" + ket + "'" + ",'" + NoKontrak + "'" ); decimal LogID = Db.SingleDecimal("SELECT TOP 1 LogID FROM MS_KONTRAK_LOG ORDER BY LogID DESC"); Db.Execute("UPDATE MS_KONTRAK_LOG SET Project = '" + Project + "' WHERE LogID = " + LogID); } else { Db.Execute("UPDATE MS_BAST SET" + " ST='" + status + "'" + " WHERE NoKontrak = '" + NoKontrak + "'" ); if (tgltarget.Text != "") { Db.Execute("UPDATE MS_BAST SET TargetST='" + Convert.ToDateTime(tgltarget.Text) + "' WHERE NoKontrak = '" + NoKontrak + "'"); } DataTable rs = Db.Rs("SELECT" + " A.NoKontrak AS [No. Kontrak]" + ",B.NoUnit AS [Unit]" + ",C.Nama AS [Customer]" + ",CONVERT(varchar, A.TargetST, 106) AS [Tanggal Target BAST]" + ",PersenLunas AS [Prosentase Pelunasan]" + ", case when A.ST='S' then 'Target BAST' when A.ST='D' then 'BAST' when A.ST='B' then 'Belum BAST' else 'Tanda Tangan BAST' end as [Status BAST]" + " FROM MS_BAST A INNER JOIN MS_KONTRAK B" + " ON A.NoKontrak = B.NoKontrak" + " INNER JOIN MS_CUSTOMER C ON B.NoCustomer = C.NoCustomer" + " WHERE A.NoKontrak = '" + NoKontrak + "'"); string ket = Cf.LogCapture(rs) ; Db.Execute("EXEC spLogKontrak " + " 'T-BAST'" + ",'" + Act.UserID + "'" + ",'" + Act.IP + "'" + ",'" + ket + "'" + ",'" + NoKontrak + "'" ); decimal LogID = Db.SingleDecimal("SELECT TOP 1 LogID FROM MS_KONTRAK_LOG ORDER BY LogID DESC"); Db.Execute("UPDATE MS_KONTRAK_LOG SET Project = '" + Project + "' WHERE LogID = " + LogID); } if (dariReminder.Checked) { Response.Redirect("ReminderST.aspx?done=" + NoKontrak); } else { Response.Redirect("KontrakSTTarget.aspx?done=" + NoKontrak); } } }