Click here to Skip to main content
14,383,744 members
   

C#

 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
OriginalGriff12-Nov-19 1:46
protectorOriginalGriff12-Nov-19 1:46 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
Member 1464246912-Nov-19 19:28
memberMember 1464246912-Nov-19 19:28 
GeneralRe: How to Import database.mdf file in Visual Studio 2010 Project Pin
OriginalGriff12-Nov-19 21:44
protectorOriginalGriff12-Nov-19 21:44 
Questionc++ DLL import in c# Pin
Member 1465244911-Nov-19 20:49
memberMember 1465244911-Nov-19 20:49 
AnswerRe: c++ DLL import in c# Pin
Richard MacCutchan11-Nov-19 22:12
protectorRichard MacCutchan11-Nov-19 22:12 
GeneralRe: c++ DLL import in c# Pin
Member 1465244912-Nov-19 20:44
memberMember 1465244912-Nov-19 20:44 
GeneralRe: c++ DLL import in c# Pin
Richard MacCutchan12-Nov-19 23:09
protectorRichard MacCutchan12-Nov-19 23:09 
QuestionCode not splitting for login form. C# Pin
Member 1465157011-Nov-19 2:10
memberMember 1465157011-Nov-19 2:10 
Hiya all, I'm trying to get my code to allow me to login with details from a .csv file. The code is not splitting correctly and therefore says the user and pass is incorrect. I'm wanting it to open a second form.
Any suggestions? Here's the code..

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;

namespace --------
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Label1_Click(object sender, EventArgs e)
        {

        }

        private void BtnLogin_Click(object sender, EventArgs e)
        {
            string Username = txtUsername.Text;
            string Password = txtPassword.Text;
            bool Found = false;

            string FilePath = "Login.csv";
            StreamReader fileReader = new StreamReader(FilePath);
            String[] details = File.ReadAllLines(FilePath);

            String[] splitted;
            foreach (string line in details)
            {
                splitted = line.Split(',');
                if (details[0] == Username && details[1] == Password)
                {
                    Found = true;
                }
            }
            if (Found == true)
            {
                Form2 Form2 = new Form2();
                Form2.Show();
                this.Hide();
            }
            else
            {
                AutoClosingMessageBox.Show("Incorrect Login Details Entered", "Error:", 5000);
            }
        }
    }
}
public class AutoClosingMessageBox
{
    System.Threading.Timer _timeoutTimer;
    string _caption;
    AutoClosingMessageBox(string text, string caption, int timeout)
    {
        _caption = caption;
        _timeoutTimer = new System.Threading.Timer(OnTimerElapsed,
            null, timeout, System.Threading.Timeout.Infinite);
        using (_timeoutTimer)
            MessageBox.Show(text, caption);
    }
    public static void Show(string text, string caption, int timeout)
    {
        new AutoClosingMessageBox(text, caption, timeout);
    }
    void OnTimerElapsed(object state)
    {
        IntPtr mbWnd = FindWindow("#32770", _caption);
        if (mbWnd != IntPtr.Zero)
            SendMessage(mbWnd, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
        _timeoutTimer.Dispose();
    }
    const int WM_CLOSE = 0x0010;
    [System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
    static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    [System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto)]
    static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
}

AnswerRe: Code not splitting for login form. C# Pin
phil.o11-Nov-19 2:19
mvephil.o11-Nov-19 2:19 
AnswerRe: Code not splitting for login form. C# Pin
Richard MacCutchan11-Nov-19 2:32
protectorRichard MacCutchan11-Nov-19 2:32 
GeneralRe: Code not splitting for login form. C# Pin
OriginalGriff11-Nov-19 2:32
protectorOriginalGriff11-Nov-19 2:32 
GeneralRe: Code not splitting for login form. C# Pin
Richard MacCutchan11-Nov-19 2:50
protectorRichard MacCutchan11-Nov-19 2:50 
AnswerRe: Code not splitting for login form. C# Pin
OriginalGriff11-Nov-19 2:32
protectorOriginalGriff11-Nov-19 2:32 
NewsRe: Code not splitting for login form. C# Pin
Eddy Vluggen11-Nov-19 4:20
mveEddy Vluggen11-Nov-19 4:20 
QuestionQuestion Pin
Member 1450924010-Nov-19 2:39
memberMember 1450924010-Nov-19 2:39 
QuestionRe: Question Pin
Richard MacCutchan10-Nov-19 2:44
protectorRichard MacCutchan10-Nov-19 2:44 
AnswerRe: Question Pin
OriginalGriff10-Nov-19 2:48
protectorOriginalGriff10-Nov-19 2:48 
AnswerRe: Question Pin
Eddy Vluggen10-Nov-19 2:51
mveEddy Vluggen10-Nov-19 2:51 
QuestionHow to disable other buttons based on user role login Pin
Member 146022408-Nov-19 23:05
memberMember 146022408-Nov-19 23:05 
AnswerRe: How to disable other buttons based on user role login Pin
OriginalGriff8-Nov-19 23:30
protectorOriginalGriff8-Nov-19 23:30 
AnswerRe: How to disable other buttons based on user role login Pin
Richard MacCutchan8-Nov-19 23:53
protectorRichard MacCutchan8-Nov-19 23:53 
GeneralRe: How to disable other buttons based on user role login Pin
Mycroft Holmes9-Nov-19 11:21
memberMycroft Holmes9-Nov-19 11:21 
GeneralRe: How to disable other buttons based on user role login Pin
OriginalGriff9-Nov-19 11:35
protectorOriginalGriff9-Nov-19 11:35 
GeneralRe: How to disable other buttons based on user role login Pin
Richard MacCutchan9-Nov-19 21:53
protectorRichard MacCutchan9-Nov-19 21:53 
GeneralRe: How to disable other buttons based on user role login Pin
Mycroft Holmes10-Nov-19 11:08
memberMycroft Holmes10-Nov-19 11:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.