|
Thanks abhijit its nice
Shafik
|
|
|
|
|
By the task bar I assume you mean the system tray.
You need to handle the FormClosing event and add a NotifyIcon.
In the FormClosing, check if the form is Visible. If true, then hide the form, show the notify icon and set e.Cancel to true.
All that's left to do then is add a context menu to the notify icon so you can provide a way to exit and handle left/right/double click on the notify icon for unhiding the form and hiding the icon.
|
|
|
|
|
First select all product from database
private DataTable ShowProduct()
{
string mach = "select ID,Name from product";
cmd = new SqlCommand(mach,con);
adt = new SqlDataAdapter(cmd);
ds = new DataSet();
adt.Fill(ds);
return ds.Tables[0];
}
-----------------------------------------------------------------
Second build funtion create id auto
private int AutoID() //funtion create auto id
{
DataTable dt = new DataTable();
dt=ShowProduct(); //datatable store list id
int ma=-1;
int row = -1;
string mach1="";
int i = 0;
if (dt.Rows.Count > 0) //at least one id
{
int[] id = new int[dt.Rows.Count];
foreach (DataRow mach in dt.Rows) //assigned id in string array
{
ma++;
row++;
mach1 = dt.Rows[row][0].ToString();
id[ma] = Convert.ToInt32(mach1.Substring(2)); //get string index=2 to end converter int assigned id in string array
}
for (int j = 0; j < id.Length; j++) //create auto id
{
i++;
if (id[0] != 1) //first id !=1 set id =0
{
i = i - 1;
break;
}
if (id[j] > i) //id[j] != id[j-1]+1 set id=id[j-1]
{
i = id[j - 1];
break;
}
}
}
return i + 1; //return id need create
}
---------------------------------------------------------------
Using
private void bttInsert_Click(object sender, EventArgs e)
{
int id = AutoID(); ////Using
string idpro = "SP" + id.ToString().PadLeft(4, '0');
txtID.Text = idpro;
if (bttInsert.Text == "Insert")
{
txtName.Clear();
bttInsert.Text = "Save";
}
else
{
if (txtName.Text != "")
{
InsertSP(idpro, txtName.Text);
dgvShowSP.DataSource = ShowProduct();
bttInsert.Text = "Insert";
}
else
MessageBox.Show("Bạn chưa nhập tên sản phẩm");
}
}
Link download demo
CreateAutoID.rar
|
|
|
|
|
why dont you use GUID all the time.. Most useful for Primary Key....
|
|
|
|
|
I'm sorry, I speak English very bad. I idea every time user add product id auto create, information user fill out rest. I don't know GUID.
You can explain to me what the GUID?
|
|
|
|
|
You should be creating your own AutoIDs in the first place. They should be created by the database when you insert new records, not your code.
|
|
|
|
|
Every body should download demo and run. Every body will understand my idea.
|
|
|
|
|
Theres lots of info about adding buttons to title bar, like this: http://www.codeproject.com/KB/cs/mintraybtn.aspx
But ive seen a couple programs that can add a button like that to every windows window. Like an nvidia(IIRC) app which added a button next to the minimize on EVERY window. Now i need to be able to that, plus assign some code to the button.
Thanks guys.
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
That would suck; keep it off my system.
|
|
|
|
|
I need to create characters of the people as requirement of my application, I'm thinking of making cartoons from real life images, I see this done in some facebook application, how should I do this, I have done grayscale and that does not produce the result I need.
Any advice ?
Also tried box blur filter, but effect is not as desired
modified on Saturday, September 26, 2009 12:15 PM
|
|
|
|
|
Those sort of filters tend to be complex, they are certainly not a filter you can create by changing values in a convolution filter. You need to understand the theory behind it and write dedicated code to the effect you're trying to create.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi.
I'm gonna take the DateTime of 24 hours former with C# , I've written below code :
DateTime _24HoursFormer
{
get { return new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day - 1, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); }
}
But whenever DateTime.Now.Day equals 1, it throws an Exception !!
Could you guide me ?
Thanks.
|
|
|
|
|
Doesn't DateTime.Now.AddHours(-24) looks cleaner?
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Thanks a lot.
I didn't know it
|
|
|
|
|
d@nish wrote: Doesn't DateTime.Now.AddHours(-24) looks cleaner?
IMO the logical approach would be DateTime.Now.AddDays(-1)
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Especially since subtracting hours may not work on days with leap seconds or 25 hours.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: Especially since subtracting hours may not work on days with leap seconds or 25 hours.
There are no days with 25 hours, only ones with 24.
|
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: A correctly implemented DateTime class should require subtracting 25 hours on the switchover date or 23 depending on the Calender. Which is why one should subtract days and not hours.
I wish I had a dollar for every time I've been through this argument. The clocks on computers use UTC (Universal Co-ordinated Time) based on what was Greenwich Mean Time, but is now agreed by one of the UN bodies. For argument's sake it is as near to GMT as makes no difference. When you want to display the time then the library routines make an adjustment based on the local timezone and the rules for daylight saving time appropriate to that timezone. However all DateTime calculations are based on UTC so there are never any discrepancies such as you imagine; every day is 24 hours long, whatever the time of year. Only in this way can date and time calculations work correctly.
|
|
|
|
|
My original comment was in jest suggesting that a good programmer would subtract a day instead of 24 hours; hoping that the parody would drive the point home. My reply to you was to point out that it is entirely possible to come across a 23 or 25 hour day in an implementation. Of course, your reply will once again ignore the point I was trying to make so I don't know why I bother.
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: My original comment was in jest suggesting that a good programmer would subtract a day instead of 24 hours; hoping that the parody would drive the point home.
Your original comment: Especially since subtracting hours may not work on days with leap seconds or 25 hours.
Spot the humour? Well I didn't.
Ennis Ray Lynch, Jr. wrote: My reply to you was to point out that it is entirely possible to come across a 23 or 25 hour day in an implementation.
Not so, this is what you actually said:
Your reply: A correctly implemented DateTime class should require subtracting 25 hours on the switchover date or 23 depending on the Calender. Which is why one should subtract days and not hours.
No, still can't see either joke or parody.
Ennis Ray Lynch, Jr. wrote: Of course, your reply will once again ignore the point I was trying to make so I don't know why I bother.
As far as I could see, the point you were trying to make was that there are dates in the calendar where a day can equal 23 or 25 hours.
And since you seem to take umbrage when someone misses your hilarious joke, I'm not sure why you bother either.
|
|
|
|
|
True.
On the lighter side, he does not wants the day before but the time 24 hrs less than current time. Hence the reply.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Correct.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
This is a Compact framework question...
I'm building this application that deals with a lot of images coming from the network (~30 k a piece). I am starting to see serious memory issues arise after a while. While my images are mostly cached and the cache is cleaned up if you play with the app for long enough you get an out of memory exception. I can see the app running with up to 25 megabytes of memory in use, the problem is I'm not entirely sure what is causing this. My best guess is that the bitmap caches the decompressed version of the image after its been shown on the picturebox, either that or the picturebox does.
Is there a way to reduce the memory footprint while still having that amount of images (roughly 30) in memory, the only way I can think of is to not put the actual bitmap on the display but rather a copy and after the bitmap has been shown to let the garbage collector handle the copy, however I'm pretty sure that thats going to hurt performance.
Any other idea's?
|
|
|
|
|
You do call Dispose() on images you no longer need, do you?
If that doesn't help, show us some code.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|