Beispiel #1
0
        ///<summary></summary>
        public static void Refresh()
        {
            try {
                if (RemotingClient.OpenDentBusinessIsLocal)
                {
                    UserodB.Refresh();
                }
                else
                {
                    DtoUserodRefresh dto = new DtoUserodRefresh();
                    DataSet          ds  = RemotingClient.ProcessQuery(dto);
                    UserodB.RawData = ds.Tables[0];
                }
            }
            catch (Exception e) {
                MessageBox.Show(e.Message);
                return;
            }
            Listt = new List <Userod>();         //[UserB.RawData.Rows.Count];
            Userod user;

            for (int i = 0; i < UserodB.RawData.Rows.Count; i++)
            {
                user              = new Userod();
                user.UserNum      = PIn.PInt(UserodB.RawData.Rows[i][0].ToString());
                user.UserName     = PIn.PString(UserodB.RawData.Rows[i][1].ToString());
                user.Password     = PIn.PString(UserodB.RawData.Rows[i][2].ToString());
                user.UserGroupNum = PIn.PInt(UserodB.RawData.Rows[i][3].ToString());
                user.EmployeeNum  = PIn.PInt(UserodB.RawData.Rows[i][4].ToString());
                Listt.Add(user);
            }
        }
Beispiel #2
0
 private void treeUsers_DoubleClick(object sender, System.EventArgs e)
 {
     if (treeUsers.SelectedNode == null)
     {
         return;
     }
     treeUsers.ExpandAll();
     if (treeUsers.SelectedNode.Parent == null)          //group
     {
         UserGroup         group = UserGroups.List[treeUsers.SelectedNode.Index];
         FormUserGroupEdit FormU = new FormUserGroupEdit(group);
         FormU.ShowDialog();
         if (FormU.DialogResult == DialogResult.Cancel)
         {
             return;
         }
         FillTreeUsers();
         //reselect group
         for (int i = 0; i < treeUsers.Nodes.Count; i++)
         {
             if ((int)treeUsers.Nodes[i].Tag == group.UserGroupNum)
             {
                 treeUsers.SelectedNode = treeUsers.Nodes[i];
                 SelectedGroupNum       = group.UserGroupNum;
             }
         }
     }
     else             //user
     {
         Userod       user  = UserodB.GetUser((int)treeUsers.SelectedNode.Tag);
         FormUserEdit FormU = new FormUserEdit(user);
         FormU.ShowDialog();
         if (FormU.DialogResult == DialogResult.Cancel)
         {
             return;
         }
         FillTreeUsers();
         for (int i = 0; i < treeUsers.Nodes.Count; i++)
         {
             for (int j = 0; j < treeUsers.Nodes[i].Nodes.Count; j++)
             {
                 if ((int)treeUsers.Nodes[i].Nodes[j].Tag == FormU.UserCur.UserNum)
                 {
                     treeUsers.SelectedNode = treeUsers.Nodes[i].Nodes[j];
                     SelectedGroupNum       = FormU.UserCur.UserGroupNum;
                 }
             }
         }
     }
     FillTreePerm();
     changed = true;
 }
Beispiel #3
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     Debug.WriteLine(UserodB.EncryptPassword(textMasterPass.Text));
     if (!UserodB.CheckPassword(textMasterPass.Text, masterHash))
     {
         MessageBox.Show(Lan.g(this, "Master password incorrect."));
         return;
     }
     Security.ResetPassword();
     //PermissionsOld.Refresh();
     //MessageBox.Show(Lan.g(this,"Security Administration permission has been reset."));
     //DialogResult=DialogResult.OK;
 }
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textPassword.Text == "")
     {
         hashedResult = "";
     }
     else
     {
         hashedResult = UserodB.EncryptPassword(textPassword.Text);
     }
     //MessageBox.Show(hashedResult);
     DialogResult = DialogResult.OK;
 }
