Exemplo n.º 1
0
        public bool UpdatePlant(plant plant)
        {
            try
            {
                var entity = entities.plant.Find(plant.id);
                //entity.grid.Clear();
                //foreach (var childModel in plant.grid)
                //{
                //    var existingChild = entities.plant.Find(childModel.id);

                //    entity.grid.Add(childModel);
                //    entities.Attach(entity);
                //}
                //   entities.Entry(entity.grid).CurrentValues.SetValues(plant.grid);

                entities.Entry(entity).CurrentValues.SetValues(plant);
                //entity.grid = plant.grid;

                // entity = entities.plant.Find(plant.id);
                //UpdateGrid(entity);
                entities.SaveChanges();


                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 2
0
 public PlantForm()
 {
     InitializeComponent();
     StartInitialize();
     this._plant = new plant();
     lblKod.Text = "KNYA" + string.Format("{0:D7}", 28000 + entities.plant.Max(x => x.id) + 1);
 }
        public ActionResult DeleteConfirmed(int id)
        {
            plant plant = db.plantT.Find(id);

            db.plantT.Remove(plant);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            plant tmp = list[lbList.SelectedIndex];

            list.Remove(tmp);
            flag = false;
            lbList.Items.RemoveAt(lbList.SelectedIndex);
            clearValues();
        }
Exemplo n.º 5
0
        public Image getPhoto(plant plant)
        {
            if (plant.photo == null || plant.photo.Length == 4)
            {
                return(null);
            }

            return(Image.FromStream(new System.IO.MemoryStream(plant.photo)));
        }
 public ActionResult Edit([Bind(Include = "plantID,plantName,ScientificName,plantAge,plantPrice,plantPicture")] plant plant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(plant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(plant));
 }
Exemplo n.º 7
0
 private void buyAndAddPlant(InputEventMouseButton eventMouseButton)
 {
     if (eventMouseButton.Pressed && this.money >= PLANT_COST)
     {
         plant plant = ((ResourceLoader.Load("plant.tscn") as PackedScene).Instance() as plant);
         plants.Add(plant);
         plant.Position = eventMouseButton.Position;
         AddChild(plant);
         this.money -= PLANT_COST;
         this.updateLabels();
     }
 }
Exemplo n.º 8
0
        public void UpdateGrid(plant plant)
        {
            var entity = entities.plant.Find(plant.id);

            if (entity != null)
            {
                // Update and Insert children



                entities.Entry(entity).CurrentValues.SetValues(plant);
            }
        }
        public ActionResult Create([Bind(Include = "plantID,plantName,ScientificName,plantAge,plantPrice,plantPicture")] plant plant)
        {
            if (ModelState.IsValid)
            {
                db.plantT.Add(plant);
                db.SaveChanges();
                // return RedirectToAction("Index");
            }

            ModelState.Clear();
            ViewBag.Message = plant.plantName + " successfully inserted";
            return(View());
        }
Exemplo n.º 10
0
        public void Refresh(float size = 1, bool first_time = true)
        {
            if (first_time)
            {
                save        = false;
                mesh_filter = GetComponent <MeshFilter>();
                pot         = gameObject.transform.Find("pot").gameObject.GetComponent <Pots>(); // note that the transform.Find is immportant (standard Find game object finds highest in hierachy - not necessarily child)
            }

            Stopwatch pot_creation_time = new Stopwatch();                            // TIME TESTING

            pot_creation_time.Start();                                                // TIME TESTING
            pot.Refresh(size, first_time);
            pot_creation_time.Stop();                                                 // TIME TESTING
            UnityEngine.Debug.Log("pot creation time: " + pot_creation_time.Elapsed); // TIME TESTING


            Stopwatch plant_creation_time = new Stopwatch();                              // TIME TESTING

            plant_creation_time.Start();                                                  // TIME TESTING
            cactus = new plant(size);
            plant_creation_time.Stop();                                                   // TIME TESTING
            UnityEngine.Debug.Log("plant creation time: " + plant_creation_time.Elapsed); // TIME TESTING


            cactus.interpolation = true;
            cactus.optimisation  = true;

            Stopwatch plant_growing_time = new Stopwatch();                             // TIME TESTING

            plant_growing_time.Start();                                                 // TIME TESTING
            // cactus.draw(3); // WARNING, 3 does load but takes a very long time
            cactus.draw(2);                                                             // WARNING, 3 does load but takes a very long time
            plant_growing_time.Stop();                                                  // TIME TESTING
            UnityEngine.Debug.Log("plant growing time: " + plant_growing_time.Elapsed); // TIME TESTING

            mesh_filter.mesh = cactus.animal_mesh;
            if (save)
            {
                // Debug.Log("Saving animal to file...");
                cactus.save_mesh();
            }
            save = false;

            float volume       = mesh_filter.mesh.bounds.size.x * mesh_filter.mesh.bounds.size.y * mesh_filter.mesh.bounds.size.z;
            float dim          = (float)System.Math.Pow(volume, (1.0f / 3.0f));
            float scale_factor = 1.0F / dim;

            transform.localScale = new Vector3(scale_factor, scale_factor, scale_factor);
        }
        // GET: plants/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            plant plant = db.plantT.Find(id);

            if (plant == null)
            {
                return(HttpNotFound());
            }
            return(View(plant));
        }
Exemplo n.º 12
0
 public bool AddPlant(plant plant)
 {
     try
     {
         if (plant.speciesid == null)
         {
             return(false);
         }
         entities.plant.Add(plant);
         entities.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Exemplo n.º 13
0
        private void YeniBitki()
        {
            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.Max(x => x.id) + 1);
                txtKod.Text = string.Format("{0:D7}", sayi);
            }
            else
            {
                txtKod.Text = string.Format("{0:D7}", 00001);
            }
            txtKod.Enabled = true;
        }
Exemplo n.º 14
0
 private void Form_Load(object sender, EventArgs e)
 {
     try
     {
         int plantID = System.Configuration.ConfigurationManager.AppSettings["plantID"].ToInt16();
         using (var db = new SlaughterhouseEntities())
         {
             plant = db.plants.Find(plantID);
             lblProductionDate.Text = plant.production_date.ToString("dd-MM-yyyy");
             product = db.products.Find(PRODUCT_CODE);
         }
         lblMessage.Text = Constants.CHOOSE_QUEUE;
     }
     catch (Exception ex)
     {
         lblMessage.Text = ex.Message;
     }
 }
Exemplo n.º 15
0
        public PlantForm(plant plant, DataTable table)
        {
            InitializeComponent();
            StartInitialize();
            this._plant = plant;
            this.Tablo  = table;
            var photo = _plantBLL.getPhoto(plant);

            if (photo != null)
            {
                lblPhoto.Visible = false;
                pboxResim.Image  = photo;
            }
            lblKod.Text = "KNYA" + string.Format("{0:D7}", 28000 + plant.id);
            FillAreas();
            oldRow = Log.PlantRowToDict(GetRowOfPlant());

            btnKEKaydet.Text = "Bitki Güncelle";
            isUpdate         = true;
        }
Exemplo n.º 16
0
 public void Load()
 {
     if (this.Code != null)
     {
         try
         {
             using (VisitMgtDataContext vmdc = new VisitMgtDataContext())
             {
                 plant po = vmdc.plant.Single(q => q.plant_code == this.Code);
                 this.CNName  = po.plant_name;
                 this.ENName  = po.plant_name_en;
                 this.Address = po.plant_address;
             }
         }
         catch (Exception ex)
         {
             throw new Exception("获取工厂信息失败", ex);
         }
     }
 }
Exemplo n.º 17
0
        public PlantForm(int plantid, DataTable table)
        {
            InitializeComponent();
            StartInitialize();
            this._plant = entities.plant.Find(plantid);
            this.Tablo  = table;
            var photo = _plantBLL.getPhoto(_plant);

            if (photo != null)
            {
                lblPhoto.Visible = false;
                pboxResim.Image  = photo;
            }
            txtKod.Text = _plant.herbno;
            FillAreas();
            oldRow = Log.PlantRowToDict(GetRowOfPlant());

            btnKEKaydet.Text = "Bitki Güncelle";
            isUpdate         = true;
            txtKod.Enabled   = true;
        }
Exemplo n.º 18
0
 public void save()
 {
     try
     {
         using (VisitMgtDataContext vmdc = new VisitMgtDataContext())
         {
             plant po = new plant {
                 plant_name = this.CNName, plant_name_en = this.ENName, plant_address = this.Address
             };
             if (this.Code != null)
             {
                 po.plant_code = this.Code;
             }
             vmdc.plant.InsertOnSubmit(po);
             vmdc.SubmitChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("更新工厂信息失败", ex);
     }
 }
Exemplo n.º 19
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     try
     {
         if (CheckEmptyTextBoxes())
         {
             var values = GetPropertyValues();
             plant = creators[plantType].createPlant(values);
             list.Add(plant);
             lbList.Items.Add(plant.name);
             clearValues();
         }
         else
         {
             MessageBox.Show("All fields are required!");
         }
     }
     catch
     {
         MessageBox.Show("Incorrect input!");
     }
 }
Exemplo n.º 20
0
 void harvestFood(plant p)
 {
     // add crop to player inv
     n_plant.growth = PlantGrowth.Dead;
     UpdateSprite();
 }
Exemplo n.º 21
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!";
            }
        }
Exemplo n.º 22
0
 public void init(plant _p)
 {
     p = _p;
 }