| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1412 人关注过本帖
标题:一个别人做好的c#程序,找不到登陆名了密码
取消只看楼主 加入收藏
koffans
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-5-2
收藏
 问题点数:0 回复次数:6 
一个别人做好的c#程序,找不到登陆名了密码

由于附件大小限制,我只把数据库文件传了上来,登陆框的代码(由于字节限制,窗体设计代码没贴):
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace SupermarketProject
{
/// <summary>
/// frmLogin
/// </summary>
public class frmLogin : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblUserName;
private System.Windows.Forms.Label lblPwd;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.TextBox txtUserId;
private System.Windows.Forms.TextBox txtPwd;
/// <summary>

/// </summary>
private System.ComponentModel.Container components = null;

private Menu mainmenu;
private ToolBar toolbar;
public static string loginId;
private bool reLogin;

public frmLogin(Menu mnu,ToolBar tool,bool reLog)
{
//
// Windows
//
InitializeComponent();

//
// TODO: InitializeComponent
mainmenu = mnu;
toolbar = tool;
reLogin = reLog;

}

/// <summary>
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}


//Starting Point
/*[STAThread]
static void Main()
{
Application.Run(new frmLogin());
}*/
private void btnCancel_Click(object sender, System.EventArgs e)
{
if(this.reLogin == true)
{
frmMainMenu.varReLogin = 0;
this.Close();
}
else
{
Application.Exit();
}

}

private void ClearData()
{
this.txtUserId.Text ="";
this.txtPwd.Text ="";
}

