|
I usually work with VS2005 or 2008.
|
|
|
|
|
Hide I'm going to develop a program like digital signage. I want to save some audio, video and image files in a databse and display it in ascheduled interval. Can anybody help me, How can I do this? Which technology I can use? Please help me.
Thanks in advance.
|
|
|
|
|
More information is required to even point you in the correct direction!
How are you going to deliver this, internal app or over the web?
What are your existing skills?
What do you mean by digital signage in reference to media files?
What database do you intend to use?
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Its just a desktop application. I want to store the files in a folder and file references in a database. There will be a schedule table to store the file references and I want to show the saved files according to the schedule.
I,m basically a web programmer so I don't know much about the Windows methods.
Can you please help me on delivering the resources. I just want to play the saved files through any interface.
How can I show the media files and of course it should be displayed in multiple screens.
|
|
|
|
|
I am using the Directory.GetFiles to create an array of file names, then I am parsing through each one of those files and pulling a separate file name from inside the file text of which I would like to add into a new array of which I can reference later in my code.
Does anyone know how to do this? Thanks for reading.
|
|
|
|
|
|
I've never used list, do you happen to have a quick example while I start googling it?
|
|
|
|
|
To be a little more specific
I found this code, so far so good if it will work in a foreach loop.
[code]List<string> list = new List<string>();
list.Add(tXml);[/code]
how can I display this into a single message box?
|
|
|
|
|
Lol
Ok here is what I wrote, please critique, thank you for pointing me to list by the way.
<br />
<br />
List<string> list = new List<string>();<br />
<br />
foreach(string stringName in stringNames)<br />
{<br />
list.Add(tXml);<br />
}<br />
<br />
string[] list2 = list.ToArray();<br />
MessageBox.Show(messageBoxArrayToString(list2));<br />
<br />
<br />
private string messageBoxArrayToString(string[] toParse)<br />
{<br />
string arr = string.Empty;<br />
foreach (string i in toParse)<br />
{<br />
arr += i.ToString() + "\r\n";<br />
}<br />
<br />
return (arr.ToString());<br />
<br />
}<br />
<br />
<br />
modified on Friday, December 17, 2010 3:32 PM
|
|
|
|
|
turbosupramk3 wrote: foreach(string stringName in stringNames)
{
list.Add(tXml);
What is tXml ?
turbosupramk3 wrote: list.ToArray();
That seems needless.
turbosupramk3 wrote: messageBoxArrayToString(string[] toParse)
Take a look at System.String.Join<string>
turbosupramk3 wrote: string arr = string.Empty;
You don't need to initialize it.
turbosupramk3 wrote: i.ToString()
You don't need to use ToString()
turbosupramk3 wrote: [code]
Try using HTML.
|
|
|
|
|
Yes As PIEBLEDconsult suggested You can use List like.
Say your file is having a typr of string, so take List<String> .
for add the file List.Add("+FileName+");
and to make a Looping on that use,
foreach(string name in Filenames)
{
}
Hope it helps, write here for further query.
|
|
|
|
|
Dear People
I'm facing a big problem...
I have created a C# Project. In this project I have a Form1 (inside this form I have a Button1 , Panel1 and ListView1 ), a reusable UserControl1 (inside this usercontrol I have 10 buttons such as: cmdOlives , cmdSoup , etc, etc ..) and also I have a Access 2007 Database (In my database I have a table created with 10 records). Oh I almost forgot, I have created a class aswell called MenuItems.cs (see code below of this class)...
What I have done so far is:
- From Form1 the Button1_Click event calls UserControl1 and displays it (inside Panel1 ) into my Form1 .
What I'm trying to achieve is this:
- The 10 buttons in UserControl1 to be linked dynamically with my Database, what I mean by dynamically is that I dont want to create for every button_click event an opening db connection, exec query, and so on , but to create one and only one SQL query (lest say like an array query) so when I click cmdOlives to get the rocord1 from database table and display it into my ListView1 , same for cmdSoup and so on...
As you can see from the code below I have created the sql query but for some reason its not displaying any data into my listview I'm missing something and I'm stuck.
If someone could help me with this it would be very greatfull...
Polite Note: I have posted this question before but no one seem to help me
I'm new to programming, and I thought people in this forum will help
other people when posting a question
----------------------------------------------------------------
Here is the code of my C# project:
Form1
public partial class DtposMDIParentSystem : Form
{
List<Object[]> result = new List<Object[]>();
public DtposMDIParentSystem()
{
InitializeComponent();
OleDbConnection aConnection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=C:\Users\AP_AE\Desktop\DTPOS_APP\DataBase\DtposDatabase.accdb;");
OleDbCommand aCommand = new OleDbCommand("SELECT * FROM Food", aConnection);
try
{
aConnection.Open();
OleDbDataReader reader = aCommand.ExecuteReader();
int i = 0;
while (reader.Read())
{
result.Add(new Object[reader.FieldCount]);
reader.GetValues(result[i]);
}
reader.Close();
aConnection.Close();
}
catch (InvalidOperationException ex)
{
MessageBox.Show("Invalid Masseage = " + ex.Message);
}
}
private void DtposMDIParentSystem_Load(object sender, EventArgs e)
{
this.Panel1.Location = new System.Drawing.Point(332, 127);
this.Panel1.Name = "Panel1";
this.Panel1.Size = new System.Drawing.Size(700, 560);
}
UserControl1 userC = new UserControl();
private void Button1_Click(object sender, EventArgs e)
{
this.Panel1.Visible = true;
this.userC.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.userC.Location = new System.Drawing.Point(0, 0);
this.userC.Size = new System.Drawing.Size(696, 556);
this.userC.Enabled = true;
this.userC.Visible = true;
this.Panel1.Controls.Add(userC);
}
}
UserControl1
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void UserControl1_Load(object sender, EventArgs e)
{
}
private void cmdOlives_Click(object sender, EventArgs e)
{
if (result.Count > 0)
{
string temp = "";
for (int i = 0; i < result[1].Length; i++)
{
temp += result[1][i] + " ";
}
TableOrderListView.Items.Add(temp);
}
}
private void cmdSoup_Click(object sender, EventArgs e)
{
}
.
.
.
}
MenuItems.cs Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DtposApplication
{
public class MenuItems
{
private int itemNum = 0;
public int ItemNum
{
get
{
return itemNum;
}
set
{
itemNum = value;
}
}
private string itemName = string.Empty;
public string ItemName
{
get
{
return itemName;
}
set
{
itemName = value;
}
}
private double itemPrice = 0.0;
public double ItemPrice
{
get
{
return itemPrice;
}
set
{
itemPrice = value;
}
}
public void menuitemParam(int ItNo, string nam, double cost)
{
itemNum = ItNo;
itemName = nam;
itemPrice = cost;
}
public void meItem(ref MenuItems mi)
{
itemNum = mi.itemNum;
itemName = mi.itemName;
itemPrice = mi.itemPrice;
}
}
}
Thanks in advance
Kind Regards
Agron
modified on Thursday, December 16, 2010 5:07 PM
|
|
|
|
|
Hi,
1.
your code is unreadable as it lacks formatting and indentation. You should edit your existing message and add PRE tags around the code snippet.
2.
You can assign the same event handler to a number of buttons; and you can assign an arbitrary value (e.g. an item name) to a Button's Tag property; taken together, you could come up with a query that is slightly different for each of the buttons.
|
|
|
|
|
Hi Luc
Thanks for responding to my question.
I have pre tag my code so I think now can be readable.
Kind regards
Roni
|
|
|
|
|
I was a bit rude to you earlier, sorry.
I'll try to help you.
Try this.
private void cmdOlives_Click(object sender, EventArgs e)
{
if (result.Count > 0)
{
TableOrderListView.Items.Clear();
ListViewItem newItem = new ListViewItem(result[1][0])
for (int i = 1; i < result[1].Length; i++)
{
newItem.SubItems.Add(result[1][i]);
}
TableOrderListView.Items.Add(newItem);
}
}
DONT FORGET: If you want the item to be added to the listview instead of replacing existing item delete the Items.Clear() line.
You will still have the problem of differentiating your different buttons doing things this way but try this out and I will try to help you with the rest.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi again,
here are a few comments:
1.
I'm puzzled by your code.
AFAICT it should not even compile, as the "result" list is part of your DtposMDIParentSystem form, and not visible to your UserControl. How can it accept the if (result.Count > 0) line, it does not know about result??
2.
I've never used DbReader.GetValues, nor created an array of Object, like you do. I would rather have a struct or class (say FoodItem) that represents one row of your database table, and then create instances and fill them, one field at a time, using something like:
List<FoodItem> foodItems=new List<FoodItem>();
while (reader.Read()) {
FoodItem fi=new FoodItem();
fi.Name=reader["Name"];
fi.Calories=int.Parse(reader["Calories"]);
...
foodItems.Add(fi);
}
The advantage is all is fully typed, and all necessary conversions/parse operations are explicit.
3.
I would never create buttons one way (say with Visual Designer), and then try and match them up with a data structure that I obtain in another way (by reading a database). I'd rather just read the database and create the buttons (or whatever Controls are most suited) at run-time, so adding/removing a few FoodItems in the database is acceptable to the application as is.
FYI: Visual Designer stores all its stuff as regular C# code in a separate file, have a look; you can write similar code yourself, and have it execute when appropriate.
|
|
|
|
|
Hi Luc again
I got that part of your code so far is working but im having another problem at my
cmdOlives_Click event button...
private void cmdOlives_Click(object sender, EventArgs e)
{
if (menuItems.Count > 0)
{
System.Windows.Forms.ListViewItem newItem = new System.Windows.Forms.ListViewItem(menuItems[1]);
for (int i = 1; i < menuItems[1].Length; i++)
{
newItem.SubItems.Add(menuItems[i]);
}
TableOrderListView.Items.Add(newItem);
}
}
|
|
|
|
|
LAPEC wrote: im having another problem
if so, describe what you want it to do and what it actually does. Formulating accurately is what programming is all about, and it also is the way to get useful answers around here.
|
|
|
|
|
Hi Luc
Ok I will try to explain based on my code.
- When Form1 Loads (see the code below I have created database connection)
public partial class DtposMDIParentSystem : Form
{
List<MenuItems>; menuItems = new List<MenuItems>();
public DtposMDIParentSystem()
{
InitializeComponent();
OleDbConnection aConnection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\AP_AE\Desktop\DTPOS_APP\DataBase\DtposDatabase.accdb;");
OleDbCommand aCommand = new OleDbCommand("SELECT * FROM Food", aConnection);
try
{
aConnection.Open();
OleDbDataReader reader = aCommand.ExecuteReader();
while (reader.Read())
{
MenuItems mi = new MenuItems();
mi.ItemName = reader["Name"].ToString();
mi.ItemPrice = Double.Parse(reader["Price"].ToString());
menuItems.Add(mi);
}
reader.Close();
aConnection.Close();
}
catch (InvalidOperationException ex)
{
MessageBox.Show("Invalid Masseage = " + ex.Message);
}
}
- Clic the button1 (inside Form1) calls the UserControl1 and displays it into Form1 (see the code below)
UserControl1 userC = new UserControl();
private void cmdStarters_Click(object sender, EventArgs e)
{
this.StartersPanel.Visible = true;
this.userC.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.userC.Location = new System.Drawing.Point(0, 0);
this.userC.Size = new System.Drawing.Size(696, 556);
this.userC.Enabled = true;
this.userC.Visible = true;
this.StartersPanel.Controls.Add(userC);
}
- The UserControl1 has 10 Buttons (such as cmdOlives, cmdSoup etc. etc...)
- Now when I click on:
- cmdOlives_Click event button I want to display rocord1 (such as Olives) from database table and display it into my TableOrderListView...
- Also when I click on:
- cmdSoup_Click event button I want to display rocord2 (such as Soup) from database table and display it into my TableOrderListView... and so on
like so
ListView
_________________________________________
Num Name Price
_________________________________________
1 Olives £2.95
1 Soup £4.95
. . .
. . .
. . .
_________________________________________
I hope i've explained so you could understand what im trying to do...
kind regards
Roni
|
|
|
|
|
If you want a button to do something, you have to provide and connect a Click handler. I haven't seen any.
I don't know what your background is; your code is half there, and a bit bizarre at times. I think you'd be best served by a more fundamental approach. I suggest you select, buy and study an introductory book on C#; it will teach you the basics of the language, introduce you to programming in general, and do so in a systematic and meticulous way. And then I advice you to read some articles, there are lots of excellent ones here on CodeProject. Look for the ones with a high rating (above 4), and look how they handle things.
|
|
|
|
|
private void cmdOlives_Click(object sender, EventArgs e)
{
if (menuItems.Count > 0)
{
System.Windows.Forms.ListViewItem newItem = new System.Windows.Forms.ListViewItem(menuItems[1].ToString());
for (int i = 1; i < menuItems[1].ItemName.Length; i++)
{
newItem.SubItems.Add(menuItems[i].ToString());
}
TableOrderListView.Items.Add(newItem);
}
}
|
|
|
|
|
Please say what the problem is.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
I have created a working version of what I think you are trying to do. It does not use the same structures (List<> etc.) as you since I think that is not the right way to do things.
Would you like to see it?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Henry
I just came back from work.
If its not much to truble yes I would like to see it please
Kind regards
Roni
|
|
|
|
|
Look out for an email from hfam at live stop co stop uk.
I'll attach the zipped solution.
In it I am using SqlConnection, SqlDataAdapter etc. If you do not have SqlServer then change those to OleDbWhatevers and it should be OK.
The database structure I have used is designed for simplicity and would probably not be suitable for a 'real' environment.
There are two tables (Starter and Main) and both have the same structure.
Field: ItemID - int identity (autoincrement)
Field: ItemName - nvarchar(50)
Field: ItemPrice - Money
Give a shout if there are any problems with it.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|