Exemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            fCountersAdd add             = new fCountersAdd();
            var          typeContersList = from TypesOfCounters in context.TypesOfCounters select TypesOfCounters;

            add.cbTypeCounter.DataSource    = typeContersList.ToList();
            add.cbTypeCounter.ValueMember   = "IdType";
            add.cbTypeCounter.DisplayMember = "Description";
            add.cbTypeCounter.SelectedIndex = -1;

            var housesList = from Houses in context.Houses select Houses;

            add.cbNumberHouse.DataSource    = housesList.ToList();
            add.cbNumberHouse.ValueMember   = "IdHouse";
            add.cbNumberHouse.DisplayMember = "NumberHouse";
            add.cbNumberHouse.SelectedIndex = -1;

            DialogResult result = add.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }
            Counters counter = new Counters();

            counter.TypeCounter = (int)add.cbTypeCounter.SelectedValue;
            counter.House       = (int)add.cbNumberHouse.SelectedValue;
            counter.Information = (int)add.nudInformation.Value;
            context.Counters.Add(counter);
            context.SaveChanges();
            MessageBox.Show("Успешное добавление");
            LoadData();
        }
Exemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            fOwnersAdd   add    = new fOwnersAdd();
            DialogResult result = add.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }
            Owners owner = new Owners();

            owner.FIO      = add.tbFIO.Text;
            owner.Passport = add.tbPassport.Text;
            context.Owners.Add(owner);
            context.SaveChanges();
            MessageBox.Show("Запись выполнена");
            LoadData();
        }
Exemplo n.º 3
0
        private void AddOld()
        {
            HousingCooperativeEntities context = new HousingCooperativeEntities();
            Rates oldRate = context.Rates.Find(dgvData.SelectedCells[0].Value);

            oldRate.StatusRate = 2;
            context.Rates.Add(oldRate);
            context.SaveChanges();
        }
Exemplo n.º 4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            fOwnersOfHousesAdd f = new fOwnersOfHousesAdd();
            var ownersList       = from Owners in context.Owners select Owners;

            f.cbOwner.DataSource    = ownersList.ToList();
            f.cbOwner.ValueMember   = "IdOwner";
            f.cbOwner.DisplayMember = "FIO";
            f.cbOwner.SelectedIndex = -1;
            var housesList = from Houses in context.Houses select Houses;

            f.cbHouse.DataSource    = housesList.ToList();
            f.cbHouse.ValueMember   = "IdHouse";
            f.cbHouse.DisplayMember = "NumberHouse";
            f.cbHouse.SelectedIndex = -1;
            var statusesList = from Statuses in context.Statuses select Statuses;

            f.cbStatus.DataSource    = statusesList.ToList();
            f.cbStatus.ValueMember   = "IdStatus";
            f.cbStatus.DisplayMember = "Description";
            DialogResult result = f.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }
            OwnersOfHouses ooh = new OwnersOfHouses();

            ooh.Owner       = (int)f.cbOwner.SelectedValue;
            ooh.House       = (int)f.cbHouse.SelectedValue;
            ooh.DatePayment = f.dtDate.Value.Date;
            ooh.StatusOwner = (int)f.cbStatus.SelectedValue;
            context.OwnersOfHouses.Add(ooh);
            context.SaveChanges();
            MessageBox.Show("Успешное добавление");
            LoadData();
        }
Exemplo n.º 5
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            HousingCooperativeEntities context = new HousingCooperativeEntities();
            fRatesAdd add     = new fRatesAdd();
            Rates     newRate = context.Rates.Find(dgvData.SelectedCells[0].Value);

            add.lbRate.Text       = dgvData.SelectedCells[1].Value.ToString();
            add.nudRate.Value     = newRate.Rate;
            add.tbUnit.Text       = newRate.Unit;
            add.dtMonthYear.Value = new DateTime(newRate.YearBegin, newRate.MonthBegin, 1);
            DialogResult result = add.ShowDialog();

            if (result == DialogResult.Cancel)
            {
                return;
            }
            AddOld();
            newRate.Rate       = add.nudRate.Value;
            newRate.Unit       = add.tbUnit.Text;
            newRate.MonthBegin = add.dtMonthYear.Value.Month;
            newRate.YearBegin  = add.dtMonthYear.Value.Year;
            context.SaveChanges();
            LoadData();
        }