Exemplo n.º 1
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            db.Connect();
            string temName = DBUtil.AddQuotes(nameTB.Text);
            string temDesc = DBUtil.AddQuotes(descTB.Text);

            string[] evFields = new string[] { "name", "description", "expert_id" };
            string[] evValues = new string[] { temName, temDesc, user.ToString() };

            int evId = db.InsertToBD("event_template", evFields, evValues);

            foreach (DataGridViewRow row in materialListGrid.Rows)
            {
                Resource res = row.Cells[0].Value as Resource;
                if (res != null)
                {
                    string desc  = "";
                    string value = "";
                    //if (row.Cells[descCol].Value != null)
                    //    desc = DBUtil.AddQuotes(row.Cells[descCol].Value.ToString());
                    //if (row.Cells[valueCol].Value != null)
                    //    value = row.Cells[valueCol].Value.ToString();

                    string[] fields = { "template_id", "resource_id" };
                    string[] values = { evId.ToString(), res.id.ToString() };

                    db.InsertToBD("template_resource", fields, values);
                }
            }
            db.Disconnect();
        }
Exemplo n.º 2
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            //db.Connect();

            string login = DBUtil.AddQuotes(loginTB.Text);
            string pass  = DBUtil.AddQuotes(passTB.Text);

            var user = db.GetRows("user", "*", "user_name=" + login +
                                  " AND password="******"Користувача знайдено. Id експерта = " + user[0][2].ToString());
                // LoginHandler(Int32.Parse(user[0][2].ToString()));
                //  new Main().ShowDialog();
                DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("Користувача не знайдено");
                DialogResult = DialogResult.None;
            }

            db.Disconnect();
        }
Exemplo n.º 3
0
 private void addBtn_Click(object sender, EventArgs e)
 {
     db.Connect();
     string[] fields = { "name", "description" };
     string[] values = { DBUtil.AddQuotes(nameTB.Text), DBUtil.AddQuotes(descTB.Text) };
     db.InsertToBD("resource", fields, values);
     db.Disconnect();
     this.Close();
 }
Exemplo n.º 4
0
        private void EditCurrentUser(object sender, DataGridViewCellMouseEventArgs e)
        {
            int    currentRow   = this.UsersDGV.CurrentCell.RowIndex;
            string userName     = this.UsersDGV.Rows[currentRow].Cells[0].Value.ToString();
            string userPassword = this.UsersDGV.Rows[currentRow].Cells[1].Value.ToString();
            string userType     = this.UsersDGV.Rows[currentRow].Cells[2].Value.ToString();

            this.userName = DBUtil.AddQuotes(userName);

            this.UsernameTextBox.Text  = userName;
            this.PasswordTextBox.Text  = userPassword;
            this.ExperTypeTextBox.Text = userType;
        }
Exemplo n.º 5
0
        private void deleteCurrentUser(object sender, EventArgs e)
        {
            string userName     = DBUtil.AddQuotes(this.UsernameTextBox.Text);
            string userPassword = DBUtil.AddQuotes(this.PasswordTextBox.Text);
            string userType     = DBUtil.AddQuotes(this.ExperTypeTextBox.Text);

            db.Connect();

            db.DeleteFromDB("user", "user_name", userName);

            db.Disconnect();

            RefreshDVG();
        }
Exemplo n.º 6
0
        private void UpdateCurrentUser(object sender, EventArgs e)
        {
            string userName     = DBUtil.AddQuotes(this.UsernameTextBox.Text.Replace('\'', '`'));
            string userPassword = DBUtil.AddQuotes(this.PasswordTextBox.Text.Replace('\'', '`'));
            string userType     = DBUtil.AddQuotes(this.ExperTypeTextBox.Text.Replace('\'', '`'));

            string[] updateCols = new string[] { "user_name", "user_name", "password", "id_of_expert" };
            string[] updateVals = new string[] { this.userName, userName, userPassword, userType };

            db.Connect();
            db.UpdateRecord("user", updateCols, updateVals);
            db.Disconnect();

            RefreshDVG();
        }
Exemplo n.º 7
0
 private void addBtn_Click(object sender, EventArgs e)
 {
     try
     {
         db.Connect();
         string[] fields = { "name", "description", "price", "units" };
         string[] values = { DBUtil.AddQuotes(nameTB.Text), DBUtil.AddQuotes(descTB.Text), Double.Parse(priceTB.Text).ToString(), DBUtil.AddQuotes(unitsTB.Text) };
         db.InsertToBD("resource", fields, values);
         db.Disconnect();
         this.Close();
     }
     catch (Exception)
     {
         MessageBox.Show("Неправильно введено ціну.");
     }
 }
Exemplo n.º 8
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            item.name        = nameTB.Text;
            item.description = descrTB.Text;

            db.Connect();
            string[] cols = { "issue_id", "name", "description" };

            //int calcSeriesId = (seriesCB.SelectedItem as CalculationSeries).id;
            //string calcSeries = calcSeriesId == -1 ? "null" : calcSeriesId.ToString();
            string[] values = { item.id.ToString(), DBUtil.AddQuotes(nameTB.Text), DBUtil.AddQuotes(descrTB.Text) };

            db.UpdateRecord("issues", cols, values);
            db.Disconnect();
            this.Close();
        }
