|
Nobody is going to download your code. You can paste your code here (at least, the relevant bits). What is your question? What are you having a problem with?
Pass the values into the child form via the constructor. Return the result when the child form closes by storing them to a public property of the child form. The parent form can then access that property after the child form closes and save that value for later (e.g., when passing it again to the constructor of the child form).
Is that the answer you were looking for, or did you have a more specific problem?
|
|
|
|
|
in my parent form i created an array string with values. i passed that array to the child form's constructor. then i created instance array in the child form and i set that equal to the array passed from the constructor so i can use it. i used it to display the passed string value in my combo box. i also created a public string variable. then on button click i set the public string variable equal to the newly selected item from combo box. i go back to my parent form and my code looks something like this:
private void updateProductInfo_Click(object sender, EventArgs e)
{
productStatus = false;
ProductForm pFTwo = new ProductForm(this, category);
pFTwo.Show();
if (pFTwo.updateStatus == true)
{
category[pFTwo.aProductCategoryIndex] = pFTwo.aProductCategory;
}
}
as u can see my public variables from my child form is "aProductCategory". but nothing is happening when i reopen my child form. the combo box value is still the same
|
|
|
|
|
You are using a local variable for your ProductForm so every time you go through the updateProductInfo_Click() method you start a new form. Create your child form in your main form intialisation and use that throughout your code.txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
|
Set the data how you would like in your child's form load event.
|
|
|
|
|
|
Dear frd's
I have a problem in reading data from parallel port. There is a serial port control available which will work with serial port in asp.net and c# but i never find any parallel port related class. Then I was using "inpout32.dll" third party DLL which is giving two methods Inp32 and Out32 by which we can read or write to parallel port.
But unlike serial port there is no data received event available in this dll. Is there any way available to get the data when ever parallel port receives some data.
Thanks for you time and consideration.Thanks & Regards,
Anil Chelasani
|
|
|
|
|
I'm wanting to add all the values i get from my for statements into a list of type string. I tried the following but i get a casting error
List<string> str = new List<string>();
int rCount = 0;
int cCount = 0;
range = xlWorkSheet.UsedRange;
for (rCount = 1; rCount <= range.Rows.Count; rCount++)
{
for (cCount = 1; cCount <= range.Columns.Count; cCount++)
{
str = (List<string>)(range.Cells[rCount, cCount] as Excel.Range).Value2;
}
}
one day I hope to not be the one asking the questions but the one answering them. Until then please forgive me for my basic questions
|
|
|
|
|
Replace it with something like this:
for(rCount...){
for(cCount...){
str.Add(range.Cells[rCount, cCount].Value2.ToString());
}
}
|
|
|
|
|
ahh thank you very much...
|
|
|
|
|
|
Hey one last thing if you have the time... What I'm trying to do using an example of course. is read my excel sheet columns a,b,c,d,e one row at a time into a list so I can take those values and hopefully insert them into a database. I have the database insert method working fine I just need to figure out how to get the data into a format so I can pass it to the stored procedure I made.
I'm aiming to get index[0].text index[1].text and so forth for each row... What I have so far gets the values of each row but one column at a time so lets say I have tony smith testing somethingelse 1.99
i get the following results
[0] tony
[1] smith
[2] testing
[3] somethingelse
[4] 1.99
what I'd like to do is label the results if all possible like first = [0], last =[0]
that way when i wanted to use the data i could simply do something like this
row.first
row.last
row.whatever
here is the code i have those for but I'm confused how to accomplish what i'm trying to do
private void importDataFromExcelToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenExcelFile.Title = "SELECT EXCEL FILE TO IMPORT FROM ";
OpenExcelFile.Filter = "XLS FILES|*.XLS";
OpenExcelFile.InitialDirectory = @"c:\";
string filepath = null;
if (OpenExcelFile.ShowDialog() == DialogResult.OK)
{
filepath = OpenExcelFile.FileName;
}
Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
Excel.Range range;
xlApp = new Excel.ApplicationClass();
xlWorkBook = xlApp.Workbooks.Open(filepath, 0, true, 5, "", "", true,
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t",
false, false, 0, true, 1, 0);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
List<string> strList= new List<string>();
string str;
int rCount = 0;
int cCount = 0;
range = xlWorkSheet.UsedRange;
for (rCount = 1; rCount <= range.Rows.Count; rCount++)
{
for (cCount = 1; cCount <= range.Columns.Count; cCount++)
{
str = (string)(range.Cells[rCount, cCount] as Excel.Range).Value2;
strList.Add(str);
}
}
xlWorkBook.Close(true, null, null);
xlApp.Quit();
releaseObject(xlWorkSheet);
releaseObject(xlWorkBook);
releaseObject(xlApp);
}
private void releaseObject(object obj)
{
try
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
obj = null;
}
catch (Exception ex)
{
obj = null;
MessageBox.Show("Unable to release the Object " + ex.ToString());
}
finally
{
GC.Collect();
}
}
|
|
|
|
|
Hy,
It's all wrong.
1)Create a class like
public class Something{
public string Name{get;set;}
public string Surname{get;set;}
.
.
.
}
And then create a List<Something> instead of list of string(s);
2) When loading data if you keep loading it using Interop create something like:
for(RCount...{
curr = new Something();
for(cCount...){
if(c==1){
curr.Name = (string)(range.Cells[rCount, cCount] as Excel.Range).Value2;
}
if(c==2){
...
}
.
.
}
lst.Add(curr);
}
But I Really don't recomend this approach.
Use something like this. It's a lot faster and it does not require Excel to be installed
string connString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + yourFileNameHere+ ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=2\";";
OleDbConnection con = null;
lst = new List<Something>();
Something curr = new Something();
con = new OleDbConnection(connString);
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
cmd.CommandText = "SELECT Name,SurName,etc.. " +
"FROM [Sheet1$]";
OleDbDataReader dr = null;
try
{
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
curr = new Something();
curr.Name = dr.IsDBNull(0) ? "Empty" : dr.GetString(0);
curr.SurName = dr.IsDBNull(1) ? "Empty" : dr.GetString(1);
.
.
if (curr.IsOK())
{
lst.Add(curr);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (con.State != ConnectionState.Closed)
{
con.Close();
}
con.Dispose();
con = null;
}
and a create a method inside your class(Something) in this silly example of mine that returns true if the current Something is OK, else false.
Usefull in order to avoid filing your list with "Empty"/Nok rows.
[EDIT] And now you could use LINQ to get the datas something like:
var needed = from rec in lst
where rec.Name=="YourName"
select whateverYouNeed;
modified on Thursday, February 18, 2010 1:02 AM
|
|
|
|
|
WOW!!!! Thanks I didn't expect you to go through all this trouble but I really appreciate it. As you can tell I'm learning and trying. Honestly hate asking so many questions but I guess that is the only way to learn.
Once again I totally appreciate your time.
|
|
|
|
|
One again you're welcome.
But it didn't took me much time as I have some small "inhouse aaps/tricks" to load all kind of
excel data to the DBs and vice versa. So I just copy and paste, renamed the columns/fields deleted
logic and that's all.
|
|
|
|
|
You ever have the problem of copying stuff from access into an excel spreadsheet. and for whatever reason
the code you posted does not read it? It keeps on tripping up on the getstring().
In my excel file I have a field called Price which I add a number to like 2.99 3.99 and so forth.
if i type the stuff out manually in this format
id authorfirst authorlast title price keywords
1 tony smith a book 1.99 blah,blah
it works fine
but if i paste from access into excel the price files get the little thing convert text to number.
if i leave it alone it throws exception saying it can't cast double. so i changed it to getdouble
same error. i converted it to number. tried again same exception. if i take and click on the field and edit it manually to say 3.99 then bam works fine. Just curious if you ever ran into this issue and if so how do you resolve it ?
|
|
|
|
|
Nope, not really but I see what you mean.
Could be many reasons:
1) Check to see if your excel data doesn't contain any "'" sign at the beging
2) Try no formatting => leave the cells to general.
3) If all this fails then two options:
a) check your regional and language settings. See what's the decimal separator.
While C# by default uses the Culture Invariant/Neutral, excel uses the system
settings. Ex: in US Language and settings 300.05 => OK it loads it as a number
in Romanian 300,05 => to load it as a number.
b) if all this fails and hell gets lose than go to the last resource and fight back with
some VBA => macros.
Create a macro that transforms your cells.
|
|
|
|
|
i got it to work. simply took and typed in a number in another field. selected it and copied.
then selected all the price values i wanted to use. right clicked paste special and selected formulas and number formating and it worked just fine. thanks again.
Now If i can only figure out this dang treenode thing I'll be cookin with gas.
|
|
|
|
|
Hello everybody!
I have developed a digital book management application called BookStore, written in C# / .NET 2.0, that allows the user to store all of its' digital books (chm, html, doc, odf, pdf, rtf, txt, etc.) in a central single-file database repository, without the need to keep the books as individual files and folders on the disc, thus reducing disc fragmentation and easing content cohesion and portability (by copying the books database to a memory stick, for example).
The books to be imported can be either file-based books (such as a single pdf document) or folder-based books (such as a website offline copy). Books can be loaded one at a time or many-at-once (bulk-load). Once imported, each book can be visualized or deleted.
Each book stored in the system is characterized by 5 attributes: title, set of authors, set of tags, publishing house and year of publishing. Each of these attributes can be set for every book. The user can then query a particular set of books, based upon a combination of the aforementioned attributes. As such, the querying system is very powerful, while retaining its ease of use.
The application supports multi-user access on the same PC, as each user can have its own database, without any interference with the data of other users. Also, since the user is able to select the application's working folders, the solution can be run by any user, irrespective of its privileges on the system.
I would be very happy and grateful to receive any input on my application. Also, programmers are very welcome to contribute code, should they wish to. If you have any desire to do so, I can grant you access rights to the project and your contributions will be acknowledged on the project's page. For example, a Mono port would be very appreciated and not too difficult to achieve.
Project page : http://code.google.com/p/bookstoredotnet/
Thank you for taking the time to read my post!
Yours truly,
Mihnea Rădulescu
modified 20-Aug-18 21:01pm.
|
|
|
|
|
So you don't have an actual question, just self-promotion and advertising. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
You are going about this the wrong way. As you do not consider your code proprietary then you should write and article based on your app, highlighting any challenges and how you dealt with them. Many more people would then be exposed to the article and you may get others involved.
There are a number of very successful apps that began life as articles.Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks for the advice, Mycroft Holmes!
I'll begin sketching an article and then submit it to codeproject.com.
All the very best,
Mihnea
modified 20-Aug-18 21:01pm.
|
|
|
|
|
IF you have any question regarding any topic then you should put here.
And Your application is not user friendly. and you should a lot of Update for your application.
OkIf you can think then I Can.
|
|
|
|
|
I wrote a custom pipeline component to validate csv data before inserting into Sql server DB.
my problem is I have to be able to read the following data and retreive each field data to check if required fields are empty or not and then let the orchestration process the data.
my Ibasemessage.bodypart looks like foll:
"<Sales xmlns=\"http://ADI.ADI_FlatFile\">
<SalesDetailInfo DealID=\""Deal #\" Logon_StoreID=\"Logon/Store#\" CustomerID=\"Customer #\" Customer_Name_Salutation=\"Customer Name Salutation\" Customer_First_Name=\"Customer First Name\" Customer_Middle_Name=\"Customer Middle Name\" Customer_Last_name=\"Customer Last Name\" Customer_Name_Suffix=\"Customer Name Suffix\" Customer_Employer_name=\"Customer Employer Name\" Customer_Job_Title=\"Customer Work Position/Job Title\" Customer_Birth_Date=\"Customer Birth Date\" Address=\"Address\" Address2=\"Address 2\" City=\"City\" State=\"State\" Zipcode=\"Zip\" HomePhone=\"Home Phone\" WorkPhone=\"Work Phone\" CellPhone=\"Cell Phone\" Email=\"EMail\" StockID=\"Stock #\" VIN=\"VIN\" Make=\"Make\" Odometer=\"Odometer\" Ext_Color=\"Exterior Color\" Int_Color=\"Interior Color\" Veh_Type_N_U_C=\"New/Used/Certified\" Agreed_Selling_Price=\"Agreed Selling Price\" MSRP=\"MSRP\" Trade1_StockID=\"Trade 1 Stock #\" Trade1_VIN=\"Trade 1 VIN\" Trade1_Payoff_Amount=\"Trade 1 Payoff Amount\" Trade1_ACV=\"Trade 1 ACV\" Trade2_StockID=\"Trade 2 Stock #\" Trade2_VIN=\"Trade 2 VIN\" Trade2_Payoff_Amount=\"Trade 2 Payoff Amount\" Trade2_ACV=\"Trade 2 ACV\" Salesman1_ID=\"Salesman 1 #\" Salesman1_FirstName=\"Salesman 1 First Name\" Salesman1_LastName=\"Salesman 1 Last Name\" Salesman1_Email=\"Salesman 1 Email\" Salesman2_ID=\"Salesman 2 #\" Salesman2_FirstName=\"Salesman 2 First Name\" Salesman2_LastName=\"Salesman 2 Last Name\" Salesman2_Email=\"Salesman 2 Email\" SalesManager_ID=\"Sales Manager #\" SalesManager_FirstName=\"Sales Manager First Name\" SalesManager_LastName=\"Sales Manager Last Name\" SalesManager_Email=\"Sales Manager Email\" F_I_managerID=\"F&I Manager #\" F_I_ManagerFirstName=\"F&I Manager First Name\" F_I_ManagerLastName=\"F&I Manager Last Name\" F_I_ManagerEmail=\"F&I Manager Email\" Deal_Sale_Type=\"Deal Sale Type\" Deal_Date=\"Deal Date\" Term=\"Term\" First_Payment_Date=\"First Payment Date\" Cash_Down=\"Cash Down\" Bank_Code=\"Bank Code\" Bank_Name=\"Bank Name\" Purchase_Monthly_Payment=\"Purchase Monthly Payment\" Amount_Financed=\"Amount Financed\" Deferred_Balloon_Payment=\"Deferred/Balloon Payment\" Base_Payment=\"Base Payment\" Lease_Monthly_payment=\"Lease Monthly Payment\" Net_Capitalized_Cost=\"Net Capitalized Cost\" Residual_Amount=\"Residual Amount\" Yearly_Miles=\"Yearly Miles\" Penalty_Rate=\"Penalty Rate\" Warranty_Company=\"Warranty Company\" Warranty_Miles=\"Warranty Miles\" Warranty_Term=\"Warranty Term\" Model_Number=\"Model Number"\" xmlns=\"\" />
<SalesDetailInfo DealID=\""311154\" CustomerID=\"50160\" Customer_Last_name=\"MERCEDES-BENZ OF HOUSTON NORTH\" Address=\"17510 NORTH FWY\" City=\"HOUSTON\" State=\"TX\" Zipcode=\"77090-4902\" HomePhone=\"2818856000\" StockID=\"2744\" VIN=\"WDDHF5GBXAA113364\" Make=\"MERCEDES-BENZ\" Odometer=\"12\" Ext_Color=\"WHITE\" Veh_Type_N_U_C=\"NEW\" Agreed_Selling_Price=\"52484.00\" MSRP=\"0\" Trade1_Payoff_Amount=\"0\" Trade1_ACV=\"0\" Trade2_Payoff_Amount=\"0\" Trade2_ACV=\"0\" Salesman1_ID=\"997\" Salesman1_FirstName=\"DEALER\" Salesman1_LastName=\"TRANSFER\" SalesManager_ID=\"351\" SalesManager_LastName=\"STERN\" F_I_managerID=\"2950\" F_I_ManagerLastName=\"VASQUEZ\" Deal_Sale_Type=\"P\" Deal_Date=\"01/08/2010\" Term=\"0\" First_Payment_Date=\"01/29/2010\" Cash_Down=\"0\" Bank_Code=\"CASH\" Bank_Name=\"CASH\" Purchase_Monthly_Payment=\"52484.00\" Amount_Financed=\"52484.00\" Deferred_Balloon_Payment=\"0\" Residual_Amount=\"0\" Yearly_Miles=\"0\" Penalty_Rate=\"0\" Warranty_Company=\"Vehicle Service Contr\" Warranty_Miles=\"100000\" Warranty_Term=\"60\" Model_Number=\""\" xmlns=\"\" />
</Sales>
I am unable to understand this format and how do I retreive my field names from this stream of data :
eg: I have to check if (Deal# = "" & VIN ="") then
"DO NOT PROCESS THE ROW"
"GO TO NEXT ROW "
"AND INSERT ONLY THOSE ROWS THAT HAVE rREQUIRED FIELDS"
"I HAVE 73 fields in each ROW.
"1st row is header row (I need to exclude that row too)
HOW DO I DO THIS , Please any support is gr8tly appreciated
|
|
|
|
|
This format is simply an XML file.
To manipulate the message body into a BizTalk pipeline, you have to change the BodyPart of your message object to another stream you populate with modified data.
Essentially, you must do the following in the component Execute method:
1. Save the original BodyPart value in a variable (e.g. origBody)
2. Assign a new instance of VirtualStream to the BodyPart property
3. Create an XmlReader from origBody
4. Create an XmlWriter to populate the new BodyPart stream
5. Loop through the nodes using the XmlReadr and write data to the XmlWriter according to your logic.
6. Return the modified message.
Still, if you only want to translate a message to a schema to another I strongly suggest you to create a Map and apply it to your receive port. You can implement your translation logic more easily by using the BizTalk map designer or a custom XSL transform.
|
|
|
|