Beispiel #5
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (Userods.Listt[listUser.SelectedIndex].Password != "")
     {
         if (!UserodB.CheckPassword(textPassword.Text, Userods.Listt[listUser.SelectedIndex].Password))
         {
             MsgBox.Show(this, "Incorrect password");
             return;
         }
     }
     Security.CurUser = Userods.Listt[listUser.SelectedIndex].Copy();
     //SecurityLogs.MakeLogEntry(Permissions.StartupSingleUser,"");
     DialogResult = DialogResult.OK;
 }
Beispiel #6
0
        ///<summary>DataSet cannot be null.</summary>
        public static DataSet ProcessQuery(DtoQueryBase dto)
        {
            if (dto.GetType() == typeof(DtoGeneralGetTable))
            {
                return(GeneralB.GetTable(((DtoGeneralGetTable)dto).Command));
            }
            else if (dto.GetType() == typeof(DtoGeneralGetTableLow))
            {
                return(GeneralB.GetTableLow(((DtoGeneralGetTableLow)dto).Command));
            }
            else if (dto.GetType() == typeof(DtoGeneralGetDataSet))
            {
                return(GeneralB.GetDataSet(((DtoGeneralGetDataSet)dto).Commands));
            }
            else if (dto.GetType() == typeof(DtoAccountModuleGetAll))
            {
                return(AccountModuleB.GetAll(((DtoAccountModuleGetAll)dto).PatNum));
            }
            else if (dto.GetType() == typeof(DtoChartModuleGetAll))
            {
                return(ChartModuleB.GetAll(((DtoChartModuleGetAll)dto).PatNum, ((DtoChartModuleGetAll)dto).IsAuditMode));
            }
            else if (dto.GetType() == typeof(DtoCovCatRefresh))
            {
                return(CovCatB.Refresh());
            }
            else if (dto.GetType() == typeof(DtoDefRefresh))
            {
                return(DefB.Refresh());
            }
            else if (dto.GetType() == typeof(DtoPrefRefresh))
            {
                return(PrefB.Refresh());
            }
            else if (dto.GetType() == typeof(DtoProcedureRefresh))
            {
                return(ProcedureB.Refresh(((DtoProcedureRefresh)dto).PatNum));
            }
            else if (dto.GetType() == typeof(DtoUserodRefresh))
            {
                return(UserodB.Refresh());
            }


            else
            {
                throw new Exception("OpenDentServer.BusinessLayer.ProcessObject(dto) is missing a case for "
                                    + dto.GetType().ToString());
            }
        }
Beispiel #7
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            Userod selectedUser = (Userod)listUser.SelectedItem;

            if (selectedUser.Password != "")
            {
                if (!UserodB.CheckPassword(textPassword.Text, selectedUser.Password))
                {
                    MsgBox.Show(this, "Incorrect password");
                    return;
                }
            }
            Security.CurUser = selectedUser.Copy();
            DialogResult     = DialogResult.OK;
        }
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textPassword.Text != textPasswordAgain.Text)
     {
         MsgBox.Show(this, "Passwords do not match.");
         return;
     }
     if (textPassword.Text == "")
     {
         hashedResult = "";
     }
     else
     {
         hashedResult = UserodB.EncryptPassword(textPassword.Text);
     }
     //MessageBox.Show(hashedResult);
     DialogResult = DialogResult.OK;
 }
        public static int Login(string database, string oduser, string odpasshash)
        {
            //Get the database server, user, and password from the config file
            //make sure there's an entry for the requested database:
            XPathNavigator navConn = Navigator.SelectSingleNode("//DatabaseConnection[Database='" + database + "']");

            if (navConn == null)
            {
                throw new Exception(database + " is not an allowed database.");
            }
            //return navOne.SelectSingleNode("summary").Value;
            //now, get the values for this connection
            string         server           = navConn.SelectSingleNode("ComputerName").Value;
            string         mysqlUser        = navConn.SelectSingleNode("User").Value;
            string         mysqlPassword    = navConn.SelectSingleNode("Password").Value;
            string         mysqlUserLow     = navConn.SelectSingleNode("UserLow").Value;
            string         mysqlPasswordLow = navConn.SelectSingleNode("PasswordLow").Value;
            XPathNavigator dbTypeNav        = navConn.SelectSingleNode("DatabaseType");
            DatabaseType   dbtype           = DatabaseType.MySql;

            if (dbTypeNav != null)
            {
                if (dbTypeNav.Value == "Oracle")
                {
                    dbtype = DatabaseType.Oracle;
                }
            }
            DataConnection dcon = new DataConnection();

            //Try to connect to the database
            try {
                dcon.SetDb(server, database, mysqlUser, mysqlPassword, mysqlUserLow, mysqlPasswordLow, dbtype);
                Console.WriteLine(oduser);
            }
            catch {
                throw new Exception(@"Connection to database failed.  Check the values in the config file on the server, usually at C:\Program Files\Open Dental Server\OpenDentServerConfig.xml");
            }
            //Then, check username and password
            if (!UserodB.CheckUserAndPassword(oduser, odpasshash))
            {
                throw new Exception("Invalid username or password.");
            }
            return(0);           //meaningless
        }
