private void MTRBtnLogin_Click(object sender, EventArgs e) { string id = this.MTRTxtId.Text; string password = this.MTRTxtPassword.Text; string sql = "select * from login where userId='" + id + "' and password='******';"; this.Ds = Da.ExecuteQuery(sql); if (this.Ds.Tables[0].Rows.Count > 0) { MessageBox.Show("Login Successful"); UserHomeDashboard UHD = new UserHomeDashboard(id); UHD.Visible = true; this.Visible = false; this.Id = this.MTRTxtId.Text; Thread OutOfMedicineThread = new Thread(this.CheckOutOfMedicineList); OutOfMedicineThread.IsBackground = true; OutOfMedicineThread.Start(); DataSet dsMorning = Da.ExecuteQuery("select * from [HealthyHome].[dbo].[Medicines] where userId='" + id + "' and morningAlarm='Yes' ;"); DataSet dsDay = Da.ExecuteQuery("select * from [HealthyHome].[dbo].[Medicines] where userId='" + id + "' and dayAlarm='Yes' ;"); DataSet dsNight = Da.ExecuteQuery("select * from [HealthyHome].[dbo].[Medicines] where userId='" + id + "' and nightAlarm='Yes' ;"); this.DD = dsDay; this.DM = dsMorning; this.DN = dsNight; Thread alarm = new Thread(startAlarm); alarm.IsBackground = true; this.AlarmThread = alarm; alarm.Start(); } else { MessageBox.Show("Invalid User Id or Password"); } }
private void SetAlarm_FormClosing(object sender, FormClosingEventArgs e) { UserHomeDashboard UHD = new UserHomeDashboard(this.Id); UHD.Visible = true; this.Hide(); }
private void AddMedicine_FormClosing(object sender, FormClosingEventArgs e) { //Application.Exit(); UserHomeDashboard UHD = new UserHomeDashboard(this.Id); UHD.Visible = true; this.Hide(); }
private void MTRUpdateHealth_FormClosing(object sender, FormClosingEventArgs e) { //Application.Exit() UserHomeDashboard UHD = new UserHomeDashboard(this.Id); UHD.Visible = true; this.Hide();; }
private void MTRbtnCancel_Click(object sender, EventArgs e) { UserHomeDashboard UHD = new UserHomeDashboard(U.Id); UHD.U = this.U; UHD.Visible = true; this.Hide(); }
private void MTReditUser_FormClosing(object sender, FormClosingEventArgs e) { UserHomeDashboard UHD = new UserHomeDashboard(U.Id); UHD.U = this.U; UHD.Visible = true; this.Hide(); }
private void MTRbtnSave_Click(object sender, EventArgs e) { this.U.Id = this.MTRtxtId.Text; int validation = 1; if (this.MTRtxtName.Text.Equals("") || this.MTRtxtName.Text.Any(c => char.IsDigit(c)) == true) { MessageBox.Show("Invalid Name"); validation = 0; } if (this.MTRtxtPassword.Text.Equals("") || this.MTRtxtPassword.Text.Length > 20 || this.MTRtxtPassword.Text.Length < 4) { MessageBox.Show("Invalid Password (4-20 Charachter)"); validation = 0; } try { int x; if (this.MTRtxtPhoneNo.Text[0] != '0' || this.MTRtxtPhoneNo.Text.Length == 10 || int.TryParse(this.MTRtxtPhoneNo.Text, out x) == false) { MessageBox.Show("Invalid Phone Number"); validation = 0; } } catch { MessageBox.Show("Invalid Phone Number"); validation = 0; } if (validation == 1) { this.U.Name = this.MTRtxtName.Text; this.U.Password = this.MTRtxtPassword.Text; this.U.Email = this.MTRtxtEmail.Text; this.U.PhoneNo = this.MTRtxtPhoneNo.Text; if (this.MTRrbMale.Checked == true) { this.U.Gender = this.MTRrbMale.Text.ToString(); } else if (this.MTRrbFemale.Checked == true) { this.U.Gender = this.MTRrbFemale.Text.ToString(); } this.U.DateOfBirth = MTRdtmDateOfBirth.Text; UserRepo URP = new UserRepo(); U = URP.UpdateUserInfo(U.Id, U); this.Hide(); UserHomeDashboard UHDB = new UserHomeDashboard(U.Id); UHDB.Visible = true; } }
private void MTRbtnSaveAlarm_Click(object sender, EventArgs e) { string sql = "select * from [HealthyHome].[dbo].[Alarm] where userId='" + this.Id + "';"; this.Ds = this.Da.ExecuteQuery(sql); if (this.Ds.Tables[0].Rows.Count < 1) { sql = "insert into [HealthyHome].[dbo].[Alarm] values('" + this.Id + "','" + this.MTRdtmMorning.Text + "','" + this.MTRdtmDay.Text + "','" + this.MTRdtmNight.Text + "');"; Da.ExecuteQuery(sql); MessageBox.Show("Insert Completed"); } else { sql = "update [HealthyHome].[dbo].[Alarm] set morning='" + this.MTRdtmMorning.Text + "',day='" + this.MTRdtmDay.Text + "',night='" + this.MTRdtmNight.Text + "'"; Da.ExecuteUpdateQuery(sql); MessageBox.Show("Update Completed"); } this.Hide(); UserHomeDashboard UHD = new UserHomeDashboard(this.Id); UHD.Visible = true; }
private void MTRbtnSaveContact_Click(object sender, EventArgs e) { int v = 1; DataSet ds = new DataSet(); DataAccess da = new DataAccess(); if (this.txtContactID.Text.Equals("") || this.txtContactID.Text.Length > 20) { MessageBox.Show("Invalid Contact Id"); v = 0; } int x; if (this.txtName.Text.Equals("") || int.TryParse(this.txtName.Text, out x) == true || this.txtName.Text.Any(c => char.IsDigit(c)) == true) { MessageBox.Show("Invalid Name"); v = 0; } try { if (this.txtPhoneNo.Text[0] != '0' || this.txtPhoneNo.Text.Length == 10 || int.TryParse(this.txtPhoneNo.Text, out x) == false) { MessageBox.Show("Invalid Phone Number"); v = 0; } } catch { MessageBox.Show("Invalid Phone Number"); v = 0; } string sql; if (v == 1) { try { sql = "select * from [HealthyHome].[dbo].[Contacts] where contactId='" + this.txtContactID.Text + "' and userId='" + this.Id + "' ;"; ds = da.ExecuteQuery(sql); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (ds.Tables[0].Rows.Count < 1) { try { sql = "insert into [HealthyHome].[dbo].[Contacts] values('" + this.Id + "' , '" + this.txtContactID.Text + "' , '" + this.txtName.Text + "' ,'" + this.txtPhoneNo.Text + "' );"; da.ExecuteQuery(sql); } catch (Exception ex) { MessageBox.Show(ex.Message); } UserHomeDashboard UHD = new UserHomeDashboard(this.Id); UHD.Visible = true; this.Hide(); } else { try { //MessageBox.Show("Here"); sql = "update [HealthyHome].[dbo].[Contacts] set name='" + this.txtName.Text + "',phoneNo='" + this.txtPhoneNo.Text + "' where userId='" + this.Id + "' and contactId='" + this.txtContactID.Text + "';"; //MessageBox.Show("Here 1"); da.ExecuteUpdateQuery(sql); //MessageBox.Show("Here 2"); } catch (Exception ex) { MessageBox.Show(ex.Message); } UserHomeDashboard UHD = new UserHomeDashboard(this.Id); UHD.Visible = true; this.Hide(); } } }
private void MTRbtnSave_Click(object sender, EventArgs e) { string userId = this.Id; string name = null; float price = 0; int count = 0; int validation = 1; int x; if (this.MTRtxtMedName.Text.Length == 0 || Int32.TryParse(this.MTRtxtMedName.Text, out x) == true) { MessageBox.Show("Invalid Name"); validation = 0; } else { name = this.MTRtxtMedName.Text; } float y; if (this.MTRtxtMedPrice.Text.Equals("") || float.TryParse(this.MTRtxtMedPrice.Text, out y) == false) { MessageBox.Show("Invalid Price"); validation = 0; } else { price = float.Parse(this.MTRtxtMedPrice.Text); } if (this.MTRtxtMedCount.Text.Equals("") || Int32.TryParse(this.MTRtxtMedCount.Text, out x) == false) { MessageBox.Show("Invalid Count"); validation = 0; } else { count = Int32.Parse(this.MTRtxtMedCount.Text); } string morningAlarm, dayAlarm, nightAlarm; if (MTRchkMorning.Checked) { morningAlarm = "Yes"; } else { morningAlarm = "No"; } if (MTRchkDay.Checked) { dayAlarm = "Yes"; } else { dayAlarm = "No"; } if (MTRchkNight.Checked) { nightAlarm = "Yes"; } else { nightAlarm = "No"; } if (validation == 1) { MessageBox.Show("Valid Inputs"); DataSet ds = new DataSet(); DataAccess da = new DataAccess(); string sql; try { sql = "select * from [HealthyHome].[dbo].[Medicines] where userId='" + this.Id + "' and medName='" + name + "'"; ds = da.ExecuteQuery(sql); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (ds.Tables[0].Rows.Count < 1) { try { sql = "insert into [HealthyHome].[dbo].[Medicines] values('" + userId + "','" + name + "'," + price + "," + count + ",'" + morningAlarm + "','" + dayAlarm + "','" + nightAlarm + "') ;"; da.ExecuteQuery(sql); } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Hide(); UserHomeDashboard UHD = new UserHomeDashboard(this.Id); UHD.Visible = true; } else { try { sql = "update [HealthyHome].[dbo].[Medicines] set price=" + price + ", count =" + count + ",morningAlarm='" + morningAlarm + "',dayAlarm='" + dayAlarm + "',nightAlarm='" + nightAlarm + "' where userId ='" + userId + "' and medName = '" + name + "' ;"; da.ExecuteQuery(sql); } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Hide(); UserHomeDashboard UHD = new UserHomeDashboard(this.Id); UHD.Visible = true; } } else { MessageBox.Show("Invalid Inputs"); } }
private void MTRbtnUpdateHealthSave_Click(object sender, EventArgs e) { int validation = 1; DataSet ds = new DataSet(); DataAccess Da = new DataAccess(); if (this.cmbBG.SelectedItem.ToString().Equals("")) { MessageBox.Show("Select Blood Group"); validation = 0; } float x; if (this.MTRtxtHeight.Text.Equals("") || float.TryParse(this.MTRtxtHeight.Text, out x) == false || float.Parse(this.MTRtxtHeight.Text) < 0 || float.Parse(this.MTRtxtHeight.Text) > 2.5) { MessageBox.Show("Invalid Height"); validation = 0; } if (this.MTRtxtWeight.Text.Equals("") || float.TryParse(this.MTRtxtWeight.Text, out x) == false || float.Parse(this.MTRtxtWeight.Text) < 0) { MessageBox.Show("Invalid Weight"); validation = 0; } if (this.MTRtxtSugarLevel.Text.Equals("") || float.TryParse(this.MTRtxtSugarLevel.Text, out x) == false || float.Parse(this.MTRtxtSugarLevel.Text) < 0 || float.Parse(this.MTRtxtSugarLevel.Text) > 25) { MessageBox.Show("Invalid Sugar Level"); validation = 0; } int y; if (this.MTRtxtBPH.Text.Equals("") || Int32.Parse(this.MTRtxtBPH.Text) < 0 || Int32.Parse(this.MTRtxtBPH.Text) > 300 || Int32.TryParse(this.MTRtxtBPH.Text, out y) == false || Int32.Parse(this.MTRtxtBPH.Text) < Int32.Parse(this.MTRtxtBPL.Text)) { MessageBox.Show("Invalid BP value"); validation = 0; } if (this.MTRtxtBPL.Text.Equals("") || Int32.Parse(this.MTRtxtBPL.Text) < 0 || Int32.Parse(this.MTRtxtBPL.Text) > 300 || Int32.TryParse(this.MTRtxtBPL.Text, out y) == false || Int32.Parse(this.MTRtxtBPH.Text) < Int32.Parse(this.MTRtxtBPL.Text)) { MessageBox.Show("Invalid BP value"); validation = 0; } if (validation == 1) { string sql = "select * from [HealthyHome].[dbo].[Health] where userId='" + this.Id + "';"; ds = Da.ExecuteQuery(sql); if (ds.Tables[0].Rows.Count < 1) { sql = "insert into [HealthyHome].[dbo].[Health] values('" + this.Id + "','" + this.cmbBG.Text + "'," + float.Parse(this.MTRtxtHeight.Text) + ", " + float.Parse(this.MTRtxtWeight.Text) + " ," + float.Parse(this.MTRtxtSugarLevel.Text) + ", " + Int32.Parse(this.MTRtxtBPH.Text) + ", " + Int32.Parse(this.MTRtxtBPL.Text) + ");"; Da.ExecuteQuery(sql); this.Close(); } else { sql = "update [HealthyHome].[dbo].[Health] set bloodGroup='" + this.cmbBG.Text + "',height = " + float.Parse(this.MTRtxtHeight.Text) + " , weight = " + float.Parse(this.MTRtxtWeight.Text) + ",sugarLevel=" + float.Parse(this.MTRtxtSugarLevel.Text) + " ,bpHigh = " + Int32.Parse(this.MTRtxtBPH.Text) + ",bpLow=" + Int32.Parse(this.MTRtxtBPL.Text) + " ;"; Da.ExecuteUpdateQuery(sql); this.Hide(); } UserHomeDashboard UHD = new UserHomeDashboard(this.Id); UHD.Visible = true; this.Hide(); } else { MessageBox.Show("Invalid Inputs"); } }