Exemplo n.º 9
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            db.Connect();
            string[] fields = { "name", "description" };

            string[] values = { DBUtil.AddQuotes(nameTB.Text), DBUtil.AddQuotes(descrTB.Text) };

            int id = db.InsertToBD("issues", fields, values);

            //Issue issue = new Issue(id, nameTB.Text, descrTB.Text, DateTime.Now, calcSeries);
            //issuesLB.Items.Add(issue);

            db.Disconnect();

            this.Close();
        }
Exemplo n.º 10
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            var ev = templatesLB.SelectedItem as Event;

            db.Connect();
            string[] cols   = { "template_id", "name", "description" };
            string[] values = { ev.id.ToString(), DBUtil.AddQuotes(nameTB.Text), DBUtil.AddQuotes(descTB.Text) };

            ev.name        = nameTB.Text;
            ev.description = descTB.Text;

            templatesLB.Refresh();

            db.UpdateRecord("event_template", cols, values);

            //Get all resources for thar template
            var ress = db.GetRows("template_resource", "resource_id", "template_id=" + ev.id);

            //Update resources for event
            foreach (DataGridViewRow row in materialListGrid.Rows)
            {
                var res = row.Cells[0].Value as Resource;

                //Remove present resources to delete left ones
                ress.RemoveAll(o => Int32.Parse(o[0].ToString()) == res.id);

                string[] resCols   = { "template_id" };
                string[] resValues = { ev.id + " AND resource_id=" + res.id };
                if (db.GetRows("template_resource", "*", "template_id=" + ev.id + " AND resource_id=" + res.id).Count == 0)
                {
                    string[] resColsIns   = { "template_id", "resource_id" };
                    string[] resValuesIns = { ev.id.ToString(), res.id.ToString() };
                    db.InsertToBDWithoutId("template_resource", resColsIns, resValuesIns);
                }
            }

            //Delete resources thar are not in grid view
            foreach (var resId in ress)
            {
                string resCols   = "template_id";
                string resValues = ev.id + " AND resource_id=" + resId[0].ToString();

                db.DeleteFromDB("template_resource", resCols, resValues);
            }

            db.Disconnect();
        }
Exemplo n.º 11
0
        private void AddNewUser(object sender, EventArgs e)
        {
            string userName     = DBUtil.AddQuotes(this.UsernameTextBox.Text);
            string userPassword = DBUtil.AddQuotes(this.PasswordTextBox.Text);
            string userType     = DBUtil.AddQuotes(this.ExperTypeTextBox.Text);

            string[] fields = new string[] { "user_name", "password", "id_of_expert" };
            string[] values = new string[] { userName, userPassword, userType };

            db.Connect();

            db.InsertToBD("user", fields, values);

            db.Disconnect();

            RefreshDVG();
        }
Exemplo n.º 12
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in resDGV.Rows)
            {
                if (row.Cells[0].Value is Resource res)
                {
                    db.Connect();

                    string[] cols   = { "resource_id", "name", "description" };
                    string[] values = { res.id.ToString(), DBUtil.AddQuotes(res.name), DBUtil.AddQuotes(res.description) };

                    db.UpdateRecord("resource", cols, values);

                    db.Disconnect();
                }
            }
        }
Exemplo n.º 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            Event ev = eventsLB.SelectedItem as Event;

            db.Connect();
            string evName = DBUtil.AddQuotes(evNameTB.Text);
            string evDesc = DBUtil.AddQuotes(descTB.Text);

            string[] evFields = new string[] { "name", "description", "id_of_user", "issue_id" };

            string issueId = (issuesCB.SelectedItem as Issue).id.ToString();

            string[] evValues = new string[] { evName, evDesc, user.ToString(), issueId };

            int evId = db.InsertToBD("event", evFields, evValues);

            foreach (DataGridViewRow row in eventListGrid.Rows)
            {
                if (row.Cells[0].Value is Resource)
                {
                    var    res   = row.Cells[0].Value as Resource;
                    string desc  = "";
                    string value = "";
                    if (row.Cells[descCol].Value != null)
                    {
                        desc = DBUtil.AddQuotes(row.Cells[descCol].Value.ToString());
                    }
                    if (row.Cells[valueCol].Value != null)
                    {
                        value = row.Cells[valueCol].Value.ToString();
                    }

                    string[] fields = { "event_id", "resource_id", "value", "description" };
                    string[] values = { evId.ToString(), res.id.ToString(), value, desc };

                    db.InsertToBD("event_resource", fields, values);
                }
            }
            db.Disconnect();

            MessageBox.Show("Захід " + evNameTB.Text + " додано.");
        }
Exemplo n.º 14
0
        private void loginBtn_Click(object sender, EventArgs e)
        {
            db.Connect();

            string login = DBUtil.AddQuotes(loginTB.Text);
            string pass  = DBUtil.AddQuotes(passTB.Text);

            var user = db.GetRows("user", "*", "user_name=" + login +
                                  " AND password="******"User found. Expert id is" + user[0][2].ToString());
                LoginHandler(Int32.Parse(user[0][2].ToString()));
                this.Visible = false;
            }
            else
            {
                MessageBox.Show("No user found");
            }


            db.Disconnect();
        }