Beispiel #10
0
        private void treeUsers_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            TreeNode clickedNode = treeUsers.GetNodeAt(e.X, e.Y);

            if (clickedNode == null)
            {
                return;
            }
            SelectedGroupNum = 0;
            if (clickedNode.Parent == null)          //group
            {
                SelectedGroupNum = (int)clickedNode.Tag;
            }
            else             //user
            {
                SelectedGroupNum = UserodB.GetUser((int)clickedNode.Tag).UserGroupNum;
            }
            FillTreePerm();
        }
Beispiel #11
0
        private void FillGrid()
        {
            SecurityLog[] logList = SecurityLogs.Refresh(PatNum, PermTypes);
            grid.BeginUpdate();
            grid.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < logList.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(logList[i].LogDateTime.ToShortDateString() + " " + logList[i].LogDateTime.ToShortTimeString());
                row.Cells.Add(UserodB.GetUser(logList[i].UserNum).UserName);
                row.Cells.Add(logList[i].PermType.ToString());
                row.Cells.Add(logList[i].LogText);
                grid.Rows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollToEnd();
        }
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            Userod       user  = UserodB.GetUser(PIn.PInt(table.Rows[e.Row]["UserNum"].ToString()));
            FormUserEdit FormU = new FormUserEdit(user);

            FormU.ShowDialog();
            if (FormU.DialogResult == DialogResult.Cancel)
            {
                return;
            }
            FillUsers();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (table.Rows[i]["UserNum"].ToString() == FormU.UserCur.UserNum.ToString())
                {
                    gridMain.SetSelected(i, true);
                    SelectedGroupNum = FormU.UserCur.UserGroupNum;
                }
            }
            FillTreePerm();
            changed = true;
        }
