Exemplo n.º 1
0
        //private void BtnSaveAndNew_Click(object sender, System.EventArgs e)
        //{
        //    try
        //    {
        //        SavePlant();
        //        MessageBox.Show("บันทึกข้อมูลเรียบร้อย.", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Information);

        //        txtPlantName.Text = "";
        //        txtPlantName.Focus();
        //        chkActive.Checked = true;
        //    }
        //    catch (System.Exception ex)
        //    {
        //        MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        //    }
        //}


        #endregion

        private void LoadData()
        {
            try
            {
                if (this.plantId > 0)
                {
                    Plant plant = PlantController.GetPlant();
                    txtPlantId.Text   = this.plantId.ToString();;
                    txtPlantName.Text = plant.PlantName.ToString();
                    txtAddress.Text   = plant.Address.ToString();
                    txtEstNo.Text     = plant.EstNo.ToString();
                    if (plant.LogoImage != null)
                    {
                        if (plant.LogoImage.Length != 0)
                        {
                            imgLogo.Image = ByteToImage(plant.LogoImage);
                        }
                    }

                    //BtnSaveAndNew.Visible = false;
                    //txtTruckNo.Enabled = false;
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
 // Use this for initialization
 void Start()
 {
     rb2d       = GetComponent <Rigidbody2D>();
     controller = GetComponent <PlantController>();
     InvokeRepeating("PhotoSyn", 5.0f, 5.0f);
     InvokeRepeating("Reproduce", 10.0f, 40.0f);
 }
    public TaskCollect(GameObject go, PlantItem plantItem) : base(go)
    {
        this.plantItem = plantItem;
        pc             = taskGameObject.GetComponent <PlantController>();

        ChangePlayerPositionTarget(go.transform.parent.gameObject);
    }
Exemplo n.º 4
0
    protected virtual void LookForTree()
    {
        List <PlantController> trees = GameController.instance.trees;

        if (trees.Count == 0)
        {
            attackMode = false;
            return;
        }

        int   targetIndex = 0;
        float closestDist = TreeClosest(trees[targetIndex]);

        for (int i = 0; i < trees.Count; i++)
        {
            if (!trees[i].beingChoppedDown && !trees[i].onFire)
            {
                float d = TreeClosest(trees[i]);
                if (d < closestDist)
                {
                    closestDist = d;
                    targetIndex = i;
                }
            }
        }
        target = trees[targetIndex];
        target.beingChoppedDown = true;
    }
Exemplo n.º 5
0
        public PlantControllerTest()
        {
            //Mock Setup
            plantMock  = new Mock <ImyPlant>();
            plantsMock = new List <ImyPlant> {
                plantMock.Object
            };
            addPlantMock    = new Mock <IAddPlant>();
            updatePlantMock = new Mock <IUpdatePlant>();
            mockRepo        = new Mock <IRepoWrapper>();
            plant           = new myPlant();
            plants          = new List <myPlant>();
            var allPlants = GetPlants();


            //Sample Models
            addPlant = new AddPlant {
                ID = 1, Name = "Radish", DatePlanted = "29.10.2019", DateLastWatered = "30.10.2019", Garden = "Windowsill"
            };
            updatePlant = new UpdatePlant {
                ID = 1, Name = "Radish", DatePlanted = "29.10.2019", DateLastWatered = "30.10.2019", Garden = "Windowsill"
            };

            //Controller Setup
            var plantResultMock = new Mock <IActionResult>();

            plantController = new PlantController(mockRepo.Object);
        }
Exemplo n.º 6
0
        private void LoadPlant()
        {
            //var farmCtrl = new FarmController();
            var coll = PlantController.GetAllPlants();

            gv.DataSource = coll;
            //LoadItem("");
        }
    private IEnumerator AddToPlantRoutine(PlantController plant)
    {
        do
        {
            yield return(new WaitForSeconds(usableItem.useSpeed));

            plant.AddStat(usableItem.statTypeForPlant, usableItem.addSpeed);
        } while (true);
    }
    private void OnTriggerExit(Collider other)
    {
        PlantController plant = other.GetComponent <PlantController>();

        if (plant)
        {
            currentPlant = null;
        }
    }
Exemplo n.º 9
0
 protected virtual void AttackTree()
 {
     target.Attacked(attack);
     timeSinceAttack = 0;
     if (target.health < 0)
     {
         target = null;
     }
 }
Exemplo n.º 10
0
    public void Spread(PlantController plant)
    {
        Fire f = Instantiate(gameObject).GetComponent <Fire>();

        f.tree               = plant;
        f.fireSize           = 0;
        f.transform.position = plant.transform.position;
        plant.onFire         = true;
        f.treeColor          = plant.spriteRenderer.color;
    }
Exemplo n.º 11
0
 private void OnTriggerStay(Collider other)
 {
     //If the enemy is melee
     if (other.gameObject.CompareTag("Player"))
     {
         target     = other.gameObject;
         treeTarget = null;
         navigation.SetDestination(target.transform.position);
         if (rangedEnemy)
         {
             Shoot(other.gameObject);
         }
     }
 }
Exemplo n.º 12
0
    void ChooseTarget()
    {
        int targetChoice = Random.Range(0, 4);

        if (targetChoice < 3)
        {
            int treeChoice = Random.Range(0, trees.Count);
            target     = trees[treeChoice].gameObject;
            treeTarget = target.GetComponent <PlantController>();
        }
        else
        {
            target = player;
        }
        navigation.SetDestination(target.transform.position);
    }
Exemplo n.º 13
0
        public static void Main()
        {
            IInputReader        inputReader        = new ConsoleReader();
            IOutputWriter       outputWriter       = new ConsoleWriter();
            IInputOutputManager inputOutputManager = new IOManager(inputReader, outputWriter);

            ICoreIdManager   coreIdManager     = new CoreIdManager();
            ICoreFactory     coreFactory       = new CoreFactory();
            IFragmentFactory fragmentFactory   = new FragmentFactory();
            IPlantController plantController   = new PlantController(coreIdManager, coreFactory, fragmentFactory);
            IInterpreter     commandIntepreter = new CommandInterpreter(plantController);

            IRunnable engine = new Engine(inputOutputManager, commandIntepreter);

            engine.Run();
        }
Exemplo n.º 14
0
    public void Plant(PlantItem plantItem)
    {
        GameObject prefab     = plantItem.GetItemPrefab();
        Renderer   prefabRend = prefab.GetComponent <Renderer>();
        Vector3    pos        = transform.position;

        pos.y   = rend.bounds.max.y;
        pos.y  += prefabRend.bounds.max.y - prefabRend.bounds.center.y; // position if pivot is object center but it's not propably
        pos.y  -= prefabRend.bounds.center.y - transform.position.y;    // correction for pivot point;
        PlantGO = Instantiate(prefab, pos, prefab.transform.rotation);
        PlantGO.transform.parent = transform;

        PlantController pc = PlantGO.GetComponent <PlantController>();

        if (!pc)
        {
            pc = PlantGO.AddComponent <PlantController>();
        }
        pc.Init(plantItem);
    }
Exemplo n.º 15
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (!TouchedOnUI())
            {
                RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

                if (hit.collider != null)
                {
                    if (hit.collider.gameObject.tag == "Plant")
                    {
                        PlantController selectedPlant = hit.collider.gameObject.GetComponent <PlantController>();

                        if (selectedPlant == activePlant.Value)
                        {
                            activePlant.Value = null;
                        }
                        else
                        {
                            activePlant.Value = selectedPlant;
                        }
                    }

                    else
                    {
                        activePlant.Value = null;
                    }
                }

                else
                {
                    activePlant.Value = null;
                }

                onPlantSelected.RaiseEvent();
                onStatusUpdated.RaiseEvent();
            }
        }
    }
Exemplo n.º 16
0
        public void Can_Paginate()
        {
            //Arrange
            var mock = new Mock <IPlantRepository>();

            mock.Setup(m => m.Plants).Returns(new List <Plant>
            {
                new Plant {
                    PlantId = 1, Name = "Pinus"
                },
                new Plant {
                    PlantId = 2, Name = "Thuja"
                },
                new Plant {
                    PlantId = 3, Name = "Juniperus"
                },
                new Plant {
                    PlantId = 4, Name = "Picea"
                },
                new Plant {
                    PlantId = 5, Name = "Acer"
                },
            }
                                              );
            var controller = new PlantController(mock.Object);

            controller.pageSize = 3;

            //Act
            IEnumerable <Plant> result = (IEnumerable <Plant>)controller.List(2).Model;

            //Assert
            List <Plant> plants = result.ToList();

            Assert.IsTrue(plants.Count == 2);
            Assert.AreEqual(plants[0].Name, "Picea");
            Assert.AreEqual(plants[1].Name, "Acer");
        }
Exemplo n.º 17
0
        private void SavePlant()
        {
            try
            {
                var plant = new Plant();
                plant.PlantId   = Convert.ToInt32(txtPlantId.Text);
                plant.PlantName = txtPlantName.Text;
                plant.Address   = txtAddress.Text;
                plant.EstNo     = txtEstNo.Text;
                if (openFileDialog1.FileName != "openFileDialog1")
                {
                    plant.LogoImage = File.ReadAllBytes(openFileDialog1.FileName);
                }
                plant.Active   = chkActive.Checked;
                plant.CreateBy = "system";

                PlantController.Update(plant);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 18
0
 void BurnTree(PlantController tree)
 {
     tree.Burn();
 }
Exemplo n.º 19
0
 private void Start()
 {
     _plantController = _plantUiView.PlantController;
     _plantController.RegisterCallback(NotificationType.PlantGrown, OnPlantGrown);
 }
Exemplo n.º 20
0
    void Start()
    {
        // Establish instance.
        if (instance != null)
        {
            Debug.LogError("There is already a GameController");
        }
        else
        {
            instance = this;
        }

        CalculateDaysTillNextHunter();

        // Generate terrain
        TileController tc = new TileController(GRID_SIZE);

        tc.InitGrid();
        foreach (List <Tile> gridX in tc.grid)
        {
            foreach (Tile t in gridX)
            {
                var terrainGameObject = Instantiate(terrainPrefab, t.location, Quaternion.identity);
                terrainGameObject.GetComponent <SpriteRenderer>().sprite         = t.sprite;
                terrainGameObject.GetComponent <SpriteRenderer>().material.color = t.color;

                // Add marsh ponds if required
                if (t.isMarshy)
                {
                    foreach (MarshSubTile m in t.marsh)
                    {
                        var marshGameObject = Instantiate(terrainPrefab, m.location, Quaternion.Euler(new Vector3(0, 0, (int)(m.rotation * 360))));
                        var sr = marshGameObject.GetComponent <SpriteRenderer>();
                        sr.sprite         = m.sprite;
                        sr.flipX          = m.flipX;
                        sr.flipY          = m.flipY;
                        sr.material.color = new Color(0.0f, 0.05f, 0.4f);
                    }
                }
            }
        }

        // Init the animal types.
        AnimalType.InitAnimalTypes();

        // Place some inital trees.
        for (int i = 0; i < 100; i++)
        {
            Vector3 c     = Random.onUnitSphere;
            Vector2 coord = new Vector2(c.x, c.y);
            coord = coord.normalized * Mathf.Sqrt(Random.Range(0f, 1f)) * 10f;
            PlantController newPlant = CreatePlant(coord, PlantType.GetRandomPlantType());
            newPlant.SetAge(Random.Range(1, newPlant.plantType.matureTime));
        }

        // Place some initial animals.
        foreach (var animalType in AnimalType.animalTypes)
        {
            for (int i = 0; i < animalType.GetHabitability(trees, animals); i++)
            {
                SpawnAnimal(animalType);
            }
        }

        UIController.instance.OnCarbonChanged();
        UIController.instance.OnWaterChanged();
    }
Exemplo n.º 21
0
    void PickNewTarget()
    {
        if (audioSource != null && Random.Range(0f, 1f) <= AUDIO_CHANCE_ON_TARGET_CHANGE)
        {
            audioSource.Play();
        }

        // First check we are near a tree.
        Collider2D[] colliders  = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), animalType.sightRange * 3);
        bool         treeNearby = false;

        foreach (var collider in colliders)
        {
            var pc = collider.GetComponent <PlantController>();
            if (pc != null)
            {
                // There is a tree nearby, so we are fine.
                treeNearby = true;
                break;
            }
        }
        if (!treeNearby)
        {
            // Move towards a random tree.
            target = GameController.instance.trees[Random.Range(0, GameController.instance.trees.Count)].transform.position;
            return;
        }

        // Anything to attack...
        if (FindAnimalTarget(animalType.attackRange))
        {
            return;
        }


        List <Vector3> possibleTargets = new List <Vector3>();

        // Check for anything to run away from...
        if (animalType.runsFrom.Count > 0)
        {
            colliders = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), animalType.sightRange);
            foreach (var collider in colliders)
            {
                AnimalController ac = collider.GetComponent <AnimalController>();
                if (ac != null && animalType.runsFrom.Find(x => x == ac.animalType) != null)
                {
                    // Run away from this animal.
                    possibleTargets.Add(transform.position + (transform.position - ac.transform.position));
                }
            }
        }

        if (possibleTargets.Count > 0)
        {
            float closest = Mathf.Infinity;
            foreach (var possibleTarget in possibleTargets)
            {
                var sqrMag = (possibleTarget - transform.position).sqrMagnitude;
                if (sqrMag < closest)
                {
                    closest = sqrMag;
                    target  = transform.position + (transform.position - possibleTarget).normalized * 100f;
                }
            }
            return;
        }

        // Okay, nothing to run from. Anything to run towards...
        if (FindAnimalTarget(animalType.sightRange))
        {
            return;
        }

        // Move towards a plant?
        if (animalType.attractedToPlants.Count > 0)
        {
            // Whether we move to a plant.
            bool moveToPlant = true;

            // If we aren't in eye sight of one of our favourite plants, move to the closest one.
            colliders = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), animalType.sightRange);
            foreach (var collider in colliders)
            {
                PlantController pc = collider.GetComponent <PlantController>();
                if (pc != null && animalType.attractedToPlants.Find(x => x == pc.plantType) != null)
                {
                    // We are close to one.
                    moveToPlant = false;
                    break;
                }
            }

            if (moveToPlant)
            {
                float closest = Mathf.Infinity;
                possibleTargets = new List <Vector3>();
                foreach (var plant in GameController.instance.trees)
                {
                    if (animalType.attractedToPlants.Find(x => x == plant.plantType) != null)
                    {
                        possibleTargets.Add(plant.transform.position);
                    }
                }
                foreach (var possibleTarget in possibleTargets)
                {
                    var sqrMag = (possibleTarget - transform.position).sqrMagnitude;
                    if (sqrMag < closest)
                    {
                        closest = sqrMag;
                        target  = possibleTarget;

                        // Make the time before the next target check be at most the time it will take to reach the target's current position.
                        timer = Random.Range(0f, (target - transform.position).magnitude / animalType.moveSpeed);
                    }
                }

                return;
            }
        }

        // Just move somewhere random.
        target = transform.position + Random.onUnitSphere * animalType.sightRange;
    }
