I really appreciate this forum for all the code snippets I can reuse in Visual Studio.
Bernard Laplace
Posts
-
How to check if one date is bigger than another... -
How to handle dates _properly_. [modified]Not sure about that, but I can feel some kind of irony in this post... :laugh:
-
Try to find something dumber if you can...all what you said + the ad hoc SQL + (cherry on the cake) the fact that it stores in a session variable a TSID value from the database queried from a table where TSID is equal to the TSID from the query string (and no it wasn't designed to validate the existence of the TSID in the database since nothing handles the fact that the returned TSID could be null)...
-
Try to find something dumber if you can...No comment...
If Request.QueryString("tsid") IsNot Nothing Then Session("TSID") = sql.SQLValue("SELECT TSID FROM TimeRegHeader WHERE TSID = " & Request.QueryString("tsid")) End If
-
A real MessWell I can see I am not the only one practicing irony here, am I?
-
Sith Interviewing Tactics [modified]I won't be really fussy for the english, since I am french, I do not master this langage Just a little test, which sentence is correct: "I hide behind the bar waiting for the cowboys stop shooting" "I hide behind the bar waiting for the cowboys to stop shooting"
-
Sith Interviewing Tactics [modified]Well I suppose you were talking about Fibonacci... It is just a supposition since Google doesn't know about "Fabbinicci" ...
-
A real MessFrench code smells cheese and has blue spots... :laugh:
-
A real MessWell I have his home address, but I believe he's already dead, at least his brain was when he 'coded' this.
-
A real MessHoorray! I fixed it!!!! Well when the procedure found a time over 4 hours for a day it used to skip the next records for that day :doh: I am so proud that I can not resist to post the fixed method :-D
Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim i As Integer
Dim r As Integer
Dim sEmployeeID As String
Dim dDateFrom As DateTime = Convert.ToDateTime(DateFrom.Text)
Dim dDateTo As DateTime = Convert.ToDateTime(DateTo.Text)
Dim dDateCurrent As Date = dDateFrom
Dim sConsultantInfoDay As String = ""
Dim sProjectInfo1 As String = ""
Dim sProjectInfo2 As String = ""
Dim sProject As String = ""
Dim DateEnd As Object
Dim DaysNoticeExt As Object
Dim sColor1 As String = "#FFFFFF"
Dim sColor2 As String = "#FFFFFF"
Dim PreviousColor As String = "#FFFFFF"
Dim hl As New HyperLink
Dim lb As New Label
Dim lb2 As New Label
Dim iDayofWeek As Integer
Dim sDayName As String
Dim sExit As String
Dim bgColor As Drawing.Color
Dim sColorProject As String = "#FFFFFF"
Dim bTSClosed As Boolean
Dim Hours As Double
Dim HoursClientMonth As Double
Dim HoursMonth As Double
Dim HoursTBPMonth As Double
Dim HoursInternalMonth As Double
Dim DailyHoursTBP As Double
Dim TSID As Integer
Dim oEmpDateStart As Object
Dim oEmpDateEnd As Object
Dim bClientProject As Boolean = False
Dim bProjectFoundMonth As Boolean = False
Dim WorkPerc As Double
Dim sHoliday As String
Dim ProjectID As Integer
Dim TotalHoursMonth As Double
Dim dteRenewal, dteCurrentNotification, dteCurrentEndProj As DateTime
Dim intRenewalCpt As Integer = -1
Dim blnIsFirstTime As Boolean = True
Dim intRenewsEachNbMonths As IntegerSelect Case e.Row.RowType Case DataControlRowType.Header Dim iMonth As Integer e.Row.Cells(0).Visible = False e.Row.Cells(1).Visible = False e.Row.Cells(2).Visible = False e.Row.Cells(3).Visible = False e.Row.Cells(iColDaysStart - 1).Width = ConsultantColWidth e.Row.Cells(iColDaysStart - 1).Text = sEmployeeHeader e.Row.Cells(iColDaysStart - 1).Font.Size = iFontSizeEmployees e.Row.Cells(iColDaysStart - 1).Font.Bold = True e.Row.Cells(iColDaysStart - 1).ForeColor = Drawing.Color.White e.Row.Cells(iColDaysStart - 1).BackColor = Drawing.Color.DarkBlue i = iColDaysStart Do While dDateCurrent <= dDateTo iMonth = dDateCurrent.Month sDayName = WeekdayName(DatePart("w", dDateCurrent), True, Microsoft.V
-
A real MessNothing yet, the problem is the whole application is badly design, so from my point of view it is better to build a new application from scratch.
-
A real MessAny donation is welcome.
-
A real MessWell this code has been made in Switzerland...
-
A real MessThis is just one method, but do not expect it to be short... :sigh: I spent my days debugging this kind of code... X|
Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
Dim i As Integer
Dim r As Integer
Dim sEmployeeID As String
Dim dDateFrom As DateTime = Convert.ToDateTime(DateFrom.Text)
Dim dDateTo As DateTime = Convert.ToDateTime(DateTo.Text)
Dim dDateCurrent As Date = dDateFrom
Dim sConsultantInfoDay As String = ""
Dim sProjectInfo1 As String = ""
Dim sProjectInfo2 As String = ""
Dim sProject As String = ""
Dim DateEnd As Object
Dim DaysNoticeExt As Object
Dim sColor1 As String = "#FFFFFF"
Dim sColor2 As String = "#FFFFFF"
Dim PreviousColor As String = "#FFFFFF"
Dim hl As New HyperLink
Dim lb As New Label
Dim lb2 As New Label
Dim iDayofWeek As Integer
Dim sDayName As String
Dim sExit As String
Dim bgColor As Drawing.Color
Dim sColorProject As String = "#FFFFFF"
Dim bTSClosed As Boolean
Dim Hours As Double
Dim HoursClientMonth As Double
Dim HoursMonth As Double
Dim HoursTBPMonth As Double
Dim HoursInternalMonth As Double
Dim DailyHoursTBP As Double
Dim TSID As Integer
Dim oEmpDateStart As Object
Dim oEmpDateEnd As Object
Dim bClientProject As Boolean = False
Dim bProjectFoundMonth As Boolean = False
Dim WorkPerc As Double
Dim sHoliday As String
Dim ProjectID As Integer
Dim TotalHoursMonth As Double
Dim dteRenewal, dteCurrentNotification, dteCurrentEndProj As DateTime
Dim intRenewalCpt As Integer = -1
Dim blnIsFirstTime As Boolean = True
Dim intRenewsEachNbMonths As IntegerSelect Case e.Row.RowType Case DataControlRowType.Header Dim iMonth As Integer e.Row.Cells(0).Visible = False e.Row.Cells(1).Visible = False e.Row.Cells(2).Visible = False e.Row.Cells(3).Visible = False e.Row.Cells(iColDaysStart - 1).Width = ConsultantColWidth e.Row.Cells(iColDaysStart - 1).Text = sEmployeeHeader e.Row.Cells(iColDaysStart - 1).Font.Size = iFontSizeEmployees e.Row.Cells(iColDaysStart - 1).Font.Bold = True e.Row.Cells(iColDaysStart - 1).ForeColor = Drawing.Color.White e.Row.Cells(iColDaysStart - 1).BackColor = Drawing.Color.DarkBlue i = iColDaysStart Do While dDateCurrent <= dDateTo iMonth = dDateCurrent.Month sDayName = WeekdayName(DatePart("w", dDateCurrent), True, Microsoft.VisualBasic.FirstDayOfWeek.Sunday) e.Row.Cells(i).Text = String.Concat(Left(sDayNam
-
High end SQLFound in a stored procedure... Declare @IsClosed bit SET @IsClosed = (SELECT ISNULL(Closed,0) FROM TimeRegHeader WHERE TSID = @TSID) If @IsClosed Is Null BEGIN Select 0 END else BEGIN Select @IsClosed END
-
Adding an attribute to a property in a partial classHi, I am using Entity framework in a dynamic data web app with C#. So far I have created a source file with partial declarations of my entity classes on which I have set attributes like ScaffoldTable. I did that in order to not lose this code in case of regeneration of the entity classes.
using System.ComponentModel; using System.ComponentModel.DataAnnotations; namespace AdmissionForm { \[ScaffoldTable(true)\] public partial class AdmissionForm { } ... }
I would like to know if there is a way to add attributes to the properties defined in this entity classes from the source file I have added. Regards.
-
SQL Server trigger codeWell, I am ok with triggers so far you make a sensible use of them (which is not the case for the database where I found this). You should avoid the use of cursors with SQL Server, that is not good but most people would not call that an horror. The point is: Why on earth would someone open a cursor on a 1 row set???? In this case it is far more simple and efficient to type: SELECT TOP 1 @A=Column1, @B=Column2.... instead of declaring a cursor, fetch the data and close it.
-
SQL Server trigger codeDECLARE p_cursor CURSOR FOR
SELECT TOP 1 SortDateStart AS DateStart, SortDateEnd AS DateEnd
...This code was in a trigger... :omg:
-
Reflection in a Windows Service & WCFI found out! It works when I load the assemblies using LoadFrom instead of LoadFile (it is in a function that I have not provided).
-
Reflection in a Windows Service & WCFHi, I am trying to run the following code in a dynamically loaded WCF service hosted in a Windows Service. It seems I can't load types because of the following exception: Could not load file or assembly 'APLUGINASSEMBLY, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ddd7975916a1e051' or one of its dependencies. The system cannot find the file specified. Here is the list of the referenced assemblies: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089Viveo.Data, Version=1.4.0.0, Culture=neutral, PublicKeyToken=ddd7975916a1e051 NavigationProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullSystem.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Please note that the very same code works fine when I run the WCF Service from Visual Studio. :doh: Thanks.
protected static void AnalysePlugins(Assembly[] Assemblies)
{
foreach (Assembly anAssembly in Assemblies)
{
try
{
foreach (Type aType in anAssembly.GetExportedTypes())
{
try
{
if (aType.GetInterface("ANINTERFACE") != null)
{
//Retrieves the name of each navigation
string theNavigationName = (string)aType.InvokeMember("Name", BindingFlags.GetProperty, null, aType.GetConstructor(new Type[]{}).Invoke(new object[]{}), null);
//Fills the data structures that keep reference of the navigation/type/assembly
NavigationRepository[theNavigationName] = aType;
PluginRepository[aType] = anAssembly;
}
}
catch(Exception ex)
{
Trace.WriteLine(aType + " could not have its name queried");
}
}
}
catch (Exception ex)
{System.Diagnostics.EventLog.WriteEntry("BusinessServer", ex.Message); System.Diagnostics.EventLog.WriteEntry("BusinessServer", string.Concat(anAssembly.GetReferencedAssemblies())); } } }