Beispiel #13
0
        private void FillGrid()
        {
            int userNum = 0;

            if (comboUser.SelectedIndex > 0)
            {
                userNum = Userods.Listt[comboUser.SelectedIndex - 1].UserNum;
            }
            SecurityLog[] logList = SecurityLogs.Refresh(PIn.PDate(textDateFrom.Text), PIn.PDate(textDateTo.Text),
                                                         (Permissions)comboPermission.SelectedIndex, PatNum, userNum);
            grid.BeginUpdate();
            grid.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableAudit", "Date Time"), 120);

            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "User"), 70);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "Permission"), 110);
            grid.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableAudit", "Log Text"), 570);
            grid.Columns.Add(col);
            grid.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < logList.Length; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(logList[i].LogDateTime.ToShortDateString() + " " + logList[i].LogDateTime.ToShortTimeString());
                row.Cells.Add(UserodB.GetUser(logList[i].UserNum).UserName);
                row.Cells.Add(logList[i].PermType.ToString());
                row.Cells.Add(logList[i].LogText);
                grid.Rows.Add(row);
            }
            grid.EndUpdate();
            grid.ScrollToEnd();
        }
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (checkConnectServer.Checked)
     {
         if (textPort.errorProvider1.GetError(textPort) != "")
         {
             MsgBox.Show(this, "Please fix data entry errors first.");
             return;
         }
         string originalServer = RemotingClient.ServerName;
         int    originalPort   = RemotingClient.ServerPort;
         RemotingClient.ServerName = comboServerName2.Text;
         RemotingClient.ServerPort = PIn.PInt(textPort.Text);
         DtoLogin dto = new DtoLogin();
         dto.Database   = comboDatabase2.Text;
         dto.OdUser     = textUser2.Text;
         dto.OdPassHash = UserodB.EncryptPassword(textPassword2.Text);
         try{
             RemotingClient.ProcessCommand(dto);
             RemotingClient.OpenDentBusinessIsLocal = false;
         }
         catch (Exception ex) {
             RemotingClient.ServerName = originalServer;
             RemotingClient.ServerPort = originalPort;
             MessageBox.Show(ex.Message);
             return;
         }
     }
     else
     {
         OpenDentBusiness.DataConnection dcon;
         //Try to connect to the database directly
         try {
             DBtype = DatabaseType.MySql;
             if (listType.SelectedIndex == 1)
             {
                 DBtype = DatabaseType.Oracle;
             }
             dcon = new OpenDentBusiness.DataConnection(DBtype);
             if (textConnectionString.Text.Length > 0)
             {
                 dcon.SetDb(textConnectionString.Text, "", DBtype);
             }
             else
             {
                 dcon.SetDb(comboComputerName.Text, comboDatabase.Text, textUser.Text, textPassword.Text, "", "", DBtype);
             }
             //a direct connection does not utilize lower privileges.
         }
         catch (Exception ex) {
             MessageBox.Show(                    //Lan.g(this,"Could not establish connection to database."));
                 ex.Message);
             return;
         }
         RemotingClient.OpenDentBusinessIsLocal = true;
     }
     try{
         XmlWriterSettings settings = new XmlWriterSettings();
         settings.Indent      = true;
         settings.IndentChars = ("    ");
         using (XmlWriter writer = XmlWriter.Create("FreeDentalConfig.xml", settings)) {
             writer.WriteStartElement("ConnectionSettings");
             if (RemotingClient.OpenDentBusinessIsLocal)
             {
                 writer.WriteStartElement("DatabaseConnection");
                 writer.WriteStartElement("ComputerName");
                 writer.WriteString(comboComputerName.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Database");
                 writer.WriteString(comboDatabase.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("User");
                 writer.WriteString(textUser.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Password");
                 writer.WriteString(textPassword.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("NoShowOnStartup");
                 if (checkNoShow.Checked)
                 {
                     writer.WriteString("True");
                 }
                 else
                 {
                     writer.WriteString("False");
                 }
                 writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             else
             {
                 writer.WriteStartElement("ServerConnection");
                 writer.WriteStartElement("ComputerName");
                 writer.WriteString(comboServerName2.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("ServerPort");
                 writer.WriteString(textPort.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Database");
                 writer.WriteString(comboDatabase2.Text);
                 writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             writer.WriteStartElement("DatabaseType");
             if (listType.SelectedIndex == 0)
             {
                 writer.WriteString("MySql");
             }
             else
             {
                 writer.WriteString("Oracle");
             }
             writer.WriteEndElement();
             writer.WriteEndElement();
             writer.Flush();
         }                //using writer
     }
     catch {
         //data not saved.
     }
     //fyiReporting.RDL.DataSource.SetOpenDentalConnectionString(
     //	"Server="+ComputerName+";Database="+Database+";User ID="+DbUser+";Password="******";CharSet=utf8");
     DialogResult = DialogResult.OK;
 }