Exemplo n.º 22
0
    float TreeClosest(PlantController tree)
    {
        float closestLocal = Vector3.SqrMagnitude(tree.transform.position - transform.position) + Vector3.SqrMagnitude(tree.transform.position - home.position);

        return(closestLocal);
    }
Exemplo n.º 23
0
        //public static Receive GetReceive(string receiveNo, string productCode)
        //{
        //    try
        //    {

        //        using (var conn = new MySqlConnection(Globals.CONN_STR))
        //        {
        //            conn.Open();
        //            var sql = @"SELECT x.*,y.farm_name,z.breeder_name
        //                        FROM
        //                            (SELECT a.receive_no,
        //                            a.receive_date,
        //                            a.transport_doc_no,
        //                            a.truck_no,
        //                            a.farm_code,
        //                            a.coop_no,
        //                            a.breeder_code,
        //                            a.queue_no,
        //                            a.farm_qty,
        //                            a.farm_wgh,
        //                            IFNULL(SUM(receive_qty),0) as factory_qty,
        //                            IFNULL(SUM(receive_wgh),0) as factory_wgh
        //                            FROM receives a
        //                            LEFT JOIN receive_item b
        //                            ON a.receive_no=b.receive_no
        //                            WHERE  a.receive_no =@receive_no
        //                            AND b.product_code =@product_code
        //                        ) x,farm y,breeder z
        //                        WHERE x.farm_code =y.farm_code
        //                        AND x.breeder_code =z.breeder_code";


        //            var cmd = new MySqlCommand(sql, conn);
        //            cmd.Parameters.AddWithValue("receive_no", receiveNo);
        //            cmd.Parameters.AddWithValue("product_code", productCode);
        //            var da = new MySqlDataAdapter(cmd);

        //            var ds = new DataSet();
        //            da.Fill(ds);

        //            Receive receive = new Receive();
        //            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        //            {


        //                receive.ReceiveNo = (string)ds.Tables[0].Rows[i]["receive_no"];
        //                receive.ReceiveDate = (DateTime)ds.Tables[0].Rows[i]["receive_date"];
        //                receive.TransportDocNo = (string)ds.Tables[0].Rows[i]["transport_doc_no"];
        //                receive.TruckNo = (string)ds.Tables[0].Rows[i]["truck_no"];
        //                receive.Farm = new Farm
        //                {
        //                    FarmCode = (string)ds.Tables[0].Rows[i]["farm_code"],
        //                    FarmName = (string)ds.Tables[0].Rows[i]["farm_name"]

        //                };
        //                receive.CoopNo = ds.Tables[0].Rows[i]["coop_no"].ToString();
        //                receive.Breeder = new Breeder
        //                {
        //                    BreederCode = ds.Tables[0].Rows[i]["breeder_code"].ToString().ToInt16(),
        //                    BreederName = (string)ds.Tables[0].Rows[i]["breeder_name"]
        //                };
        //                receive.QueueNo = ds.Tables[0].Rows[i]["queue_no"].ToString().ToInt16();
        //                receive.FarmQty = ds.Tables[0].Rows[i]["farm_qty"].ToString().ToInt16();
        //                receive.FarmWgh = ds.Tables[0].Rows[i]["farm_wgh"].ToString().ToDecimal();
        //                receive.FactoryQty = ds.Tables[0].Rows[i]["factory_qty"].ToString().ToInt16();
        //                receive.FactoryWgh = ds.Tables[0].Rows[i]["factory_wgh"].ToString().ToDecimal();
        //            }
        //            return receive;

        //        }
        //    }
        //    catch (Exception)
        //    {

        //        throw;
        //    }
        //}

        public static bool InsertOrUpdate(Receive receive)
        {
            try
            {
                var plant = PlantController.GetPlant();
                using (var conn = new MySqlConnection(Globals.CONN_STR))
                {
                    conn.Open();
                    if (string.IsNullOrEmpty(receive.ReceiveNo))
                    {
                        //ADD NEW
                        var sql = @"SELECT MAX(queue_no)
                                    FROM receives
                                    WHERE receive_date=@receive_date
                                    GROUP BY receive_no";

                        var cmd = new MySqlCommand(sql, conn);
                        cmd.Parameters.AddWithValue("receive_date", receive.ReceiveDate.ToString("yyyy/MM/dd"));
                        var queue_no = cmd.ExecuteScalar();
                        if (queue_no == null)
                        {
                            receive.QueueNo = 1;
                        }
                        else
                        {
                            receive.QueueNo = queue_no.ToString().ToInt16() + 1;
                        }

                        receive.ReceiveNo = DocumentGenerate.GetDocumentRunningFormat("REV", receive.ReceiveDate);
                        receive.LotNo     = DocumentGenerate.GetSwineLotNo(plant.PlantId, receive.QueueNo);
                        sql = @"INSERT INTO receives(
                                receive_no,
                                receive_date,
                                transport_doc_no,
                                truck_id,
                                farm_code,
                                coop_no,
                                breeder_code,
                                queue_no,
                                lot_no,
                                farm_qty,
                                farm_wgh,
                                receive_flag,
                                create_by)
                                VALUES(
                                @receive_no,
                                @receive_date,
                                @transport_doc_no,
                                @truck_id,
                                @farm_code,
                                @coop_no,
                                @breeder_code,
                                @queue_no,
                                @lot_no,
                                @farm_qty,
                                @farm_wgh,
                                @receive_flag,
                                @create_by)";
                        cmd = new MySqlCommand(sql, conn);
                        cmd.Parameters.AddWithValue("receive_no", receive.ReceiveNo);
                        cmd.Parameters.AddWithValue("receive_date", receive.ReceiveDate);
                        cmd.Parameters.AddWithValue("transport_doc_no", receive.TransportDocNo);
                        cmd.Parameters.AddWithValue("truck_id", receive.Truck.TruckId);
                        cmd.Parameters.AddWithValue("farm_code", receive.Farm.FarmCode);
                        cmd.Parameters.AddWithValue("coop_no", receive.CoopNo);
                        cmd.Parameters.AddWithValue("breeder_code", receive.Breeder.BreederCode);
                        cmd.Parameters.AddWithValue("queue_no", receive.QueueNo);
                        cmd.Parameters.AddWithValue("lot_no", receive.LotNo);
                        cmd.Parameters.AddWithValue("farm_qty", receive.FarmQty);
                        cmd.Parameters.AddWithValue("farm_wgh", receive.FarmWgh);
                        cmd.Parameters.AddWithValue("receive_flag", receive.ReceiveFlag);
                        cmd.Parameters.AddWithValue("create_by", receive.CreateBy);
                        cmd.ExecuteNonQuery();


                        //sql = @"INSERT INTO receive_item_by_product(
                        //            receive_no,
                        //            bom_product_code,
                        //            product_code,
                        //            lot_no,
                        //            target_qty,
                        //            target_wgh,
                        //            actual_qty,
                        //            actual_wgh,
                        //            create_by
                        //        )VALUES(
                        //            @receive_no,
                        //            @bom_product_code,
                        //            @product_code,
                        //            @lot_no,
                        //            @target_qty,
                        //            @target_wgh,
                        //            @actual_qty,
                        //            @actual_wgh,
                        //            @create_by
                        //        )";
                        ////GET BOM
                        ////00101 เครื่องในแดง
                        //List<string> list = BomItemController.GetBomItemByProductCode("00101");
                        //list.Add("00101");
                        ////INSERT By PRODUCT
                        //foreach (var item in list)
                        //{
                        //    int target_qty = item == "00101" ? (receive.FarmQty * (list.Count - 1)) : receive.FarmQty;
                        //    cmd = new MySqlCommand(sql, conn);
                        //    cmd.Parameters.AddWithValue("receive_no", receive.ReceiveNo);
                        //    cmd.Parameters.AddWithValue("bom_product_code", "00101");
                        //    cmd.Parameters.AddWithValue("product_code", item);
                        //    cmd.Parameters.AddWithValue("lot_no", receive.LotNo);
                        //    cmd.Parameters.AddWithValue("target_qty", target_qty == 0 ? receive.FarmQty : target_qty);
                        //    cmd.Parameters.AddWithValue("target_wgh", receive.FarmWgh);
                        //    cmd.Parameters.AddWithValue("actual_qty", 0);
                        //    cmd.Parameters.AddWithValue("actual_wgh", 0);
                        //    cmd.Parameters.AddWithValue("create_by", receive.CreateBy);
                        //    cmd.ExecuteNonQuery();
                        //}
                        //list.Clear();
                        ////00201 เครื่องในขาว
                        //list = BomItemController.GetBomItemByProductCode("00201");
                        //list.Add("00201");
                        ////INSERT By PRODUCT
                        //foreach (var item in list)
                        //{
                        //    int target_qty = item == "00201" ? (receive.FarmQty * (list.Count - 1)) : receive.FarmQty;
                        //    cmd = new MySqlCommand(sql, conn);
                        //    cmd.Parameters.AddWithValue("receive_no", receive.ReceiveNo);
                        //    cmd.Parameters.AddWithValue("bom_product_code", "00201");
                        //    cmd.Parameters.AddWithValue("product_code", item);
                        //    cmd.Parameters.AddWithValue("lot_no", receive.LotNo);
                        //    cmd.Parameters.AddWithValue("target_qty", target_qty == 0 ? receive.FarmQty : target_qty);
                        //    cmd.Parameters.AddWithValue("target_wgh", receive.FarmWgh);
                        //    cmd.Parameters.AddWithValue("actual_qty", 0);
                        //    cmd.Parameters.AddWithValue("actual_wgh", 0);
                        //    cmd.Parameters.AddWithValue("create_by", receive.CreateBy);
                        //    cmd.ExecuteNonQuery();
                        //}
                    }
                    else
                    {
                        //UPDATE
                        var sql = @"UPDATE receives SET
                                transport_doc_no=@transport_doc_no,
                                truck_id=@truck_id,
                                farm_code=@farm_code,
                                coop_no=@coop_no,
                                breeder_code=@breeder_code,
                                farm_qty=@farm_qty,
                                farm_wgh=@farm_wgh,
                                modified_at=CURRENT_TIMESTAMP,
                                modified_by=@modified_by
                                WHERE receive_no=@receive_no";
                        var cmd = new MySqlCommand(sql, conn);
                        cmd.Parameters.AddWithValue("receive_no", receive.ReceiveNo);
                        cmd.Parameters.AddWithValue("transport_doc_no", receive.TransportDocNo);
                        cmd.Parameters.AddWithValue("truck_id", receive.Truck.TruckId);
                        cmd.Parameters.AddWithValue("farm_code", receive.Farm.FarmCode);
                        cmd.Parameters.AddWithValue("coop_no", receive.CoopNo);
                        cmd.Parameters.AddWithValue("breeder_code", receive.Breeder.BreederCode);
                        cmd.Parameters.AddWithValue("farm_qty", receive.FarmQty);
                        cmd.Parameters.AddWithValue("farm_wgh", receive.FarmWgh);
                        cmd.Parameters.AddWithValue("modified_by", receive.ModifiedBy);
                        cmd.ExecuteNonQuery();
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }