|
I am using the code at the botoom to generate the monthly contracts invoices and save every invoice as a separate PDF I am generating all invoices to have the same GUID so it will be easier to retrieve all but it will be more than one invoice so for example they will all have same GUID but I will have 5 or 6 companies. I want to use the same code below to generate the separate PDFs using the invoice_number as file name.
private void generate_invoices()
{
this.Cursor = Cursors.WaitCursor;
sql_connection = new SqlConnection(public_var.sql_server_connection);
try
{
sql_connection.Open();
sql_command = new SqlCommand("sp_get_account_book_by_book_guid", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_command.Parameters.Add("@book_guid", SqlDbType.UniqueIdentifier).Value = book_guid;
DataSet data_set = new dsReports();
reportTICS.Reset();
sql_reader = sql_command.ExecuteReader();
data_set.Tables[0].Load(sql_reader);
reportTICS.LocalReport.ReportEmbeddedResource = "dsReports_sp_get_account_book_by_book_guid";
reportTICS.LocalReport.ReportPath = @"C:\Users\Jassim\Documents\Visual Studio 2008\Projects\Takhlees\Takhlees\envoice.rdlc";
ReportDataSource rds = new ReportDataSource();
rds.Name = "dsReports_sp_get_account_book_by_book_guid";
rds.Value = data_set.Tables[0];
reportTICS.LocalReport.DataSources.Add(rds);
ReportDataSource rds2 = new ReportDataSource();
rds2.Name = "dsReports_sp_get_account_book_by_account_number";
rds2.Value = data_set.Tables[0];
reportTICS.LocalReport.DataSources.Add(rds2);
reportTICS.LocalReport.Refresh();
reportTICS.RefreshReport();
if (chkSaveInvoice.Checked == true)
{
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string filenameExtension;
byte[] bytes = reportTICS.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
string file_path = "c:\\temp\\envoice\\" + DateTime.Now.ToString("dd MMM yyyy");
System.IO.Directory.CreateDirectory(file_path);
string file_namr = file_path + "\\" + System.Guid.NewGuid() + ".pdf";
using (System.IO.FileStream fs = new System.IO.FileStream(file_namr, System.IO.FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
}
Process.Start(file_path);
}
progressInvoice.Minimum = 0;
progressInvoice.Maximum = data_set.Tables[0].Rows.Count;
}
catch (Exception exp)
{
event_log.create_event("Problem preparing or viewing daily report." + Environment.NewLine + Environment.NewLine + exp.Message + Environment.NewLine + Environment.NewLine + exp.Data + Environment.NewLine + Environment.NewLine + exp.StackTrace + Environment.NewLine + Environment.NewLine + exp.InnerException, EventLogEntryType.Error, 9999);
MessageBox.Show("Problem preparing or viewing daily report!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(exp.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.Close();
}
finally
{
if (sql_reader != null) sql_reader.Close();
if (sql_connection != null)
{
if (sql_connection.State == ConnectionState.Open)
sql_connection.Close();
}
}
this.Cursor = Cursors.Default;
}
|
|
|
|
|
Hi all
How can i add a column to mydatagridview in code that the duty of this row is deleting the current row?
|
|
|
|
|
Basically you need to create a column and add it to the columns collection. As far as it's duty, I have no idea what you are talking about!
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Thanks for your help;
I mean that I want a column for deleting the current row that has been clicked;
Additionally i want a gridview that has a deleting ability and i want to add this ability to my datagrtidview in code.
|
|
|
|
|
Well, in my applications, selecting the row header and pressing the delete key deletes the row. If you need something different, then maybe using a checkbox or button column and doing the delete when that is selected would work, but it seems convoluted to me.
Or maybe I still don't understand what you want to do?
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Hi,
add a ButtonColumn to DataGridView and name it like Colremove
then write code for dataGridView CellContentClick event like shown below
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex > -1)
{
if (e.ColumnIndex == dataGridView1.Columns["dataGridView1.Colremove"].Index)
{
dataGridView1.Rows.RemoveAt(e.RowIndex);
}
}
}
modified on Friday, December 18, 2009 1:55 PM
|
|
|
|
|
I want to change skin of form with skincrafter and write below code for it but does'nt work Why?
SKINCRAFTERLib.SCSkin3Class ss = new SKINCRAFTERLib.SCSkin3Class();
ss.RemoveSkin();
ss.LoadSkinFromFile("Zondar.skf");
ss.ApplySkin();
|
|
|
|
|
I don't know, ask the people who made the library, or on their support forum if they have it?
|
|
|
|
|
Hi all,
Design question, I have three library projects, A, B and C.
Project A - error logging class
Project B - properties class with static methods
Project C - eventing class with static methods
Unfortunately, I want project A to use the properties class B, B to use the eventing class C, and C to contain an error logger object, resulting in a circular dependancy:
A <<uses>> B <<uses>> C <<contains>> A
How can I get around / redesign this? I'm a bit of a novice and might be missing the obvious but I don't see how I can use an interface, as C contains an error logging object, it is not passed an error logger as a method parameter.
Thanks in advance, am so confused!
|
|
|
|
|
Combine C & A or B & A. That's the simplest way. By combine I mean either the whole project, or just the code that relies on the other reference.
|
|
|
|
|
Combine them even though (strictly speaking) they have unrelated functionality? Thanks for your help!
|
|
|
|
|
Assuming each project doesn't really contain a single class - move the class that is offending out into a fourth project - that can then be referenced by the others as necessary.
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
dae22000 wrote: C contains an error logging object, it is not passed an error logger as a method parameter.
But it could be... it could be.
Or why not as a constructor parameter? Or, if it's not required, perhaps as a property?
And what is an "eventing class"?
|
|
|
|
|
PIEBALDconsult wrote: what is an "eventing class"?
sounds like fun.
|
|
|
|
|
I prefer events without class.
|
|
|
|
|
The error logging class is a part of your infrastructure and should be a placed in a common location that should be refrenced by all other classes. It should not be dependent on any other dlls.
If there is no way to avoid a particular dependency, move that dependency into the common location(from B into say, D) as well. It is likely that some of your classes could need this new dependency in the future.
There's nothing left in my right brain and nothing right in my left brain. |
|
|
|
|
|
On further thought, perhaps project C shouldn't use the logger directly but instead raise events that contain the interesting information.
The application can then attach the logger to the instance of C. An additional benefit is that information from several instances of C can all be logged to the same log without them tripping over each other. This is how I log with my Windows Services.
|
|
|
|
|
Thanks all!
Have implemented a solution thats a bit of everything. Created an intermediary project which the two offending projects both reference. The first project passes delegates of its static method calls to the intermediary project, and the seconds project invokes the delegates on the intermediary project.
Again, thanks for your help
|
|
|
|
|
How come Math.Floor(0.3 / 0.1) returns 2.0??? I assume it is some sort of rounding issue. How can I fix this?
Edit: This is what I came up with: Math.Floor(Math.Round(0.3 / 0.1, 2)); Is there an easier way?
Thanks
modified on Tuesday, December 15, 2009 1:03 PM
|
|
|
|
|
It's because 0.3/0.1 returns a double, and there are all sorts of rounding problems associated with doubles.
Console.WriteLine(Math.Floor(0.3M / 0.1M)); uses decimal arithmatic, and you get the expected answer.
CCC solved so far: 2 (including a Hard One!)
37!?!! - Randall, Clerks
|
|
|
|
|
keefb is 100% correct. If you type "0.3 / 0.1" into the immediate window, it spits out 2.9999999999999996... Now, we all know that's pretty much "3", but if you do a Floor(), it rounds down to 2. As keefb said, use decimals and you'll get the right answer.
But if you need to work with doubles, or have other constraints, you could "hack" it by, say, adding 0.0000001 before going through the Floor()... Kind of like the stone-age trick of adding 0.5 before a truncation to simulate rounding up or down to an integer.
|
|
|
|
|
How can I get all the running process list from a remote IPs / LAN and send a request to stop a particular application/process using C#.
You suggestion required.....
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
|
Thanks for your prompt response.. Yes; It will work on windows system.. Thanks once again for the link..
Thanks
Md. Marufuzzaman
Don't forget to click [Vote] / [Good Answer] on the post(s) that helped you.
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I want to get the last element of a dictionary collection. The methods listed in the IDE for the class seem pretty sparse, looking online led me to this:
http://msdn.microsoft.com/en-us/library/ckzcawb8.aspx[^]
However these are listed as extension methods, and don't appear available to me in .Net 2.0. Is this in fact the case? If it is, is there no other way than to manually loop till the last element? Isn't that a little absurd? Or am I missing something obvious here?
As others have mentioned I can use SortedDictionary and dictionary.Values[dictionary.Count - 1]. Thanks all!
modified on Tuesday, December 15, 2009 10:50 AM
|
|
|
|