Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

Bernard Laplace

@Bernard Laplace
About
Posts
21
Topics
7
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How to check if one date is bigger than another...
    B Bernard Laplace

    I really appreciate this forum for all the code snippets I can reuse in Visual Studio.

    The Weird and The Wonderful help tutorial

  • How to handle dates _properly_. [modified]
    B Bernard Laplace

    Not sure about that, but I can feel some kind of irony in this post... :laugh:

    The Weird and The Wonderful tutorial json question

  • Try to find something dumber if you can...
    B Bernard Laplace

    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)...

    The Weird and The Wonderful database

  • Try to find something dumber if you can...
    B Bernard Laplace

    No comment...

    	If Request.QueryString("tsid") IsNot Nothing Then
    		Session("TSID") = sql.SQLValue("SELECT TSID FROM TimeRegHeader 
                                                        WHERE TSID = " & Request.QueryString("tsid"))
    	End If
    
    The Weird and The Wonderful database

  • A real Mess
    B Bernard Laplace

    Well I can see I am not the only one practicing irony here, am I?

    The Weird and The Wonderful graphics

  • Sith Interviewing Tactics [modified]
    B Bernard Laplace

    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"

    The Weird and The Wonderful csharp career com graphics algorithms

  • Sith Interviewing Tactics [modified]
    B Bernard Laplace

    Well I suppose you were talking about Fibonacci... It is just a supposition since Google doesn't know about "Fabbinicci" ...

    The Weird and The Wonderful csharp career com graphics algorithms

  • A real Mess
    B Bernard Laplace

    French code smells cheese and has blue spots... :laugh:

    The Weird and The Wonderful graphics

  • A real Mess
    B Bernard Laplace

    Well I have his home address, but I believe he's already dead, at least his brain was when he 'coded' this.

    The Weird and The Wonderful graphics

  • A real Mess
    B Bernard Laplace

    Hoorray! 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 Integer

    	Select 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
    
    The Weird and The Wonderful graphics

  • A real Mess
    B Bernard Laplace

    Nothing 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.

    The Weird and The Wonderful graphics

  • A real Mess
    B Bernard Laplace

    Any donation is welcome.

    The Weird and The Wonderful graphics

  • A real Mess
    B Bernard Laplace

    Well this code has been made in Switzerland...

    The Weird and The Wonderful graphics

  • A real Mess
    B Bernard Laplace

    This 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 Integer

    	Select 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
    
    The Weird and The Wonderful graphics

  • High end SQL
    B Bernard Laplace

    Found 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

    The Weird and The Wonderful database

  • Adding an attribute to a property in a partial class
    B Bernard Laplace

    Hi, 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.

    .NET (Core and Framework) csharp

  • SQL Server trigger code
    B Bernard Laplace

    Well, 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.

    The Weird and The Wonderful database sql-server sysadmin

  • SQL Server trigger code
    B Bernard Laplace

    DECLARE p_cursor CURSOR FOR
    SELECT TOP 1 SortDateStart AS DateStart, SortDateEnd AS DateEnd
    ...

    This code was in a trigger... :omg:

    The Weird and The Wonderful database sql-server sysadmin

  • Reflection in a Windows Service & WCF
    B Bernard Laplace

    I found out! It works when I load the assemblies using LoadFrom instead of LoadFile (it is in a function that I have not provided).

    C# csharp visual-studio wcf debugging announcement

  • Reflection in a Windows Service & WCF
    B Bernard Laplace

    Hi, 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()));
                }
            }
        }
    
    C# csharp visual-studio wcf debugging announcement
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups