Пример #1
0
        /*-------------Button clicks--------------------*/
        //Salary
        private void addButton_Click(object sender, EventArgs e)
        {
            setSalary f = new setSalary(DateTime.Now);

            f.ShowDialog();
            if (f.values_set == true)
            {
                dataGridView1.Rows.Add(f.result, f.salary);
                this.dataGridView1.Sort(this.dataGridView1.Columns["Date"], ListSortDirection.Ascending);
            }
        }
Пример #2
0
        private void editButton_Click(object sender, EventArgs e)
        {
            int row_index = -1;

            if (dataGridView1.SelectedRows.Count > 0)
            {
                row_index = dataGridView1.SelectedRows[0].Index;
            }
            if (dataGridView1.SelectedCells.Count > 0 && row_index < 0)
            {
                row_index = dataGridView1.SelectedCells[0].RowIndex;
            }
            if (row_index < 0)
            {
                return;
            }
            DateTime d      = Convert.ToDateTime(dataGridView1.Rows[row_index].Cells["Date"].Value.ToString());
            float    salary = -1F;

            try
            {
                string temp = dataGridView1.Rows[row_index].Cells["Salary"].Value.ToString();
                salary = float.Parse(temp);
            }
            catch { };
            setSalary f = new setSalary(d, salary);

            f.ShowDialog();
            if (f.values_set == true)
            {
                dataGridView1.Rows[row_index].SetValues(f.result, f.salary);
                this.dataGridView2.Sort(this.dataGridView2.Columns["Begin_Date"], ListSortDirection.Ascending);
                if (this.edit_form == false)
                {
                    dataGridView2.Rows[0].Cells["Begin_Date"].Value = f.result;
                }
            }
        }