public static int DeleteT_ATTAINS_ASSESS(int aSSESS_IDX) { using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities()) { try { T_ATTAINS_ASSESS r = (from c in ctx.T_ATTAINS_ASSESS where c.ATTAINS_ASSESS_IDX == aSSESS_IDX select c).FirstOrDefault(); ctx.DeleteObject(r); ctx.SaveChanges(); return(1); } catch { return(0); } } }
private void PopulateForm() { if (hdnReportIDX.Value.ConvertOrDefault <int>() > 0) { int?AssessID = hdnAssessIDX.Value.ConvertOrDefault <int?>(); T_ATTAINS_ASSESS a = db_Attains.GetT_ATTAINS_ASSESS_byID(AssessID.ConvertOrDefault <int>()); if (a != null) { ddlAssessUnit.SelectedValue = a.ATTAINS_ASSESS_UNIT_IDX.ToString(); txtRptCycle.Text = a.REPORTING_CYCLE; txtLastAssess.Text = a.CYCLE_LAST_ASSESSED; txtLastMon.Text = a.CYCLE_LAST_MONITORED; ddlAgencyCode.SelectedValue = a.AGENCY_CODE; ddlReportStatus.SelectedValue = a.REPORT_STATUS; ddlTrophicStatus.SelectedValue = a.TROPHIC_STATUS_CODE; } } }
public static int InsertOrUpdateATTAINS_ASSESS(int?aTTAINS_ASSESS_IDX, string rEPORTING_CYCLE, string rEPORT_STATUS, int aTTAINS_ASSESS_UNIT_IDX, string aGENCY_CODE, string cYCLE_LAST_ASSESSED, string cYCLE_LAST_MONITORED, string tROPHIC_STATUS_CODE, String cREATE_USER = "******") { using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities()) { Boolean insInd = false; try { if (aTTAINS_ASSESS_IDX == -1) { aTTAINS_ASSESS_IDX = null; } T_ATTAINS_ASSESS a = null; if (aTTAINS_ASSESS_IDX != null) { a = (from c in ctx.T_ATTAINS_ASSESS where c.ATTAINS_ASSESS_IDX == aTTAINS_ASSESS_IDX select c).FirstOrDefault(); } if (a == null) { a = new T_ATTAINS_ASSESS(); insInd = true; } if (rEPORTING_CYCLE != null) { a.REPORTING_CYCLE = rEPORTING_CYCLE; } if (rEPORT_STATUS != null) { a.REPORT_STATUS = rEPORT_STATUS; } a.ATTAINS_ASSESS_UNIT_IDX = aTTAINS_ASSESS_UNIT_IDX; if (aGENCY_CODE != null) { a.AGENCY_CODE = aGENCY_CODE; } if (cYCLE_LAST_ASSESSED != null) { a.CYCLE_LAST_ASSESSED = cYCLE_LAST_ASSESSED; } if (cYCLE_LAST_MONITORED != null) { a.CYCLE_LAST_MONITORED = cYCLE_LAST_MONITORED; } if (tROPHIC_STATUS_CODE != null) { a.TROPHIC_STATUS_CODE = tROPHIC_STATUS_CODE; } if (insInd) //insert case { a.CREATE_USERID = cREATE_USER.ToUpper(); a.CREATE_DT = System.DateTime.Now; ctx.AddToT_ATTAINS_ASSESS(a); } else { a.MODIFY_USERID = cREATE_USER.ToUpper(); a.MODIFY_DT = System.DateTime.Now; } ctx.SaveChanges(); return(a.ATTAINS_ASSESS_IDX); } catch (Exception ex) { return(0); } } }