please give a desktop application sample
i have form name Login Form there has 2 element 1st username and 2nd password
i`ve fixed username = 'abc' and password='123'
after authenticate this username and password if match 100%
then Login Form will be hide and Home form will be show
and there has some link when click any link result will be load on same window
please help me to give sample code
Loading
Satyapriya NayakPosted Feb 3, 2013, 12:33 PM
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Login_Form_in_Csharp_Using_ProgressBar
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
OleDbDataAdapter oledbda;
DataSet ds;
string str;
public Form1()
{
InitializeComponent();
}
private void btnlogin_Click(object sender, EventArgs e)
{
if (txtusername.Text == "" || txtpassword.Text == "")
{
MessageBox.Show("Please enter User ID or Password");
txtusername.Text = "";
txtpassword.Text = "";
}
else
{
OleDbConnection con = new OleDbConnection(ConnectionString);
con.Open();
str = "select count(*) from login where userid='" + txtusername.Text.Trim() + "' and password='" + txtpassword.Text.Trim() + "'";
com = new OleDbCommand(str, con);
oledbda = new OleDbDataAdapter(com);
ds = new DataSet();
oledbda.Fill(ds, "login");
long x;
x = Convert.ToInt64(com.ExecuteScalar());
if (x == 1)
{
int y = 0;
progressBar1.Visible = true;
progressBar1.Minimum = 1;
progressBar1.Maximum = 100000;
progressBar1.Value = 1;
progressBar1.Step = 1;
for (y = 1; y <= 100000; y++)
{
progressBar1.PerformStep();
}
Form2 f1 = new Form2();
f1.Show();
this.Hide();
}
else
{
MessageBox.Show("Invalid User ID or Password! Try Again!");
txtusername.Text = "";
txtpassword.Text = "";
}
con.Close();
}
}
}
}
Sudhakar ChaudharyPosted Feb 3, 2013, 11:32 AM
{
if (textBox1.Text == "abc" && textBox2.Text == "123")
{
this.Hide();
new Home().Show();
}
else
{
MessageBox.Show("Wrong Id or Password!!");
}
}
in second part of the question, do u want mdi child form ?