>>public static class MiscFunctions >>{ >> public static object GetNonNull(object Test, object Default) >> { >> if (Test != DBNull.Value && Test != null) >> return Test; >> else >> return Default; >> } >> >> public static string GetNonNull(object Test, string Default) >> { >> if (Test != DBNull.Value && Test != null) >> { >> if (Test is DateTime) >> { >> DateTime TestDT = Convert.ToDateTime(Test); >> DateTime SqlNull = new DateTime(1900, 1, 1); >> if (TestDT == SqlNull) >> return Default; >> } >> else >> if (Test is bool) >> { >> bool YesNo = Convert.ToBoolean(Test); >> if (YesNo) >> return "Yes"; >> else >> return "No"; >> } >> return Test.ToString().Trim(); >> } >> else >> return Default; >> } >> >> public static int GetNonNull(this object Test, int Default) >> { >> if (Test != DBNull.Value && Test != null) >> return Convert.ToInt32(Test); >> else >> return Default; >> } >> >> public static float GetNonNull(this object Test, float Default) >> { >> if (Test != DBNull.Value && Test != null) >> { >> return Convert.ToSingle(Test); ; >> } >> else >> { >> return Default; >> } >> } >> >> public static DateTime GetNonNull(object Test, DateTime Default) >> { >> if (Test != DBNull.Value && Test != null) >> { >> DateTime TestDT = Convert.ToDateTime(Test); >> DateTime SqlNull = new DateTime(1900, 1, 1); >> DateTime NetNull = new DateTime(1, 1, 1); >> if (TestDT != SqlNull && TestDT != NetNull) >> return TestDT; >> else >> return Default; >> } >> else >> return Default; >> } >> >> public static string GetNonNullDate(object Test, string Default) >> { >> if (Test != DBNull.Value && Test != null) >> { >> if (Test is DateTime) >> { >> DateTime TestDT = Convert.ToDateTime(Test); >> DateTime SqlNull = new DateTime(1900, 1, 1); >> if (TestDT != SqlNull) >> return TestDT.ToShortDateString(); >> } >> return Default; >> } >> else >> return Default; >> } >> >> public static DateTime GetNonNullDate(object Test) >> { >> if (Test != DBNull.Value && Test != null && Test is DateTime) >> return Convert.ToDateTime(Test); >> else >> return new DateTime(1900, 1, 1); >> } >>} >>>>
>>public override void LoadData() >>{ >> DataSet ds = AppDataAccess.GetProjects(this.RecordId); >> >> if (ds != null && ds.Tables.Count > 0) >> { >> _ProjectKey = (int)ds.Tables[0].Rows[0]["ProjectKey"].GetNonNull(0); >> _ClientKey = (int)ds.Tables[0].Rows[0]["ClientKey"].GetNonNull(0); >> _ProjectTypeKey = (int)ds.Tables[0].Rows[0]["ProjectTypeKey"].GetNonNull(0); >> _RateTypeKey = (int)ds.Tables[0].Rows[0]["RateTypeKey"].GetNonNull(0); >> _ProjectStatusKey = (int)ds.Tables[0].Rows[0]["ProjectStatusKey"].GetNonNull(0); >> _PriorityKey = (int)ds.Tables[0].Rows[0]["PriorityKey"].GetNonNull(0); >> _ManagerKey = (int)ds.Tables[0].Rows[0]["ManagerKey"].GetNonNull(0); >> _ProjectName = ds.Tables[0].Rows[0]["ProjectName"].ToString(); >> _ProjectCode = ds.Tables[0].Rows[0]["ProjectCode"].ToString(); >> _RateAmt = (float)ds.Tables[0].Rows[0]["RateAmt"].GetNonNull(0.00f); >> _EstHours = (float)ds.Tables[0].Rows[0]["EstHours"].GetNonNull(0.00f); >> _TotalHours = (float)ds.Tables[0].Rows[0]["TotalHours"].GetNonNull(0.00f); >> _EstStartDate = (DateTime)ds.Tables[0].Rows[0]["EstStartDate"].GetNonNull(); // Problem here >> _EstEndDate = (DateTime)ds.Tables[0].Rows[0]["EstEndDate"]; >> _ActualStartDate = (DateTime)ds.Tables[0].Rows[0]["ActualStartDate"]; >> _ActualEndDate = (DateTime)ds.Tables[0].Rows[0]["ActualEndDate"]; >> _PercentDone = (float)ds.Tables[0].Rows[0]["PercentDone"].GetNonNull(0.00f); >> _Comments = ds.Tables[0].Rows[0]["Comments"].ToString(); >> _ProjectType = ds.Tables[0].Rows[0]["ProjectType"].ToString(); >> _RateType = ds.Tables[0].Rows[0]["RateType"].ToString(); >> _Status = ds.Tables[0].Rows[0]["Status"].ToString(); >> _Priority = ds.Tables[0].Rows[0]["Priority"].ToString(); >> _MgrFirstName = ds.Tables[0].Rows[0]["MgrFirstName"].ToString(); >> _MgrLastName = ds.Tables[0].Rows[0]["MgrLastName"].ToString(); >> } >>}>>