|
Hi im using VS2008 / SQLServer2005
Im using Linq, ive created my .dbml file - is there a tool in vs2008 that I can use to generate the DAL and/or BLL for basic CRUD operations or do I need to code it myself?
Many thanks,
Chas
|
|
|
|
|
Yes and no. You can use the T4-enigne[^] in VS2k8 to generate the source-code, but then you'd probably have to write the templates yourself.
You can also research MyGeneration [^]or CodeSmith[^].
Good luck
I are Troll
|
|
|
|
|
|
Sorry to have to post this guys and I believe this is the right group to target. Any help would be absolutely fantastic and obviously very much appreciated.....
I would say I am a beginner and have learnt from asp.net c sharp and SQL books. I have got to a stage where things make sense and like many of you will know it is pretty good place to be. Obviously I still have a long way to go hence I have thrown myself into a project which will I guess test many core technology.
Basically I am going to start work on a business system which logs information at each stage of a production process. The item gets picked up and ideally scanned in as it should already have a barcode (act as a primary id). When it gets to the premises it is booked in and then goes through each process of modification or testing (refurbishment) and then sent out again to a new origin when it is sold.
Ideally I want to use ASP.NET, C sharp and obviously SQL. Could you guys possibly give me some advice as to what areas of additional technology I should look into to implement it if there is anything? I trust barcode readers are universal and just plug the serial onto an excel spreadsheet which I could import into SQL database.
I read about things like Workflows, MVC's LINQ an WPF etc etc or is this not the way forward. I have a logical idea of how this thing should work but unclear as to what is out there if you see where I'm coming from.
I like the idea of running Sharepoint alongside this system but that comes later.
Any help will be awesome. Where to start? Just hope I haven't screwed myself!
Cheers for reading everyone.
|
|
|
|
|
I am using a datagridview with an INSERT, DELETE and an UPDATE button. But whenever I run my form the error that I have stated above rises. Kindly help me to solve this problem.
<code>
string constr = "Server=PACE-BB95D506B2; Database=Dotnet67; uid=sa; pwd=123";
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
DataTable table = null;
SqlDataAdapter da = null;
private void LoadCashiers()
{
string query = "SELECT * FROM Cashier_2";
da = new SqlDataAdapter(query, constr);
table = new DataTable();
da.Fill(table);
dataGridView1.DataSource = table;
dataGridView1.Refresh();
SqlCommandBuilder b = new SqlCommandBuilder(da);
// The error rises in the line of code below
da.UpdateCommand = b.GetUpdateCommand();
}
private void ManageCashier_Load(object sender, EventArgs e)
{
LoadCashiers();
}
private void btnLoadCashiers_Click(object sender, EventArgs e)
{
LoadCashiers();
}
private void btnInsertCashier_Click(object sender, EventArgs e)
{
DALHelper helper = new DALHelper();
helper.InsertCashier(textBox1.Text);
LoadCashiers();
}
List<int>cashierIDsToDelete = new List<int>();
private void btnDelete_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow row in dataGridView1.Rows)
{
bool deleteStatus = Convert.ToBoolean(row.Cells[0].Value);
int cashierID = Convert.ToInt32(row.Cells[1].Value);
if (deleteStatus)
{
row.Selected = true;
cashierIDsToDelete.Add(cashierID);
}
}
foreach (DataGridViewRow selectedRow in dataGridView1.SelectedRows)
{
dataGridView1.Rows.Remove(selectedRow);
}
DALHelper dal = new DALHelper();
dal.DeleteCashiers(cashierIDsToDelete);
cashierIDsToDelete.Clear();
// Load Cashiers from Database
LoadCashiers();
}
private void btnUpdate_Click(object sender, EventArgs e)
{
da.Update(table);
MessageBox.Show("Update");
}
}
</code>
|
|
|
|
|
The error means you don't have a primary key defined in your database table.
A primary key is mandatory if you want to use SqlCommandBuilder .
You must either define a primary key in the database table or write the code to build the insert, delete and update SQL commands by hand.
2+2=5 for very large amounts of 2
(always loved that one hehe!)
|
|
|
|
|
i have developed a very simple application which contains a single win form and two classes.
i would like provide or show some text from those classess into my win textbox form.
how can i achieve it?
what I want excatly sames as "View Syn status" in MY SQL Replication.
i am trying to achieve from c#.
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Use
string s = "Hello";
textBox.Text = s; for a single line TextBox, or
string[] as = new string[n];
...
TextBox.Lines = as; for a multiline.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
my friend. i am asking about how can i access from other classess not from my win form.
from win form that is ok, but if i want to access it from other classes how can i access it and set the text to "hello" or something else?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Set a public property of the form to set the text like
public string SetText
{
get
{
return textbox1.Text;
}
set
{
textbox1.Text = value;
}
}
And call it from your class by accessing it through the instance of the form on which the text box resides.
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|
|
If I understand you correctly, you have a form with a textbox, and a separate class which does some work and is to display text in the textbox?
If yes, then either:
1) the class needs to be given the instance of the form.
or
2) the class needs to signal to the form that data is ready for display.
The first way is pretty trivial, the second is better practice.
Assuming:
myForm formMine = new myForm();
myClass classMine = new myClass();
In the first case, create a field in myClass:
public myForm formDisplayResult;
and assign it after the form and class creation:
myForm formMine = new myForm();
myClass classMine = new myClass();
classMine.formDisplayResult = formMine;
then access the textbox from your class:
formDisplayResult.tbResultsGoHere.Text = "Hello";
In the second case, it is a little more complex:
In myClass:
public partial class myClass
{
public delegate void ChangeHandler(object sender, EventArgs e);
public event ChangeHandler Changed;
protected virtual void OnChanged(EventArgs e)
{
ChangeHandler ch = Changed;
if (ch != null)
{
ch(this, e);
}
}
private void DoSomethingToChangeData()
{
OnChanged(null);
}
}
----- The asign to ch is in case the handler changes between null check
----- and exec.
----- (unlikely, but possible)
----- The null check is to ensure there is a handler. If not, better to
----- ignore it gracefully, than to rely on the thrown exception
----- (NullReferenceException)
In myForm:
myClass classMine = new myClass();
public myForm()
{
classMine.Change += new myClass.ChangeHandler(Changed);
}
private void Changed(object sender, EventArgs e)
{
tbResultsGoHere.Text = classMine.strResults;
}
It is easy really - you just have to get your head around it!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
thx alot, I really appreciate the second one, the first one might be bad habbit
but one thing, does the class inherits from some thing, or its simply
public class className
{
//cnt and others
{
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Either. It makes no real difference for your example.
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.”
|
|
|
|
|
As Henry said, it doesn't matter - any class (derived or not) can generate events.
Sorry for the late reply, I was busy making a bulk supply of meatballs...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Good answer!
For future reference, there is no need to create a delegate if using 2.0 or above.
public event ChangeHandler Changed;
can be written as
public event EventHandler Changed;
If custom event args are needed, there is a generic event handler
public event EventHandler<ChangedEventArgs> Changed;
Yay, no more delegate writing when using events
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Thanks!
I didn't know that, I'll give it a try sometime soon. Would be nice to simplify delegate / handler construction a bit...
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Well, i think i need more help
for (int i=0; i<count; i++)
{
="" result="i.ToString();
" display="" the="" variable="" contents="" into="" win="" form="" text="" box?
}
how="" can="" i="" send="" content="" winform="" box.=""
<div="" class="ForumSig">Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
I think you mean that your class generates a sequence of results, rather than a single result?
If so, then I would output them to a list and signal to the higher level that there were available.
Specifically, I would set up a queue in your class:
public Queue<string> qsOutputResults = new Queue<string>(100);
(Always create a queue with a minimum size or it gets extended the first time you use it)
Then when your results are available:
qsOutputResults.Enqueue(i.ToString());
OnChanged(null);
This adds the results to the queue and signals the results are ready.
In your form:
private void Changed(object sender, EventArgs e)
{
while (classMine.qsOutputResults.Count > 0)
{
tbResultsGoHere.AppendText(classMine.qsOutputResults.Dequeue());
}
}
Using the queue means they come off in the same order they went on.
If your form is too busy, they will just wait on the queue until you are ready.
You can replace the string with whatever is sensible for your results (of course).
You probably don't want to AppendText (it depends on your app) it was just for example.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
thx dude, that is really appreciated.
the thing which i got concern with, My messsage will not increase than 1000 lines, in each 1000 lines i will clear the textbox contents,
well do i need to use queue for my case, or i should use some other collection for good performance? and if the size of queue increase will it affect the speed and performance of computer?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
The performance of the queue should be pretty good anyway (except when the size is increased, at which point a new structure has to be created and populated with a copy of the original). Just a case of setting the initial size to a reasonable limit.
If you use another collection (a List<T> for example) then you would have to take care of the FIFO ordering which a Queue guarantees. If you are displaying the latest results (as you seem to) then why re-invent the wheel?
[edit]Removed word "not" from "should not be pretty good" above[/edit]
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
thx alot, you helped me alot, thanks again
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
i want to read all the appointments of a outlook 2007 and bind it to DataGridView.
in my application i've add refernce of following library-
Microsoft.Office.Interop.Outlook, Version=12.0.0.0
I'm reading appointments as-
Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.ApplicationClass();
Microsoft.Office.Interop.Outlook.NameSpace NS = app.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.MAPIFolder objFolder = NS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);
foreach (Microsoft.Office.Interop.Outlook._AppointmentItem Item in objFolder.Items)
{
string Id = Item.Subject;
}
but I'm unable to get Item.GlobalAppointmentID .I've search and find there is GlobalAppointmentID propery but I'm unable to get it. plz help me.
|
|
|
|
|
Hello....
In my application i am having a datagriview with columns
Column1 column2 column3
Accountname Debit Credit
-----------------------------------
total debit total credit
The total debit and total credit are two textboxes outside the gridview.
And my gridview is unbound.
Plz help me how i can caluclate all the values in the debit column and get
the result in the toatldebit textbox and similarly credit into total
credit textbox.
Plz someone post me the code...
It's helpful
Thanks in advance...
|
|
|
|
|
Anjani Poornima wrote: Plz someone post me the code...
It is unlikely that you are going to get the entire code here. Have you tried anything?
You can handle the CellLeave event of the gridview and set the value in the textbox. Check the column index of the cell and if it is debit/credit and then set the text of textboxes below.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus
|
|
|
|
|
I am developing one window application. In which I am using crystal report. I want to pass sql query to crystal report programatically from C#.net.
For example: "select * foms staffmaster where id=78"
So how can I create report.
Thanks in advance!
|
|
|
|