예제 #1
0
        private void ChangeRow(DataGridViewRow row)
        {
            InputCoffeeForm inForm = new InputCoffeeForm(Coffee.RowToCoffee(row));

            inForm.EditOrFind();
            if (inForm.DialogResult == DialogResult.OK)
            {
                int index = row.Index;
                dgv.Rows.RemoveAt(index);
                dgv.Rows.Insert(index, Coffee.CoffeeToRow(inForm.coffee, dgv));
                RefreshIndex();
            }
            inForm.Dispose();
        }
예제 #2
0
        private void BtTask_Click(object sender, EventArgs e)
        {
            InputKindForm inputKindForm = new InputKindForm();

            if (!(inputKindForm.ShowDialog() == DialogResult.OK && inputKindForm.kind != enumKind.Null))
            {
                if (inputKindForm.DialogResult != DialogResult.OK)
                {
                    MessageBox.Show("Были введены некорректные данные!");
                }
                return;
            }
            enumKind  kind      = inputKindForm.kind;
            InputForm inputForm = new InputForm("Введите максимальную цену");
            int       tempNum   = 0;

            if (!(inputForm.ShowDialog() == DialogResult.OK && Int32.TryParse(inputForm.inText, out tempNum) && tempNum >= 0))
            {
                if (inputForm.DialogResult != DialogResult.OK)
                {
                    MessageBox.Show("Были введены некорректные данные!");
                }
                return;
            }
            List <DataGridViewRow> rowList = new List <DataGridViewRow>();

            foreach (DataGridViewRow row in dgv.Rows)
            {
                if (!(Coffee.StringToKind(row.Cells[1].Value.ToString()) == kind && Double.Parse(row.Cells[4].Value.ToString()) <= tempNum))
                {
                    rowList.Add(row);
                    backList.Add(Coffee.CoffeeToRow(Coffee.RowToCoffee(row), dgv));
                }
            }
            foreach (DataGridViewRow row in rowList)
            {
                dgv.Rows.Remove(row);
            }
            dgv.Sort(dgv.Columns[4], ListSortDirection.Ascending);
        }