using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace JXC_MIS.UserTier.CommonForm
{
	/// <summary>
	/// frmLogIn 的摘要说明。
	/// </summary>
	public class frmLogIn : System.Windows.Forms.Form
	{
		private System.Windows.Forms.PictureBox pictureBox1;
		private System.Windows.Forms.ComboBox cbo_Operator;
		private System.Windows.Forms.TextBox txt_PassWord;
		private System.Windows.Forms.Button cmd_OK;
		private System.Windows.Forms.Button cmd_Cancel;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Label label3;
		private System.Windows.Forms.DateTimePicker dtp_LogInDate;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmLogIn));
			this.pictureBox1 = new System.Windows.Forms.PictureBox();
			this.cbo_Operator = new System.Windows.Forms.ComboBox();
			this.txt_PassWord = new System.Windows.Forms.TextBox();
			this.dtp_LogInDate = new System.Windows.Forms.DateTimePicker();
			this.cmd_OK = new System.Windows.Forms.Button();
			this.cmd_Cancel = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.label3 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// pictureBox1
			// 
			this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
			this.pictureBox1.Location = new System.Drawing.Point(6, 14);
			this.pictureBox1.Name = "pictureBox1";
			this.pictureBox1.Size = new System.Drawing.Size(78, 80);
			this.pictureBox1.TabIndex = 0;
			this.pictureBox1.TabStop = false;
			// 
			// cbo_Operator
			// 
			this.cbo_Operator.Items.AddRange(new object[] {
															  "刘金山",
															  "周方勇"});
			this.cbo_Operator.Location = new System.Drawing.Point(164, 40);
			this.cbo_Operator.Name = "cbo_Operator";
			this.cbo_Operator.Size = new System.Drawing.Size(108, 20);
			this.cbo_Operator.TabIndex = 1;
			this.cbo_Operator.Text = "刘金山";
			// 
			// txt_PassWord
			// 
			this.txt_PassWord.Location = new System.Drawing.Point(164, 64);
			this.txt_PassWord.Name = "txt_PassWord";
			this.txt_PassWord.PasswordChar = '*';
			this.txt_PassWord.Size = new System.Drawing.Size(108, 21);
			this.txt_PassWord.TabIndex = 2;
			this.txt_PassWord.Text = "";
			// 
			// dtp_LogInDate
			// 
			this.dtp_LogInDate.CustomFormat = "yyyy-MM-dd";
			this.dtp_LogInDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
			this.dtp_LogInDate.Location = new System.Drawing.Point(164, 12);
			this.dtp_LogInDate.Name = "dtp_LogInDate";
			this.dtp_LogInDate.Size = new System.Drawing.Size(108, 21);
			this.dtp_LogInDate.TabIndex = 3;
			this.dtp_LogInDate.Value = new System.DateTime(2004, 11, 1, 0, 0, 0, 0);
			// 
			// cmd_OK
			// 
			this.cmd_OK.Location = new System.Drawing.Point(146, 96);
			this.cmd_OK.Name = "cmd_OK";
			this.cmd_OK.Size = new System.Drawing.Size(56, 24);
			this.cmd_OK.TabIndex = 4;
			this.cmd_OK.Text = "确定(&O)";
			this.cmd_OK.Click += new System.EventHandler(this.cmd_OK_Click);
			// 
			// cmd_Cancel
			// 
			this.cmd_Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.cmd_Cancel.Location = new System.Drawing.Point(210, 96);
			this.cmd_Cancel.Name = "cmd_Cancel";
			this.cmd_Cancel.Size = new System.Drawing.Size(58, 24);
			this.cmd_Cancel.TabIndex = 5;
			this.cmd_Cancel.Text = "取消(&C)";
			this.cmd_Cancel.Click += new System.EventHandler(this.cmd_Cancel_Click);
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(106, 14);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(54, 17);
			this.label1.TabIndex = 6;
			this.label1.Text = "日  期：";
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.Location = new System.Drawing.Point(108, 42);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(54, 17);
			this.label2.TabIndex = 7;
			this.label2.Text = "操作员：";
			// 
			// label3
			// 
			this.label3.AutoSize = true;
			this.label3.Location = new System.Drawing.Point(108, 68);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(54, 17);
			this.label3.TabIndex = 8;
			this.label3.Text = "密  码：";
			// 
			// frmLogIn
			// 
			this.AcceptButton = this.cmd_OK;
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.CancelButton = this.cmd_Cancel;
			this.ClientSize = new System.Drawing.Size(290, 139);
			this.Controls.Add(this.label3);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.txt_PassWord);
			this.Controls.Add(this.cmd_Cancel);
			this.Controls.Add(this.cmd_OK);
			this.Controls.Add(this.dtp_LogInDate);
			this.Controls.Add(this.cbo_Operator);
			this.Controls.Add(this.pictureBox1);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
			this.Name = "frmLogIn";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "登录";
			this.Load += new System.EventHandler(this.frmLogIn_Load);
			this.ResumeLayout(false);

		}
		#endregion

		private void frmLogIn_Load(object sender, System.EventArgs e)
		{
		dtp_LogInDate.Text=DateTime.Today.ToString() ;
		}
	
		private void ReadIniFile()
		{
//			string sPath;
//			sPath = Application.StartupPath+"\\Config.ini";
//			ClsReadIniFile ini = new ClsReadIniFile(sPath);
//			GlobalData.DBServer = ini.IniReadValue ("Database","ServerName");
//			GlobalData.DBUserID  = ini.IniReadValue ("Database","UserID");
//			GlobalData.DBPassword  = ini.IniReadValue ("Database","PassWord");
//			GlobalData.DBName  = ini.IniReadValue ("Database","DataName");
			JXC_MIS.MyClass.GlobalData.Operator =cbo_Operator.Text ;
			JXC_MIS.MyClass.GlobalData.LoginDate=dtp_LogInDate.Text ; 


		}

		private void cmd_OK_Click(object sender, System.EventArgs e)
		{
			if (RightCheck(cbo_Operator.Text,txt_PassWord.Text)==false)
			{
				MessageBox.Show( "密码或用户名错误，再试一次！", "提示", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
                txt_PassWord.Focus(); 
			   return ;
			}
			ReadIniFile();
			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)
		{
			JXC_MIS.DataTier.ClsDataBaseAccess newADO=new JXC_MIS.DataTier.ClsDataBaseAccess();
			System.Data.DataSet dst = new System.Data.DataSet();
			dst= newADO.GetDataSet("Select * from I_Operator where fcOperator='"+p_Operator+"' And fcPassWord='"+p_Pws+"'");
			int rs=dst.Tables[0].Rows.Count ;
			if (rs>0)
			{
				return true;
			}
			else
			{
			    return false;
			}
		}





	}
}
