public void Delete(ILaporanDinasKey key) { var ld = _laporanDinasDal.GetData(key); // proses simpan using (var trans = TransHelper.NewScope()) { // update ke db _laporanDinasDal.Delete(ld); // commit changes trans.Complete(); } }
public void Delete(ILaporanDinasKey key) { var sql = @" DELETE OFTA_LaporanDinas WHERE LaporanDinasID = @LaporanDinasID"; using (var conn = new SqlConnection(ConnStringHelper.Get())) using (var cmd = new SqlCommand(sql, conn)) { cmd.AddParam("@LaporanDinasID", key.LaporanDinasID, SqlDbType.VarChar); conn.Open(); cmd.ExecuteNonQuery(); } }
public LaporanDinasModel GetData(ILaporanDinasKey key) { LaporanDinasModel result = null; var sql = @" SELECT aa.LaporanDinasID, aa.TglJamCreate, aa.ReportedPegID, aa.SuratDinasID, aa.TglSelesai, aa.HasilKerja, aa.KMAkhir, aa.DiketahuiPegID, aa.IsSignedDiketahui, ISNULL( bb.PegName,'') ReportedPegName, ISNULL( cc.PegName, '') DiketahuiPegName, ISNULL( dd.TglMulai, '1900-01-01T00:00:00') TglMulai FROM OFTA_LaporanDinas aa LEFT JOIN Peg bb ON aa.ReportedPegID = bb.PegID LEFT JOIN Peg cc ON aa.DiketahuiPegID = cc.PegID LEFT JOIN SuratDinas dd ON aa.SuratDinasID = dd.SuratDinasID WHERE LaporanDinasID = @LaporanDinasID "; using (var conn = new SqlConnection(ConnStringHelper.Get())) using (var cmd = new SqlCommand(sql, conn)) { cmd.AddParam("@LaporanDinasID", key.LaporanDinasID, SqlDbType.VarChar); conn.Open(); using (var dr = cmd.ExecuteReader()) { if (!dr.HasRows) return null; dr.Read(); result = new LaporanDinasModel { LaporanDinasID = dr["LaporanDinasID"].ToString(), TglJamCreate = Convert.ToDateTime(dr["TglJamCreate"]), PegID = dr["ReportedPegID"].ToString(), PegName = dr["ReportedPegName"].ToString(), SuratDinasID = dr["SuratDinasID"].ToString(), TglMulai = Convert.ToDateTime(dr["TglMulai"]), TglSelesai = Convert.ToDateTime(dr["TglSelesai"]), HasilKerja = dr["HasilKerja"].ToString(), KMAkhir = Convert.ToInt64(dr["KMAkhir"]) }; } } return result; }
public LaporanDinasModel GetData(ILaporanDinasKey key) { var result = _laporanDinasDal.GetData(key); return(result); }