private void btn_Exit_Click(object sender, EventArgs e) { this.Dispose(); frm_Login frm = new frm_Login(); frm.ShowDialog(); this.Close(); }
private void MainForm_Load(object sender, EventArgs e) { //string SqlStatus = _common.GetSqlStatus("MSSQLSERVER"); //if (SqlStatus != "Running") //{ // _common.StartService("MSSQLSERVER", 100000); //} frm_Login _form = new frm_Login(); _form.ShowDialog(); menuStrip1.Visible = _form.result; bttn_Login.Visible = !_form.result; if (_form.type == "user") { reportToolStripMenuItem.Enabled = false; } if (!_Act.CheckActivation()) { menuStrip1.Enabled = false; } string Valid = _Act.CheckValidity(); if (Valid == "Valid") { label1.Visible = false; } else if (Valid == "Invalid") { MessageBox.Show("Validity Expired \n Please Contact Service Provider\n +91-7709885767"); menuStrip1.Visible = false; label1.Visible = true; } else { lbl_ValidDays.Text = Valid + " Days left for Trial"; lbl_ValidDays.Visible = true; } dtSett = _common.getSettingValue(); if (dtSett.Maintenance == "No") { serviceToolStripMenuItem.Visible = false; } else { serviceToolStripMenuItem.Visible = true; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); frm_Login frmLogin = new frm_Login(); if (frmLogin.ShowDialog() == DialogResult.OK) { Application.Run(new frm_MainForm(frmLogin.UserName, frmLogin.UserFullName)); } }
private void ts_btn_Login_Click(object sender, EventArgs e) { if (this.ts_btn_Login.Name == "ts_btn_Login") { frm_Login frm = new frm_Login(); frm.ShowDialog(); } else { Properties.Settings.Default.Reset(); Application.Exit(); } }
/// <summary> /// Opens frm_Login, from which the credentials to access the database are captured. Persists the form until /// either a successful login or user cancels (closing application). /// </summary> private void setCredentials() { using (frm_Login Login = new frm_Login()) { while (Login.loggedIn == false & Login.loginCancel == false) { Login.ShowDialog(); } if (Login.loginCancel == true) { Environment.Exit(0); } lbl_LoggedInAs.Text = SQL_Stuff.credential.UserId; } }
/// <summary> /// Opens frm_Login, from which the credentials to access the database are captured. Persists the form until /// either a successful login or user cancels (closing application). /// </summary> private void setCredentials() { using (frm_Login Login = new frm_Login()) { while (Login.loggedIn == false & Login.loginCancel == false) { Login.ShowDialog(); } if (Login.loginCancel == true) { Environment.Exit(0); } if (SQL_Stuff.env == "test") { lbl_LoggedInAs.Text = "*** TEST ENVIRONMENT *** " + SQL_Stuff.credential.UserId; } else { lbl_LoggedInAs.Text = SQL_Stuff.credential.UserId; } } }
public frm_Main() { InitializeComponent(); dgv_ContentTermin.RowTemplate.Height = 50; DataAccessLayer DAL = new DataAccessLayer(); if (frm == null) { frm = this; } //Properties.Settings.Default.Reset(); try { string selectQuery = "select * from tbl_users where userName = '******' and userPass = '******'"; DataTable Dt = new DataTable(); Dt = DAL.fetchData(selectQuery); if (Dt.Rows.Count == 0) { Properties.Settings.Default.Reset(); btn_AddKalender.Enabled = false; } else { } } catch (Exception ex) { MessageBox.Show(ex.Message); } // Connect to Database MySqlConnection mySqlConnection = DAL.myConnection(); try { mySqlConnection.Open(); lbl_OnOff.BackColor = Color.Green; } catch (Exception ex) { //To write log file when some problem hapend with the connection to database using (StreamWriter w = File.AppendText(Environment.CurrentDirectory + "\\log.txt")) { w.WriteLine(DateTime.Now + "-->" + ex.Message); } lbl_OnOff.BackColor = Color.Red; } //to get Days of current month int DaysOfMonth = DateTime.DaysInMonth(int.Parse(DateTime.Now.ToString("yyyy")), int.Parse(DateTime.Now.ToString("MM"))); DAL.disconnect(mySqlConnection); if (string.IsNullOrEmpty(Properties.Settings.Default.userName) && string.IsNullOrEmpty(Properties.Settings.Default.Password)) { ts_btn_Termin.Enabled = false; frm_Login frm_Login = new frm_Login(); frm_Login.ShowDialog(); } else { ts_btn_Login.Text = "Abmelden"; ts_btn_Login.Name = "ts_btn_Abmelden"; //ts_btn_Login.Image = Image.FromFile(Environment.CurrentDirectory + "\\icon\\Logout.png"); } lbl_UserName.Text = "Benutzer: " + Properties.Settings.Default.userName; //fuctions.cmbGenrator(red, green, blue, cbName, cbTitel); //TODO: All in one function try { fLP_Kalender.Controls.Clear(); string query = "select * from tbl_kalender where userId = " + Properties.Settings.Default.userId; DataTable Dt = DAL.fetchData(query); for (int i = 0; i < Dt.Rows.Count; i++) { string kalenderColor = Dt.Rows[i]["color"].ToString(); string[] colorArray = kalenderColor.Split(' '); red = int.Parse(colorArray[0]); green = int.Parse(colorArray[1]); blue = int.Parse(colorArray[2]); CheckBox cb = new CheckBox(); cb.Name = "cb_" + Dt.Rows[i]["kalenderName"].ToString(); cb.Text = Dt.Rows[i]["kalenderName"].ToString(); cb.BackColor = Color.FromArgb(red, green, blue); cb.CheckedChanged += Cb_Selected; cb.MouseHover += Item_MouseHover; cb.ContextMenuStrip = frm_Main.getMainForm.contextMS_Kalender; frm_Main.getMainForm.fLP_Kalender.Controls.Add(cb); } Dt.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } try { fLP_SharedCalender.Controls.Clear(); string query = "select k.kalenderName, k.color,u.userName from tbl_kalender as k " + "inner join tbl_shared as s on k.kalender_Id = s.kalenderId " + "inner join tbl_users as u on k.userId = u.user_Id " + "where s.userId = " + Properties.Settings.Default.userId; DataTable Dt = DAL.fetchData(query); for (int i = 0; i < Dt.Rows.Count; i++) { //TO call the value from Color Columns string kalenderColor = Dt.Rows[i]["color"].ToString(); string[] colorArray = kalenderColor.Split(' '); red = int.Parse(colorArray[0]); green = int.Parse(colorArray[1]); blue = int.Parse(colorArray[2]); CheckBox cb = new CheckBox(); cb.Name = "cb_" + Dt.Rows[i]["kalenderName"].ToString(); cb.Text = Dt.Rows[i]["kalenderName"].ToString() + "-(" + Dt.Rows[i]["userName"].ToString() + ")"; cb.BackColor = Color.FromArgb(red, green, blue); cb.CheckedChanged += Cb_Shared_CheckedChanged; cb.MouseHover += Item_MouseHover; //cb.ContextMenuStrip = frm_Main.getMainForm.contextMS_Kalender; fLP_SharedCalender.Controls.Add(cb); } Dt.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }