|
string[] PkgIDs = rData.details.Where(c => c.batch_id == batchID).Select(c => c.Package_ID).Distinct().ToArray();
if(PkgIDs.Count > 0)
{
foreach (string PkgID in PkgIDs)
{
}
}
|
|
|
|
|
Totally unnecessary, foreach can iterate over a zero size collection without any problem.
|
|
|
|
|
Write unit tests for the situations you are worried about and see if the result is correct?
|
|
|
|
|
I need to write a C# 2010 windows service that will check for new files in a specified directory path . Can you tell me how to accomplish this goal?
|
|
|
|
|
rachel_m wrote: Can you tell me how to accomplish this goal?
By writing the service.
Seriously, what is it that you are having trouble with?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
sorry accidently posted a weong message
|
|
|
|
|
Using the FileSystemWatcher[^] control. There's a full example on the bottom of the page, assuming a normal winapp, not a service.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
Hi All,
In C#, How To Send A Hyperlink Using Query String Method.
I have developing a web application of user enter enters the personal data. That information has sent to admin mail with approve/reject link button.
When the Admin click the approve link, it has approve.aspx page with the user id as query string to update the db as approved. otherwise rejected.
I can try the following code.
mail.Subject = "New User";
mail.Body = "<p>Dear Sir, <br><br> " + txtfname.Text + " " + txtlname.Text + ", has raised a requisition that needs your approval. <br><br><br> Please click to [<a href='http://localhost:1240/IMA/Approve.aspx?id="+tt+"'> Approve</a> ] [<a href='Reject.aspx'>Reject</a> ] the request. <br> <br> <br> <b>Note</b> : Please do not reply. This e-mail has been auto-generated.</p>";
mail.IsBodyHtml = true;
In the mail i have move the mouse over the approve link it shows http://.../approve.aspx?id=1, but click the appove link
it shows <a href="http://.../id=1.
I don't know why.
Please help me out.
Thanks in advance,
Murugavel S
modified 6-Oct-12 20:54pm.
|
|
|
|
|
Check the source of mail message to see if link renders correctly.
No more Mister Nice Guy... >: |
|
|
|
|
|
For a C# 2010 application, I need to check for the values in a column being all spaces. The number of space characters in a field can change. Thus can you tell me how to tell if a field in a string and/or a datadbase column is all spaces?
|
|
|
|
|
This is stimple string manipulation. Every string has a Chars array. All you do is iterate over the array and compare that character to " ".
|
|
|
|
|
One way to do it would be to use the Trim() method of the string, and if the resulting string is zero characters in length, then you know it's all spaces:
if (myString.Length > 0)
if (myString.Trim().Length == 0)
return true;
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
how to get all the tables from a particular database in c# codes???
|
|
|
|
|
|
Try:
SELECT column_name, data_type, is_nullable, character_maximum_length FROM information_schema.COLUMNS WHERE table_name='myTable'
Or
select column_name from information_schema.columns where table_name = 'Test'
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
namespace tictoegame
{
public class gamestart
{
int functionalcount, computernumber,usernumber;
char[] box = new char[9];
static int j=6;
public gamestart()
{
for(int k=0;k<9;k++)
{
box[k] = ' ';
}
functionalcount = 0;
Random rd = new Random();
while(true)
{
computernumber = rd.Next(0, 8);
if (box[computernumber]!='x'&& box[computernumber]!='X'&&box[computernumber]!='o'&& box[computernumber]!='O')
{
insertvalue(computernumber,Program.computersymbol);
break;
}
}
functionalcount++;
userturn();
}
public void position()
{
int i=1;
Console.CursorLeft=i;
Console.CursorTop=j;
j++;
}
public void userturn()
{
if (functionalcount != 9)
{
bool flag1 = checkwin(Program.usersymbol);
if (flag1)
{
position();
Console.WriteLine("you won");
Thread.Sleep(3000);
Environment.Exit(0);
}
else
{
while (true)
{
position();
Console.WriteLine("enter the number for symbol");
usernumber = Convert.ToInt32(Console.ReadLine());
if (box[usernumber] != 'x' || box[usernumber] != 'X' && box[usernumber] != 'o' || box[usernumber] != 'O')
{
insertvalue(usernumber, Program.usersymbol);
functionalcount++;
break;
}
}
computerturn();
}
}
}
public void computerturn()
{
int count=0,i;
if (functionalcount == 2)
{
Random rd = new Random();
while (true)
{
computernumber = rd.Next(0, 8);
if((box[computernumber] != 'x' || box[computernumber] != 'X') && (box[computernumber] != 'o' || box[computernumber] != 'O'))
{
insertvalue(computernumber,Program.computersymbol);
functionalcount++;
break;
}
}
userturn();
}
if(functionalcount==4||functionalcount==6)
{
bool flag=checkthirdposition(Program.computersymbol,ref count);
bool flag1 = checkwin(Program.computersymbol);
if(flag1)
{
position();
Console.WriteLine("computer wins");
Thread.Sleep(3000);
Environment.Exit(0);
}
bool flag2=checkthirdposition(Program.usersymbol,ref count);
if(flag2)
{
box[count]=Program.computersymbol;
insertvalue(count,Program.computersymbol);
functionalcount++;
userturn();
}
else
{
Random rd = new Random();
while (true)
{
computernumber = rd.Next(0, 8);
if((box[computernumber] != 'x' || box[computernumber] != 'X' )&&( box[computernumber] != 'o' || box[computernumber] != 'O'))
{
insertvalue(computernumber,Program.computersymbol);
functionalcount++;
break;
}
}
userturn();
}
}
if(functionalcount==8)
{
int con;
for(i=0;i<9;i++)
{
if((box[i]!='x'||box[i]!='X')&&(box[i]!='o'||box[i]!='O'))
{
con=i;
box[con]=Program.computersymbol;
insertvalue(con,Program.computersymbol);
}
}
functionalcount++;
position();
Console.WriteLine("draw");
userturn();
}
}
public bool checkthirdposition(char ch, ref int x)
{
if (checkpos(1, 2, 0, ch) || checkpos(3, 6, 0, ch) || checkpos(4, 8, 0, ch))
{
if (ch == Program.computersymbol)
{
insertvalue(0, ch);
x = 0;
return true;
}
else
if(ch==Program.usersymbol)
{
x=0;
return true;
}
}
if (checkpos(0,2,1, ch) || checkpos(7,4,1,ch))
{
if (ch == Program.computersymbol)
{
insertvalue(1, ch);
x = 1;
return true;
}
else
if(ch==Program.usersymbol)
{
x = 1;
return true;
}
}
if(checkpos(0,1,2,ch) || checkpos(8,5,2,ch)||checkpos(6,4,2,ch))
{
if (ch == Program.computersymbol)
{
insertvalue(2, ch);
x = 2;
return true;
}
else
if(ch==Program.usersymbol)
{
x = 2;
return true;
}
}
if(checkpos(0,6,3,ch) || checkpos(5,4,3,ch))
{
if (ch == Program.computersymbol)
{
insertvalue(3, ch);
x = 3;
return true;
}
else
if(ch==Program.usersymbol)
{
x = 3;
return true;
}
}
if(checkpos(0,8,4,ch) || checkpos(2,6,4,ch)||checkpos(1,7,4,ch)||checkpos(3,5,4,ch))
{
if (ch == Program.computersymbol)
{
insertvalue(4, ch);
x = 4;
return true;
}
else
if(ch==Program.usersymbol)
{
x = 4;
return true;
}
}
if(checkpos(2,8,5,ch) || checkpos(3,4,5,ch))
{
if (ch == Program.computersymbol)
{
insertvalue(5, ch);
x = 5;
return true;
}
else
if(ch==Program.usersymbol)
{
x = 5;
return true;
}
}
if(checkpos(0,3,6,ch) || checkpos(2,4,6,ch)||checkpos(8,7,6,ch))
{
if (ch == Program.computersymbol)
{
insertvalue(6, ch);
x = 6;
return true;
}
else
if(ch==Program.usersymbol)
{
x = 6;
return true;
}
}
if(checkpos(1,4,7,ch) || checkpos(6,8,7,ch))
{
if (ch == Program.computersymbol)
{
insertvalue(7, ch);
x = 7;
return true;
}
else
if(ch==Program.usersymbol)
{
x = 7;
return true;
}
}
if(checkpos(2,5,8,ch) || checkpos(6,7,8,ch)||checkpos(0,4,8,ch))
{
if (ch == Program.computersymbol)
{
insertvalue(8, ch);
x = 8;
return true;
}
else
if(ch==Program.usersymbol)
{
x = 8;
return true;
}
}
return false;
}
public bool checkpos(int i, int j, int k, char ch1)
{
if ((box[i] == box[j] && box[i] == ch1) && (box[k] != 'x' || box[k] != 'X' || box[k] != 'o' || box[k] != 'O'))
{
return true;
}
else
{
return false;
}
}
public bool checkwin(char ch)
{
if((box[0] == box[1] && box[1]==box[2] && box[0]==ch)||(box[3]==box[4]&&box[4]==box[5]&&box[3]==ch)||(box[6]==box[7]&&box[7]==box[8]&&box[6]==ch)||((box[0]==box[3]&&box[3]==box[6]&&box[0]==ch)||
(box[1]==box[4]&&box[4]==box[7]&&box[1]==ch)||(box[2]==box[5]&&box[5]==box[8]&&box[2]==ch)||(box[0]==box[4]&&box[4]==box[8]&&box[0]==ch)||(box[6]==box[4]&&box[4]==box[2])&&box[6]==ch))
{
return true;
}
else
{
return false;
}
}
public void insertvalue(int x, char ch)
{
box[x] = ch;
switch (x)
{
case 0:
Console.SetCursorPosition(1, 0);
Console.Write(ch);
break;
case 1:
Console.SetCursorPosition(5, 0);
Console.Write(ch);
break;
case 2:
Console.SetCursorPosition(9, 0);
Console.Write(ch);
break;
case 3:
Console.SetCursorPosition(1,2);
Console.Write(ch);
break;
case 4:
Console.SetCursorPosition(5, 2);
Console.Write(ch);
break;
case 5:
Console.SetCursorPosition(9, 2);
Console.Write(ch);
break;
case 6:
Console.SetCursorPosition(1,4);
Console.Write(ch);
break;
case 7:
Console.SetCursorPosition(5, 4);
Console.Write(ch);
break;
case 8:
Console.SetCursorPosition(9,4);
Console.Write(ch);
break;
}
}
}
class Program
{
static public char usersymbol;
static public char computersymbol;
static void Main(string[] args)
{
Console.WriteLine(" to enter the symbol in any box number it from 1 to 9");
picksymbol();
Thread.Sleep(3000);
Console.Clear();
display();
resets();
gamestart gs = new gamestart();
Console.ReadLine();
}
public static void display()
{
Console.WriteLine(" " + " " +" "+ "|" + " " + " " +" "+ "|");
Console.WriteLine("_" + "_" + "_" + "|" + "_" + "_" + "_" + "|"+"_"+"_"+"_");
Console.WriteLine(" " + " " + " " + "|" + " " + " " + " " + "|");
Console.WriteLine("_" + "_" + "_" + "|" + "_" + "_" + "_" + "|" + "_" + "_" + "_");
Console.WriteLine(" " + " " + " " + "|" + " " + " " + " " + "|");
Console.WriteLine(" " + " " + " " + "|" + " " + " " + " " + "|");
}
public static void picksymbol()
{
while (true)
{
Console.WriteLine("enter the symbol-- either x or o");
usersymbol = Convert.ToChar(Console.ReadLine());
if (usersymbol == 'x' || usersymbol == 'X' || usersymbol == 'o' || usersymbol == 'O')
{
break;
}
}
if (usersymbol == 'x' || usersymbol == 'X')
{
Console.WriteLine(" you picked {0}", usersymbol);
computersymbol = 'o';
Console.WriteLine(" the computer symbol is {0}", computersymbol);
}
else
{
Console.WriteLine(" you picked {0}", usersymbol);
computersymbol = 'x';
Console.WriteLine(" the computer symbol is {0}", computersymbol);
}
}
static void resets()
{
int i,j;
for (i = 1, j = 0; j <= 4; i = i + 4)
{
Console.SetCursorPosition(i, j);
Console.Write(' ');
if (i == 9)
{
i = -3;
j = j + 2;
}
}
Console.WriteLine();
Console.WriteLine();
}
}
}
|
|
|
|
|
You haven't said what the problem really is, so how do you think we can help? You need to debug your application and try to narrow down what is happening yourself.
|
|
|
|
|
|
I was thinking about a software that can send messages without connecting any phone to your computer. You just have to register your number and than receiver's number and message will be send using your GSM services. If you know what i mean. It will use your phone's credit there is no role of phone physically. I am thinking about using c#. Help if someone can help me.
|
|
|
|
|
zain_zone wrote: Help if someone can help me. Help with what, exactly? All you have is a description of what the software should be able to do. No-one will write the software for you; if you want this idea to become reality, you'll have to start writing code. If you get stuck and have a specific question, we could help. "Help" means a pointer in the right direction, not "writing lots of code based on a vague idea". FWIW, I'd recommend researching whether what you want is technically possible.
I do not own a mobile phone, so these might be non-issues to you. Still, I'm wondering how this would work with a prepaid-phone. How will you perform a transaction without physical access to the phone?
Even without prepaid, let's assume a subscription. How would you know who my provider is, and how would you do a financial transaction on that? I bet it's not going to be easy, otherwise a lot of people would simply be stealing credits, wouldn't they?
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
I think you are right - at the very minimum you would need the IMEI number I assume. Sounds a bit "iffy" to me - would probably need to be discussed with the carrier companies before you could go ahead with it.
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Hi
I need your help in,
I am working on a project, MYSQL and PHP based, with WAMP SERVER
I have a field storytext, (data collected in URDU) detail are:
<b>Field Type Collation Null Default
storytext text utf8_unicode_ci Yes NULL</b>
Retrieving URDU Data from MY SQL 5.5.8 running on wamp server with PHP is OK,
And the soft ware is only for Internal use not web base!
------------------------------------------------------------------------------------------
<b>HERE IS THE PROBLEM:</b>
One section of it is designed on Visual Studio.NET 2010 in which
I have a datagrid, on clicking any row I got the TEXT in details on text box,
which show <b>URDU TEXT</b>, from data base here is the problem with <b>TEXT BOX and DATAGRID.</b>
I got this..........
<b>DESP. ITEM
پروگرام رانا مب
شر ايٹ پرائم ٹائم ميں
گ٠تگو کرتے Û ÙˆØ¦Û’ وزير٠اعظم Ú©Û’
وکيل Ú†ÙˆÛ Ø¯Ø±ÙŠ اعتزاز اØسن
کا Ú©Û Ù†Ø§ تھا Ú©Û ØµØ¯Ø± Ú©Û’ Ø¹Û Ø¯Û’
Ú©Ùˆ استشني Øاصل Û Û’
وزير٠اعظم Ø</b>
-------------------------------------------------------------------------------------------------------
I also use in visual studio
<b>cnString = "datasource=localhost;username=root;password=;database=spidernews;charset=utf8;"</b>
How can I solve this problem,
can you help me out !
<b>URDU NOT SHOWING, </b>
<pre lang="vb">Here is Whole CODE of Visual Studio, I am using:
------------------------------------------------------------------------------------------------------------------------</pre>
<pre lang="text">
Imports MySql.Data.MySqlClient
Public Class Form1
Dim conn As Common.DbConnection
Dim da As Common.DbDataAdapter
Dim ds As DataSet = New DataSet
Dim cnString As String
Dim sqlQRY As String
'Dim dt As DataTable
'Dim strBuilder As Char
'''' SCROLLONG TEXT START
Dim scrollingText As String = "Spider NEWS "
Dim txtStr(scrollingText.Length - 1) As String
Dim txtPos As Integer = -1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'strBuilder.ToString ("tblnews" & char(34))
cnString = "datasource=localhost;username=root;password=;database=spidernews;charset=utf8;"
sqlQRY = "SET NAMES UTF8; SET CHARACTER SET UTF8;Select slugid,slug,storytext,storyduration,segmentdescription,prioritydescription,mosstatus from tblnews"
'sqlQRY = "SET NAMES UTF8; SET CHARACTER SET latin1;Select slugid,slug,storytext,storyduration,segmentdescription,prioritydescription,mosstatus from tblnews"
conn = New MySqlConnection(cnString)
Try
conn.Open()
da = New MySqlDataAdapter(sqlQRY, conn)
Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(da)
da.Fill(ds, "tblnews")
DataGridView1.DataSource = ds
DataGridView1.DataMember = "tblnews"
'''''
Catch ex As Common.DbException
MsgBox(ex.ToString)
Finally
conn.Close()
End Try
'''' SCROLLONG TEXT START
For idx As Integer = 0 To UBound(txtStr)
Dim workedString As String = ""
workedString = scrollingText.Substring(idx) & " " & scrollingText.Substring(0, idx)
txtStr(idx) = workedString
Next
Timer1.Interval = 5000
Timer1.Enabled = True
Timer1.Start()
'''' SCROLLONG TEXT END
Label2.Text = System.DateTime.Now
End Sub
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
da.Update(ds, "" + TextBox1.Text + "")
MsgBox("Data sent", MsgBoxStyle.OkOnly, "Sucess")
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
Dim i, j As Integer
i = DataGridView1.CurrentRow.Index
RichTextBox1.Text = DataGridView1.Item(2, i).Value
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim i, j As Integer
i = DataGridView1.CurrentRow.Index
'''' SCROLLONG TEXT START
txtPos += 1
Dim timerStr As String
timerStr = txtStr(txtPos)
RichTextBox1.Text = DataGridView1.Item(2, i).Value
Label1.Text = timerStr
If txtPos = UBound(txtStr) Then txtPos = -1
'''' SCROLLONG TEXT START
End Sub
End Class
</pre>
|
|
|
|
|
This is not the correct forum for this question; try the VB.NET forum, and please fix the formatting of your message.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I am working on setting up a C# 2010 application that will search directory file paths to see when there has been a files added
to the directory since the last time the directory was searched. I basically want to look for the following:
1. files that end with *.xls or *.xlsx.
2. I will look for files in the 'highest' level directory path and serach for new files that have been added since the last time the search was made.
Thus I am hoping you can tell me how to accomplish this goal and/or point me to referneces that will let me how to accomplish this goal.
|
|
|
|
|