|
How to create sale invoice and print using datagridview values in c# windows applications.
Please help me to find out this solution. Thanks.
|
|
|
|
|
|
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
And so far, we have no idea of what you have tried, where you are stuck, or what help you might need.
Since we aren't in the business of doing all your work for free, we aren't going to guess and write you a complete app!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I'm not "brand new" to C# and so I'm still struggling with some concepts. All of the projects I've created so far have a Globals.cs class. It's a class without a namespace and so I use it to hold just a few configuration settings that I want to apply to every file in my project.
I've recently been told that I should NEVER use what he called, top level properties. They aren't read only so they can't be considered constants.
Is there a better way to handle this?
Maybe it's common practice to handle this with a config class?
Maybe I should be using abstraction?
Any advice would be awesome
Thanks for your help!
The lack of surety in programming is part of the reason software is fragile.
|
|
|
|
|
That had a few things I have no idea about
I did not know you could even create a class without a namespace
What is a top level property google did not help!
What would you want to apply to EVERY (presumably .cs) file in a project.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Some folks hate static anything; some folks hate the idea of a Class "floating" outside any NameSpace; pundits rail against both as "violations" of OOP.
.Net itself often glues a bunch of static methods in a Type definition, like with 'String.
But, fact is: .NET C# provides a facility to allow a Class to be declared outside any user-defined NameSpace and used as a repository accessible to all app entities (when declared 'static, of course). This "floating Class" will exist in the Global Application NameSpace.
Whether you should use this facility should be, imho, a result of your choice based on your knowledge of .NET facilities for saving state of the app, of the app's controls, of the data the app manages. And, possible threading issues if the app is multi-user.Rick_Bishop wrote: They aren't read only you can make its contents read-only:
using System;
using System.IO;
public static class Globals
{
public const Int32 MaxFormWidth = 1000;
public static String SerializeFileName { set; get; } = @"Data.xml";
static readonly String SerializeFolderPath = @"MyAppSavedData";
public static string GetSerializeFilePath(string filename = "")
{
if (filename != "" && SerializeFileName != filename)
{
SerializeFileName = filename;
}
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
path = Path.Combine(path, SerializeFolderPath, SerializeFileName);
if(IsValidPath(path)) return path;
throw new FileLoadException($"{path} is not a valid file path");
}
static bool IsValidPath(string path)
{
}
} 'MaxFormWidth is readonly, 'SerializeFileName is read/write, 'SerializeFolderPath is read-only.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
modified 19-Feb-18 3:45am.
|
|
|
|
|
Thanks for the insight! This line of code:
public static String SerializeFileName { set; get; } = @"Data.xml"; Is that setting a default value on SerializeFileName? I didn't know you could do that. Wow. Thank you. I always thought you had to do that in a backing field.
The lack of surety in programming is part of the reason software is fragile.
|
|
|
|
|
It's a newer syntax for initializing an auto-property available with C# 6: [^].
cheers, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
That's really nice. I love when I learn new things like that. Thanks, Bill!
The lack of surety in programming is part of the reason software is fragile.
|
|
|
|
|
Thank you - I learn lots every day.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
A minor correction; you cannot have a class outside a namespace. If you fail to define one, your class will automatically be added to the global namespace[^].
This space for rent
|
|
|
|
|
A good point, Pete; I will revise my post to say: "outside a user-defined NameSpace."
cheers, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Hi Team,
Need your help on Copy/Paste on DateTimePicker.
I am displaying the UI in DD/MM/YY format and when I copy it copies in the same format(DD/MM/YY).
But Paste uses MM/DD/YY format.
How can i change the Paste format to DD/MM/YY?
Example UI is displaying 16/02/18(which is todays date in DD/MM/YY) and when I copy it copies as it is 16/12/18.
Now I modify it as tomorrows date 17/12/18 I does not allow as it validates for MM/DD/YY and 17 is greater then 12 so it does not copy.
How can i change the format to DD/MM/YY before pasting?
Thanks
Sharan
|
|
|
|
|
How are you copying?
How are you pasting?
Show the relevant code fragments!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I have not added any code specific for copy paste.
I have just changed the property of DateTimePicker
is.dateTimePicker.CustomFormat = "dd/MM/yy HH:mm:ss";
is.dateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
is.dateTimePickerExecTime.ShowUpDown = true;
Once right click on Control I select on Copy it copies and I copy it in excel .
From excel I again copy and trying to paste it on control.
|
|
|
|
|
Well what did you expect to happen?
You copy a date in a non-standard form, paste it into a spreadsheet (which identifies it as a date and converts it to a DateTime object), then you copy that datetime object from Excel (in standard-for-that-PC format), and paste it back onto a control that doesn't expect standard format.
There isn't a whole lot that we can do to prevent that causing a problem!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Yes.
Copy in DD/MM/YY format and paste the same in spreadsheet.
Edit the DateTime in spreadsheet.
Copy from spreadsheet and paste back to the DateTime control.
But DateTime control allows MM/DD/YY format.
That's the issue
|
|
|
|
|
And I'm confused about what you think we can do about a user input problem like that!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Your idea of "paste" may not correspond to the reality of the situation.
Sometimes you can use "windows paste commands"; at other times, you need to interect with the "clip board", reformat, copy (not "paste") to a property of the TextBox; etc. i.e. "programming".
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thanks for all your responses
Is there a way where I can change the .MaxValue Property?
Presently it displays in MM/DD/YYYY(12/31/9999 11:59 PM).
Can I set it to DD/MM/YYYY(31/12/1999).
|
|
|
|
|
Do we have any event for Paste where I can trigger and reformat the Date and paste it in the control ?
|
|
|
|
|
You didn't specify WPF, Windows Forms or ASP.NET or ...
If you're going to use a "date picker", you need to "learn it" before "looking around" for "other" solutions.
This may help; also note the reference to "system settings".
c# - Getting date from DatePicker in format yyyy/MM/dd - Stack Overflow
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Thank you for your suggestions.
I have achieved it using ParseExact function with some formatting the DateTime value.
Thanks
Sharan
|
|
|
|
|
Hi
if you are into privacy, freedom of speech and like things like Tor or whatsApp then read on because I want to build a network unlike one ever built before that is sort of a mix between Bitcoin, Tor, WhatsApp that is decentralized and uses Sept256k security (Pinched from Bitcoin) to send messages or requests for services around the world.
The services provided by other nodes on this new network could be anything from file storage to proxy servers or even highly encrypted messages delivered to email type services so the network itself become plugable using internal packages that look something a bit like socket addresses but instead of the IP-Address we use the public key of host service followed by the well known name of the service.
abcdef1234567-32-bit-key-abcdef:DNS
abcdef1234567-32-bit-key-abcdef:Proxy
abcdef1234567-32-bit-key-abcdef:Mail
This project will be open source and might even include a type of "Gas" at a future date with the apps talking to to the main network entry nodes using sockets with encrypted data (Will need ASE key) or decrypted data can then be pumped down the network pipe depending on how the entry node (Windows .EXE) has been configured.
Please PM me if you are interested or have any thoughts on the subject.
|
|
|
|