Tuesday, July 30, 2013

SQL Server - T-SQL for setting Date

DECLARE @DayOfMonth TINYINT SET @DayOfMonth = 31
DECLARE @Month TINYINT SET @Month = 3
DECLARE @Year INTEGER SET @Year = YEAR(GETDATE()) + 1
DECLARE @NextWaiverYear AS DATETIME2


 ------------------------------------
SET @NextWaiverYear = (Select DateAdd(day, @DayOfMonth - 1,
          DateAdd(month, @Month - 1,
              DateAdd(Year, @Year-1900, 0))))

SELECT DISTINCT TblSlotWaiverYear.WaiverYrID, TblSlotWaiverYear.Description AS SlotWaiverYearDescription
FROM            TblSlotWaiverYear WHERE EndDt <= @NextWaiverYear

Monday, July 29, 2013

GET and SET - 101 Knowledge - Source - http://msdn.microsoft.com/en-us/library/w86s7x04.aspx

Using Properties (C# Programming Guide)

Visual Studio 2012
11 out of 15 rated this helpful Rate this topic
Properties combine aspects of both fields and methods. To the user of an object, a property appears to be a field, accessing the property requires the same syntax. To the implementer of a class, a property is one or two code blocks, representing a get accessor and/or a set accessor. The code block for the get accessor is executed when the property is read; the code block for the set accessor is executed when the property is assigned a new value. A property without a set accessor is considered read-only. A property without a get accessor is considered write-only. A property that has both accessors is read-write.
Unlike fields, properties are not classified as variables. Therefore, you cannot pass a property as a ref (C# Reference) or out (C# Reference) parameter.
Properties have many uses: they can validate data before allowing a change; they can transparently expose data on a class where that data is actually retrieved from some other source, such as a database; they can take an action when data is changed, such as raising an event, or changing the value of other fields.

Thursday, July 18, 2013

TFS Check Pending files

C:\Program Files (x86)\Microsoft Visual Studio 11.0>tf status /user:Domain\UserAccount /XXXXXXXXXXX;:Domain\UserAccount /collection:"http://XXXXX:808
0/tfs/MyProject
There are no pending changes. (If not files are checked out...


How do you get a co-workers workspace you ask?


Next -



DOS or CMD paging content

Type you command and add

More

10 out of 13 rated this helpful Rate this topic
Displays one screen of output at a time.

Syntax

command | more [/c] [/p] [/s] [/tn] [+n]
more [[/c] [/p] [/s] [/tn] [+n]] < [Drive:] [PathFileName
more [/c] [/p] [/s] [/tn] [+n] [files]

Parameters

[ Drive : ] [ Path FileName   Specifies the file to display.
command   Specifies a command for which you want to display the output.
/c   Clears screen before displaying page.
/p   Expands form-feed characters.
/s   Changes multiple blank lines to one blank line.
/t n   Changes tabs to the number of spaces specified by n.
+ n   Displays first file beginning at the line specified by n.
files   Specifies list of files to display. Separate file names with a space.
/?   Displays help at the command prompt.

Wednesday, July 17, 2013

Link Button Post back

The PostBackUrl property allows you to perform a cross-page post using the LinkButton control. Set the PostBackUrl property to the URL of the Web page to post to when the LinkButton control is clicked. For example, specifying Page2.aspx causes the page that contains the LinkButton control to post to Page2.aspx. If you do not specify a value for the PostBackUrl property, the page posts back to itself. (Who would have known)

Moojjoo

Monday, July 15, 2013

Debugging Console application

When you debug the application, the console window will close when
the application has finished executing, which may prevent you from
inspecting the output. You can put a breakpoint at the end of the method
for debugging. Alternatively, you can run without debugging (CTRL +
F5), in which case Visual Studio will ensure that the console window
remains open after the program has finished executing.

Reference - Programming Eneity Framework: DbContext Page 17

Reading - Programming Entity Framework: DbContext - Quote from Julie Lerman

The LINQ query looks the same as any other query that filters based on name. We then
use the Singlemethod to let Entity Framework know that we expect a single result. If
the query returns no results, or more than one result, an exception will be thrown. If
there are potentially no matches, you can use the SingleOrDefault method, which will
return  null if  no  results  are  found.  Example  2-16 shows  the  FindGreatBarrierReef
method updated to account for the fact it may not exist in the database.

If two rows are found,  Singleand  SingleOrDefault will throw an error because there is not a
single result. If you just want the first result, and aren’t concerned if there is more than
one result, you can use Firstor FirstOrDefault.

Coding 101

All code needs an event that will result in causing the code to work aka (Function/Method).  This could be a button click or the page load but always be sure to understand that your code has to have a behavior to fire your code.

It all starts with the process that puts something in motion.   If nothing can trigger, fire, or cause the the code to process then you cannot find the debug issue or even add functionality.

My 2 cents for the day.

Monday, July 08, 2013

Inserting Entities

In the YELLOW is KEY

'Insert Entity and Database
            Using Context As New qmEntities()
                Dim myServiceDefinition = New tbl_service_definitions()
                myServiceDefinition.srvc_def_desc = txtSrvDefDesc.Text.Trim()
                myServiceDefinition.eff_dt = txtsrvEffDt.SelectedDate
                myServiceDefinition.end_dt = txtsrvEndDt.SelectedDate
                myServiceDefinition.update_dt = DateTime.Now
                myServiceDefinition.update_by_id = SecurityMethods.GetLoginUserId(Session("AuthUser"))
                myServiceDefinition.create_dt = DateTime.Now
                myServiceDefinition.created_by_id = SecurityMethods.GetLoginUserId(Session("AuthUser"))
                myServiceDefinition.active = True
                Context.tbl_service_definitions.Add(myServiceDefinition)
                Context.SaveChanges()
            End Using