|
If I were designing a Form to be used for viewing the current state of a Customer, I would not have a method available from that form to actually delete a Customer ... for security reasons. I would allow only the Manager's Form to delete a Customer, or delete any agreement with the Customer.
I would probably want to show, on a given Customer's Form:
1. the customer information appropriate to the role of the person viewing the Form
2. at least the fact that the Customer has a current agreement(s).
3. depending on design: perhaps a mechanism to notify the Manager the customer has made a request to delete account/agreement.
I'd suggest (hard to be more specific without seeing/understanding your code):
1. when the current Customer Form is created, pass to it the necessary information it needs to present what you want to appear on the Form about the current agreement(s), or the fact there is no current agreement.
2. I'd use a separate Form to notify the Manager of a request for deleting an account, or agreement ... if the Customer Form did not allow such a notifiaction by the person using it.
«A man will be imprisoned in a room with a door that's unlocked and opens inwards ... as long as it does not occur to him to pull rather than push» Wittgenstein
|
|
|
|
|
Hi All,
We need to build our own workflow engine using c#,
please help me if you can how to start do that and let me know if it is possible or not.
Thanks
|
|
|
|
|
The first question I would have to ask is why? .NET has Workflow Foundation available for free, so have you looked into what it offers? As to the second part, yes it is possible to build your own Workflow engine using C#. Only you and your team can decide what you want it to be able to do, so it's up to you to define your requirements. For instance, what database do you intend to use to provide support for your Serializable Large Objects (SLOBs)?
|
|
|
|
|
|
What?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
We'd love to be able to help you, but we don't understand your question. I appreciate that English isn't your first language, but if you could find someone who was more fluency in English to help you write your question, this will probably help everyone.
|
|
|
|
|
|
Hi
i need to create a windows service which can run continuously
i have some ms sql qureys which i would like to run can any one help me i don't have any idea on c# if any one can help it will be great full.
Thank
Sharm
|
|
|
|
|
Have a look at Topshelf or Cinchoo for getting started with a service - when you have a running service then add the ability to connect and query a database to it - you might like to think about how you're going to 'schedule' the execution of your queries - some sort of timing mechanism - its not too hard to use Quartz.Net with Topshelf to provide this ability
have fun
|
|
|
|
|
int a = 0;
int inputvalue = 0;
for (int i = 0; i < 1; i++)
{
Console.WriteLine("Give me a number");
inputvalue = Convert.ToInt16(Console.ReadLine());
if (i == 0)
a = inputvalue;
while ()
}
Console.ReadLine();
Hi guys, this is what I have so far. I am trying to learn this but i cant even understand the basics and i am really frustrated. Heres what im trying to do. Im trying to have a loop repeat certain code before it exits out. So in this example, I want to be able to write a nested loop where if I dont meet a certain condition, it continues to repeat until the condition is met. For example,
Give me a number greater than 50.
If the condition is met then loop out of the nested loop and ask for another number, if condition is not met, ask again until condition is met.
Am I close? do I have to use a loop at all or will an if statement suffice?
|
|
|
|
|
Nearly, but I would likely do the inner loop more like this:
do
{
Console.Write("Give me a number");
}
while (!System.Int16.TryParse(Console.ReadLine() , out inputvalue ) || (inputvalue <= 50 ) ) ;
|
|
|
|
|
Nested Loop defines as create the new loop inside the already existing loop. e.g.
for(int i =0;i<5;i++)
{
for(int j=0;j<i;j++)
{
Console.Write("*");
}
Console.WriteLine("");
}
Here is the example of nested for loop. You may also include the while or do-while loop inside or outside the loop.
Happy Coding
|
|
|
|
|
Your code here ... the for-loop ... suggests you want to get a certain number of numbers from the user, but I don't see you storing those numbers for future use.
PieBald's response here shows you how to use 'TryParse, and you should definitely be using that.
Do you need to preserve the user's entries ?
Also, what about letting the user quit the loop when they enter something like "quit" ?
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
I did it the tryparse way and its good but I guess im just doing this to exercise my mind and think in a logical manner. Granted, this is the more complex way but im trying different ways to program the same thing.
|
|
|
|
|
Hi, Nothing wrong with exercising the mind and trying out different things ! Experimenting is, imho, a vital part of getting the "feel" of the language ... I'm addicted to it cheers, Bill
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Hi,
I have a winform application that is a simple form with three textboxes, submit button, and cancel button. When a user is entering data, I would like the application to detect if the Enter key is pressed and "click" the Submit button when the key press is detected without regard to which control currently has focus.
Does this require a key press event for each control or is there a way to globally detect the key press?
Thanks,
Rob
|
|
|
|
|
It's very simple. Just look at the AcceptButton property of your form. Set it to the button that will be clicked when the user hits [Enter]. That's all you have to do.
|
|
|
|
|
Note that to use this with the standard Ms TextBox you will have to set the 'AcceptsReturn Property to 'true.
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|
|
Actually, you don't have to do that at all. The AcceptsReturn property is only for Multiline textboxes.
What does have to happen, which I forgot about, is that you have to handle the Click event for the button you set as the AcceptButton and set the forms DialogResult property to whatever you want it to be in order for the AcceptButton property to work. The CancelButton property sets this for you, but the AcceptButton doesn't.
|
|
|
|
|
Rob, Open the properties of the required control (eg textBox), click on the event button. here you will see the keydown property. Double click on it and code here.
private void textBox2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode.ToString() == "Return")
{
}
}
|
|
|
|
|
tarun1991,
Do I need to do this for each textbox? Your example refers to textBox2 only. I have 3 textboxes total.
-Rob
|
|
|
|
|
Rob, it depends on you. At which point you are creating its object, you need to create its event.
If you create the control inside the loop, you have to declare its location and size. Here you will call it as :
for(int i =0;i<3;i++)
{
TextBox textBox = new TextBox();
textBox.Text .....
textBox.Location....
textBox.size....
textBox.KeyDown += (press TabButton) //whole next coding will automatically generated.
}
//This part will generate automatically.
public void textBox_KeyDown(Object sender,Eventargs e)
{
// here you need to code you statement part.
}
Regards
Tarun
|
|
|
|
|
Rob, There is also an another way. You need to write the code one time and set the all textboxes event name as textBox_Keydown. This can be done, if all the textbox performs same function with same behavior.
|
|
|
|
|
In addition to the method that Dave shows, you can also set the Form's KeyPreview property to 'true, and catch the Enter Key in a KeyUp EventHandler:
private void Form1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Console.WriteLine("enter key seen");
}
} If you have both an 'AcceptButton defined for the Form, and KeyPreview set to 'true, and a KeyUp EventHandler: both Events will fire, with the Button getting a "virtual click" first.
However, I think using either of these two techniques is (almost always) a mistake because most applications are going to need to perform some kind of validation on user entry before "submit."
With either of these two techniques, you won't know where the Enter key Event came from (okay, there is a work-around for that using 'ActiveControl, but I'll skip over that).
imho a much better technique is something like this:
private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine("button click ... active Control is {0}", ActiveControl.Name);
}
private void TextBoxes_KeyUp(object sender, KeyEventArgs e)
{
if (! (e.KeyCode == Keys.Enter)) return;
button1.Enabled = false;
TextBox activeTextBox = sender as TextBox;
string currentText = activeTextBox.Text;
if(currentText.Where(ch => Char.IsDigit(ch)).ToList().Count > 3)
{
Console.WriteLine("fail: TextBox{0} has more than 3 digits", activeTextBox);
activeTextBox.Focus();
e.Handled = true;
return;
}
switch (activeTextBox.Name)
{
case "textBox1":
if (! (currentText.Where(ch => Char.IsLetter(ch)).ToList().Count == 4))
{
Console.WriteLine("fail: TextBox1 does not have 4 letters");
activeTextBox.Focus();
e.Handled = true;
return;
}
break;
case "textBox2":
break;
case "textBox3":
break;
}
button1.Enabled = true;
button1.PerformClick();
} Note that you need to wire-up the KeyUp EventHandler to each of the TextBoxes you wish to validate.
Also, note that the decision to disable the Button used for "submit" reflects my own conviction that it is better to have UI controls that do not function if using them would have unknown side-effects, or allow errors.
While disabling the Button may not quite make sense in this example; my choice would be to enable the Button only when all 3 TextBoxes have validated content. Your Application design may not require this.
Writing code to keep track of which TextBoxes are currently validated, and to evaluate whether all TextBoxes have valid content is not difficult.
Validation is a good thing !
«OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. » Alan Kay's clarification on what he meant by the term "Object" in "Object-Oriented Programming."
|
|
|
|