예제 #1
0
        private void UpdateBtn_Click(object sender, EventArgs e)
        {
            int selectedRowIndex = 0;

            if (table.SelectedCells.Count > 0)
            {
                Software.Model.Data Data = new Software.Model.Data();

                selectedRowIndex = table.SelectedCells[0].RowIndex;
                DataGridViewRow selectedRow = table.Rows[selectedRowIndex];

                Data.Id         = Convert.ToInt32(Convert.ToString(selectedRow.Cells["Id"].Value));
                Data.Data_Name  = nameBox.Text;
                Data.Data_Value = Convert.ToInt32(Convert.ToString(selectedRow.Cells["Data_Value"].Value));


                Software.Database.SQL.DataDB.UpdateData(Data);

                MetroFramework.MetroMessageBox.Show(this, "Your data has been updated successfully.", "Successfully Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MetroFramework.MetroMessageBox.Show(this, "You must select a row to update its value!", "Invalid Selection");
            }

            DoRefresh();
            table.CurrentCell = table.Rows[selectedRowIndex].Cells[0];
            table.Rows[selectedRowIndex].Selected = true;
        }
예제 #2
0
        private void createBtn_Click(object sender, EventArgs e)
        {
            Software.Model.Data Data = new Software.Model.Data();
            Data.Data_Name  = nameBox.Text;
            Data.Data_Value = Convert.ToInt32(datavalBox.Text);

            Software.Database.SQL.DataDB.InsertData(Data);
            MetroFramework.MetroMessageBox.Show(this, "Data has been inserted!", "Successfully Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
            Close();
        }