private void EnableDisableMenu(int prior)
{
// For System Admin Users
if(prior ==1 )
{
mainmenu.MenuItems[0].Enabled = true;
mainmenu.MenuItems[1].Enabled = false;
mainmenu.MenuItems[2].Enabled = false;
mainmenu.MenuItems[3].Enabled = false;
mainmenu.MenuItems[4].Enabled = false;

toolbar.Buttons[0].Enabled = true;
toolbar.Buttons[1].Enabled= false;
toolbar.Buttons[3].Enabled= false;
toolbar.Buttons[4].Enabled= false;
toolbar.Buttons[5].Enabled= false;
}
// For Stock Manager Users
else if (prior == 2)
{
mainmenu.MenuItems[0].Enabled = false;
mainmenu.MenuItems[1].Enabled = true;
mainmenu.MenuItems[2].Enabled = true;
mainmenu.MenuItems[3].Enabled = false;
mainmenu.MenuItems[4].Enabled = false;

toolbar.Buttons[0].Enabled = false;
toolbar.Buttons[1].Enabled= false;
toolbar.Buttons[3].Enabled= true;
toolbar.Buttons[4].Enabled= true;
toolbar.Buttons[5].Enabled= false;
}
// For Teller Users
else if(prior == 4)
{
mainmenu.MenuItems[0].Enabled = false;
mainmenu.MenuItems[1].Enabled = false;
mainmenu.MenuItems[2].Enabled = false;
mainmenu.MenuItems[3].Enabled = false;
mainmenu.MenuItems[4].Enabled = true;

toolbar.Buttons[0].Enabled = false;
toolbar.Buttons[1].Enabled= true;
toolbar.Buttons[3].Enabled= false;
toolbar.Buttons[4].Enabled= false;
toolbar.Buttons[5].Enabled= false;
}
//For Sales Admin Users
else if(prior == 8)
{
mainmenu.MenuItems[0].Enabled = false;
mainmenu.MenuItems[1].Enabled = false;
mainmenu.MenuItems[2].Enabled = false;
mainmenu.MenuItems[3].Enabled = true;
mainmenu.MenuItems[4].MenuItems[0].Enabled= false;
mainmenu.MenuItems[4].MenuItems[1].Enabled= true;

toolbar.Buttons[0].Enabled = false;
toolbar.Buttons[1].Enabled= false;
toolbar.Buttons[3].Enabled= false;
toolbar.Buttons[4].Enabled= false;
toolbar.Buttons[5].Enabled= true;
}
// For System Admin + Stock Manager
else if (prior == 3)
{
mainmenu.MenuItems[0].Enabled = true;
mainmenu.MenuItems[1].Enabled = true;
mainmenu.MenuItems[2].Enabled = true;
mainmenu.MenuItems[3].Enabled = false;
mainmenu.MenuItems[4].Enabled = false;

toolbar.Buttons[0].Enabled = true;
toolbar.Buttons[1].Enabled= false;
toolbar.Buttons[3].Enabled= true;
toolbar.Buttons[4].Enabled= true;
toolbar.Buttons[5].Enabled= false;
}
//For System Admin + Teller
else if(prior == 5)
{
mainmenu.MenuItems[0].Enabled = true;
mainmenu.MenuItems[1].Enabled = false;
mainmenu.MenuItems[2].Enabled = false;
mainmenu.MenuItems[3].Enabled = false;
mainmenu.MenuItems[4].Enabled = true;

toolbar.Buttons[0].Enabled = true;
toolbar.Buttons[1].Enabled= true;
toolbar.Buttons[3].Enabled= false;
toolbar.Buttons[4].Enabled= false;
toolbar.Buttons[5].Enabled= false;
}
//For Teller + Stock Manager
else if(prior == 6)
{
mainmenu.MenuItems[0].Enabled = false;
mainmenu.MenuItems[1].Enabled = true;
mainmenu.MenuItems[2].Enabled = true;
mainmenu.MenuItems[3].Enabled = false;
mainmenu.MenuItems[4].Enabled = true;

toolbar.Buttons[0].Enabled = false;
toolbar.Buttons[1].Enabled= true;
toolbar.Buttons[3].Enabled= true;
toolbar.Buttons[4].Enabled= true;
toolbar.Buttons[5].Enabled= false;
}
//For System Admin + Teller + Stock Manager
else if (prior == 7)
{
mainmenu.MenuItems[0].Enabled = true;
mainmenu.MenuItems[1].Enabled = true;
mainmenu.MenuItems[2].Enabled = true;
mainmenu.MenuItems[3].Enabled = false;
mainmenu.MenuItems[4].Enabled = true;

toolbar.Buttons[0].Enabled = true;
toolbar.Buttons[1].Enabled= true;
toolbar.Buttons[3].Enabled= true;
toolbar.Buttons[4].Enabled= true;
toolbar.Buttons[5].Enabled= false;
}
//For System Admin + Sales Admin
else if(prior == 9)
{
mainmenu.MenuItems[0].Enabled = true;
mainmenu.MenuItems[1].Enabled = false;
mainmenu.MenuItems[2].Enabled = false;
mainmenu.MenuItems[3].Enabled = true;
mainmenu.MenuItems[4].MenuItems[0].Enabled = false;
mainmenu.MenuItems[4].MenuItems[1].Enabled = true;

toolbar.Buttons[0].Enabled = true;
toolbar.Buttons[1].Enabled = false;
toolbar.Buttons[3].Enabled = false;
toolbar.Buttons[4].Enabled = false;
toolbar.Buttons[5].Enabled = true;
}
//For Stock Manager + Sales Admin
else if(prior == 10)
{
mainmenu.MenuItems[0].Enabled = false;
mainmenu.MenuItems[1].Enabled = true;
mainmenu.MenuItems[2].Enabled = true;
mainmenu.MenuItems[3].Enabled = true;
mainmenu.MenuItems[4].MenuItems[0].Enabled = false;
mainmenu.MenuItems[4].MenuItems[1].Enabled = true;

toolbar.Buttons[0].Enabled = false;
toolbar.Buttons[1].Enabled= false;
toolbar.Buttons[3].Enabled= true;
toolbar.Buttons[4].Enabled= true;
toolbar.Buttons[5].Enabled= true;
}
//For System Admin + Stock Manager + Sales Admin
else if(prior == 11)
{
mainmenu.MenuItems[0].Enabled = true;
mainmenu.MenuItems[1].Enabled = true;
mainmenu.MenuItems[2].Enabled = true;
mainmenu.MenuItems[3].Enabled = true;
mainmenu.MenuItems[4].MenuItems[0].Enabled = false;
mainmenu.MenuItems[4].MenuItems[1].Enabled = true;

toolbar.Buttons[0].Enabled = true;
toolbar.Buttons[1].Enabled= false;
toolbar.Buttons[3].Enabled= true;
toolbar.Buttons[4].Enabled= true;
toolbar.Buttons[5].Enabled= true;
}
//For Teller + Sales Admin
else if(prior == 12)
{
mainmenu.MenuItems[0].Enabled = false;
mainmenu.MenuItems[1].Enabled = false;
mainmenu.MenuItems[2].Enabled = false;
mainmenu.MenuItems[3].Enabled = true;
mainmenu.MenuItems[4].Enabled = true;

toolbar.Buttons[0].Enabled = false;
toolbar.Buttons[1].Enabled= true;
toolbar.Buttons[3].Enabled= false;
toolbar.Buttons[4].Enabled= false;
toolbar.Buttons[5].Enabled= true;
}
//For a user with all rights
else if(prior == 15)
{
mainmenu.MenuItems[0].Enabled = true;
mainmenu.MenuItems[1].Enabled = true;
mainmenu.MenuItems[2].Enabled = true;
mainmenu.MenuItems[3].Enabled = true;
mainmenu.MenuItems[4].Enabled = true;

toolbar.Buttons[0].Enabled = true;
toolbar.Buttons[1].Enabled= true;
toolbar.Buttons[3].Enabled= true;
toolbar.Buttons[4].Enabled= true;
toolbar.Buttons[5].Enabled= true;
}

}

