private void logOffToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure to LogOff?", "Log-Off", MessageBoxButtons.YesNo) == DialogResult.Yes) { this.Dispose(true); Home h = new Home(); h.Show(); } else { //e.Cancel = false; } }
private void logOffToolStripMenuItem_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure to LogOff?", "Log-Off", MessageBoxButtons.YesNo) == DialogResult.Yes) { this.Dispose(true); Home h = new Home(); h.Show(); } else { //e.Cancel = false; } }
private void button1_Click(object sender, EventArgs e) { home.Show(); this.Close(); }
private void btn_login_Click(object sender, EventArgs e) { lblerror.Visible = false; pictureBox1.Visible = true; btn_login.Enabled = false; if (txtname.Text.ToString() != "" && txtemail.Text.ToString() != "") { UName = txtname.Text.ToString(); Email = txtemail.Text.ToString(); //db.UserDatas.Add(new UserData //{ // Name = txtname.Text, // Email = txtemail.Text //}); //db.SaveChanges(); string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)); string emailsPath = path + @"\emails.xlsx"; try { Excel.Application xlApp = new Excel.Application(); object misValue = System.Reflection.Missing.Value; Excel.Workbook xlWorkBook; //= xlApp.Workbooks.Open(emailsPath,misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue); Excel.Worksheet xlWorkSheet; xlApp.DisplayAlerts = false; xlWorkBook = xlApp.Workbooks.Add(misValue); if (!File.Exists(emailsPath)) { xlWorkBook = xlApp.Workbooks.Add(); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); xlWorkSheet.Cells[1, 1] = "Name"; xlWorkSheet.Cells[1, 2] = "Email"; } else { xlWorkBook = xlApp.Workbooks.Open(emailsPath, misValue, false, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); } //xlWorkBook = xlApp.Workbooks.Open(emailsPath, misValue, false, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue); //xlWorkSheet.Cells[1, 1] = "Names"; //xlWorkSheet.Cells[1, 2] = "Email ID"; Excel.Range last = xlWorkSheet.Cells.SpecialCells(Excel.XlCellType.xlCellTypeLastCell, Type.Missing); Excel.Range range = xlWorkSheet.get_Range("A1", last); int lastUsedRow = last.Row; int lastUsedColumn = last.Column; xlWorkSheet.Cells[lastUsedRow + 1, 1] = txtname.Text.ToString(); xlWorkSheet.Cells[lastUsedRow + 1, 2] = txtemail.Text.ToString(); xlWorkBook.SaveAs(emailsPath, misValue, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlNoChange, misValue, misValue, misValue, misValue, misValue); //GetExcelProcess(xlApp); xlWorkBook.Close(true, emailsPath, misValue); System.Diagnostics.Process[] process = System.Diagnostics.Process.GetProcessesByName("Excel"); foreach (System.Diagnostics.Process p in process) { if (!string.IsNullOrEmpty(p.ProcessName)) { try { p.Kill(); } catch { } } } //xlWorkBook.Close(0); //Marshal.ReleaseComObject(xlWorkSheet); //Marshal.ReleaseComObject(xlWorkBook); //Marshal.ReleaseComObject(xlApp); xlWorkSheet = null; xlWorkBook = null; last = null; range = null; //GC(); //xlApp.Quit(); xlApp = null; //GC(); //GetExcelProcess(xlApp); } catch (Exception ex) { } //var list = db.UserDatas.ToList(); //this.Hide(); //Home home = new Home(); //home.Show(); bool IsOpen = false; FormCollection fc = Application.OpenForms; foreach (Form f in fc) { if (f.Name == "Home") { IsOpen = true; f.Focus(); break; } } if (IsOpen == false) { Home home = new Home(); home.Show(); } //this.Hide(); //Home f1obj = new Home(); this.Hide(); btn_login.Enabled = true; pictureBox1.Visible = true; } else { lblerror.Visible = true; btn_login.Enabled = true; } }
private void logOffToolStripMenuItem_Click(object sender, EventArgs e) { this.Dispose(true); Home h = new Home(); h.Show(); }
private void button1_Click(object sender, EventArgs e) { bool user = false; //string line; //System.IO.StreamReader database = new System.IO.StreamReader("users.in"); //while (!database.EndOfStream) { user = true; user currentUser = new user(); //line=database.ReadLine(); //string username = ""; //int i = 0; //for(i=0;line[i]!=' ';i++) //{ linqtoregdbDataContext db = new linqtoregdbDataContext(); bool valid = false; var queryIsUsername = from usr in db.users select usr; List <string> allUsernames = new List <string>(); foreach (var c in queryIsUsername) { allUsernames.Add(c.username.ToLower()); if (c.username.ToLower() == maskedTextBox1.Text.ToLower()) { User.username = c.username; valid = true; currentUser = c; } } if (currentUser.password != Hasher.GetHash(maskedTextBox2.Text).ToString()) { MessageBox.Show("Invalid username/password combination!"); } else { //username += line[i]; //if (maskedTextBox1.Text.ToString().ToLower()[i] != char.ToLower(line[i])) //{ // user = false; // break; //} //} //if (user) //{ // User.username = username; // i = 11; // user = false; // foreach (char c in maskedTextBox2.Text.ToString()) // { // user = true; // if (c != line[i]) // { // user = false; // break; // } // i++; // } // if (user) //{ //i = 70; //string status=""; //for(i=70;i<line.Length&&line[i]!='\n'&&line[i]!=' ';i++) // status+=line[i]; string name = "Welcome,\n"; name += currentUser.lastName + ", " + currentUser.firstName; //for (i = 22; line[i] != ' '; i++) // name += line[i]; MessageBox.Show(name); User.type = currentUser.usertype; //if (User.type == "admin") //{ // AdminWindow adminScreen = new AdminWindow(this, User); // adminScreen.Show(); //} //else if (User.type == "faculty") //{ // FacultyHome facultyScreen = new FacultyHome(User, this); // facultyScreen.Show(); //} //else //{ Home screen = new Home(this, User); screen.Show(); //} this.Hide(); } } //if (maskedTextBox2.Text.ToString() == "pong") //{ // linqtoregdbDataContext db = new linqtoregdbDataContext(); // var queryUsername = from usr in db.users // where usr.username.ToLower()==maskedTextBox1.Text.ToLower() // select usr.username; // if (queryUsername.Count() == 1) // { // PongForm pongWindow = new PongForm(this,queryUsername.First()); // pongWindow.Show(); // this.Hide(); // } // /*MessageBox.Show("Welcome"); // Classes screen = new Classes(this); // screen.Show(); // this.Hide();*/ //} //database.Close(); maskedTextBox2.Text = ""; //maskedTextBox1.Text=""; }