|
Mate, I assume that you need show the related employees in the gridview as per the combobox selection.
It is just the matter of reading the selected value from the combobox,
selectedItem = comboBox1.SelectedItem;
Pass this selected value to filter the Employee table and read the results.
Finally, Rebind(); the gridview.
This is the basic logic. Try the above(There are plenty of resources online). If you get any real problem after your own attempt, post them in Questions area. Good luck.
|
|
|
|
|
I started to learn how to write mvc tests from the following site http://www.asp.net/mvc/tutorials/older-versions/contact-manager/iteration-5-create-unit-tests-cs"
However when running the test I keep getting a object not set to instance exception
[TestMethod]
public void CreateRace()
{
RACE race = new RACE();
race.RACE_CODE = 1;
race.Logourl = "dasdad";
race.RegattaCity = "Durban";
race.RegattaProvince = "Kzn";
race.RegattaStreetAddress = "232Chats";
race.MAXPARTICA = 12;
race.SECRETARY_EMAIL = "ssasda";
race.SECRETARY_MOBILE = 1422434;
race.SECRETARY_NAME = "jsjsjs";
race.ENTRYAMOUNT = Convert.ToDecimal(23.58);
race.EVENT_NAME = "sadada";
race.status = "Active";
race.UserId = 1;
race.LATEENTRYAMOUNT = Convert.ToDecimal(23.58);
string eventstart = "2014/05/12 12:02", eventend = "2014/05/17 12:02", entrydeadline = "2014/05/11 12:02", withdrawdate = "2014/05/11 12:02", YachtClubname = "durban";
var result = _service.CreateRace(race, eventstart, eventend, entrydeadline, withdrawdate, YachtClubname, "Kzn");
Assert.IsTrue(result);
}
//Create Service Method
public bool CreateRace(RACE race, string eventstart, string eventend, string entrydeadline, string withdrawaldate,string YachtClubname,string Province )
{
if (!ValidateRace( race,eventstart, eventend, entrydeadline, withdrawaldate,YachtClubname,Province))
return false;
try
{
_repository.CreateRace(race, eventstart, eventend, entrydeadline, withdrawaldate,YachtClubname,Province);
}
catch
{
return false;
}
return true;
}
|
|
|
|
|
I see two possible locations in there. One is that you haven't initialized _service, the other being _repository.
|
|
|
|
|
Thank you for your reply;Is this what you meant by Initialization:
private Mock<IRaceRepository> _mockRepository;
private ModelStateDictionary _modelState;
private IRaceService _service;
[TestInitialize]
public void Initialize()
{
_mockRepository = new Mock<IRaceRepository>();
_modelState = new ModelStateDictionary();
_service = new RaceServiceRepository(new ModelStateWrapper(_modelState), _mockRepository.Object);
}
Unfortunately it still gives me Object not set to an instance on an object error
|
|
|
|
|
Then throw us a bone and do some debugging. Find out which line is throwing this exception. Until you do this, we can't help.
|
|
|
|
|
That's one of the easiest errors to track down. One of the objects you're using is null. It's that simple.
Use the debugger to find out which one. You're getting this error because you're code is assuming that every property and method you're calling is returning an object. One or more of them returned null.
Step through the code line by line in the debugger and hover the mouse over each and every variable to see what it's value is.
|
|
|
|
|
You can set the development environment (Visual Studio) to break where the exception was originally throw (if it's re-thrown) by changing the following setting: "Debug->Exceptions..." and check the Thrown column for "Common Language Runtime Exceptions".
modified 12-Feb-22 21:01pm.
|
|
|
|
|
Goodmorning,
I would like to start my form having the mouse set in the form area (in any position is ok, but in the form) at the start.
Is it possible?
Thanks
|
|
|
|
|
Windows Forms? If so, just set MouseLocation to your desired location.
|
|
|
|
|
MouseLocation is it a proprties? of which object?
|
|
|
|
|
Yes - you have to work relative to the Form Location property, but it's pretty simple:
private void frmMain_Load(object sender, EventArgs e)
{
Cursor.Position = new Point(Location.X + 10, Location.Y + 10);
}
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
private void Form1_Load(object sender, EventArgs e)
{
Point mid = new Point(Width / 2, Height / 2);
Cursor.Position = new Point(this.Left + mid.X, this.Top + mid.Y);
}
Happy Coding...
modified 3-Sep-19 21:02pm.
|
|
|
|
|
I’m developing a Window’s forms application for collecting and graphing historical data and utilizing a monthcalendar control that allows the user to select a day or range of days for graphing (MaxSelectionCount = 7). Additionally, since the user should never be selecting future dates, I have set the maxdate property to today (DateTime.Now).
Utilizing this configuration the user is allowed select any individual valid date (including today) without a problem, AND the user is allowed select any group of “previous” dates without a problem. However, the control will NOT allow the user to select a range of dates that includes today. Any ideas on why this doesn’t work???
I can even set the MaxDate to tomorrow (DateTime.Now.AddDays(1)) with similar results; However, setting MaxDate to the day after tomorrow (DateTime.Now.AddDays(2)) DOES allow the user to select a range including today… But it also lets them select a range of dates that includes tomorrow, and the day after tomorrow can be selected as an individual date…
Kip
|
|
|
|
|
The MaxDate property works up to the exact DateTime that you set: but DateTime.Now includes the hours, minutes and seconds - so setting MaxDate to it pretty much excludes the final date from a range as it has already passed (I think - I haven;t looked at the .NET code). What you need to do is set it to the end of day that you want to include:
myMonthCalendar.MaxDate = DateTime.Now.AddDays(1).Date.AddSeconds(-1); Should do it.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Or just use DateTime.Today.
|
|
|
|
|
You could, but you'd have to make it:
myMonthCalendar.MaxDate = DateTime.Today.AddDays(1).AddSeconds(-1);
DateTime.Today is midnight last night, which gives the same problem on it's own.
But it's tidier with Today, I'll admit!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Thank you for the quick replies! I went with the “DateTime.Today.AddDays(1).AddSeconds(-1)” solution. Works great; thanks again!
|
|
|
|
|
You're welcome!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
As we can't see your code, we have no way other than randomly guessing.
|
|
|
|
|
I don't randomly guess, I try it!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
how to add coding to send Encryption text via smtp mail and this is the code. thanks
private void SendMail_Click(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
{
MessageBox.Show("Require, must content the row !!!");
}
else
try
{
obj_SMTPClient = new SmtpClient("smtp.gmail.com");
Obj_MailMsg = new MailMessage();
obj_Attachment = new System.Net.Mail.Attachment(textBox7.Text);
Obj_MailMsg.From = new MailAddress(textBox1.Text);
Obj_MailMsg.To.Add(textBox3.Text);
Obj_MailMsg.Body = textBox5.Text;
Obj_MailMsg.Attachments.Add(obj_Attachment);
Obj_MailMsg.Subject = textBox4.Text;
SmtpClient smtps = new SmtpClient("smtp.gmail.com", 587);
obj_SMTPClient.Credentials = new NetworkCredential();
obj_SMTPClient.Port = 587;
obj_SMTPClient.Credentials = new System.Net.NetworkCredential(textBox1.Text, textBox2.Text);
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
obj_SMTPClient.EnableSsl = true;
obj_SMTPClient.Send(Obj_MailMsg);
MessageBox.Show("Message Successfuly Sent!!!");
}
catch
{
MessageBox.Show("Failed to Send Message!!!");
}
}
private void EncryptionText_Click_1(object sender, EventArgs e)
{
cipherData = textBox6.Text;
plainbytes = Encoding.ASCII.GetBytes(cipherData);
desObj.GenerateKey();
desObj.GenerateIV();
desObj.Mode = CipherMode.CBC;
desObj.Padding = PaddingMode.PKCS7;
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms,
desObj.CreateEncryptor(),
CryptoStreamMode.Write);
cs.Write(plainbytes, 0, plainbytes.Length);
cs.Close();
cipherbytes = ms.ToArray();
ms.Close();
textBox5.Text = Encoding.ASCII.GetString(cipherbytes);
}
private void DecryptionText_Click_1(object sender, EventArgs e)
{
MemoryStream ms1 = new MemoryStream(cipherbytes);
CryptoStream cs1 = new CryptoStream(ms1,
desObj.CreateDecryptor(),
CryptoStreamMode.Read);
plainbytes = new Byte[cipherbytes.Length];
cs1.Read(plainbytes, 0, cipherbytes.Length);
cs1.Close();
ms1.Close();
textBox5.Text = Encoding.ASCII.GetString(plainbytes);
}
|
|
|
|
|
What's the problem?
That's just code without any explanation of the help you need.
Remember that we can't see your screen, access your HDD, or read your mind, so we only get what you tell us to work on.
Help us to help you!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
This is a small problem to sending text without attachment file, need your help me??
|
|
|
|
|
It'd probably be easier to tackle both problems separately; mailing a text and encrypting a text.
So, what's the problem with above code? Does it throw an exception? Does it encrypt?
If you're having trouble decrypting the text on another machine, then take in consideration that you're generating a new key
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Yes, I will send encryption file using mail but code above only file attachment which sending. how to i adding the code to sending encrypt file without attachment. thanks
|
|
|
|
|