示例#1
0
        private void LogInbtn_Click(object sender, EventArgs e)
        {
            if (MainForm.CurrentUser.UserName != "")
            {
                MainForm.StatusMSG = MainForm.CurrentUser.FullName + " must log out before continue.";
                MainForm.SEL.LBEvents.Items.Add(MainForm.CurrentUser.FullName + " must log out before continue.  " + DateTime.Now.ToString());
                this.Close();
                return;
            }
            Control_User USer = Control_User.Get(UserNameTXT.Text, PasswordTXT.Text);

            if (USer == null)
            {
                MainForm.SEL.LBEvents.Items.Add(UserNameTXT.Text + " failed while log in.  " + DateTime.Now.ToString());
                MainForm.StatusMSG  = UserNameTXT.Text + " failed while log in.  ";
                Resultlbl.Text      = "Failed";
                Resultlbl.ForeColor = Color.Red;
            }
            else
            {
                MainForm.SEL.LBEvents.Items.Add(USer.FullName + " has just sign in.  " + DateTime.Now.ToString());
                MainForm.StatusMSG                = USer.FullName + " has just sign in.  ";
                Resultlbl.Text                    = "Success";
                Resultlbl.ForeColor               = Color.LightGreen;
                MainForm.CurrentUser.UserName     = USer.UserName;
                MainForm.CurrentUser.Password     = USer.Password;
                MainForm.CurrentUser.FullName     = USer.FullName;
                pictureBox2.BackgroundImageLayout = ImageLayout.Zoom;
                pictureBox2.BackgroundImage       = USer.UserImage;
                timer1.Start();
            }
        }
示例#2
0
 private void LoadUsers()
 {
     DGVUsers.Rows.Clear();
     foreach (Control_User CU in Control_User.GetUsers())
     {
         DGVUsers.Rows.Add(CU.UserName, CU.Password, CU.FullName, CU.UserImage);
     }
 }
示例#3
0
 private void logOutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     foreach (Form F in this.MdiChildren)
     {
         F.Close();
     }
     MainForm.SEL.LBEvents.Items.Add(CurrentUser.FullName + " has just sign out.  " + DateTime.Now.ToString());
     MainForm.StatusMSG = CurrentUser.FullName + " has just sign out.  ";
     CurrentUser        = new Control_User();
 }
示例#4
0
 private void Removebtn_Click(object sender, EventArgs e)
 {
     if (RemovePasswordTXT.Text == "")
     {
         errorProvider1.SetError(RemovePasswordTXT, "Please Enter Password.");
         return;
     }
     if (Control_User.Delete(UserName.Text, RemovePasswordTXT.Text))
     {
         ConfirmRemovePB.Image = imageList1.Images[0];
         LoadUsers();
     }
     else
     {
         ConfirmRemovePB.Image = imageList1.Images[1];
     }
 }
示例#5
0
        public static Control_User Get(string UserName, string Password)
        {
            Control_User  result = null;
            SqlDataReader rdr    = null;

            try
            {
                DBConnection.Conn.Open();
                SqlCommand   cmd           = new SqlCommand("select * from UsersInfo where UserName=@UserName and Password=@Password", DBConnection.Conn);
                SqlParameter UserNameParam = new SqlParameter("@UserName", UserName);
                SqlParameter PasswordParam = new SqlParameter("@Password", Password);
                cmd.Parameters.Add(UserNameParam);
                cmd.Parameters.Add(PasswordParam);
                rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    result          = new Control_User();
                    result.UserName = rdr["UserName"].ToString();
                    result.Password = rdr["Password"].ToString();
                    result.FullName = rdr["Fullname"].ToString();
                    rdr.Close();
                    try
                    {
                        result.UserImage = Image.FromStream(RetrieveImage(result.UserName));
                        break;
                    }
                    catch (Exception ex)
                    { }
                }
            }
            catch (Exception ex)
            {
                MainForm.SEL.LBEvents.Items.Add("Couldn't get user's info. (" + ex.Message + ")  " + DateTime.Now.ToString());
                MainForm.StatusMSG = "Couldn't get user's info. (" + ex.Message + ")";
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
                DBConnection.Conn.Close();
            }
            return(result);
        }
示例#6
0
        public static bool Add(Control_User Usr)
        {
            bool result = false;

            try
            {
                DBConnection.Conn.Open();
                SqlCommand   cmd           = new SqlCommand("insert into UsersInfo values(@UserName,@Password,@FullName,@UserImage)", DBConnection.Conn);
                SqlParameter UserNameParam = new SqlParameter("@UserName", Usr.UserName);
                SqlParameter PasswordParam = new SqlParameter("@Password", Usr.Password);
                SqlParameter FullNameParam = new SqlParameter("@FullName", Usr.FullName);
                SqlParameter ImageParam    = new SqlParameter();
                ImageParam.ParameterName = "@UserImage";
                if (Usr.ImageFile != "")
                {
                    Bitmap       data   = new Bitmap(Usr.ImageFile);
                    MemoryStream stream = new MemoryStream();
                    data.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    ImageParam.Value = stream.ToArray();
                }
                else
                {
                    ImageParam.Value = new byte[2];
                }
                cmd.Parameters.Add(UserNameParam);
                cmd.Parameters.Add(PasswordParam);
                cmd.Parameters.Add(FullNameParam);
                cmd.Parameters.Add(ImageParam);
                cmd.ExecuteNonQuery();
                result = true;
                MainForm.SEL.LBEvents.Items.Add(Usr.FullName + " is now in the user list.  " + DateTime.Now.ToString());
                MainForm.StatusMSG = Usr.FullName + " is now in the user list.  ";
            }
            catch (Exception ex)
            {
                MainForm.SEL.LBEvents.Items.Add("Couldn't add user. (" + ex.Message + ")  " + DateTime.Now.ToString());
                MainForm.StatusMSG = "Couldn't add user. (" + ex.Message + ")";
            }
            finally
            {
                DBConnection.Conn.Close();
            }
            return(result);
        }
示例#7
0
        public static List <Control_User> GetUsers()
        {
            List <Control_User> result = null;
            SqlDataReader       rdr    = null;

            try
            {
                DBConnection.Conn.Open();
                SqlCommand cmd = new SqlCommand("select * from UsersInfo", DBConnection.Conn);
                rdr    = cmd.ExecuteReader();
                result = new List <Control_User>();
                while (rdr.Read())
                {
                    Control_User CU = new Control_User();
                    CU.UserName = rdr["UserName"].ToString();
                    CU.Password = rdr["Password"].ToString();
                    CU.FullName = rdr["FullName"].ToString();
                    result.Add(CU);
                }
                rdr.Close();
                for (int i = 0; i < result.Count; i++)
                {
                    result[i].UserImage = Image.FromStream(RetrieveImage(result[i].UserName));
                }
            }
            catch (Exception ex)
            {
                MainForm.SEL.LBEvents.Items.Add("Couldn't get users info. (" + ex.Message + ")  " + DateTime.Now.ToString());
                MainForm.StatusMSG = "Couldn't get users info. (" + ex.Message + ")";
            }
            finally
            {
                if (rdr != null)
                {
                    rdr.Close();
                }
                DBConnection.Conn.Close();
            }
            return(result);
        }
示例#8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (PasswordTXT.Text == "")
            {
                errorProvider1.SetError(PasswordTXT, "Please Enter Password.");
                return;
            }
            if (PasswordTXT.Text != ConfirmPasswordTXT.Text)
            {
                errorProvider1.SetError(PasswordTXT, "Please Confirm Password.");
                return;
            }

            Control_User CU = new Control_User();

            CU.UserName = UserNameTXT.Text;
            CU.Password = PasswordTXT.Text;
            CU.FullName = AgentNameTXT.Text;
            if (PictureBrowser.FileName != "")
            {
                CU.UserImage = Image.FromFile(PictureBrowser.FileName);
            }
            CU.ImageFile = PictureBrowser.FileName;

            if (Control_User.Add(CU))
            {
                ConfirmPictureBox.Image = imageList1.Images[0];
                UserNameTXT.Text        = "";
                PasswordTXT.Text        = "";
                AgentNameTXT.Text       = "";
                ConfirmPasswordTXT.Text = "";
                LoadUsers();
            }
            else
            {
                ConfirmPictureBox.Image = imageList1.Images[1];
            }
        }
示例#9
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     TimerStatusBar.Start();
     SEL = new System_Event_Log();
     SEL.Show();
     SEL.Visible = false;
     SEL.LBEvents.Items.Add("System Event log initilized.  " + DateTime.Now.ToString());
     CheckRegistry();
     //if (DBConnection.checkInfo())
     //    Application.Exit();
     //else
     //    DBConnection.InitilizeConnection();
     CurrentUser  = new Control_User();
     StatusThread = new Thread(new ThreadStart(StatusCheck));
     StatusThread.Start();
     CI                 = new Console_Interface();
     CI.Dock            = DockStyle.Top;
     CI.VisibleChanged += new EventHandler(OnConsole_Visibility_Changed);
     CI.MdiParent       = this;
     CI.Show();
     CI.Visible             = false;
     Core_unit              = new Core(Application.StartupPath);
     Core_unit.Main.TExtRef = CI.RTBConsole;
     CI.Core_Unit_Ref       = Core_unit;
     Core_unit.CompileCode();
     Communicator = new CommunicationManager();
     Ts           = new Transport_Status();
     Ts.Show();
     Ts.Visible = false;
     Core_unit.LoadVariablesData();
     InferenceThread = new Thread(new ThreadStart(RunInference));
     //InferenceThread.Start();//must be started and aborted from the channel controller
     CommunicationManager.CurrentHex = "13";
     R = new Random();
     InvisiblePreview = new test();
 }