private void btnOK_Click(object sender, System.EventArgs e)
{
this.checkLogin();
}

private void frmLogin_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
frmMainMenu.varReLogin = 0;
}

private void txtPwd_Leave(object sender, System.EventArgs e)
{
this.btnOK.Focus();
}

private void txtPwd_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar ==13)
{
this.btnOK.Focus();
this.checkLogin();
}

}

private void btnOK_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if (e.KeyChar ==13)
{
this.checkLogin();
}
}

private void checkLogin()
{
bool status;
if(this.txtUserId.Text !="")
{
UserManagement usrMgmt = new UserManagement();
status = usrMgmt.Login(this.txtUserId.Text,this.txtPwd.Text);

if (status == true)
{
if(loginId != this.txtUserId.Text)
{
frmSplash splash = new frmSplash(this.txtUserId.Text);
loginId = this.txtUserId.Text;
frmMainMenu.varReLogin = 0;
this.Close();
Application.DoEvents();
splash.ShowDialog();
splash.Refresh();
Application.DoEvents();

MainForm mFrm = new MainForm(this.txtUserId.Text);
int prior = mFrm.DisplayMainMenuByPriority();
this.EnableDisableMenu(prior);
this.Close();
}
else
{
MessageBox.Show("您已登录");
this.Close();
}
}
else
{
MessageBox.Show("拒绝访问");
this.ClearData();
this.txtUserId.Focus();
}
}
else
{
this.txtUserId.Focus();
MessageBox.Show("输入用户名");

}
}

private void frmLogin_Load(object sender, System.EventArgs e)
{

}


}
}

搜索更多相关主题的帖子: using System 密码 数据库 Forms 
2007-10-11 18:20
koffans
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-5-2
收藏
得分:0 

怎么没看见我的附件,再传一下

M8ZQOSV4.rar (36.57 KB) 一个别人做好的c#程序,找不到登陆名了密码



2007-10-11 18:26
koffans
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-5-2
收藏
得分:0 
我还是看不出来,数据库里到是有个Id和Passwd字段,可里面的数据我试了个遍,一个也进不去.

2007-10-11 18:45
koffans
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-5-2
收藏
得分:0 
本来是想直接问他本人的,可他说:"进不去是吧,那是你代码没看懂,接着看去." 郁闷.我想这个登陆名和密码应该是在数据库里,可就是不知道是哪个字段.

2007-10-11 23:42
koffans
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-5-2
收藏
得分:0 

它的程序入口是主窗口而不是登陆框,我用逐语句调试到验证用户名和密码时有一个SQL语句指向数据库的两个字段,可我用那里的数据进不去.


2007-10-13 15:06
koffans
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-5-2
收藏
得分:0 

是不是这个?
public class UserManagement
{
public UserManagement();

public void AddEmployee(stEmployee stEmp);
public DataTable FetchEmployeeDetails(string[] searchValue);
public bool Login(string usrid, string password);
public void ModifyEmployee(stEmployee stEmp);
public void ModifyPassWord(string newPwd, string UsrId);
public void SendMail(string mail, string id, string pwd);
}


2007-10-15 16:58
koffans
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-5-2
收藏
得分:0 
额滴神.

2007-10-15 17:22
快速回复:一个别人做好的c#程序,找不到登陆名了密码
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039049 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved