For those new to message boards please try to follow a few simple rules when posting your question.
Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
Keep the subject line brief, but descriptive. eg "File Serialization problem"
Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
No advertising or soliciting.
We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
I would like to know if it is possible for someone to perhaps do a good example of how to add domain / business layer. The following are the steps I follow but I always get stuck on the domain...
* I start with a blank solution.
* I add an MVC project.
* I do my tables and hook up entity framework so I have a quick prototype. I used DB first (not code first) as I like the control it gives me over the DB. EF auto generates my model classes.
* Next I extract the models to a class library project and move the authentication out to the same database and model layer as well. This means I have a single DB in sql server and a single set of model classes all stored in the model layer.
* Next I move the DB access logic out of the controller to a repository layer (another class library project). For the most part a generic repo does well with the various crud operations modelled on an generic interface, and implemented on a generic repo class that I use in my controllers. But occasionally I have to specialise it. This makes my controller actions usually only 1 or 2 lines.
* Where possible / necessary I hook up view models for my views.
From there I get lost. If I add some business logic in the repo layer, they become very specialised very quick and start to grow very fast. If I do it in the controllers the same applies. What I want is to have a separate layer. A business logic layer or domain as its known.
* I want to call the domain layer from my controller.
* The domain layer in turn calls the repository layer.
* The repo layer does the data access using EF models.
The problem I am having is that to do this I either have to create a whole new set of classes to mirror the Model classes in the domain layer, and them "map" what is returned from the repo to them (is this normal, seems a bit much, what if the models change, now I have 2 places to alter it, possibly 3 if it affects the repo layer. Doesn't smell right?). Or I have to allow direct access to the model layer, within the domain layer defeating the purpose of the repo layer as it effectively could be bypassed.
Ideally I would like to have something that mimics or uses the Façade design pattern. Where each layer has to go through an API of sorts to access the layer below, and can only access one layer below not skip over the layers. Then I would like to invert it using DI/IOC if possible.
Anyway, even when I forget about layering it, and try to do it in the controller itself I get lost. As I usually have to bypass the repo layer to map what should be returned from the repo to the view models or view. So I am totally confused about how to add this and I would hope someone can write an article demonstrating it for me. I would be happy to document my existing work and perhaps share credit for the article as I have a lot of this already documented on a private github repo.
I think this would help the community in general and would greatly appreciate any help.
I tried this code. I am getting the download rate in the result but how can I calculate the speed just like speedtest.net.
for example: I tried below code and got 69kb/sec and when I try the same time on speedtest.net the result will show 1.69Mbps.
How can I display similar result?
Uri URL = new Uri("http://www.jassimrahma.com/speedtest/1024kb.txt");
WebClient wc = new WebClient();
double starttime = Environment.TickCount;
// download file from the specified URL, and save it to C:\speedtest.txt
// get current tickcount
double endtime = Environment.TickCount;
// how many seconds did it take?
// we are calculating this by subtracting starttime from endtime
// and dividing by 1000 (since the tickcount is in miliseconds.. 1000 ms = 1 sec)
double secs = Math.Floor(endtime - starttime) / 1000;
// round the number of secs and remove the decimal point
double secs2 = Math.Round(secs, 0);
// calculate download rate in kb per sec.
// this is done by dividing 1024 by the number of seconds it
// took to download the file (1024 bytes = 1 kilobyte)
double kbsec = Math.Round(1024 / secs);
lblStatus.Text = "Download rate: " + kbsec + " kb/sec";
// delete downloaded file
// lblStatus.Text = "Couldn't delete download file.":
// Response.Write("Couldn't delete download file.");
// Response.Write("To delete the file yourself, go to your C-drive and look for the file 'speedtest.txt'.");
//The WHERE CASE @Field are radio buttons in the form where if one RB is selected populate the SELECT fields in a datarepeater. The commented out is what I tried, produces diff. errors.
-- Add the parameters for the stored procedure here
ASBEGIN-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @Criteria varchar(502) = '%'+ @Search + '%'SELECT
WHERECASEWhen @Field = 'ServedBy'then ServedBy
When @Field = 'CaseDocNumber'then CaseDocNumber
When @Field = 'SenderAddress'then SenderAddress
When @Field = 'Claim'then Claim
ORDERBY EnterDate DESC;
PLEASE help to use @Field correctly in my code.
Maybe I am doing it ALL WRONG. Thank yoU!
0) (Unrelated to the error) There is no need to specify the datatypes for the parameters; they will be set when you set the value.
1) If you don't set the Value, or if the value is NULL, set the Value to DBNull.Value
2) You may need to set the Direction of the parameters.
3) = edtPicker; and = udtPicker; -- Don't those need a .Value ?
3) DateTime edtPicker = Convert.ToDateTime(EnterdateDateTimePicker.Value); -- you don't need to convert; just cast DateTime edtPicker = (DateTime) EnterdateDateTimePicker.Value;
4) The procedure returns a DataTable, are you expecting it to set your parameters?
I am not clear if I need params or not, new to this. To start, I have a very simply search, display winform. Select a radio button, (ServedBy, CaseDocNumber, SenderAddress), hit Search, and storedProc populates fields(EnterDate, EnterTime,EnterBy,CaseTypeID, MethodTypID,UpdateDate,UpdateBy) in a datarepeater in same form. Do I just bind the controls to a datasource? I figure I need to do a sql conn first, then add params. The @Fields in the storedProc throws me off thinking I need to use that. Sorry if its confusing.
i am use 4 multicolumncombi in my form in first navigatorbinding is correct but when one record insert in database my moveprevious and next previous is not show correct tytle in multicolumncombobox and
when close program and run program again bindingnavigator is correct but when save again not show tytle correct
my source code:
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e)
if (phonebookDataSet.moshtarakin_hoghoghi.Compute("max(SysCode)+1", null).ToString() != null)
editBox1.Text = phonebookDataSet.moshtarakin_hoghoghi.Compute("max(SysCode)+1", null).ToString();
editBox1.Text = 1.ToString();
editBox3.Text = "";
editBox2.Text = "";
editBox4.Text = "";
multiColumnCombo1.Text = "";
multiColumnCombo2.Text = "";
multiColumnCombo3.Text = "";
multiColumnCombo4.Text = "";
uiComboBox1.Text = "";
private void multiColumnCombo1_TextChanged(object sender, EventArgs e)
if (multiColumnCombo1.Text != "")
stateCityBindingSource.Filter = "State_Id='" + Convert.ToInt32(multiColumnCombo1.Value.ToString()) + "'";