|
Member 10263519 wrote: property:hi Folder don't have a propertybag; what property are you referring to?
Member 10263519 wrote: how to get the location of that folder in c# program. By getting the "current directory"; that's the location from which your executable launches. Or ask the assembly where it's located. Your "upload" folder is a subfolder thereof.
System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); You'd Path.Combine the "upload" part to that path, and then you have the complete path to that specific folder.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi,
How do I Deserialize this?
public static void SerializeToXML(MainWindow window, Canvas canvas, int dpi, string filename)
{
string mystrXAML = XamlWriter.Save(canvas);
FileStream filestream = File.Create(filename);
StreamWriter streamwriter = new StreamWriter(filestream);
streamwriter.Write(mystrXAML);
streamwriter.Close();
filestream.Close();
}
Thanks
|
|
|
|
|
Please do not cross post. You have received a response already How do I Deserialize?[^]
"Bastards encourage idiots to use Oracle Forms, Web Forms, Access and a number of other dinky web publishing tolls.", Mycroft Holmes[ ^]
|
|
|
|
|
Hi,
I have following 2 tables and displaying both Table columns on single form (c# WinForms). How can I save data in both tables at same time (retrive also) using OOPS.
Customer:
CustomerID
FirstName
MiddleName
LastName
Salutation
CustomerAddress:
CustomerID
HouseNo
Address1
Address2
City
State
Country
Pincode
Thanks
Gaurav
Gaurav Gupta
|
|
|
|
|
gaurav2325 wrote: using OOPS. What do you mean by "OOPS", and what does it have to do with saving data? If you want to save your data then it largely depends on where you are saving it. Is this to be serialised to a simple file, converted to XML, stored in a database etc?
Veni, vidi, abiit domum
|
|
|
|
|
As it stands, we can't really answer this: there are just too many options:
Text file
Custom content
Flat - line based
XML
CSV
Binary file
Database
SQL Server
MySql
SqLite
SQLCE
Access
Oracle
...
Excel
Application config file
Binary Serializer
XML Serializer
... Those are just some of the options - and each of them has many, many variants. Some are environment specific, others require external software.
You need to think about what you want to save, what you want to do with it once you have saved it, and what technologies you have available. To say nothing of what you understand and know about already!
Never underestimate the power of stupid things in large numbers
--- Serious Sam
|
|
|
|
|
You can't; databases don't speak OOPS, they speak SQL. You can "add" a record into both tables simultaneous by wrapping them in a transaction. Ditto for updates.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi Everyone!
I have list of classes (say class Person with FirstName and LastName as property).
I have combobox that is dynamically populated whose items are the class's properties (in this case FirstName and LastName).
And lastly I have textbox that takes user input.
Here's the challenge. I want to filter the list whose property selected in the combobox contains the text written in the textbox.
Thank you very much in advance! Any help is much appreciated.
|
|
|
|
|
Here's one way to do this:
- Handle the text changed event of the text box.
- Use the current text to repopulate the combobox.
/ravi
|
|
|
|
|
Please, when posting a question, throw in some code to discuss. If below does not what you expected, then I probably misinterpreted your question. When including code, please wrap in <PRE> tags. I've included some linenumers so we can easily refer to parts of the code using it's linenumber.
1 class Program
2 {
3
4 class Person
5 {
6 public string FirstName { get; set; }
7 public string LastName { get; set; }
8 }
9
10 static void Main(string[] args)
11 {
12 using (var f = new Form())
13 {
14
15
16
17 var cmb = new ComboBox()
18 {
19 Dock = DockStyle.Top,
20 DataSource = typeof(Person)
21 .GetProperties()
22 .Select(p => p.Name)
23 .ToArray()
24 };
25
26
27
28 var theTextBox = new TextBox()
29 {
30 Dock = DockStyle.Top
31 };
32
33
34 theTextBox.TextChanged += delegate
35 {
36 string zeTextDatWeNeed = theTextBox.Text;
37 cmb.DataSource = typeof(Person)
38 .GetProperties()
39 .Select(p => p.Name)
40 .Where(p => p.Contains(zeTextDatWeNeed))
41 .ToArray();
42 };
43
44 f.Controls.AddRange(new Control[]{ theTextBox, cmb });
45 f.ShowDialog();
46 }
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
This sounded easy at first and I'm already spending a whole day.
I am looking for cells which contain non-zero or non-null float values in one particular column. My code is
Excel.Range Cells = currentWorksheet.get_Range(lowRange, upRange);
currentFind = Cells.Find(cellName, lowRange, Excel.XlFindLookIn.xlValues, Excel.XlLookAt.xlWhole, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false, misValue, misValue);
Now the problem lies with cellName. I cannot define it because I don't know what float values I will be getting from my cells. And is there anything like definite non-null or non-zero object that I can possibly use in place of cellName?
Thanks in advance!
modified 15-Jan-14 3:17am.
|
|
|
|
|
According to MSDN[^], the first parameter is the value you look for, not the cells' name. It'll look at all the cells in the specified range, and return those with specified value. MSDN suggest foreach-ing them.
emma.sun.sts wrote: And is there anything like definite non-null or non-zero object that I can possibly use in place of cellName? Not if it expects a name; but if the cell is named, then there would not be a use for the range.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
No, the cells are not named. I don't even know what values those cells are holding.
|
|
|
|
|
The Find method is not appropriate for this type of filtered enumeration.
You could apply an Autofilter to the Range and then retrieve the Range.SpecialCells(Excel.XlCellType.xlCellTypeVisible) Range and iterate over that. However this is a lot work that would be easier to do in your own .Net code.
Once you have a Range object defined, you can retrieve the entire range as a two dimensional array of System.Object. Here is snippet showing how to do this.
rng = ws.get_Range("A1", "A5");
object[,] retrievedarray = (object[,])rng.get_Value(Excel.XlRangeValueDataType.xlRangeValueDefault);
for (Int32 col = retrievedarray.GetLowerBound(1); col <= retrievedarray.GetUpperBound(1); col++)
{
for (Int32 row = retrievedarray.GetLowerBound(0); row <= retrievedarray.GetUpperBound(0); row++)
{
if (retrievedarray[row, col] is double)
{
double value = (double)retrievedarray[row, col];
System.Diagnostics.Debug.WriteLine(value.ToString());
}
else if (retrievedarray[row, col] == null)
{
System.Diagnostics.Debug.WriteLine("null");
}
}
}
|
|
|
|
|
This works amazingly! Thank you so much!
|
|
|
|
|
I am using Visual Studio 2010, Sql server Express Edition & C#.
I have develop a simple Master Detail application (mostly with the help of experts help from this forum) An Order system, and now I want to go one step further from simple application to N-Tier version.
Did some search on net and came up with Tutorial which guides me enough to create Order class which contains methods: -DataTable GetOrders(int OrdId) Retrieve order based on ID provided -int SaveData(string CustID, DateTime ShpDate, DateTime OrdDate) To save the order, This method has all Insert, Update, Delete command in it, using SqlAdapter.
Following the same pattern I've also created OrderDetails class for setting up line items for each order. OrderDetails also contains methods GetOrder & SaveData...
Now the main problem, what should I do to save the whole Order with OrderDetails? I know this is something I should wrap up in Transaction and create Relation after adding Data to Dataset...But not sure how to do it? any link/tutorial/sample/guidance will be highly appreciated.
I've not posted any code due to make this post clear...If required I will post the code immediately.
Thanks
Ahmed
|
|
|
|
|
"N-Tier" means usually "3-tier", which usually means having a GUI, a DAL, and a BO-layer. Take a look at some codegenerators, they usually come with templates to generate a lot of the scaffolding.
I suggest adding layers as you need them; the database is a DAL - it has abstracted away the data-saving and validation in abstraction that one can query using SQL. There are also some nice ORM-packages out there that automagically load datatables into BO's.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thanks for your reply,
I've created DAL class for data access ofcourse, purpose of which is to provide Database connection and execute Sql commands or stored proc.
As mentioned in my question, I've created Order class which will access DAL class and Get and Save Order..
The problem I am facing is from OrderDetails class...
My approach is: On the Winform (which is I think Presentation layer) when user clicks save button It should do the following:
1-Create Order class instance (for eg. Order od = new Order()) and then call Order class SaveData method by providing parameters: Like od.SaveData(OrdId,CustId OrdDate, ShpDate)
Which then ultimately save the order Master data...Order master is bind to DataTable.
Now the problem: How should I save OrderDetails...which is in DataGridView name dgGrd, dgGrd is also bind to DataTable.
OrderDetails also have SaveData method which take parameters (ProductID, Quantity, UnitPrice)...How should I call SaveData method within Order class? How should I pass whole DataGridView DataTable to SaveData method of OrderDetails class?
I will be very much appreciate if you could help me to line up my coding, perhaps if you could provide a sample? showing N-Tier Master Detail...I am still at beginner learning stage...And still doing lots of net searching for answer..
Thanks in advance
Ahmed
|
|
|
|
|
ahmed_one wrote: I've created DAL class for data access ofcourse, purpose of which is to provide Database connection and execute Sql commands or stored proc. That means that the other two layers aren't allowed to touch the database.
ahmed_one wrote: Now the problem: How should I save OrderDetails...which is in DataGridView name dgGrd, dgGrd is also bind to DataTable. That's a problem indeed; one would use the Order and OrderDetails classes, not a DataTable. If the GUI has a datatable, then you have a data-access class in your UI (you'd have an element in the presentation layer that should not be known outside the DAL)
ahmed_one wrote: How should I call SaveData method within Order class? When the order is saved, foreach the details and save them under the correct order-Id.
ahmed_one wrote: I will be very much appreciate if you could help me to line up my coding I can help with specific questions; if you'd post a summary on how the order(detail) class looks and is saved and we'll look at it.
ahmed_one wrote: perhaps if you could provide a sample? The N-Tier architecture is a bit too elaborate to catch in a small sample.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Thank you very much for your reply...
I've modified my Order and OrderDetails class..Actually overall Project..
Now My form Master Fields bind to DataTable dt and Details DataGridView was bind to dtDet...
Then create relation for both tables
Then both tables added to Dataset...2 bindingSource bindMaster and bindDetail created...Set bindMaster datasource to Dt and bindDetail datasource to relation name. Pass the dataset to Order's SaveData method..
Both class's SaveData method are also modified to accept Dataset and DataTable....Also both classes now set up for Sql Insert/Update/Delete commands via SqlAdapter.
Now it works for Saving Order with order Details...Now I need to move one step further to use classes for search the orders by OrderID or OrderDate options...I guess this is not so difficult task as saving the order...
Thanks again for your guidance...I hope if I will stuck in future I will get help from here
Regards
Ahmed
|
|
|
|
|
ahmed_one wrote: Now it works for Saving Order with order Details Nice
ahmed_one wrote: Now I need to move one step further to use classes for search the orders by OrderID or OrderDate options The DataTable has a handy filter-method.
ahmed_one wrote: I hope if I will stuck in future I will get help from here That's the idea; and soon you'll be helping others to get unstuck
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I've add SearchOrder method to Order class which take Id as parameter and retrieve records from Database, same method added to OrderDetails class. Difference is only return type, Order class method return Dataset because in Order class I've also retrieve OrderDetails (which return as DataTable) and add to Dataset of Order class SearchOrder method. Then I bind the WinForm with this DataSet...
I hope one day I will be competent enough to help others.
Thanks for your help and support.
regards
Ahmed
|
|
|
|
|
You're welcome
|
|
|
|
|
|
You've come to the wrong forum. This is not the place to post your "jobs".
|
|
|
|