コード例 #1
0
ファイル: Edit_Software.cs プロジェクト: pikakapi93/besmart
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            string msg_error = "";
            msg_error += nameCorrect();
            msg_error += idCorrect();
            msg_error += characteristicsCorrect();

            if (msg_error.Equals("") == false)
            {
                MessageBox.Show(msg_error, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string name = textBoxName.Text;
            int id = System.Convert.ToInt32(textBoxID.Text);
            string link = "";
            link += textBoxLink.Text;

            Dictionary<int, string> v = new Dictionary<int, string>();
            foreach (DataGridViewRow line in dataGridViewCharacteristics.Rows)
            {
                int i = System.Convert.ToInt32(line.Cells[1].Value.ToString());
                string value = line.Cells[0].Value.ToString();
                v.Add(i, value);
            }

            bool rem = Business.ManagementDataBase.remove_software(id_software);
            bool add = false;
            // vai remover e depois adicionar
            if (rem)
            {
                Business.Software s = new Business.Software(id, name, link, v);
                add = Business.ManagementDataBase.add_software(s);

            }
            if (add && rem)
            {
                MessageBox.Show("Software edited.", "Software", MessageBoxButtons.OK, MessageBoxIcon.None);
                this.Close();
            }

            else
            {
                msg_error += "Please check if the ID is not being used by another sodtware.";
                MessageBox.Show(msg_error, "Software", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
ファイル: Add_Software.cs プロジェクト: pikakapi93/besmart
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            string msg_error = "";
            msg_error += nameCorrect();
            msg_error += idCorrect();
            msg_error += characteristicsCorrect();

            if (msg_error.Equals("") == false)
            {
                MessageBox.Show(msg_error, "ERRO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string name = textBoxName.Text;
            int id = System.Convert.ToInt32(textBoxID.Text);
            string link = "";
            link += textBoxLink.Text;

            Dictionary<int, string> v = new Dictionary<int, string>();
            foreach (DataGridViewRow line in dataGridViewCharacteristics.Rows)
            {
                int i = System.Convert.ToInt32(line.Cells[1].Value.ToString());
                string value = line.Cells[0].Value.ToString();
                v.Add(i, value);
            }

            Business.Software s = new Business.Software(id, name, link, v);

            bool b = Business.ManagementDataBase.add_software(s);

            if (b)
            {
                MessageBox.Show("Software added.", "Software", MessageBoxButtons.OK, MessageBoxIcon.None);
                this.Close();
            }

            else
            {
                MessageBox.Show(msg_error, "Characteristics", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }