Пример #1
0
        private void frmEdit_Load(object sender, EventArgs e)
        {
            db = new Database();
            sql = "SELECT * FROM Tickets WHERE id='"+id+"'";
            reader = db.query(sql);
            reader.Read();

            txtAddress.Text = reader["address"].ToString();
            txtCity.Text = reader["city"].ToString();

            //Needs to seperate with comma for names
            string first = reader["name"].ToString().Split(new char[] { ',' })[0].Replace("''", "'");
            string last = reader["name"].ToString().Split(new char[] { ',' })[1].Trim().Replace("''", "'");
            txtFirstName.Text = first;
            txtLastName.Text = last;

            txtModel.Text = reader["model"].ToString().Replace("''", "'");
            txtPhone.Text = reader["phone"].ToString().Replace("''", "'");
            txtProblem.Text = reader["issue"].ToString().Replace("''", "'");
            txtSolution.Text = reader["solution"].ToString().Replace("''", "'");
            txtState.Text = reader["state"].ToString().Replace("''", "'");
            txtZip.Text = reader["zip"].ToString().Replace("''", "'");
            txtMaker.Text = reader["computer"].ToString().Replace("''", "'");
            cbFixed.Text = Convert.ToBoolean(reader["fixed"])? "Yes":"No";
            cbOS.Text = reader["os"].ToString().Replace("''", "'");
            cbType.Text = reader["type"].ToString().Replace("''", "'");
            txtDate.Text = DateTime.Parse(reader["date"].ToString().Replace("''", "'")).ToString("d");

            //Info for creator USING like operator
            sql = "SELECT * FROM Users WHERE tickets LIKE '%, " + id + ", %'";
            SqlDataReader crea = db.query(sql);
            crea.Read();
            txtCreator.Text = crea["name"].ToString().Replace("''", "'");
        }
Пример #2
0
        private void frmUsers_Load(object sender, EventArgs e)
        {
            db = new Database();
            sql = "SELECT * FROM Users";
            reader = db.query(sql);
            string[] test;
            while (reader.Read())
            {
                string tickets;
                if(reader["tickets"].ToString().Length > 2)
                {
                    tickets = reader["tickets"].ToString().Replace("''", "'").Substring(2, reader["tickets"].ToString().Replace("''", "'").Length-2);
                } else
                    tickets = "";
                test = new string[] { reader["id"].ToString(),
                    reader["name"].ToString().Replace("''", "'"),
                    reader["username"].ToString().Replace("''", "'"),
                    tickets,
                    reader["level"].ToString().Replace("''", "'"),
                    DateTime.Parse(reader["lastLogin"].ToString().Replace("''", "'")).ToString("d"),
                    reader["ip"].ToString().Replace("''", "'") };
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dataGridView1, test);
                dataGridView1.Rows.Add(row);
            }

            dataGridView1.AutoResizeColumns();
            dataGridView1.AutoResizeRows();

            SelectedId = dataGridView1.FirstDisplayedCell.Value.ToString();
        }
Пример #3
0
 private void frmCreate_Load(object sender, EventArgs e)
 {
     db = new Database();
     txtFirstName.Focus();
 }
Пример #4
0
 public User()
 {
     db = new Database();
 }
Пример #5
0
        private void frmBrowse_Load(object sender, EventArgs e)
        {
            db = new Database();
            sql = "SELECT * FROM Tickets";
            reader = db.query(sql);
            string[] test;
            while (reader.Read())
            {
                string fixedIt = "No";
                if (Convert.ToBoolean(reader["fixed"]))
                {
                    fixedIt = "Yes";
                }
                test = new string[] { reader["id"].ToString(), reader["name"].ToString().Replace("''", "'"), reader["phone"].ToString().Replace("''", "'"), reader["address"].ToString().Replace("''", "'"), reader["city"].ToString().Replace("''", "'"), reader["state"].ToString().Replace("''", "'"), reader["zip"].ToString().Replace("''", "'"), reader["computer"].ToString().Replace("''", "'"), reader["type"].ToString().Replace("''", "'"), reader["os"].ToString().Replace("''", "'"), reader["model"].ToString().Replace("''", "'"), reader["issue"].ToString().Replace("''", "'"), fixedIt, reader["solution"].ToString().Replace("''", "'"), DateTime.Parse(reader["date"].ToString().Replace("''", "'")).ToString("d") };
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dataGridView1, test);
                dataGridView1.Rows.Add(row);
            }
            dataGridView1.AutoResizeRows();
            dataGridView1.AutoResizeColumns();

            SelectedId = dataGridView1.FirstDisplayedCell.Value.ToString();
        }