0% found this document useful (0 votes)
6 views3 pages

Project

The document contains a C# code snippet for a login functionality in a Windows Forms application. It defines an abstract class 'CropForm' and a class 'LivestockForm' with a method that is not implemented. The login method checks for valid credentials and either opens a dashboard form or displays an error message for invalid login attempts.

Uploaded by

harowntowett
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views3 pages

Project

The document contains a C# code snippet for a login functionality in a Windows Forms application. It defines an abstract class 'CropForm' and a class 'LivestockForm' with a method that is not implemented. The login method checks for valid credentials and either opens a dashboard form or displays an error message for invalid login attempts.

Uploaded by

harowntowett
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

public abstract class CropForm

{
public abstract void ShowDialog();
}

internal class LivestockForm


{
public void ShowDialog()
{
throw new NotImplementedException();
}
}

using System;
using System.Diagnostics;
using System.Windows.Forms;
using FarmManagementSystem;

namespace WindowsFormsApp001
{

private void btnLogin_Click(object sender, EventArgs e)

{
object txtUsername;
string username = txtUsername.Text.Trim();
object txtPassword;
string password = txtPassword.Text;

if (username == "admin" && password == "farm123")


{
// Open Dashboard form and close Login form
DashboardForm dashboardForm = new DashboardForm();
DashboardForm.ShowDialog();
{
Site = null,
AccessibleDescription = null,
AccessibleName = null,
AccessibleRole = AccessibleRole.None,
AllowDrop = false,
Anchor = AnchorStyles.None,
AutoScrollOffset = default,
BackgroundImage = null,
BackgroundImageLayout = ImageLayout.None,
Bounds = default,
Capture = false,
CausesValidation = false,
ContextMenu = null,
ContextMenuStrip = null,
Cursor = null,
Dock = DockStyle.None,
Enabled = false,
Font = null,
ForeColor = default,
Height = 0,
IsAccessible = false,
Left = 0,
Name = null,
Parent = null,
Region = null,
RightToLeft = RightToLeft.No,
Tag = null,
Top = 0,
UseWaitCursor = false,
Visible = false,
Width = 0,
WindowTarget = null,
Padding = default,
ImeMode = ImeMode.NoControl,
AutoScrollMargin = default,
AutoScrollPosition = default,
AutoScrollMinSize = default,
BindingContext = null,
AutoScaleDimensions = default,
AutoScaleMode = AutoScaleMode.None,
ActiveControl = null,
AutoSize = false,
BackColor = default,
ClientSize = default,
Location = default,
Margin = default,
MaximumSize = default,
MinimumSize = default,
Size = default,
TabIndex = 0,
TabStop = false,
Text = null,
AutoScroll = false,
AutoValidate = AutoValidate.Disable,
AcceptButton = null,
AllowTransparency = false,
AutoScaleBaseSize = default,
AutoSizeMode = AutoSizeMode.GrowAndShrink,
FormBorderStyle = FormBorderStyle.None,
CancelButton = null,
ControlBox = false,
DesktopBounds = default,
DesktopLocation = default,
DialogResult = DialogResult.None,
HelpButton = false,
Icon = null,
IsMdiContainer = false,
KeyPreview = false,
MainMenuStrip = null,
Menu = null,
MaximizeBox = false,
MdiParent = null,
MinimizeBox = false,
Opacity = 0,
Owner = null,
RightToLeftLayout = false,
ShowInTaskbar = false,
ShowIcon = false,
SizeGripStyle = SizeGripStyle.Auto,
StartPosition = FormStartPosition.Manual,
TopLevel = false,
TopMost = false,
TransparencyKey = default,
WindowState = FormWindowState.Normal
};
}
else
{
MessageBox.Show("Invalid username or password. Please try again.",
"Login Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtPassword.Clear();
txtPassword.Focus();
}
}
}

You might also like