예제 #1
0
        private void btn_upgrade_Click_1(object sender, EventArgs e)
        {
            Cursor oCursor = Cursors.WaitCursor;

            try
            {
                if (rdb_OD.Checked || rdb_FD.Checked || rdb_PW.Checked)
                {
                    if (string.IsNullOrEmpty(txtdatabase.Text) || string.IsNullOrEmpty(txtserver.Text) || string.IsNullOrEmpty(txtusername.Text))
                    {
                        oCursor = Cursors.Default;
                        MessageBox.Show("Please enter database details.", "HRDsq Plugin", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    //  btn_upgrade.Enabled = false;

                    EnCryptDecryptEngine _objED = new EnCryptDecryptEngine();

                    if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\config.txt"))
                    {
                        File.Delete(AppDomain.CurrentDomain.BaseDirectory + "\\config.txt");
                    }

                    string dbcontents = "", port = "", server = "";

                    if (txtserver.Text.Contains(":"))
                    {
                        port = (txtserver.Text.Split(new string[] { ":" }, StringSplitOptions.None)[1]).Split(' ')[0].ToString();

                        server = (txtserver.Text.Split(new string[] { ":" }, StringSplitOptions.None)[0]).Split(' ')[0].ToString();
                    }
                    else
                    {
                        server = txtserver.Text;
                        port   = "3306";
                    }


                    string connection = "server=" + server + ";user id=" + txtusername.Text + "; password="******";database=" + txtdatabase.Text + ";SslMode=none" + ";" + "Port=" + port + ";" + "AllowZeroDateTime=True;" + "AllowUserVariables=True; pooling=false " + "";


                    Library.WriteErrorLog(connection + "jsdhvksv");
                    try
                    {
                        using (MySqlConnection con = new MySqlConnection(connection))
                        {
                            con.Open();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Not able to connect to specified database.", "HRDsq Plugin", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    dbcontents = _objED.Encrypt(txtdatabase.Text.ToString().Trim(), true) + Environment.NewLine + _objED.Encrypt(server.Trim(), true) + Environment.NewLine + _objED.Encrypt(txtusername.Text.ToString().Trim(), true) + Environment.NewLine + _objED.Encrypt(txtpass.Text.ToString(), true) + Environment.NewLine + _objED.Encrypt(port.Trim(), true);

                    StreamWriter sw = null;

                    try
                    {
                        sw = new StreamWriter(AppDomain.CurrentDomain.BaseDirectory + "\\config.txt", true);
                        sw.WriteLine(dbcontents);
                        sw.Flush();
                        sw.Close();

                        ContextMenus cc = new ContextMenus();
                        cc.Restart_Click(null, null);
                        this.Close();
                    }

                    catch (Exception ex)
                    {
                        btn_upgrade.Enabled = true;
                        oCursor             = Cursors.Default;


                        MessageBox.Show("Something when wrong.." + Environment.NewLine + ex.Message + Environment.NewLine + ex.StackTrace, "HRDsq Plugin", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }

            catch (Exception ex)
            {
                btn_upgrade.Enabled = true;
                Library.WriteErrorLog(ex.Message);
            }
        }
예제 #2
0
        private void tabControlsetting_Selected(object sender, TabControlEventArgs e)
        {
            //  MessageBox.Show("Outside if");
            if (e.TabPage.Text.ToString().ToLower() == "incoming popup")
            {
                //  MessageBox.Show("Inside evnet");
                string query = "select TaskDock from computerpref where computerName='" + Environment.MachineName + "_hrdsq_service'";
                DentalPlugin.Connection connection = new DentalPlugin.Connection();

                this.command = query;

                tbxIncomingTimer.Text = Convert.ToString(connection.ExecuteScalar(this.command, CommandType.Text, (MySqlParameter[])null));
            }


            else if (e.TabPage.Text.ToString().ToLower() == "database")
            {
                try
                {
                    EnCryptDecryptEngine _objED = new EnCryptDecryptEngine();

                    if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\config.txt"))
                    {
                        fcontent = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "\\config.txt");
                        using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "\\config.txt"))
                        {
                            string line;
                            int    i = 1;
                            while ((line = sr.ReadLine()) != null)
                            {
                                if (i == 1)
                                {
                                    dbname = line.ToString().Trim();
                                }
                                else if (i == 2)
                                {
                                    dbhost = line.ToString().Trim();
                                }
                                else if (i == 3)
                                {
                                    dbusername = line.ToString().Trim();
                                }
                                else if (i == 4)
                                {
                                    dbpass = line.ToString().Trim();
                                }
                                else if (i == 5)
                                {
                                    dbport = line.ToString().Trim();
                                }
                                i++;


                                string Server = _objED.Decrypt(dbhost, true);

                                string port = _objED.Decrypt(dbport, true);

                                txtserver.Text = Server + ":" + port;

                                txtdatabase.Text = _objED.Decrypt(dbname, true);
                                txtpass.Text     = _objED.Decrypt(dbpass, true);
                                txtusername.Text = _objED.Decrypt(dbusername, true);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Library.WriteErrorLog(ex.Message);
                }
            }

            else if (e.TabPage.Text.ToString().ToLower() == "exclude operatory")
            {
                if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "\\config.txt"))
                {
                    if (radCheckedDropDownList1.DataSource == null)
                    {
                        Connection conn   = new Connection();
                        string     Qry    = "SELECT operatorynum , OpName from operatory";
                        DataTable  dtLang = conn.GetDataSet(Qry.ToString().Trim(), CommandType.Text, null).Tables[0];

                        if (dtLang.Rows.Count > 0)
                        {
                            foreach (DataRow dr in dtLang.Rows)
                            {
                                if (!string.IsNullOrEmpty(Convert.ToString(dr["OpName"].ToString())))
                                {
                                    OpList.Add(new Operatory
                                    {
                                        operatorynum = Convert.ToInt64(dr["OperatoryNum"].ToString()),
                                        OpName       = Convert.ToString(dr["OpName"].ToString()),
                                    });
                                }
                            }
                        }
                        radCheckedDropDownList1.DataSource    = null;
                        radCheckedDropDownList1.DisplayMember = "OpName";
                        radCheckedDropDownList1.ValueMember   = "operatorynum";

                        radCheckedDropDownList1.DataSource = OpList.ToList();

                        //=================================================================================================
                        string command = "select valuestring from preference where prefname ='px_exclude_op_confirmation&remainder' ";
                        string data    = Convert.ToString(conn.ExecuteScalar(command.ToString().Trim(), CommandType.Text, null));

                        if (data != null && data != "")
                        {
                            //Checking all the Default form items
                            string[] fff = data.Split(',');
                            for (int i = 0; i < fff.Count(); i++)
                            {
                                int index = radCheckedDropDownList1.Items.Where(a => a.Value.ToString().Equals(fff[i])).Select(a => a.Index).FirstOrDefault();
                                this.radCheckedDropDownList1.Items[index].Checked = true;
                            }
                        }
                    }
                }
            }
        }