|
As it's my first post here I should probably say "Hello"
In WinForms application I'm developing I'd like to have a Panel (let's name it "controlContent"), that should be editable in inherited classes (I want to add controls to it) and second Panel, that will have some buttons common to all controls in this hierarchy. The problem is that when I do it the simplest way - by setting controlContent to be protected - StyleCop says, that field should not be protected, create property instead. Well obviously he's right. But when I create what he want's I don't have access through Visual Studio designer to the Panel. And of course I don't wan't to write controls' layout manually.
Did anyone have similar issue? How can I solve it? (I was searching web, but either I'm asking google wrong questions or answer isn't there).
|
|
|
|
|
StyleCop is right - field members should be private, but this is one of those circumstances where the only sensible way to do what you want is to set the field to protected. Just go with that and ignore the StyleCop rule.
"An eye for an eye only ends up making the whole world blind"
|
|
|
|
|
Yeah. That's what I'm doing right now. I was just wondering if there's some workaround. Either way thanks for your answer. And I'll still be waiting, maybe someone knows something
|
|
|
|
|
HI
Here i m try to do clear the Browser cookies.
When i m logout my Application
Here i removeall my session but when i m click to back button in my browser its navigating to my application page. But i want to show Login.aspx page could you tell me how to do this?
try and try untill reach success..
|
|
|
|
|
See here for cookies.
My signature "sucks" today
|
|
|
|
|
Hi Experts
Can you tell me how to create the own keyword in .net
like .net in-Built keyword like where,new,from etc..
Dinesh Sharma
|
|
|
|
|
As far as i know you can't.
Why would you want to? There may be a better or existing way to achieve what you want...
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
I think you may be a little confused: .NET has no "keywords" - the C# language has keywords, VB has a slightly different set of keywords, C++, F# etc. all have their own keywords.
What are you trying to achieve? If you explain, we may be able to help you to do it.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Actually i am learning LINQ then i see the keyword like from,order by, where etc. in my project which is winForm app. in VS 2005 then i am making DAL(Data Access Layer) for that project so i want to
create such type of keyword in that project..
|
|
|
|
|
You can't create your own keywords, unless you join the development team. MS has provided the ability to extend items, and this might be what you want to achieve. For instance, suppose you want all DataTables to have a Dump facility to dump the contents to a file, you could extend it using:
public static class Utility
{
public static void Dump(this DataTable datatable)
{
}
} This code then appears as an operation for an instance of the DataTable.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Pete - do extension methods work in VS2005? I know they came in at C#3.0, so they can't be used with .NET 2.0, but I'm not sure they exist in 2005. I can't check, I only have VS08 loaded.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
It's the other way around, they can be used with .NET 2.0 (see below), but they can not be used (AFAIK) with VS05 because the version of the compiler it uses doesn't understand them. (unless you use custom build magic maybe)
Code to use extension methods with .NET 2.0:
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly)]
public sealed class ExtensionAttribute : Attribute
{
public ExtensionAttribute() { }
}
}
|
|
|
|
|
I thought I remembered there was something dodgy about the combination! Hopefully, the OP will spot this before he gets too confused...
Thanks for clearing that up.
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Thank u harold aptroot for Appreciation.
|
|
|
|
|
No. As has been said, they can work in .NET 2, but they were introduced in .NET 3 which was released with VS2008. As the OP said he was dealing with LINQ however, it's a safe bet that he's using VS2008/VS2010.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
That's what I thought - but the OP post was talking about 2005, so that's why I asked. He probably has something a bit confused...
Sharma Dinesh Kumar wrote: in my project which is winForm app. in VS 2005
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
The best you can probably do is use extension methods[^].
My signature "sucks" today
|
|
|
|
|
public void InsertPlannedMaterialMasterRequest(int id, string requestDocument, string requestDescription, string requestType, string hodApproval, int companyCode, string hodRemarks, string det_Description, string name, int qty, string code)
{
string query = "INSERT INTO MasterRequest (ID,Req_Document,Req_Description,ReqType,HODApproval,CompanyCode,HODRemarks) VALUES (@ID,@Req_Document,@Req_Description,@ReqType,@HODApproval,@CompanyCode,@HODRemarks)";
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand(query, con);
com.Parameters.Add("@ID", SqlDbType.Int).Value = id;
com.Parameters.Add("@Req_Document", SqlDbType.NVarChar).Value = requestDocument;
com.Parameters.Add("@Req_Description", SqlDbType.NVarChar).Value = requestDescription;
com.Parameters.Add("@ReqType", SqlDbType.NVarChar).Value = requestType;
com.Parameters.Add("@HODApproval", SqlDbType.NVarChar).Value = hodApproval;
com.Parameters.Add("@CompanyCode", SqlDbType.Int).Value = companyCode;
com.Parameters.Add("@HODRemarks", SqlDbType.NVarChar).Value = hodRemarks;
con.Open();
com.ExecuteNonQuery();
con.Close();
string query2 = "INSERT INTO DetailRequest (ID,Req_Document,Description,Approval) VALUES (@ID,@Req_Document,@Description,@Approval)";
SqlConnection con2 = new SqlConnection(constr);
SqlCommand com2 = new SqlCommand(query2, con2);
com2.Parameters.Add("@ID", SqlDbType.Int).Value = id;
com2.Parameters.Add("@Req_Document", SqlDbType.NVarChar).Value = requestDocument;
com2.Parameters.Add("@Description", SqlDbType.NVarChar).Value = det_Description;
com2.Parameters.Add("@Approval", SqlDbType.NVarChar).Value = hodApproval;
con2.Open();
com2.ExecuteNonQuery();
con2.Close();
string query3 = "INSERT INTO ITEMS (ID,Code,Name,Quantity) VALUES (@ID,@Code,@Name,@Quantity)";
SqlConnection con3 = new SqlConnection(constr);
SqlCommand com3 = new SqlCommand(query3, con3);
com3.Parameters.Add("@ID", SqlDbType.Int).Value = id;
com3.Parameters.Add("@Code", SqlDbType.NVarChar).Value = code;
com3.Parameters.Add("@Name", SqlDbType.NVarChar).Value = name;
com3.Parameters.Add("@Quantity", SqlDbType.Int).Value = qty;
con3.Open();
com3.ExecuteNonQuery();
con3.Close();
}
protected void Button1_Click(object sender, EventArgs e)
{
MasterRequest_DAL helper = new MasterRequest_DAL();
PlannedMaterialRequest pnd = new PlannedMaterialRequest();
ItemsHandling itm = new ItemsHandling();
string[] labelName = new string[100];
string[] coder = new string[100];
string[] quantity = new string[100];
if (TextBox6.Text != "0")
{
labelName[1] = itm.Code(0).ToString();
labelName[2] = TextBox6.Text;
helper.InsertPlannedMaterialMasterRequest(Convert.ToInt32(TextBox1.Text), TextBox2.Text, TextBox4.Text, DropDownList6.SelectedValue, DropDownList2.SelectedValue, Convert.ToInt32(TextBox11.Text), TextBox12.Text, TextBox13.Text, Label8.Text, Convert.ToInt32(TextBox6.Text), labelName[1]);
}
if (TextBox12.Text != "0")
{
labelName[1] = itm.Code(1).ToString();
labelName[2] = TextBox12.Text;
helper.InsertPlannedMaterialMasterRequest(Convert.ToInt32(TextBox1.Text), TextBox2.Text, TextBox4.Text, DropDownList6.SelectedValue, DropDownList2.SelectedValue, Convert.ToInt32(TextBox11.Text), TextBox12.Text, TextBox13.Text, Label12.Text, Convert.ToInt32(TextBox8.Text), labelName[1]);
}
}
The problem I am facing is that using the above code. The ID goes multiple times in MasterRequest table which should go only once, while the same ID must go to Items table multiple times as per the quantities being entered. I want only the ID to go into MasterRequest table just once not multiple times.
|
|
|
|
|
Do you want to say the it insert data into the MasterRequest table multiple times? Is there any postback issues.
|
|
|
|
|
yes this is exactly what it is happening. I just want the ID to enter into Master Request table for once while the same ID to enter into ITEMS table as many times the quantities are entered.
|
|
|
|
|
Thanks to all who assisted. My little flow calculator, ugly stepchild that it is, works nicely now.
My boss thanks you, my HP-15c calculator thanks you; my work PC has mixed feelings...
For the next version I'm going to figure out how to draw my pipe and channel cross-sections, rather than do them in AutoCAD, export them to pdf in CutePDF, import them and resize them in GIMP 2, then save them as jpg so Windows can render them.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Great. This may be the right time to write that long overdue second article, and tell us a bit about flow equations.
PS: points for a unique subject line!
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
I'm sure the world can wait for another article from me. I'm a decent writer, but a lousy programmer. Maybe when I get around to cleaning it up, adding validation code, and making the images self-drawing I'll consider posting it.
But since you asked, Manning's equation is used to calculate fluid flows in an open channel, and works well enough in a closed pipe to use as a general purpose calculation. It's based on empirical measurements, and doesn't rely on knowledge of the type of flow (turbulent or laminar) or the viscosity (which leads to a whole bunch of details). Simply stated:
V, ft/sec = (1.486/n) * R2/3 * S1/2 where,
n = Manning's coefficient, a frictional factor determined by the material of the channel,
R = Hydraulic radius
S = Slope
The hydraulic radius is simply, R = A/P, where A is the cross-sectional area of the fluid flow, and P is the wetted perimeter of the pipe or channel. While the basic equation is easy, these parameters are difficult to calculate. As an exercise for the student, try determining the area of a water flow that fills a pipe only 1/3; it's not a trivial solution.
The goal in designing a sewer pipe is to keep the flow rate between 2 and 10 ft/sec. Any slower, material will tend to accumulate in the pipe rather than flow through smoothly. Above 10 ft/sec, though, the momentum of the water will cause pipes to shift and separate at curves and tees. Water also becomes corrosive at high flow rates, causing erosion of the pipes.
I use the equation to iterate through various slopes assuming minimal flow levels and nearly full levels to arrive at a slope that will meet both constraints. Then I calculate the maximum gpm the pipe can carry and compare it to the load the line is expected to carry. If it's not enough, I pick a larger pipe and start over.
As you can see, it's tedious, and this little app will save me hours!
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
|
|
|
|
|
Thanks. That information too would be welcome in an article; focus doesn't have to be on the code, the application domain itself can be interesting too. Throw in a few drawings/photo's, some typical values for Manning's coefficient, the units to be used in the formula(s), and we can get a pleasant read out of it.
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read formatted code with indentation, so please use PRE tags for code snippets.
I'm not participating in frackin' Q&A, so if you want my opinion, ask away in a real forum (or on my profile page).
|
|
|
|
|
Congratulations
Roger Wright wrote: do them in AutoCAD, export them to pdf in CutePDF, import them and resize them in GIMP 2, then save them as jpg
Yeah, just drawing them will be way easier!
If you're using WinForms (I seem to remember you were) then the easiest way to start is to draw your own control and drop that on a form rather than try to draw on the form itself. A Panel is a good control to derive from for this.
The little snippet below shows the basic principle - I've made this control redraw and realign a legend when the Padding property changes as an example.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace RogerWright.Drawing
{
public class DrawingSurface : Panel
{
private const string Legend = "Drawing Surface";
public DrawingSurface()
{
DoubleBuffered = true;
}
private Rectangle GetLayoutRectangle()
{
return new Rectangle(
Padding.Left,
Padding.Top,
Width - Padding.Horizontal,
Height - Padding.Vertical);
}
protected override void OnPaddingChanged(EventArgs e)
{
Invalidate();
base.OnPaddingChanged(e);
}
protected override void OnPaint(PaintEventArgs e)
{
Rectangle layoutRectangle = GetLayoutRectangle();
using (Brush textBrush = new SolidBrush(ForeColor))
{
e.Graphics.DrawString(Legend, Font, textBrush, layoutRectangle);
}
float yOffset = e.Graphics.MeasureString(Legend, Font).Height;
base.OnPaint(e);
}
}
} Hope it helps!
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|