|
Why not use a MaskedTextBox?
|
|
|
|
|
You can set up an event handler for keypress event to check whether the key that was pressed is digit or not. Depending on that you can ignore the key if it isn't a digit or a backspace
|
|
|
|
|
Hi
I want to transmit a live video from server to multi clients using UDP, I m working in C# and I've captured the video from WebCam. So please tell me the steps to be follow to accomplish this task.OR if u have any tutorials or links related to my task plz Notify me.
Regards.
Shanzay
|
|
|
|
|
i have text column in the database(access).the column contains a image path information.all i have to do is to show the image in crystal reports .if i use the ole object then it is coming fine in the crystal reports but i am stuck at showing the pic when showing the image in the crystal reports while accessing the path from the database.
Soniagupta1@yahoo.co.in
|
|
|
|
|
Sonia Gupta wrote: he column contains a image path information.all i have to do is to show the image in crystal reports
Showing dynamic images in crystal reports would be a hectic problem. Passing image name and showing it over there is not possible. One option would be storing image in database as BLOB. Crystal reports having capability to render this BLOB data. But for this you need to switch your DB to SQL Server.
|
|
|
|
|
how can i retrieve the images from the database to my form in c#? the images are in the ole type column
Soniagupta1@yahoo.co.in
|
|
|
|
|
My application will generate a word document as report. The application created Word Application and Document objects.
When users click on Close or the "X" icon on the up right corner. The application will intercept word DocumentBeforeCloseEvent, to ask users Save, No or Cancel to the document changes. Everything works fine except when users click on "Cancel", Word still displays it's own Dialog for users to select Yes, No or Cancel for saving the document changes.
Is there anyway to prevent this Word dialog because my application already process uses decision?
Here is part of the code:
Word_DocumentBeforeClose is used to process users decision.
The last part of If in else is to process when Cancel is clicked.
namespace HandleWordEvnts
{
public partial class Form1 : Form
{
#region properties
Word.ApplicationClass wordApp;
Word.Document wordDoc;
string docName;
#endregion properties
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
//===== Create a new document in Word ==============
// Create an instance of Word and make it visible.
wordApp = new Word.ApplicationClass();
wordApp.Visible = true;
// Local declarations.
Object oMissing = System.Reflection.Missing.Value;
// Add a new document.
wordDoc = wordApp.Documents.Add(ref oMissing, ref oMissing,
ref oMissing, ref oMissing); // Clean document
// Add text to the new document.
wordDoc.Content.Text = "Handle Events for Microsoft Word Using C#.";
docName = wordDoc.Name;
//============ Set up the event handlers ===============
wordApp.DocumentBeforeClose +=
new Word.ApplicationEvents2_DocumentBeforeCloseEventHandler(
Word_DocumentBeforeClose);
}
// The event handlers.
private DialogResult showSaveFileDlg(ref string fileName, ref string filePath)
{
DialogResult dlgRes = DialogResult.None;
object locker = new object();
Thread.Sleep(1000); //time needed for dialog to display
lock (locker)
{
saveFileDialog1.Title = "App Save As";
saveFileDialog1.FileName = filePath != "" ? (filePath + "\\" + fileName) : fileName; //init full name
saveFileDialog1.InitialDirectory = filePath;
saveFileDialog1.Filter = "Word Document (*.doc)|*.doc| Plain Text (*.txt)|*.txt|All files (*.*)|*.*";
saveFileDialog1.FilterIndex = 1;
saveFileDialog1.RestoreDirectory = true;
dlgRes = saveFileDialog1.ShowDialog();
if (dlgRes == DialogResult.Cancel) return dlgRes;
fileName = saveFileDialog1.FileName.Substring(saveFileDialog1.FileName.LastIndexOf("\\") + 1);
filePath = saveFileDialog1.FileName.Substring(0, saveFileDialog1.FileName.LastIndexOf("\\"));
return dlgRes;
}
}
private void Word_DocumentBeforeClose(Word.Document doc, ref bool Cancel)
{
docName = doc.Name;
string fileName = doc.Name;
string filePath = doc.Path;
// ask user to save or not
DialogResult dlgRes = DialogResult.None;
AskSaveCnanges askSave = new AskSaveCnanges();
askSave.setTxtBox1 = filePath != "" ? (filePath + "\\" + fileName) : fileName;
askSave.setTxtBox1Readonly = true;
askSave.ShowDialog();
if (askSave.DlgRes == DialogResult.Yes) //user agrees to save
{
Thread showWordDlg = new Thread(delegate() { dlgRes = showSaveFileDlg(ref fileName, ref filePath); });
showWordDlg.SetApartmentState(ApartmentState.STA);
showWordDlg.Name = "DocClose";
showWordDlg.Start();
showWordDlg.Join();
if (dlgRes == DialogResult.OK) //user agrees to save
{
MessageBox.Show("DocumentBeforeClose ( Saved " + doc.Name + " )","APP");
//Save the file, use default values except for filename
object ofileName = filePath + "\\" + fileName;
object optional = Missing.Value;
try
{
doc.SaveAs(ref ofileName, ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional,
ref optional, ref optional, ref optional, ref optional);
//doc.Save();
doc.Saved = true;
object saveChanges = true;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;
wordApp.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
}
catch (COMException e)
{
MessageBox.Show(e.Message,"ApP.DocumentBeforeClose");
}
//saveAs = false;
//Cancel = true;
}
}
else if (askSave.DlgRes == DialogResult.No)
{
MessageBox.Show("DocumentBeforeClose ( Not Saved " + doc.Name + " )","APP");
Cancel = true;
object saveChanges = false;
object originalFormat = Missing.Value;
object routeDocument = Missing.Value;
doc.Close(ref saveChanges, ref originalFormat, ref routeDocument);
wordApp.Quit(ref saveChanges, ref originalFormat, ref routeDocument);
}
else
{
MessageBox.Show("DocumentBeforeClose ( Canceled " + doc.Name + " )","APP");
//When users cilck on Cancel button.
// Cancel is set to true but Word still displays it's own dialog.
Cancel = true;
doc.Saved = false;
wordApp.Activate();
Thread.Sleep(5000);
//send key does not work either
SendKeys.SendWait("{RIGHT}{RIGHT}{ENTER}");
}
}
}
|
|
|
|
|
Hey,
I'm having some problems starting a command-line program using Process.Start(). I pass it the filename and arguments, and it runs the program, but instantly crashes and a "Program has stopped working" error comes up. I can't figure out what is wrong. The program runs fine from the command line and when I use a shortcut, and Process.Start() runs other programs fine. Can anyone tell me what is wrong?
For reference, I am running this in Vista.
|
|
|
|
|
As per my experience you have problem in passing arguments.
Try without argument passing, and change the way to pass arguments.
Hope you will find solution.
I have tried to give hint to your problem.
Best Regards,
Chetan Patel
|
|
|
|
|
Well classical problems like this are solved by using unmanaged code equivilant to the System.Diagnostics namespace from the win32 api.
(Hint: search MSDN)
Hope this helps!!;)
To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!
|
|
|
|
|
I inherited a program that takes data from a csv file and inserts it into a database.
The data is in the following format:
8/20/2007 12:14:21 PM,HDFM,"Nick Yockell","Nate Wittrock",239-850-3931,239-850-2514,"Used 2004 Harley Davidson ","bought bike
CUSTOMER WANTS TO BRING HIS YAMAHA R6 IN TO TRADE AND SEE HOW MUCH PAYMENTS WOULD BE.
",Deliver,aa32ed31-f0c8-4f43-a7d4-830d9f29edcd
For some reason the function that saves the data to the database is having a problem with the customer phone number (5th column).
The database column is a varchar(50) - the same as the customer business phone number.
If the customer home phone contains anything other that digits it cannot be saved to the database.
However, the customer business phone can contain anything and gets saved just fine.
Is there anything in the two functions that could be causing this ?
private void ProcessFile(string filename, string vendor)
{
string path = string.Empty;
string LoggingDate = DateTime.Now.ToString();
switch (vendor.ToLower())
{
case "vpulse":
path = DIRECTORYPATHVPULSE;
break;
case "calllogpro":
path = DIRECTORYPATHCALLLOGPRO;
break;
}
try
{
OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+path+"\\"+";Extended Properties=\"Text;HDR=No;FMT=Delimited()\"");
//OleDbConnection ExcelConnection = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+this.txtSource.Text+"\\"+";Extended Properties=\"Text;HDR=No;\"");
OleDbCommand ExcelCommand = new OleDbCommand(@"SELECT * FROM "+filename,ExcelConnection);
OleDbDataAdapter ExcelAdapter = new OleDbDataAdapter(ExcelCommand);
ExcelConnection.Open();
DataSet ExcelDataSet = new DataSet();
ExcelAdapter.Fill(ExcelDataSet);
ExcelConnection.Close();
//Process File
ProcessFileRecords(ExcelDataSet, vendor.ToLower());
//Email Copy to Alliance Group
this.EmailFile(path, filename, vendor);
}
catch (Exception exc)
{
string errorText = exc.ToString();
System.Diagnostics.EventLog.WriteEntry("Alliance Level 2 DataRetreiver", errorText);
}
finally
{
//Archive Copy
this.ArchiveFile(path, filename);
}
}
private void ProcessFileRecordVPulse(object[] record)
{
string logdate = string.Empty;
string dealership = string.Empty;
string salesperson = string.Empty;
string customername = string.Empty;
string homephone = string.Empty;
string businessphone = string.Empty;
string product = string.Empty;
string comments = string.Empty;
string sellstage = string.Empty;
string vpulsecalltaskid = string.Empty;
string LoggingDate = DateTime.Now.ToString();
try
{
logdate = Convert.ToDateTime(record[0]).ToShortDateString();
dealership = record[1].ToString();
salesperson = record[2].ToString();
customername = record[3].ToString();
try
{
homephone = record[4].ToString();
//homephone.Replace("-", "");
}
catch
{
homephone = "Bad format";
}
businessphone = record[5].ToString();
product = record[6].ToString();
comments = record[7].ToString().Replace("
", " ");
//***Get Sales Stage
sellstage = record[8].ToString();
switch(sellstage.ToLower())
{
case "greet":
sellstage = "1";
break;
case "probe":
sellstage = "2";
break;
case "identify machine":
sellstage = "3";
break;
case "presentation":
sellstage = "4";
break;
case "sit down":
sellstage = "5";
break;
case "write up":
sellstage = "6";
break;
case "close the deal":
sellstage = "7";
break;
case "finance":
sellstage = "8";
break;
case "deliver":
sellstage = "9";
break;
default:
if (sellstage.ToLower().IndexOf("service") == -1 && sellstage.ToLower().IndexOf("parts") == -1)
sellstage = "1";
else
sellstage = sellstage;
break;
}
//***Get Sales Stage
vpulsecalltaskid = record[9].ToString();
//Import lead record
SqlCommand command = this.GetCommand();
command.CommandText = @"INSERT INTO CallLogs
(LogDate,
VPulseCallTaskId,
CallLogTypeId,
DealerId,
SalesPerson,
CustomerName,
CustomerHomePhone,
CustomerBusinessPhone,
Product,
Comments,
SaleStage,
LogProcessFlag,
CSI14Days,
CSI17Months,
CSI14DaysProcessFlag,
CSI17MonthsProcessFlag)
VALUES
(@LogDate,
@VPulseCallTaskId,
@CallLogTypeId,
@DealerId,
@SalesPerson,
@CustomerName,
@CustomerHomePhone,
@CustomerBusinessPhone,
@Product,
@Comments,
@SaleStage,
@LogProcessFlag,
@CSI14Days,
@CSI17Months,
@CSI14DaysProcessFlag,
@CSI17MonthsProcessFlag)";
command.Parameters.Add("@LogDate", logdate);
command.Parameters.Add("@VPulseCallTaskId", vpulsecalltaskid);
if ((sellstage.ToLower().IndexOf("service") == -1)&&(sellstage.ToLower().IndexOf("parts") == -1))
{
command.Parameters.Add("@CallLogTypeId", "1");
}
else
{
if (sellstage.ToLower().IndexOf("service") != -1)
{
command.Parameters.Add("@CallLogTypeId", "1"); //Service (4)
dealership = dealership+"_SERVICE";
sellstage = "1";
}
else if (sellstage.ToLower().IndexOf("parts") != -1)
{
command.Parameters.Add("@CallLogTypeId", "1"); //Parts (3)
dealership = dealership+"_PARTS";
sellstage = "1";
}
}
command.Parameters.Add("@DealerId", dealership);
command.Parameters.Add("@SalesPerson", salesperson);
command.Parameters.Add("@CustomerName", customername);
command.Parameters.Add("@CustomerHomePhone", homephone);
command.Parameters.Add("@CustomerBusinessPhone", businessphone);
command.Parameters.Add("@Product", product);
command.Parameters.Add("@Comments", comments);
command.Parameters.Add("@SaleStage", sellstage);
command.Parameters.Add("@LogProcessFlag", false);
command.Parameters.Add("@CSI14Days", Convert.ToDateTime(logdate).AddDays(14).ToString());
command.Parameters.Add("@CSI17Months", Convert.ToDateTime(logdate).AddMonths(17).ToString());
command.Parameters.Add("@CSI14DaysProcessFlag", false);
command.Parameters.Add("@CSI17MonthsProcessFlag", false);
command.ExecuteNonQuery();
this.DisposeCommand(command);
}
catch (Exception exc)
{
string errorText = exc.ToString();
System.Diagnostics.EventLog.WriteEntry("Alliance Level 2 DataRetreiver", errorText);
}
|
|
|
|
|
I had read your code, i think it works can you give me the error.
In above code there is no error.
Best Regards,
Chetan Patel
|
|
|
|
|
If the customer home phone contains anything other that digits it cannot be saved to the database.
Thanks,
Nathan
|
|
|
|
|
digsy_ wrote: phone contains anything other that digits it cannot be saved to the database
Shouldn't you then have the phone numbers wrapped around quotations as well? Seems like most of your other fields are.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I'll try that - the next field in the csv row has exactly the same types of data in it and doesnt have any problems being saved to the database
|
|
|
|
|
Is it possible to get sound data from the microphone? Everyone keeps telling me to go for SAPI, but I'm not doing speech recognition. I'm looking for a way to get data like the sound data in a .WAV file. I need to get the sound, like the Sound Recorder program that comes with Windows. Any suggestions?
Hippophobia - Fear of horses. What?
|
|
|
|
|
DirectX is what you need
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Well I guess Direct X shall do the trick!!
To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!
|
|
|
|
|
can i design a botton in c# like circle or 3D botton or other effects
|
|
|
|
|
There are articles on this site for doing that.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
yes of course you simply need to override the button's Onpaint method to your desired shape, for more information alot of articles regarding this are found on the web and codeproject!
(Tip: Next time search google first)
To follow the path, Walk with the MASTER, See through the MASTER, Be the MASTER!
|
|
|
|
|
hi friends
i have two textbox and one context menu strip for both of them that in this menu strip i have an item that show the text of the textbox.
my problem is that in the click event of the context menu strip i dont know that on the witch one of two textbox right click and click on special item occurs.
how can i understand it.
please help me
nobody help you...
you have to help you yourself
and this is success way.
|
|
|
|
|
You have to save the source control name when you are showing the context menu in variable and use that value to proceed the context menu command.
Best Regards,
Chetan Patel
|
|
|
|
|
Handle the opening event of the context menu strip and examine the sender parameter.
|
|
|
|
|
In my Gridview rowUpdating event, am not able to retrieve e.NewValues.
e.NewValues and e.OldValues everything returns empty.
Can you please help?
Thanks.
|
|
|
|
|