登录界面源代码!

一个简单漂亮的登录界面源代码!

在这里插入图片描述
在这里插入图片描述

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="2"
    android:gravity="center"
    android:orientation="vertical">

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/yhdl"
        android:textColor="#ff0000"
        android:textSize="50dp" />
</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
    <LinearLayout
        android:layout_width="130dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:textSize="25dp"
            android:text="@string/yhm"
            android:paddingTop="15dp"
            />
        <EditText
            android:layout_width="match_parent"
            android:layout_height="20dp" />
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:gravity="right"
            android:textSize="25dp"
            android:text="@string/mima"
            android:paddingTop="15dp"
            />
    </LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="107dp"
    android:orientation="vertical"
    android:gravity="left">

<EditText
    android:id="@+id/editText7"
    android:layout_width="200dp"
    android:layout_height="5dp"
    android:layout_weight="1"
    android:ems="10"
    android:hint="@string/text"
    android:background="#ffffff"
    android:inputType="textPersonName" />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="20dp" />
    <EditText
        android:id="@+id/editText8"
        android:layout_width="200dp"
        android:layout_height="5dp"
        android:layout_weight="1"
        android:ems="10"
        android:hint="@string/password"
        android:background="#ffffff"
        android:inputType="textPassword"
        />
</LinearLayout>
</LinearLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="20dp">

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="3"
    android:orientation="horizontal">



    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_weight="2"

        android:gravity="center"
        android:orientation="horizontal">

        <Button
            android:id="@+id/button11"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"

            android:text="登录"
            android:textSize="30dp"/>
        <TextView
            android:layout_width="20dp"
            android:layout_height="match_parent"

            />

        <Button
            android:id="@+id/button12"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="top"
            android:text="取消"
            android:textSize="30dp"/>
    </LinearLayout>


</LinearLayout>
C#编程登陆界面代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Data.OleDb; namespace 人事管理系统 { public partial class FormLogin : Form { public FormLogin() { InitializeComponent(); } private void FormLogin_Load(object sender, EventArgs e) { } public void buttonLogin_Click_1(object sender, EventArgs e) { try { if (textBoxName .Text =="") { MessageBox.Show ("用户名不能为空!","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Warning ); } else { if (textBoxPassword .Text =="") { MessageBox.Show("密码不能为空!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } else { String connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\人事数据库.mdb"; OleDbConnection conn = new OleDbConnection(connStr); //String sql = "select count(*) from 用户密码表 where username='" + textBoxName.Text + "' and password='" + textBoxPassword.Text + "'"; conn.Open(); string sql = "select count(*) from 用户密码表 where username=@name and password=@pass"; OleDbCommand cmd = new OleDbCommand(sql ,conn ); cmd.Parameters.Add(new OleDbParameter ("@name",OleDbType .Char )); cmd.Parameters["@name"].Value = textBoxName.Text; cmd.Parameters.Add(new OleDbParameter("@pass", OleDbType.Char)); cmd.Parameters["@pass"].Value = textBoxPassword.Text; //OleDbDataAdapter da = new OleDbDataAdapter(sql, conn); //DataTable dt = new DataTable(); //da.Fill(dt); //int i = dt.Rows.Count; int i =(int )cmd.ExecuteScalar (); conn.Close(); if (i > 0) { FormMain fm = new FormMain(); fm.admintime = DateTime.Now.ToShortDateString(); fm.adminname = textBoxName.Text; fm.Show(); this.Hide (); } else { MessageBox.Show("用户名或密码错误!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Error ); { textBoxName.Text = ""; textBoxPassword.Text = ""; textBoxName.Focus(); } } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定要退出本系统吗?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK) { Application.Exit(); } } private void textBoxName_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { textBoxPassword.Focus(); e.Handled = true; } } private void textBoxPassword_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 13) { buttonLogin.Focus(); e.Handled = true; } } private void linkLabeladd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Form添加 fpty = new Form添加(); fpty.Show(); } private void linkLabelpass_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { Formpasswordmodify fpmd = new Formpasswordmodify(); fpmd.Show(); } } }
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值