コード例 #1
0
ファイル: hardwareMovement.cs プロジェクト: enccdz/IT-Manager
        void AddHardware()
        {
            if (MYSQLConnect.IsConnected(MYSQLConnect.addSlash("Insert into hardwaremovement VALUES (NULL, '" +
                                                               mainForm.userList[userComboBox.SelectedIndex].Id + "','" +
                                                               hardwareIdTxt.Text + "','" +
                                                               mainForm.hardwareStateList[statusComboBox.SelectedIndex].id + "'," + "NOW(), NULL)"), true))
            {
                // empty text boxes
                foreach (Control c in hardwareMovementFormContainer.Controls)
                {
                    if (c.GetType() == typeof(DevExpress.XtraEditors.TextEdit) ||
                        c.GetType() == typeof(DevExpress.XtraEditors.ComboBoxEdit))
                    {
                        c.Text = "";
                    }
                }

                LoadHardwareMovements();

                MessageBox.Show("movement added successfully");
            }
            else
            {
                MessageBox.Show("an error has occured during insertion");
            }
        }
コード例 #2
0
        private void AddAdmin()
        {
            if (MYSQLConnect.IsConnected("Insert into admin VALUES (NULL, '" +
                                         MYSQLConnect.addSlash(fullNameTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(userTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(passTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(roleComboBox.Text) + "',NOW())", true))
            {
                // empty text boxes
                foreach (Control c in AdminFormContainer.Controls)
                {
                    if (c.GetType() == typeof(DevExpress.XtraEditors.TextEdit) ||
                        c.GetType() == typeof(DevExpress.XtraEditors.ComboBoxEdit))
                    {
                        c.Text = "";
                    } /*else if(c.GetType() == typeof(DevExpress.XtraEditors.ComboBoxEdit))
                       * {
                       * c.Text = "";
                       * }*/
                }

                LoadAdmins(); // refresh list

                MessageBox.Show("admin added successfully");
            }
            else
            {
                MessageBox.Show("an error has occured during insertion");
            }
        }
コード例 #3
0
ファイル: settingUsers.cs プロジェクト: enccdz/IT-Manager
        private void AddUser()
        {
            if (MYSQLConnect.IsConnected("Insert into user VALUES (NULL, '" +
                                         MYSQLConnect.addSlash(userNameTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(passwordTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(fulNameTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(emailTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(localEmailTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(numTelTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(directionTxt.Text) + "','" +
                                         MYSQLConnect.addSlash(jobTxt.Text) + "',NOW())", true))
            {
                // empty text boxes
                foreach (Control c in AddUserFormContainer.Controls)
                {
                    if (c.GetType() == typeof(DevExpress.XtraEditors.TextEdit))
                    {
                        c.Text = "";
                    }
                }

                LoadUser(); // refresh list

                MessageBox.Show("user added successfully");
            }
            else
            {
                MessageBox.Show("an error has occured during insertion");
            }
        }
コード例 #4
0
        // ---- SQL operations ----
        private void LoadAdmins()
        {
            adminList = new DataTable();
            adminList.Columns.Add("Id");
            adminList.Columns.Add("Fullname");
            adminList.Columns.Add("Username");
            adminList.Columns.Add("Password");
            adminList.Columns.Add("Role");
            adminList.Columns.Add("Creation date");

            if (MYSQLConnect.IsConnected("SELECT * FROM `admin` ", false))
            {
                if (MYSQLConnect.myDR.HasRows)
                {
                    while (MYSQLConnect.myDR.Read())
                    {
                        DataRow tr = adminList.NewRow();
                        for (int i = 0; i < adminList.Columns.Count; i++)
                        {
                            tr[i] = MYSQLConnect.myDR.GetString(i);
                        }
                        adminList.Rows.Add(tr);
                    }

                    adminsGrid.DataSource = adminList;
                }
            }
        }
コード例 #5
0
        // SQL operations -----------------------------

        void AddHardware()
        {
            if (MYSQLConnect.IsConnected(MYSQLConnect.addSlash("Insert into hardware VALUES (NULL, '" +
                                                               mainForm.hardwareTypeList[typeComboBox.SelectedIndex].id + "','" +
                                                               mainForm.hardwareStateList[stateComboBox.SelectedIndex].id + "','" +
                                                               officeTxt.Text + "','" +
                                                               inventoryCodeTxt.Text + "','" +
                                                               serialTxt.Text + "','" +
                                                               manufacturerTxt.Text + "','" +
                                                               modelTxt.Text + "','" +
                                                               descriptionTxt.Text + "',NOW())"), true))
            {
                // empty text boxes
                foreach (Control c in addhardwareFormContainer.Controls)
                {
                    if (c.GetType() == typeof(DevExpress.XtraEditors.TextEdit) ||
                        c.GetType() == typeof(DevExpress.XtraEditors.ComboBoxEdit))
                    {
                        c.Text = "";
                    }
                }

                MessageBox.Show("hardware added successfully");
            }
            else
            {
                MessageBox.Show("an error has occured during insertion");
            }
        }
コード例 #6
0
ファイル: settingUsers.cs プロジェクト: enccdz/IT-Manager
        private void RemoveUser(string userId)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete ?", "Remove confirmation message", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                MYSQLConnect.IsConnected("DELETE FROM `user` WHERE Id = '" + MYSQLConnect.addSlash(userId) + "' LIMIT 1;", true);
                LoadUser();
            }
        }
コード例 #7
0
ファイル: settingUsers.cs プロジェクト: enccdz/IT-Manager
        private void EditUser(string userId)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to edit ?", "Edit confirmation message", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                if (MYSQLConnect.IsConnected("UPDATE user SET" +
                                             " username='******'," +
                                             " password='******'," +
                                             " fullname='" + MYSQLConnect.addSlash(fulNameTxt.Text) + "'," +
                                             " email='" + MYSQLConnect.addSlash(emailTxt.Text) + "'," +
                                             " localemail='" + MYSQLConnect.addSlash(localEmailTxt.Text) + "'," +
                                             " phone='" + MYSQLConnect.addSlash(numTelTxt.Text) + "'," +
                                             " direction='" + MYSQLConnect.addSlash(directionTxt.Text) + "'," +
                                             " job='" + MYSQLConnect.addSlash(jobTxt.Text) + "'" +
                                             " WHERE user.id = '" + MYSQLConnect.addSlash(userId) + "' Limit 1;" +
                                             "", true))
                {
                    // empty text boxes
                    foreach (Control c in AddUserFormContainer.Controls)
                    {
                        if (c.GetType() == typeof(DevExpress.XtraEditors.TextEdit))
                        {
                            c.Text = "";
                        }
                    }

                    LoadUser(); // refresh list

                    addUserBtn.Text = "Add user";
                    isEdit          = false;

                    MessageBox.Show("user updated successfully");
                }
                else
                {
                    MessageBox.Show("an error has occured during update");
                }
            }
        }
コード例 #8
0
ファイル: settingUsers.cs プロジェクト: enccdz/IT-Manager
        // ----- SQL Operations -----
        private void LoadUser()
        {
            userList = new DataTable();
            userList.Columns.Add("Id");
            userList.Columns.Add("Username");
            userList.Columns.Add("Password");
            userList.Columns.Add("Fullname");
            userList.Columns.Add("Email");
            userList.Columns.Add("Local email");
            userList.Columns.Add("Phone");
            userList.Columns.Add("Direction");
            userList.Columns.Add("Job");
            userList.Columns.Add("Entry date");

            if (MYSQLConnect.IsConnected("SELECT * FROM `user` ", false))
            {
                if (MYSQLConnect.myDR.HasRows)
                {
                    while (MYSQLConnect.myDR.Read())
                    {
                        //badge1.Visible = false;
                        DataRow tr = userList.NewRow();
                        for (int i = 0; i < userList.Columns.Count; i++)
                        {
                            tr[i] = MYSQLConnect.myDR.GetString(i);
                        }

                        userList.Rows.Add(tr);

                        //MessageBox.Show(MYSQLConnect.myDR.GetString("date"));//MYSQLConnect.myDR.GetString(1)
                    }

                    usersGrid.DataSource = userList;
                    // usersGrid.
                }
            }
        }