示例#1
0
        private void btnKEKaydet_Click(object sender, EventArgs e)
        {
            if (_plant.speciesid == null)
            {
                MessageBox.Show("Tür boş bırakılamaz");
                return;
            }

            _plant.localname   = txtLocalName.Text;
            _plant.subsp       = txtSubsp.Text;
            _plant.variety     = txtVaryete.Text;
            _plant.endemism    = rdbYes.Checked;
            _plant.typeexample = txtTypeExample.Text;
            _plant.localite    = txtlocalite.Text;
            _plant.date        = dtPicker.Value;
            _plant.minimum     = Convert.ToDouble(nmMin.Value);
            _plant.maximum     = Convert.ToDouble(nmMaks.Value);
            _plant.diagnose    = rchDiagnose.Text;
            _plant.collector   = rchCollector.Text;
            _plant.explanation = rchDetails.Text;
            _plant.herbno      = lblKod.Text;

            //_plantBLL.addGrids(_plant, txtGrids.Text);
            _plant.habitat = _plantBLL.getHabitatId(txtHabitat.Text);

            city city = entities.city.FirstOrDefault(x => x.name == cmbIl.Text);

            if (city != null)
            {
                district district = entities.district.FirstOrDefault(x => x.name == cmbIlce.Text && x.cityid == city.id);
                district = district is null?entities.district.FirstOrDefault(x => x.cityid == city.id) : district;

                _plant.districtid = district.id;
            }
            if (_plantBLL.Location != null && _plantBLL.Location.Valid)
            {
                _plant.latitude  = Convert.ToDouble(_plantBLL.Location.DecLatitude);
                _plant.longitude = Convert.ToDouble(_plantBLL.Location.DecLongitude);
            }

            if (!isUpdate)
            {
                _plantBLL.AddPlant(_plant);
                var satir = Tablo.NewRow();
                satir = SatiriDoldur(satir);
                Tablo.Rows.InsertAt(satir, 0);
                Log.Debug("[Yeni Bitki]: " + _plant.herbno, "Eklenen bitki:\n" + Log.PlantRowToJson(satir));
            }
            else
            {
                _plantBLL.UpdatePlant(_plant);
                DataRow satir = GetRowOfPlant();
                SatiriDoldur(satir);
                satir.AcceptChanges();
                Log.Debug("[Güncellenen Bitki]: " + _plant.herbno, "Değişiklikler:\n" + Log.DiffBetweenTwoDict(Log.PlantRowToDict(satir), oldRow) + "\nGüncelleme sonrası:\n" + Log.PlantRowToJson(satir) + "\nGüncelleme öncesi:\n" + Log.DictToJson(oldRow));
            }

            MessageBox.Show("Başarıyla Eklendi");
        }
示例#2
0
        public void UpdatePlantTest()
        {
            PlantBLL target = new PlantBLL(); // TODO: Initialize to an appropriate value
            Plant    plant  = null;           // TODO: Initialize to an appropriate value

            target.UpdatePlant(plant);
            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
示例#3
0
        private void btnKEKaydet_Click(object sender, EventArgs e)
        {
            if (_plant.speciesid == null)
            {
                ShowMessage.Error("Tür boş bırakılamaz");
                return;
            }
            if (_plantBLL.entities.plant.FirstOrDefault(x => x.herbno == txtKod.Text.Trim() && x.id != _plant.id) != null)
            {
                ShowMessage.Error(txtKod.Text + " herbaryum numarası daha önce kullanılmış değiştirin");
                return;
            }
            _plant.localname   = txtLocalName.Text;
            _plant.subsp       = txtSubsp.Text;
            _plant.variety     = txtVaryete.Text;
            _plant.endemism    = rdbYes.Checked;
            _plant.typeexample = txtTypeExample.Text;
            _plant.localite    = txtlocalite.Text;
            _plant.date        = dtPicker.Value;
            _plant.minimum     = Convert.ToDouble(nmMin.Value);
            _plant.maximum     = Convert.ToDouble(nmMaks.Value);
            _plant.diagnose    = txtDiagnose.Text;
            _plant.collector   = txtCollector.Text;
            _plant.explanation = rchDetails.Text;
            _plant.herbno      = txtKod.Text.Trim();
            _plant.coordinates = txtCoord.Text;

            //_plantBLL.addGrids(_plant, txtGrids.Text);
            _plant.habitat = _plantBLL.getHabitatId(txtHabitat.Text);

            city city = entities.city.FirstOrDefault(x => x.name == cmbIl.Text);

            if (city != null)
            {
                district district = entities.district.FirstOrDefault(x => x.name == cmbIlce.Text && x.cityid == city.id);
                district = district is null?entities.district.FirstOrDefault(x => x.cityid == city.id) : district;

                _plant.districtid = district.id;
            }
            // if (_plantBLL.Location!=null && _plantBLL.Location.Valid)
            // {
            //     _plant.latitude = Convert.ToDouble(_plantBLL.Location.DecLatitude);
            //    _plant.longitude = Convert.ToDouble(_plantBLL.Location.DecLongitude);
            // }

            if (!isUpdate)
            {
                _plantBLL.AddPlant(_plant);
                var satir = Tablo.NewRow();
                satir = SatiriDoldur(satir);
                Tablo.Rows.InsertAt(satir, 0);

                lblDurum.Text = _plant.herbno + " başarıyla eklendi!";
                Log.Debug("[Yeni Bitki]: " + _plant.herbno, $"{_plant.herbno} kodlu {DateTime.Now.ToString()} tarihinde {UserBLL.ActiveUser.name} tarafından {cmbSpecies.Text} eklendi.\nEklenen bitkinin detayları:\n" + Log.PlantRowToJson(satir));
                StartInitialize();
                this._plant = new plant();
                var count = entities.plant.Count();
                if (count > 0)
                {
                    var list = entities.plant.OrderBy(x => x.id).ToList();
                    int sayi = Convert.ToInt32(entities.plant.OrderBy(x => x.id).ToList()[0].herbno.Substring(4)) + 1;
                    txtKod.Text = "KNYA" + string.Format("{0:D7}", sayi);
                }
                else
                {
                    txtKod.Text = "KNYA" + string.Format("{0:D7}", 28001);
                }
                YeniBitki();
                Temizle();
                timer1.Start();
                pnlBildirim.Visible = true;
            }
            else
            {
                _plantBLL.UpdatePlant(_plant);
                DataRow satir = GetRowOfPlant();
                SatiriDoldur(satir);
                satir.AcceptChanges();
                Log.Debug("[Güncellenen Bitki]: " + _plant.herbno, $"{_plant.herbno} kodlu {DateTime.Now.ToString()} tarihinde {UserBLL.ActiveUser.name} tarafından {cmbSpecies.Text} güncellendi.\nDeğişiklikler:\n" + Log.DiffBetweenTwoDict(Log.PlantRowToDict(satir), oldRow) + "\nGüncelleme sonrası:\n" + Log.PlantRowToJson(satir) + "\nGüncelleme öncesi:\n" + Log.DictToJson(oldRow));
                timer1.Start();
                pnlBildirim.Visible = true;
                lblDurum.Text       = _plant.herbno + " başarıyla güncellendi!";
            }
        }