Exemple #1
0
        private void додатиПокупцяToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var users = new AddUsers();

            if (users.ShowDialog() == DialogResult.OK)
            {
                dgvUsers.RowCount += 1;
                dgvUsers[colDate.Index, dgvUsers.RowCount - 1].Value        = users.Time;
                dgvUsers[colName.Index, dgvUsers.RowCount - 1].Value        = users.NameUser;
                dgvUsers[colSurname.Index, dgvUsers.RowCount - 1].Value     = users.Surname;
                dgvUsers[colPhoneNumber.Index, dgvUsers.RowCount - 1].Value = users.PhoneNumber;
                dgvUsers[colStatus.Index, dgvUsers.RowCount - 1].Value      = users.Status;
                dgvUsers[colGoods.Index, dgvUsers.RowCount - 1].Value       = users.Goods;

                var user = new Users
                {
                    Date        = users.Time,
                    Name        = users.NameUser,
                    GoodName    = users.Goods,
                    NumberPhone = users.PhoneNumber,
                    Status      = users.Status,
                    Surname     = users.Surname
                };
                _storageGood.Users.Add(user);
            }
        }
Exemple #2
0
        private void редагуватиПокупцяToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var users           = new AddUsers();
            int indexUserInList = -1;

            if (dgvUsers.CurrentRow != null)
            {
                DateTime.TryParse(dgvUsers[colDate.Index, dgvUsers.RowCount - 1].Value.ToString(), out DateTime time);
                users.Time        = time;
                users.NameUser    = dgvUsers[colName.Index, dgvUsers.CurrentRow.Index].Value.ToString();
                users.PhoneNumber = dgvUsers[colPhoneNumber.Index, dgvUsers.CurrentRow.Index].Value.ToString();
                users.Surname     = dgvUsers[colSurname.Index, dgvUsers.CurrentRow.Index].Value.ToString();
                users.Status      = dgvUsers[colStatus.Index, dgvUsers.CurrentRow.Index].Value.ToString();
                users.Goods       = dgvUsers[colGoods.Index, dgvUsers.CurrentRow.Index].Value.ToString();

                indexUserInList = _storageGood.Users.FindIndex(f => f.Name == users.NameUser);
            }
            if (users.ShowDialog() == DialogResult.OK)
            {
                if (dgvUsers.CurrentRow != null)
                {
                    dgvUsers[colName.Index, dgvUsers.CurrentRow.Index].Value        = users.NameUser;
                    dgvUsers[colSurname.Index, dgvUsers.CurrentRow.Index].Value     = users.Surname;
                    dgvUsers[colPhoneNumber.Index, dgvUsers.CurrentRow.Index].Value = users.PhoneNumber;
                    dgvUsers[colStatus.Index, dgvUsers.CurrentRow.Index].Value      = users.Status;
                    dgvUsers[colGoods.Index, dgvUsers.CurrentRow.Index].Value       = users.Goods;

                    _storageGood.Users[indexUserInList].Name        = users.NameUser;
                    _storageGood.Users[indexUserInList].Date        = DateTime.Now;
                    _storageGood.Users[indexUserInList].GoodName    = users.Goods;
                    _storageGood.Users[indexUserInList].NumberPhone = users.PhoneNumber;
                    _storageGood.Users[indexUserInList].Surname     = users.Surname;
                    _storageGood.Users[indexUserInList].Status      = users.Status;
                }
            }
        }