Login Pada C#



using System;
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.SqlClient;
namespace Makanan
{
public partial class frmlogin : Form
{
SqlConnection con = null;
SqlCommand cmd = null;
public static string kasir = "";
public frmlogin()
{
InitializeComponent();
}
private void cmdcancel_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void cmdlogin_Click(object sender, EventArgs e)
{
if (con.State == ConnectionState.Closed)
con.Open();
string ssql = "select * from tbloperator where kasir ='" + txtuser.Text + "' and pass='"+txtpass.Text+"'";
cmd = new SqlCommand(ssql, con);
SqlDataReader reader = cmd.ExecuteReader();
if (reader.HasRows)
{
kasir = txtuser.Text;
frmutama menu=new frmutama(); 
menu.Show();
menu.Focus();
Hide();
}
else
{
MessageBox.Show("User dan Password tidak ditemukan");
}
reader.Close();
con.Close();
}
private void frmlogin_Load(object sender, EventArgs e)
{
string connstring = Properties.Settings.Default.restoran;
con = new SqlConnection(connstring);
con.Open();
}
}
}


sumber : http://ketutmardika.blogspot.com/

Post a Comment