コード例 #1
0
ファイル: Login.cs プロジェクト: surajleadsoft/OCC
        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();
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: Login.cs プロジェクト: surajleadsoft/OCC
        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();
        }
コード例 #5
0
ファイル: AllEmails.cs プロジェクト: surajleadsoft/OCC
        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();
                pb.Dispose();
            };
            bwConn.RunWorkerAsync();
            pb.ShowDialog();
        }