标题:一个别人做好的c#程序,找不到登陆名了密码
只看楼主
koffans
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-5-2
 问题点数:0 回复次数:14 
一个别人做好的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
crazymk
Rank: 1
等 级:新手上路
威 望:1
帖 子:343
专家分:0
注 册:2007-8-30
得分:0 
順藤摸瓜,去這個方法裡找
status = usrMgmt.Login(this.txtUserId.Text,this.txtPwd.Text);

すばらしいコードを書き出すのは楽しい事です
2007-10-11 18:24
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
shizhusz110
Rank: 1
等 级:新手上路
帖 子:307
专家分:0
注 册:2006-12-21
得分:0 
把你的代码发上来塞!
2007-10-11 21:03
天使不哭
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:677
专家分:22
注 册:2006-7-9
得分:0 

经过加密后的用户名和密码吧 ~~


C#Winform技术群:25380362
博客:http:///boyliupan/
2007-10-11 21:22
pacocai
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:1583
专家分:0
注 册:2007-3-12
得分:0 

很大一种可能就是数据库里的数据是加密的。这样就要看看别人怎样读数据库里的东西了。不过讨厌直接这样看别人的代码,累啊……还不如我自己写。


浮生若梦天边月,醉死如酒水中星。红楼一梦千人叹,岂让万夫空做贱。博客:http://hi.baidu.com/rxvip
2007-10-11 23:20
koffans
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-5-2
得分:0 
本来是想直接问他本人的,可他说:"进不去是吧,那是你代码没看懂,接着看去." 郁闷.我想这个登陆名和密码应该是在数据库里,可就是不知道是哪个字段.

2007-10-11 23:42
virusswb
Rank: 1
等 级:新手上路
威 望:1
帖 子:342
专家分:0
注 册:2005-8-6
得分:0 
UserManagement usrMgmt = new UserManagement();
status = usrMgmt.Login(this.txtUserId.Text,this.txtPwd.Text);
这两句是关键吧,你要看看UserManagement 这个类的定义,里面的Login方法有名堂啊,你看啊,他们接受的两个参数,用户名和密码,肯定在里面有验证啊,不是SQL语句就是procedure了

jorden008@
2007-10-11 23:53
pacocai
Rank: 3Rank: 3
等 级:新手上路
威 望:6
帖 子:1583
专家分:0
注 册:2007-3-12
得分:0 
呵呵,其实你可以试一下用单步调试的方法看看,很快就能知道是那几个地方处理登陆密码了。把那几句相关的东西提出来再分析就能知道登录的密码和帐号了。

浮生若梦天边月,醉死如酒水中星。红楼一梦千人叹,岂让万夫空做贱。博客:http://hi.baidu.com/rxvip
2007-10-12 14:19



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-176828-1-1.html




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

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