private void fillCombo() { if (item_panel.Controls.Count > 0) { item_panel.Controls.Clear(); } TableLayoutPanel.CheckForIllegalCrossThreadCalls = false; BedDetails.CheckForIllegalCrossThreadCalls = false; ComboBox.CheckForIllegalCrossThreadCalls = false; BackgroundWorker bwConn = new BackgroundWorker(); PleaseWait pb = new PleaseWait(); bwConn.DoWork += (sender, e) => { var connectionString = DbConnect.conString; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "SELECT * From Beds WHERE (CenterType='" + lbtype.Text + "' and CenterName='" + lbname.Text + "') and (WardCode='" + cmbcode.Text + "') Order By ID"; using (var command = new MySqlCommand(query, connection)) { using (var reader = command.ExecuteReader()) { int rowIndex = this.item_panel.RowCount++; //MessageBox.Show(rowIndex.ToString()); int colIndecx = 0; while (reader.Read()) { BedDetails bed1 = new BedDetails(); bed1.setDetails(cmbcode.Text, reader["BedName"].ToString()); this.BeginInvoke((Action)(() => { item_panel.Controls.Add(bed1, colIndecx, rowIndex); })); System.Threading.Thread.Sleep(100); listControl.Add(bed1); colIndecx++; if (colIndecx > 3) { colIndecx = 0; rowIndex++; this.item_panel.RowStyles.Add(new RowStyle(SizeType.AutoSize)); } } } } } }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } pb.Close(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }
public void fillgrid() { PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender, e) => { var connectionString = DbConnect.conString; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "SELECT Name,ContactNo,Date,Address,Age,AdharCard,Remark,CenterType,CenterName,CreatedBy,CreatedAt FROM PatientsRemark WHERE CenterType='" + AdvanceSearch.centerType + "' and CenterName='" + AdvanceSearch.centerName + "'"; main_query = query; using (var command = new MySqlCommand(query, connection)) { using (var reader = command.ExecuteReader()) { int srno = 1; while (reader.Read()) { string date, fn, cn, add, age, adhar; date = reader["Date"].ToString(); fn = reader["Name"].ToString(); cn = reader["ContactNo"].ToString(); add = reader["Address"].ToString(); age = reader["Age"].ToString(); adhar = reader["AdharCard"].ToString(); string remark = reader["Remark"].ToString(); string type = reader["CenterType"].ToString(); string cname = reader["CenterName"].ToString(); string cat = reader["CreatedBy"].ToString(); gridPatientsList.Rows.Add(srno, fn, cn, DateTime.Parse(date), add, age, adhar, remark, type, cname, cat); srno++; } } } } }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } gridPatientsList.ClearSelection(); pb.Close(); }; if (gridPatientsList.Rows.Count > 0) { gridPatientsList.Rows.Clear(); } bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private void fillCenterType() { List <string> centerTypes = new List <string>(); PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender, e) => { if (cmbtype.Items.Count > 0) { cmbtype.Items.Clear(); } if (cmbname.Items.Count > 0) { cmbname.Items.Clear(); } var connectionString = DbConnect.conString; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "SELECT CenterType FROM centerType"; centerTypes.Add("--CENTER TYPE--"); using (var command = new MySqlCommand(query, connection)) { using (var reader = command.ExecuteReader()) { //Iterate through the rows and add it to the combobox's items while (reader.Read()) { string name = reader.GetString("CenterType"); if (!centerTypes.Contains(name)) { centerTypes.Add(name); } } } } } }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } cmbtype.Items.AddRange(centerTypes.ToArray()); cmbtype.SelectedIndex = 0; txtuser.Focus(); pb.Close(); pb.Dispose(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private void fillCenterType() { List <string> centerTypes = new List <string>(); PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender, e) => { if (comboBox1.Items.Count > 0) { comboBox1.Items.Clear(); } var connectionString = DbConnect.conString; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "SELECT NameOfArea,NameOfDistrict FROM Areas ORDER BY ID"; centerTypes.Add("-- ADDRESS --"); using (var command = new MySqlCommand(query, connection)) { using (var reader = command.ExecuteReader()) { //Iterate through the rows and add it to the combobox's items while (reader.Read()) { string area = reader.GetString("NameOfArea"); string district = reader.GetString("NameOfDistrict"); string name = area + "," + district; if (!centerTypes.Contains(name)) { centerTypes.Add(name); } } } } } }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } comboBox1.Items.AddRange(centerTypes.ToArray()); comboBox1.SelectedIndex = 0; pb.Close(); pb.Dispose(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private void ChangePass() { PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender, e) => { if (!validation()) { MessageBox.Show("Please fill all fields !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtnew.Text != txtconfirm.Text) { MessageBox.Show("Password doesn't match !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtconfirm.Clear(); txtnew.Clear(); txtnew.Focus(); return; } DialogResult drs = MessageBox.Show("Are You Sure Do You Want To Change Password ??", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drs == DialogResult.No) { return; } MySqlConnection cn = new MySqlConnection(); cn.ConnectionString = DbConnect.conString; cn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = "UPDATE Login SET Password='******' WHERE Username='******'"; cmd.ExecuteNonQuery(); MessageBox.Show("Password Updated Successfully !!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cn.Close(); }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Hide(); pb.Close(); pb.Dispose(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private void fillCenterName() { PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender, e) => { var connectionString = DbConnect.conString; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "SELECT CenterName FROM Centers WHERE CenterType='" + cmbtype.Text + "'"; cmbname.Items.Add("--CENTER NAME--"); using (var command = new MySqlCommand(query, connection)) { using (var reader = command.ExecuteReader()) { //Iterate through the rows and add it to the combobox's items while (reader.Read()) { string name = reader.GetString("CenterName"); if (!cmbname.Items.Contains(name)) { cmbname.Items.Add(name); } } } } } }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } cmbname.SelectedIndex = 0; pb.Close(); }; if (cmbname.Items.Count > 0) { cmbname.Items.Clear(); } bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { TextBox.CheckForIllegalCrossThreadCalls = false; ComboBox.CheckForIllegalCrossThreadCalls = false; PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); string status = ""; bwConn.DoWork += (sender1, e1) => { status = LoginUser(txtuser.Text, txtpwd.Text); }; bwConn.RunWorkerCompleted += (sender1, e1) => { if (e1.Error != null) { MessageBox.Show(e1.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (status == "ok") { MessageBox.Show("Login Sucessfull !!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); } else if (status == "not ok") { MessageBox.Show("Login Failed !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtpwd.Clear(); txtuser.Clear(); cmbtype.SelectedIndex = 0; } else { MessageBox.Show("Please enter all fields !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } pb.Close(); pb.Dispose(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private void deleteDetails() { PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender, e) => { MySqlConnection cn = new MySqlConnection(); cn.ConnectionString = DbConnect.conString; cn.Open(); DialogResult drs = MessageBox.Show("Are You Sure Do You Want To Delete This Patient's Remark ??", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drs == DialogResult.No) { return; } MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; cmd.CommandText = "DELETE FROM PatientsRemark WHERE ID=" + lbid.Text; cmd.ExecuteNonQuery(); MessageBox.Show("Patient's Remark Deleted Successfully !!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cn.Close(); }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } pb.Close(); clearAll(); actionButtonNormalStage(); unlockAll(false); fillgrid(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private string saveDetails() { string bedname = cmbbedname.Text; string WardCode = cmbcode.Text; PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); string result = ""; bwConn.DoWork += (sender, e) => { if (checkBox1.Checked) { adhar = "Not Available"; } else { adhar = txtadhar.Text; } if (!validation()) { result = "error"; } else { if (status.Equals("ADD NEW")) { DialogResult drs = MessageBox.Show("Are You Sure Do You Want To Add This Patient ??", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drs == DialogResult.No) { return; } MySqlConnection cn = new MySqlConnection(); cn.ConnectionString = DbConnect.conString; cn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; string[] address = txtadd.Text.Split(','); cmd.CommandText = "INSERT INTO Patients (Name,ContactNo,Gender,Address,Age,AdharCard,Date,Remark,CenterType,CenterName,isTest,TestName,OtherDiseases,CreatedBy,CreatedAt,Area,District,WardCode,BedName) VALUES ('" + txtname.Text + "','" + txtcontact.Text + "','" + gender + "','" + txtadd.Text + "'," + txtage.Text + ",'" + adhar + "',@date,'" + txtremark.Text + "','" + centerType + "','" + centerName + "','" + test + "','" + lbtestname.Text + "','" + txtother.Text + "','" + created_by + "','" + DateTime.Now.ToString("hh:mm:ss tt") + "','" + address[0] + "','" + address[1] + "','" + WardCode + "','" + bedname + "')"; cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtdate.Text).ToString("yyyy-MM-dd")); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); int flag = 1; if (txtremark.Text == "Discharged") { flag = 0; cmd.CommandText = "UPDATE Beds SET Flag=0 WHERE BedName='" + bedname + "' and WardCode='" + WardCode + "'"; cmd.ExecuteNonQuery(); } cmd.CommandText = "INSERT INTO PatientsRemark (Name,ContactNo,Gender,Address,Age,AdharCard,Date,Remark,CenterType,CenterName,CreatedBy,CreatedAt,Area,District,Flag) VALUES ('" + txtname.Text + "','" + txtcontact.Text + "','" + gender + "','" + txtadd.Text + "'," + txtage.Text + ",'" + adhar + "',@date,'" + txtremark.Text + "','" + centerType + "','" + centerName + "','" + created_by + "','" + DateTime.Now.ToString("hh:mm:ss tt") + "','" + address[0] + "','" + address[1] + "'," + flag + ")"; cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtdate.Text).ToString("yyyy-MM-dd")); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); cmd.CommandText = "UPDATE Beds SET Flag=1 WHERE (BedName='" + bedname + "') and (CenterType='" + centerType + "' and CenterName='" + centerName + "')"; cmd.ExecuteNonQuery(); string diseases = txtother.Text; string[] diss = diseases.Split(','); if (diss.Length > 1) { getMaxID(0); cmd.CommandText = "INSERT INTO HighRiskPatients (ID,Name,ContactNo,Gender,Address,Age,AdharCard,Date,Remark,CenterType,CenterName,isTest,TestName,OtherDiseases,CreatedBy,CreatedAt,Area,District) VALUES (" + lbid.Text + ",'" + txtname.Text + "','" + txtcontact.Text + "','" + gender + "','" + txtadd.Text + "'," + txtage.Text + ",'" + adhar + "',@date,'" + txtremark.Text + "','" + centerType + "','" + centerName + "','" + test + "','" + lbtestname.Text + "','" + txtother.Text + "','" + created_by + "','" + DateTime.Now.ToString("hh:mm:ss tt") + "','" + address[0] + "','" + address[1] + "')"; cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtdate.Text).ToString("yyyy-MM-dd")); cmd.ExecuteNonQuery(); } cn.Close(); result = "success"; } else if (status.Equals("UPDATE")) { MySqlConnection cn = new MySqlConnection(); cn.ConnectionString = DbConnect.conString; cn.Open(); DialogResult drs = MessageBox.Show("Are You Sure Do You Want To Update This Patient ??", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drs == DialogResult.No) { return; } MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; if (checkBox1.Checked) { adhar = "Not Available"; } else { adhar = txtadhar.Text; } string[] address = txtadd.Text.Split(','); int flag = 1; if (txtremark.Text == "Discharged") { flag = 0; cmd.CommandText = "UPDATE Beds SET Flag=0 WHERE BedName='" + bedname + "' and WardCode='" + WardCode + "'"; cmd.ExecuteNonQuery(); } cmd.CommandText = "UPDATE Patients SET Name='" + txtname.Text + "',ContactNo='" + txtcontact.Text + "',Gender='" + gender + "',Address='" + txtadd.Text + "',Age=" + txtage.Text + ",AdharCard='" + adhar + "',Date=@date,Remark='" + txtremark.Text + "',CenterType='" + centerType + "',CenterName='" + centerName + "',isTest='" + test + "',TestName='" + lbtestname.Text + "',OtherDiseases='" + txtother.Text + "',CreatedBy='" + created_by + "',CreatedAt='" + DateTime.Now.ToString("hh:mm:ss tt") + "',Area='" + address[0] + "',District='" + address[1] + "',WardCode='" + WardCode + "',BedName='" + bedname + "' WHERE ID=" + lbid.Text; cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtdate.Text).ToString("yyyy-MM-dd")); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); cmd.CommandText = "UPDATE Beds SET Flag=1 WHERE (BedName='" + bedname + "') and (CenterType='" + centerType + "' and CenterName='" + centerName + "')"; cmd.ExecuteNonQuery(); cmd.CommandText = "UPDATE PatientsRemark SET Name='" + txtname.Text + "',ContactNo='" + txtcontact.Text + "',Gender='" + gender + "',Address='" + txtadd.Text + "',Age=" + txtage.Text + ",AdharCard='" + adhar + "',Date=@date,Remark='" + txtremark.Text + "',CenterType='" + centerType + "',CenterName='" + centerName + "',CreatedBy='" + created_by + "',CreatedAt='" + DateTime.Now.ToString("hh:mm:ss tt") + "',Area='" + address[0] + "',District='" + address[1] + "',Flag=" + flag + " WHERE Name='" + txtname.Text + "' and ContactNo='" + txtcontact.Text + "'"; cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtdate.Text).ToString("yyyy-MM-dd")); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); string diseases = txtother.Text; string[] diss = diseases.Split(','); if (diss.Length > 1 && getCount1() == 0) { getMaxID(0); cmd.CommandText = "INSERT INTO HighRiskPatients (ID,Name,ContactNo,Gender,Address,Age,AdharCard,Date,Remark,CenterType,CenterName,isTest,TestName,OtherDiseases,CreatedBy,CreatedAt,Area,District) VALUES (" + lbid.Text + ",'" + txtname.Text + "','" + txtcontact.Text + "','" + gender + "','" + txtadd.Text + "'," + txtage.Text + ",'" + adhar + "',@date,'" + txtremark.Text + "','" + centerType + "','" + centerName + "','" + test + "','" + lbtestname.Text + "','" + txtother.Text + "','" + created_by + "','" + DateTime.Now.ToString("hh:mm:ss tt") + "','" + address[0] + "','" + address[1] + "')"; cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtdate.Text).ToString("yyyy-MM-dd")); cmd.ExecuteNonQuery(); } else { // getMaxID(0); cmd.CommandText = "UPDATE HighRiskPatients SET Name='" + txtname.Text + "',ContactNo='" + txtcontact.Text + "',Gender='" + gender + "',Address='" + txtadd.Text + "',Age=" + txtage.Text + ",AdharCard='" + adhar + "',Date=@date,Remark='" + txtremark.Text + "',CenterType='" + centerType + "',CenterName='" + centerName + "',isTest='" + test + "',TestName='" + lbtestname.Text + "',OtherDiseases='" + txtother.Text + "',CreatedBy='" + created_by + "',CreatedAt='" + DateTime.Now.ToString("hh:mm:ss tt") + "',Area='" + address[0] + "',District='" + address[1] + "' WHERE Name='" + txtname.Text + "' and ContactNo='" + txtcontact.Text + "'"; cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtdate.Text).ToString("yyyy-MM-dd")); cmd.ExecuteNonQuery(); } cn.Close(); result = "success"; } } }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (result != "error") { clearAll(); actionButtonNormalStage(); unlockAll(false); fillgrid(); } else { if (txtadd.Text == "") { MessageBox.Show("Please Enter Address !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtadd.Focus(); } else if (adhar == "") { MessageBox.Show("Please Enter AdharCard No !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtadhar.Focus(); } else if (txtage.Text == "") { MessageBox.Show("Please Enter Age !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtage.Focus(); } else if (!txtcontact.MaskFull) { MessageBox.Show("Please Enter ContactNo !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtcontact.Focus(); } else if (txtname.Text == "") { MessageBox.Show("Please Enter Fullname Of Patients !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtname.Focus(); } else if (txtother.Text == "") { MessageBox.Show("Please Enter Other Diseases !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtother.Focus(); } else if (txtremark.Text == "") { MessageBox.Show("Please Enter Remark Of Patients !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtremark.Focus(); } else if (lbtestname.Text == "") { MessageBox.Show("Please Select Test Done or Not?? !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (gender == "") { MessageBox.Show("Please Gender Of Patients !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (cmbcode.SelectedIndex == 0) { MessageBox.Show("Please select Ward Code of Patients !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbcode.Focus(); } else if (cmbbedname.SelectedIndex == 0) { MessageBox.Show("Please select Bed Name of Patients !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbbedname.Focus(); } } pb.Close(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); return(result); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { System.Windows.Forms.DataVisualization.Charting.Chart.CheckForIllegalCrossThreadCalls = false; ComboBox.CheckForIllegalCrossThreadCalls = false; chart1.ChartAreas[0].AxisX.Title = "Date"; chart1.ChartAreas[0].AxisY.Title = "Patients"; PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender1, e1) => { if (comboBox2.SelectedIndex == 1 && comboBox1.SelectedIndex != 0) { DateTime date1 = DateTime.Parse(DateTime.Now.ToShortDateString()); TimeSpan span = new TimeSpan(Int32.Parse(comboBox1.Text.Replace("Days", "")), 0, 0, 0); DateTime date2 = DateTime.Now.Subtract(span); foreach (var series in chart1.Series) { series.Points.Clear(); } while (date2 <= date1) { var connectionString = DbConnect.conString; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "SELECT DISTINCT COUNT(Name) From PatientsRemark WHERE Date=@date1"; using (var command = new MySqlCommand(query, connection)) { command.Parameters.AddWithValue("@date1", date2.ToString("yyyy-MM-dd")); using (var reader = command.ExecuteReader()) { int rows = 0; while (reader.Read()) { string dateChart = date2.Day.ToString(); string count = reader[0].ToString(); chart1.Series["Patients"].Points.AddXY(dateChart + " " + months[date2.Month - 1], count); chart1.ChartAreas[0].AxisX.Interval = 1; chart1.ChartAreas[0].AxisY.Interval = 1; rows++; } } } } date2 = date2.AddDays(1); } } if (comboBox2.SelectedIndex == 2 && comboBox1.SelectedIndex != 0) { DateTime date1 = DateTime.Parse(DateTime.Now.ToShortDateString()); TimeSpan span = new TimeSpan(Int32.Parse(comboBox1.Text.Replace("Days", "")), 0, 0, 0); DateTime date2 = DateTime.Now.Subtract(span); foreach (var series in chart1.Series) { series.Points.Clear(); } while (date2 <= date1) { var connectionString = DbConnect.conString; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "SELECT DISTINCT COUNT(Name) From PatientsRemark WHERE Date=@date1 and Remark='Active'"; using (var command = new MySqlCommand(query, connection)) { command.Parameters.AddWithValue("@date1", date2.ToString("yyyy-MM-dd")); using (var reader = command.ExecuteReader()) { int rows = 0; while (reader.Read()) { string dateChart = date2.Day.ToString(); string count = reader[0].ToString(); chart1.Series["Patients"].Points.AddXY(dateChart + " " + months[date2.Month - 1], count); chart1.ChartAreas[0].AxisX.Interval = 1; chart1.ChartAreas[0].AxisY.Interval = 1; rows++; } } } } date2 = date2.AddDays(1); } } if (comboBox2.SelectedIndex == 3 && comboBox1.SelectedIndex != 0) { DateTime date1 = DateTime.Parse(DateTime.Now.ToShortDateString()); TimeSpan span = new TimeSpan(Int32.Parse(comboBox1.Text.Replace("Days", "")), 0, 0, 0); DateTime date2 = DateTime.Now.Subtract(span); foreach (var series in chart1.Series) { series.Points.Clear(); } while (date2 <= date1) { var connectionString = DbConnect.conString; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "SELECT DISTINCT COUNT(Name) From PatientsRemark WHERE Date=@date1 and Remark='Discharged'"; using (var command = new MySqlCommand(query, connection)) { command.Parameters.AddWithValue("@date1", date2.ToString("yyyy-MM-dd")); using (var reader = command.ExecuteReader()) { int rows = 0; while (reader.Read()) { string dateChart = date2.Day.ToString(); string count = reader[0].ToString(); chart1.Series["Patients"].Points.AddXY(dateChart + " " + months[date2.Month - 1], count); chart1.ChartAreas[0].AxisX.Interval = 1; chart1.ChartAreas[0].AxisY.Interval = 1; rows++; } } } } date2 = date2.AddDays(1); } } if (comboBox2.SelectedIndex == 4 && comboBox1.SelectedIndex != 0) { DateTime date1 = DateTime.Parse(DateTime.Now.ToShortDateString()); TimeSpan span = new TimeSpan(Int32.Parse(comboBox1.Text.Replace("Days", "")), 0, 0, 0); DateTime date2 = DateTime.Now.Subtract(span); foreach (var series in chart1.Series) { series.Points.Clear(); } while (date2 <= date1) { var connectionString = DbConnect.conString; using (var connection = new MySqlConnection(connectionString)) { connection.Open(); var query = "SELECT DISTINCT COUNT(Name) From PatientsRemark WHERE Date=@date1 and CenterType='Qurantine Center'"; using (var command = new MySqlCommand(query, connection)) { command.Parameters.AddWithValue("@date1", date2.ToString("yyyy-MM-dd")); using (var reader = command.ExecuteReader()) { int rows = 0; while (reader.Read()) { string dateChart = date2.Day.ToString(); string count = reader[0].ToString(); chart1.Series["Patients"].Points.AddXY(dateChart + " " + months[date2.Month - 1], count); chart1.ChartAreas[0].AxisX.Interval = 1; chart1.ChartAreas[0].AxisY.Interval = 1; rows++; } } } } date2 = date2.AddDays(1); } } }; bwConn.RunWorkerCompleted += (sender1, e1) => { if (e1.Error != null) { MessageBox.Show(e1.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } pb.Close(); for (int i = 0; i < chart1.Series["Patients"].Points.Count; i++) { var val = chart1.Series["Patients"].Points[i].GetValueByName("Y"); int value = Int32.Parse(val.ToString()); if (Int32.Parse(value.ToString()) >= 15) { chart1.Series["Patients"].Points[i].Color = Color.Red; } else if (Int32.Parse(value.ToString()) >= 5 && Int32.Parse(value.ToString()) < 15) { chart1.Series["Patients"].Points[i].Color = Color.Orange; } else if (Int32.Parse(value.ToString()) >= 0 && Int32.Parse(value.ToString()) < 5) { chart1.Series["Patients"].Points[i].Color = Color.Green; } } }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private void loadData() { string wanted_path = ""; ReportParameter rp = new ReportParameter(); ReportDataSource rds = new ReportDataSource(); PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender, e) => { MySqlConnection cn = new MySqlConnection(); cn.ConnectionString = DbConnect.conString; cn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = main_query; cmd.Connection = cn; MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable table1 = new DataTable("Patients"); da.Fill(table1); DataSet ds = new DataSet(); ds.Tables.Add(table1); rds.Name = "DataSet1"; rds.Value = table1; var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var subFolderPath = Path.Combine(path, "OCC Reports"); if (!System.IO.Directory.Exists(subFolderPath)) { System.IO.Directory.CreateDirectory(subFolderPath); } var cur_folder = DateTime.Now.ToString("dd-MM-yyyy"); subFolderPath = subFolderPath + "//" + cur_folder; if (!System.IO.Directory.Exists(subFolderPath)) { System.IO.Directory.CreateDirectory(subFolderPath); } wanted_path = subFolderPath; rp = new ReportParameter("Date", DateTime.Now.ToShortDateString()); reportViewer1.LocalReport.DataSources.Clear(); }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath); reportViewer1.LocalReport.ReportPath = path + "//Report1.rdlc"; reportViewer1.LocalReport.SetParameters(new ReportParameter[] { rp }); reportViewer1.LocalReport.DataSources.Add(rds); reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout); reportViewer1.LocalReport.Refresh(); Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; byte[] bytes = reportViewer1.LocalReport.Render( "PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); filename = @wanted_path + "//" + DateTime.Now.ToString("hh-mm-ss") + ".pdf"; using (FileStream fs = new FileStream(filename, FileMode.Create)) { fs.Write(bytes, 0, bytes.Length); } pb.Close(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private void btnSave_Click(object sender, EventArgs e) { if (!validation()) { MessageBox.Show("Please fill all fields !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MySqlConnection cn = new MySqlConnection(); cn.ConnectionString = DbConnect.conString; cn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; DialogResult drs; if (status.Equals("ADD NEW")) { drs = MessageBox.Show("Are You Sure Do You Want To Add This Beds ??", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drs == DialogResult.No) { return; } PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); int from = Int32.Parse(txtfrom.Text); int to = Int32.Parse(txtto.Text); string result = ""; for (int i = from; i <= to; i++) { string bedname1 = cmbcode.Text + "/" + i.ToString(); int count = getCount(bedname1); if (count > 0) { result = "exists"; break; } } bwConn.DoWork += (sender1, e1) => { if (result == "") { for (int i = from; i <= to; i++) { string bedname = cmbcode.Text + "/" + i.ToString(); txtname.Text = bedname; lbinstruction.Text = "Please wait !! We are adding beds for you."; cmd.CommandText = "INSERT INTO Beds(CenterType,CenterName,WardCode,BedName,Flag) VALUES ('" + cmbtype.Text + "','" + cmbname.Text + "','" + cmbcode.Text + "','" + bedname + "',0)"; cmd.ExecuteNonQuery(); fillgrid(); } result = "success"; } }; bwConn.RunWorkerCompleted += (sender1, e1) => { if (e1.Error != null) { MessageBox.Show(e1.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } pb.Close(); if (result == "success") { MessageBox.Show("Beds Added Successfully !!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (result == "exists") { MessageBox.Show("Beds Already Exists !!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } cn.Close(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); } else if (status.Equals("UPDATE")) { drs = MessageBox.Show("Are You Sure Do You Want To Update This Ward ??", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drs == DialogResult.No) { return; } cmd.CommandText = ""; cmd.ExecuteNonQuery(); MessageBox.Show("Beds Updated Successfully !!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cn.Close(); } clearAll(); fillgrid(); unlockAll(false); actionButtonNormalStage(); }
public void loadData() { string wanted_path = ""; ReportParameter[] rp = new ReportParameter[4]; ReportDataSource rds = new ReportDataSource(); ReportDataSource rds1 = new ReportDataSource(); PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender, e) => { MySqlConnection cn = new MySqlConnection(); cn.ConnectionString = DbConnect.conString; cn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "SELECT Name,ContactNo,Date,Address,Age,AdharCard,Remark,CenterType,CenterName,CreatedBy,CreatedAt,Flag FROM PatientsRemark WHERE (CenterType='" + DailyReports.centerType + "' and CenterName='" + DailyReports.centerName + "') and (Flag=1 and Date=@date)"; cmd.Parameters.AddWithValue("@date", DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("yyyy-MM-dd")); cmd.Connection = cn; MySqlDataAdapter da = new MySqlDataAdapter(cmd); DataTable table1 = new DataTable("Patients"); da.Fill(table1); DataSet ds = new DataSet(); ds.Tables.Add(table1); rds.Name = "DataSet1"; rds.Value = table1; MySqlCommand cmd1 = new MySqlCommand(); cmd1.Connection = cn; cmd1.CommandType = CommandType.Text; cmd1.CommandText = "SELECT Name,ContactNo,Date,Address,Age,AdharCard,Remark,CenterType,CenterName,CreatedBy,CreatedAt,Flag FROM PatientsRemark WHERE (CenterType='" + DailyReports.centerType + "' and CenterName='" + DailyReports.centerName + "') and (Flag=0 and Date=@date)"; cmd1.Parameters.AddWithValue("@date", DateTime.Parse(DateTime.Now.ToShortDateString()).ToString("yyyy-MM-dd")); MySqlDataAdapter da1 = new MySqlDataAdapter(cmd1); DataTable table2 = new DataTable("Discharged"); da1.Fill(table2); DataSet ds1 = new DataSet(); ds1.Tables.Add(table2); rds1.Name = "DataSet2"; rds1.Value = table2; var path = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var subFolderPath = Path.Combine(path, "OCC Reports"); if (!System.IO.Directory.Exists(subFolderPath)) { System.IO.Directory.CreateDirectory(subFolderPath); } var cur_folder = DateTime.Now.ToString("dd-MM-yyyy"); subFolderPath = subFolderPath + "//" + cur_folder; if (!System.IO.Directory.Exists(subFolderPath)) { System.IO.Directory.CreateDirectory(subFolderPath); } wanted_path = subFolderPath; rp[0] = new ReportParameter("Date", DateTime.Now.ToShortDateString()); rp[1] = new ReportParameter("CenterType", DailyReports.centerType); rp[2] = new ReportParameter("CenterName", DailyReports.centerName); rp[3] = new ReportParameter("FilteredBy", "Daily"); }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } string path = System.IO.Path.GetDirectoryName(Application.ExecutablePath); ReportViewer1.LocalReport.ReportPath = path + "\\Report1.rdlc"; ReportViewer1.LocalReport.SetParameters(rp); ReportViewer1.LocalReport.DataSources.Add(rds); ReportViewer1.LocalReport.DataSources.Add(rds1); ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout); ReportViewer1.LocalReport.Refresh(); pb.Close(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }
private void saveDetails() { PleaseWait pb = new PleaseWait(); BackgroundWorker bwConn = new BackgroundWorker(); bwConn.DoWork += (sender, e) => { if (!validation()) { MessageBox.Show("Please fill all fields !!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (status.Equals("ADD NEW")) { DialogResult drs = MessageBox.Show("Are You Sure Do You Want To Add This Patient's Remark ??", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drs == DialogResult.No) { return; } MySqlConnection cn = new MySqlConnection(); cn.ConnectionString = DbConnect.conString; cn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; string[] address = txtadd.Text.Split(','); int flag = 1; if (txtremark.Text == "Discharged") { flag = 0; string bedname = getBedDetails("SELECT BedName From Patients WHERE Name='" + txtname.Text + "' and ContactNo='" + txtcontact.Text + "'"); string WardCode = getBedDetails("SELECT WardCode From Patients WHERE Name='" + txtname.Text + "' and ContactNo='" + txtcontact.Text + "'"); cmd.CommandText = "UPDATE Beds SET Flag=0 WHERE BedName='" + bedname + "' and WardCode='" + WardCode + "'"; cmd.ExecuteNonQuery(); } cmd.CommandText = "INSERT INTO PatientsRemark (Name,ContactNo,Gender,Address,Age,AdharCard,Date,Remark,CenterType,CenterName,CreatedBy,CreatedAt,Area,District,Flag) VALUES ('" + txtname.Text + "','" + txtcontact.Text + "','" + gender + "','" + txtadd.Text + "'," + txtage.Text + ",'" + txtadhar.Text + "',@date,'" + txtremark.Text + "','" + centerType + "','" + centerName + "','" + created_by + "','" + DateTime.Now.ToString("hh:mm:ss tt") + "','" + address[0] + "','" + address[1] + "'," + flag + ")"; cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtdate.Text).ToString("yyyy-MM-dd")); cmd.ExecuteNonQuery(); cmd.Parameters.Clear(); MessageBox.Show("Patient's Remark Added Successfully !!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cn.Close(); } else if (status.Equals("UPDATE")) { MySqlConnection cn = new MySqlConnection(); cn.ConnectionString = DbConnect.conString; cn.Open(); DialogResult drs = MessageBox.Show("Are You Sure Do You Want To Update This Patient's Remark ??", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (drs == DialogResult.No) { return; } MySqlCommand cmd = new MySqlCommand(); cmd.Connection = cn; cmd.CommandType = CommandType.Text; int flag = 1; if (txtremark.Text == "Discharged") { flag = 0; string bedname = getBedDetails("SELECT BedName From Patients WHERE Name='" + txtname.Text + "' and ContactNo='" + txtcontact.Text + "'"); string WardCode = getBedDetails("SELECT WardCode From Patients WHERE Name='" + txtname.Text + "' and ContactNo='" + txtcontact.Text + "'"); cmd.CommandText = "UPDATE Beds SET Flag=0 WHERE BedName='" + bedname + "' and WardCode='" + WardCode + "'"; cmd.ExecuteNonQuery(); } cmd.CommandText = "UPDATE PatientsRemark SET Name='" + txtname.Text + "',ContactNo='" + txtcontact.Text + "',Gender='" + gender + "',Address='" + txtadd.Text + "',Age=" + txtage.Text + ",AdharCard='" + txtadhar.Text + "',Date=@date,Remark='" + txtremark.Text + "',CenterType='" + centerType + "',CenterName='" + centerName + "',CreatedBy='" + created_by + "',CreatedAt='" + DateTime.Now.ToString("hh:mm:ss tt") + "',Flag=" + flag + " WHERE ID=" + lbid.Text; cmd.Parameters.AddWithValue("@date", DateTime.Parse(txtdate.Text).ToString("yyyy-MM-dd")); cmd.ExecuteNonQuery(); MessageBox.Show("Patient's Remark Updated Successfully !!!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); cn.Close(); } }; bwConn.RunWorkerCompleted += (sender, e) => { if (e.Error != null) { MessageBox.Show(e.Error.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } pb.Close(); clearAll(); actionButtonNormalStage(); unlockAll(false); fillgrid(); }; bwConn.RunWorkerAsync(); pb.ShowDialog(); }