?? frmlogin.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using CallCenter.BusinessLayer;
using CallCenter.DALFactory;
using CallCenter.IDAL;
using CallCenter.Modules;
using CallCenter.OracleDAL;
using System.Data;
using System.IO;
using System.Xml;
using CallCenter.BusinessInterfaces.MainForms;
namespace CallCenter.BusinessInterfaces.MainForms
{
/// <summary>
/// frmLogIn 的摘要說明。
/// </summary>
public class frmLogIn : BaseFormGradient
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label lblSplit;
private int i=0;
private DevExpress.XtraEditors.PanelControl panelControl1;
private DevExpress.XtraEditors.DateEdit dtp_LogInDate;
private DevExpress.XtraEditors.ComboBoxEdit cbo_Operator;
private DevExpress.XtraEditors.TextEdit txt_PassWord;
private DevExpress.XtraEditors.SimpleButton cmd_OK;
private DevExpress.XtraEditors.SimpleButton cmd_Cancel;
private DevExpress.LookAndFeel.DefaultLookAndFeel defaultLookAndFeel1;
private System.ComponentModel.IContainer components;
public frmLogIn()
{
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmLogIn));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.lblSplit = new System.Windows.Forms.Label();
this.panelControl1 = new DevExpress.XtraEditors.PanelControl();
this.cmd_Cancel = new DevExpress.XtraEditors.SimpleButton();
this.cmd_OK = new DevExpress.XtraEditors.SimpleButton();
this.txt_PassWord = new DevExpress.XtraEditors.TextEdit();
this.cbo_Operator = new DevExpress.XtraEditors.ComboBoxEdit();
this.dtp_LogInDate = new DevExpress.XtraEditors.DateEdit();
this.defaultLookAndFeel1 = new DevExpress.LookAndFeel.DefaultLookAndFeel(this.components);
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit();
this.panelControl1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.txt_PassWord.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cbo_Operator.Properties)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dtp_LogInDate.Properties)).BeginInit();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(7, 15);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(81, 79);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Location = new System.Drawing.Point(130, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(54, 17);
this.label1.TabIndex = 6;
this.label1.Text = "日 期:";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Location = new System.Drawing.Point(130, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(54, 17);
this.label2.TabIndex = 7;
this.label2.Text = "操作員:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label3
//
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.Location = new System.Drawing.Point(130, 70);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(54, 17);
this.label3.TabIndex = 8;
this.label3.Text = "密 碼:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// lblSplit
//
this.lblSplit.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.lblSplit.ForeColor = System.Drawing.SystemColors.ControlLightLight;
this.lblSplit.Location = new System.Drawing.Point(-77, 134);
this.lblSplit.Name = "lblSplit";
this.lblSplit.Size = new System.Drawing.Size(523, 3);
this.lblSplit.TabIndex = 9;
this.lblSplit.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panelControl1
//
this.panelControl1.Appearance.BackColor = System.Drawing.Color.Transparent;
this.panelControl1.Appearance.Options.UseBackColor = true;
this.panelControl1.Controls.Add(this.cmd_Cancel);
this.panelControl1.Controls.Add(this.cmd_OK);
this.panelControl1.Controls.Add(this.txt_PassWord);
this.panelControl1.Controls.Add(this.cbo_Operator);
this.panelControl1.Controls.Add(this.dtp_LogInDate);
this.panelControl1.Controls.Add(this.lblSplit);
this.panelControl1.Controls.Add(this.label3);
this.panelControl1.Controls.Add(this.label2);
this.panelControl1.Controls.Add(this.label1);
this.panelControl1.Controls.Add(this.pictureBox1);
this.panelControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panelControl1.Location = new System.Drawing.Point(0, 0);
this.panelControl1.Name = "panelControl1";
this.panelControl1.Size = new System.Drawing.Size(350, 144);
this.panelControl1.TabIndex = 10;
this.panelControl1.Text = "panelControl1";
//
// cmd_Cancel
//
this.cmd_Cancel.Location = new System.Drawing.Point(236, 98);
this.cmd_Cancel.Name = "cmd_Cancel";
this.cmd_Cancel.TabIndex = 14;
this.cmd_Cancel.Text = "取消(&C)";
this.cmd_Cancel.Click += new System.EventHandler(this.cmd_Cancel_Click);
//
// cmd_OK
//
this.cmd_OK.Location = new System.Drawing.Point(132, 98);
this.cmd_OK.Name = "cmd_OK";
this.cmd_OK.TabIndex = 13;
this.cmd_OK.Text = "確定(&O)";
this.cmd_OK.Click += new System.EventHandler(this.cmd_OK_Click);
//
// txt_PassWord
//
this.txt_PassWord.EditValue = "";
this.txt_PassWord.Location = new System.Drawing.Point(196, 68);
this.txt_PassWord.Name = "txt_PassWord";
//
// txt_PassWord.Properties
//
this.txt_PassWord.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.txt_PassWord.Properties.PasswordChar = '*';
this.txt_PassWord.Size = new System.Drawing.Size(136, 21);
this.txt_PassWord.TabIndex = 12;
//
// cbo_Operator
//
this.cbo_Operator.EditValue = "";
this.cbo_Operator.Location = new System.Drawing.Point(196, 44);
this.cbo_Operator.Name = "cbo_Operator";
//
// cbo_Operator.Properties
//
this.cbo_Operator.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.cbo_Operator.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.cbo_Operator.Size = new System.Drawing.Size(136, 21);
this.cbo_Operator.TabIndex = 11;
//
// dtp_LogInDate
//
this.dtp_LogInDate.EditValue = new System.DateTime(2006, 6, 29, 0, 0, 0, 0);
this.dtp_LogInDate.Location = new System.Drawing.Point(196, 20);
this.dtp_LogInDate.Name = "dtp_LogInDate";
//
// dtp_LogInDate.Properties
//
this.dtp_LogInDate.Properties.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.Default;
this.dtp_LogInDate.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] {
new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)});
this.dtp_LogInDate.Size = new System.Drawing.Size(136, 21);
this.dtp_LogInDate.TabIndex = 10;
//
// defaultLookAndFeel1
//
this.defaultLookAndFeel1.LookAndFeel.SkinName = "Liquid Sky";
this.defaultLookAndFeel1.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
this.defaultLookAndFeel1.LookAndFeel.UseWindowsXPTheme = false;
//
// frmLogIn
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.SystemColors.Menu;
this.ClientSize = new System.Drawing.Size(350, 144);
this.Color1 = System.Drawing.Color.FromArgb(((System.Byte)(214)), ((System.Byte)(223)), ((System.Byte)(247)));
this.Color2 = System.Drawing.Color.GhostWhite;
this.ControlBox = false;
this.Controls.Add(this.panelControl1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "frmLogIn";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "登錄";
this.TopMost = true;
this.Load += new System.EventHandler(this.frmLogIn_Load);
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
this.panelControl1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.txt_PassWord.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cbo_Operator.Properties)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dtp_LogInDate.Properties)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void setSkin()
{
string username="";
string loginskin="";
XmlDocument xmlDoc=new XmlDocument();
xmlDoc.Load("system.xml");
XmlNode xn=xmlDoc.SelectSingleNode("system");
XmlNodeList xnl=xn.ChildNodes;
foreach(XmlNode xnf in xnl)
{
XmlElement xe=(XmlElement)xnf;
loginskin=xe.GetAttribute("login");
this.defaultLookAndFeel1.LookAndFeel.SkinName = loginskin;
this.defaultLookAndFeel1.LookAndFeel.Style=DevExpress.LookAndFeel.LookAndFeelStyle.Skin;
username=xe.GetAttribute("name");//顯示屬性值
if(username==ShareClass.Operator)
{
XmlNodeList xnf1=xe.ChildNodes;
foreach(XmlNode xn2 in xnf1)
{
// string p_Item=xn2.InnerText;//顯示子節點文本
// MessageBox.Show(p_Item);
if(xn2.Name=="skin")
{
ShareClass.skin=xn2.InnerText;
}
else if(xn2.Name=="rcolor")
{
ShareClass.Rcolor=Convert.ToInt32(xn2.InnerText);
}
else if(xn2.Name=="gcolor")
{
ShareClass.Gcolor=Convert.ToInt32(xn2.InnerText);
}
else if(xn2.Name=="bcolor")
{
ShareClass.Bcolor=Convert.ToInt32(xn2.InnerText);
}
}
}
}
}
private void frmLogIn_Load(object sender, System.EventArgs e)
{
setSkin();
dtp_LogInDate.Text=DateTime.Now.ToString() ;
this.cbo_Operator.Focus();
}
private void ReadIniFile()
{
SysoperatorBLL sysbll=new SysoperatorBLL();
SysoperatorInfo sysinfo=new SysoperatorInfo();
sysinfo=sysbll.getSysoperatorByLname(cbo_Operator.Text );
ShareClass.sysinfo=sysinfo;
ShareClass.Operator =cbo_Operator.Text;
ShareClass.OperatorChinese=sysinfo.oname;
ShareClass.LoginDate=dtp_LogInDate.Text ;
}
private void cmd_OK_Click(object sender, System.EventArgs e)
{
if (RightCheck(cbo_Operator.Text,txt_PassWord.Text)==false)
{
i++;
if(i==3)
{
DialogResult=DialogResult.Cancel;
// ShareClass.loginfail="exit";
}
// else
// {
// ShareClass.loginfail="fail";
//
// txt_PassWord.Focus();
// return ;
// }
}
else
{
ReadIniFile();
setSkin();
DialogResult=DialogResult.OK;
this.Close();
}
}
private void cmd_Cancel_Click(object sender, System.EventArgs e)
{
this.Close();
Application.Exit();
}
/// <summary>
/// 操作員登錄驗證
/// </summary>
/// <param name="p_Operator"></param>
/// <param name="p_Pws"></param>
/// <returns></returns>
private bool RightCheck(string p_Operator,string p_Pws)
{
try
{
SysoperatorBLL sysbll=new SysoperatorBLL();
SysoperatorInfo sysinfo=new SysoperatorInfo();
sysinfo=sysbll.login(p_Operator,p_Pws);
if(sysinfo.lname!=cbo_Operator.Text || cbo_Operator.Text=="")
{
MessageBox.Show("用戶名輸入錯誤,請重新輸入!","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning);
cbo_Operator.Focus();
return false;
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
return true;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -