|
You could determine all the second Tuesdays for a year or two and then select the ones that fall within the target date range. Here are the second Tuesdays for 2014:
for ( int i = 0; i < 12; i++ ) {
DateTime beginDate = new DateTime( 2014, 01 + i, 01 );
int dayDiff = ( int ) DayOfWeek.Tuesday - ( int ) beginDate.DayOfWeek;
DateTime secondTuesday = beginDate.AddDays( dayDiff + ( dayDiff < 0 ? 14 : 7 ) );
Console.WriteLine( "2nd Tuesday: {0}", secondTuesday );
}
|
|
|
|
|
Well, the brute force method is to find the first Tuesday of a month and add 7 days. No, I'm not trying to be funny here, here's a simple way to achieve this:
public DateTime FindSecondTuesday(int month, int year)
{
int day = 1;
DateTime date = new DateTime(year, month, 1);
while (true)
{
if (date.DayOfWeek == DayOfWeek.Tuesday)
return date.AddDays(7);
date = date.AddDays(1);
}
} All you need do then, is call it for each month and year that you want to get the date from.
|
|
|
|
|
No need for a loop - just switch on the DayOfWeek :
public DateTime FindSecondTuesday(int month, int year)
{
DateTime date = new DateTime(year, month, 1);
switch (date.DayOfWeek)
{
case DayOfWeek.Sunday:
{
return date.AddDays(9);
}
case DayOfWeek.Monday:
{
return date.AddDays(8);
}
case DayOfWeek.Tuesday:
{
return date.AddDays(7);
}
case DayOfWeek.Wednesday:
{
return date.AddDays(13);
}
case DayOfWeek.Thursday:
{
return date.AddDays(12);
}
case DayOfWeek.Friday:
{
return date.AddDays(11);
}
case DayOfWeek.Saturday:
{
return date.AddDays(10);
}
default:
{
throw new InvalidOperationException("Lousy Smarch weather!");
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I would take the essence of the other 2 solutions, apply ROW_NUMBER() partitioned over the date component and select the row number 2 for each month. Turn that into a view and select the record for a month/year
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks to everyone who answered my plea. - I've since found out that the meeting on the second Tuesday of the month is purely at one persons discretion, so I've decided to let that person enter the day on the timetable themselves.
Thanks again, your answers were most appreciated.
|
|
|
|
|
can we connect SQLite using visual studio?
|
|
|
|
|
You have my permission
=========================================================
I'm an optoholic - my glass is always half full of vodka.
=========================================================
|
|
|
|
|
Yes.
Open the Server Explorer pane, and right click "Data Connections"
From the context menu, select "Add Connection..."
Use the "Change..." button to select the "Data source"
Select "System.Data.SQLite Database File" from the list, and press OK
Browse to your database, and set up the other parameters - then press OK
In the Server explorer pane, right click the database and select "Properties".
In the Properties pane, you will see a connection string you can copy and paste into your application or config file.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Entity framework connects to SQLIte easily.
|
|
|
|
|
How we can shared any folder on all user of LAN using c# code. Sir i am making a software where I want to make shared folder on all user of LAN without any Login.
please help me to do it ..
thank you In Advance..........
|
|
|
|
|
If it's a file-sharing network (like Windows networking) you don't need any code to do this, just share the directory (through right click, properties, sharing).
If it's just a TCP network then you probably want to use an SFTP server.
|
|
|
|
|
|
Hello everybody,
i am pretty new in C# and have a question about how to customize the "Popup orientation".
I have realized a popup with a "custom Placement" which is working gut. However i´ll like my Popup to recognize when there´s not enough place in the window to be fully displapled and to Change the way to appear (from right to left for example).
<Grid Name="backgroundGrid" Width="48" Height="48">
<Rectangle Name="Rect" Fill="Orange" />
<Popup Name="PopupInfo" AllowsTransparency="True" IsOpen="{Binding ElementName=backgroundGrid, Path=IsMouseOver, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}" PlacementTarget="{Binding ElementName=backgroundGrid}" Placement="Custom" >
<Canvas Width="200" Height="100">
<Path x:Name="Container" Canvas.Left="37" Canvas.Top="10" Data="M 0,40 L15,50 15,80 150,80 150,0 15,0 15,30" Fill="LightGray" Height="52" Stretch="Fill" Width="130">
<Path.Effect>
<DropShadowEffect Color="Black" ShadowDepth="10" />
</Path.Effect>
</Path>
<TextBlock Canvas.Left="50" Canvas.Top="28" Width="107" Height="22" Margin="10,0,0,0" Text="Popup with text...." TextWrapping="Wrapwithoverflow" />
</Canvas>
the code behind:
PopupInfo.CustomPopupPlacementCallback = new CustomPopupPlacementCallback(placePopup);
public CustomPopupPlacement[] placePopup(Size popupSize, Size targetSize, Point offset)
{
CustomPopupPlacement placement1 = new CustomPopupPlacement(new Point(10, -12), PopupPrimaryAxis.Vertical);
CustomPopupPlacement placement2 = new CustomPopupPlacement(new Point(0, 0), PopupPrimaryAxis.Horizontal);
CustomPopupPlacement[] ttplaces = new CustomPopupPlacement[] { placement1, placement2 };
return ttplaces;
}
I hope to get a Feedback from someone here.
Phil B.
|
|
|
|
|
Hi,
I want to convert a number from exponential form to decimal format , ie in [dot] "." notation. For example I wish to compute 0.5 ^ 100 I desire the answer to be "0.0000000000000000000000000000007888609052210118054117285652827862296732064351090230047702789306640625" instead of 7.88860905221012E-31.
I tried using
string temp=Math.Pow(0.5,100).ToString();
decimal d = Decimal.Parse(temp, System.Globalization.NumberStyles.Float);
but this did not help. Please suggest.
|
|
|
|
|
I suggest you read up on the decimal specification[^] as you are using the wrong tool for that job!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
i used this code but my picturebox is changing value but my image in not fitting in that picturebox.. it comes half or first quadrant etc.
so please help me in this
private void Calculate_btn_Click(object sender, EventArgs e)
{
Bitmap sourceimage = (Bitmap)pictureBox2.Image.Clone();
int height = sourceimage.Size.Height;
int width = sourceimage.Size.Width;
float nPercent = 0;
float nPercentW = 0;
float nPercentH = 0;
int newheight = Convert.ToInt32(height_txt.Text);
int newwidth = Convert.ToInt32(width_txt.Text);
nPercentW = ((float)newheight / (float)height);
nPercentH = ((float)newwidth / (float)width);
if (nPercentH < nPercentW)
nPercent = nPercentH;
else
nPercent = nPercentW;
int destWidth = (int)(width * nPercent);
int destHeight = (int)(height * nPercent);
Bitmap b = new Bitmap(destWidth, destHeight);
Graphics g = Graphics.FromImage((Image)b);
g.DrawImage(sourceimage, 0, 0, destWidth, destHeight);
pictureBox3.Image = sourceimage;
pictureBox3.SizeMode = PictureBoxSizeMode.StretchImage;
|
|
|
|
|
how to load a partition/ drive in text box?
|
|
|
|
|
It's not even a 'Good morning'! It's maybe a 'Go' - go and improve the question so we can help you!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
|
Hi, I am looking for a way to insert a part or a whole file(tried with an excel sheet and a word doc to not much success) into a win word doc through microsoft word interop using VC#. I stumbled across the the range.insertfile() method but resources and information seem quite scarce however I googled it. I Has anyone been regularly using this and having success? Just curious.
|
|
|
|
|
Hello, I need some help.
Currently, I have a gridview that will update with the timer and also a button when clicked, will update the gridview.
So now, I am currently facing a problem regarding when scrolling the updatepanel/gridview, I would like it to remain at scrollbar position. But when I click on the button, I will like the updatepanel/gridview to return to bottom (already have the javascript).
Thanks in advance!
<div id="scrollChat" style="overflow: auto; width: 80%; height: 250px; margin-left: auto;
margin-right: auto;">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Timer ID="timer" runat="server" OnTick="timer_Tick" Interval="2000">
</asp:Timer>
<asp:UpdatePanel ID="upChat" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="timer" EventName="Tick" />
</Triggers>
<ContentTemplate>
<asp:GridView ID="gvChat" runat="server" Style="width: 100%;" Font-Names="Verdana"
AutoGenerateColumns="True" ShowHeader="False" GridLines="None">
<RowStyle Height="25" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<div id="chat" style="height: 1px;">
</div>
</div>
<div style="width: 100%; height: 100px; text-align: center; margin-bottom: 30px;">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="tbMsg" Rows="3" Height="60px" Width="80%" TextMode="multiline" runat="server"
Style="margin-bottom: 15px;" Font-Names="Verdana" placeholder="Type your message here..."></asp:TextBox>
<br />
<asp:Button ID="btnSend" class="btn btn-primary btn-lg" runat="server" Text="Send"
OnClick="btnSend_Click" Width="200px" Font-Bold="true" Font-Names="Verdana" OnClientClick="btnSend_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
<br />
<br />
<script type="text/javascript">
Sys.Application.add_load(function () {
var t = document.getElementById('scrollChat');
t.scrollTop = t.scrollHeight;
});
</script>
|
|
|
|
|
Don't post the same thing in multiple places - it duplicates work and that annoys people.
Either post it in the forums, or QA - but not both.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
hi every one i make program it insert textBox in Word Document Using spire.dll
and it worked but when i use code for gradient fill effect to textbox it not worked so any one can help me by see my code and program and if can edit i will be thankful for him
my small project here and fill effect not work
http://www.4shared.com/rar/jkZqHHdqce/WindowsFormsApplication5.html[^]
|
|
|
|
|
|
Hello Guys,
Am facing an issue with namespace regarding WindowsInstaller
My code is to Read a MSI file and to write, other operations etc.
OS: Windows 7, 64 BIT
VS: VS2013
(I have WiX Toolset v3.8 installed on my machine, which will assist in windows installer funstions)
My Code starts like this:
using System;
using System.Linq;
using WindowsInstaller;
using Microsoft.Deployment.WindowsInstaller;
using Microsoft.Deployment.WindowsInstaller.Linq;
namespace ReadMSI
{
Error: "the type or namespace name 'deployment' does not exist in the namespace 'microsoft'"
I have related .dll installed to the below location.
"C:\Program Files (x86)\WiX Toolset v3.8\bin\Microsoft.Deployment.WindowsInstaller.dll"
Not sure what am missing.
Is this any issue with installing WiX Toolset v3.8
Please assist.
|
|
|
|