public VegetableSpeciesMaster_vsm_Info GetRecord_Previous(Model.Base.DataBaseCommandInfo commandInfo)
        {
            VegetableSpeciesMaster_vsm_Info vegetableSpeciesMasterInfo = null;

            if (commandInfo != null && commandInfo.KeyInfoList != null && commandInfo.KeyInfoList[0] != null && commandInfo.KeyInfoList[0].KeyValue != "")
            {
                try
                {
                    using (VPMSDBDataContext db = new VPMSDBDataContext())
                    {
                        VegetableSpeciesMaster_vsm vegetableSpecies = (from t in db.VegetableSpeciesMaster_vsm
                                                                       where t.vsm_iSeq < Convert.ToInt32(commandInfo.KeyInfoList[0].KeyValue)
                                                                       orderby t.vsm_iSeq descending
                                                                       select t).FirstOrDefault();

                        if (vegetableSpecies != null)
                        {
                            vegetableSpeciesMasterInfo = Common.General.CopyObjectValue <VegetableSpeciesMaster_vsm, VegetableSpeciesMaster_vsm_Info>(vegetableSpecies);
                        }
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }


            return(vegetableSpeciesMasterInfo);
        }
        public bool DeleteRecord(Model.IModel.IModelObject KeyObject)
        {
            bool isSuccess = false;

            VegetableSpeciesMaster_vsm_Info keyObject = KeyObject as VegetableSpeciesMaster_vsm_Info;

            if (keyObject != null)
            {
                try
                {
                    using (VPMSDBDataContext db = new VPMSDBDataContext())
                    {
                        VegetableSpeciesMaster_vsm vegetableSpeciesMaster = db.VegetableSpeciesMaster_vsm.FirstOrDefault(t => t.vsm_RecordID == keyObject.vsm_RecordID);

                        if (vegetableSpeciesMaster != null)
                        {
                            db.VegetableSpeciesMaster_vsm.DeleteOnSubmit(vegetableSpeciesMaster);

                            db.SubmitChanges();

                            isSuccess = true;
                        }
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }


            return(isSuccess);
        }
        public VegetableSpeciesMaster_vsm_Info GetRecord_Last()
        {
            VegetableSpeciesMaster_vsm_Info vegetableSpeciesMasterInfo = null;

            try
            {
                using (VPMSDBDataContext db = new VPMSDBDataContext())
                {
                    IEnumerable <VegetableSpeciesMaster_vsm> query = db.VegetableSpeciesMaster_vsm.OrderByDescending(t => t.vsm_iSeq);

                    if (query != null && query.Count() > 0)
                    {
                        VegetableSpeciesMaster_vsm vegetableSpeciesMaster = query.First();

                        if (vegetableSpeciesMaster != null)
                        {
                            vegetableSpeciesMasterInfo = Common.General.CopyObjectValue <VegetableSpeciesMaster_vsm, VegetableSpeciesMaster_vsm_Info>(vegetableSpeciesMaster);
                        }
                    }
                }
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(vegetableSpeciesMasterInfo);
        }
        /// <summary>
        /// 新增蔬菜品种主档记录
        /// </summary>
        /// <param name="infoObject"></param>
        /// <returns></returns>
        public bool InsertRecord(VegetableSpeciesMaster_vsm_Info infoObject)
        {
            bool isSuccess = false;

            if (infoObject != null)
            {
                try
                {
                    using (VPMSDBDataContext db = new VPMSDBDataContext())
                    {
                        VegetableSpeciesMaster_vsm vegetableSpeciesMaster = Common.General.CopyObjectValue <VegetableSpeciesMaster_vsm_Info, VegetableSpeciesMaster_vsm>(infoObject);

                        db.VegetableSpeciesMaster_vsm.InsertOnSubmit(vegetableSpeciesMaster);

                        this.InsertVegetableSpeciesTransactionTime(db, infoObject.VegetableSpeciesTransactionTimes);

                        this.InsertVegetableSpeciesMasterCost(db, infoObject.VegetableSpeciesMasterCosts);

                        this.InsertVegetableSpeciesPerdictYield(db, infoObject.VegetableSpeciesPerdictYields);

                        this.InsertVegetableSpeciesSuitPlantTime(db, infoObject.VegetableSpeciesSuitPlantTimes);

                        db.SubmitChanges();

                        isSuccess = true;
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }

            return(isSuccess);
        }
        /// <summary>
        /// 更新蔬菜品种主档记录
        /// </summary>
        /// <param name="infoObject"></param>
        /// <returns></returns>
        public bool UpdateRecord(VegetableSpeciesMaster_vsm_Info infoObject)
        {
            bool isSuccess = false;

            if (infoObject != null)
            {
                try
                {
                    using (VPMSDBDataContext db = new VPMSDBDataContext())
                    {
                        VegetableSpeciesMaster_vsm vegetableSpeciesMaster = db.VegetableSpeciesMaster_vsm.FirstOrDefault(t => t.vsm_RecordID == infoObject.vsm_RecordID);

                        if (vegetableSpeciesMaster != null)
                        {
                            vegetableSpeciesMaster.vsm_cName                = infoObject.vsm_cName;
                            vegetableSpeciesMaster.vsm_cTypeNum             = infoObject.vsm_cTypeNum;
                            vegetableSpeciesMaster.vsm_cByClassificationNum = infoObject.vsm_cByClassificationNum;
                            vegetableSpeciesMaster.vsm_iNurseryStage        = infoObject.vsm_iNurseryStage;
                            vegetableSpeciesMaster.vsm_iGrowingPeriod       = infoObject.vsm_iGrowingPeriod;
                            vegetableSpeciesMaster.vsm_iPickingPeriod       = infoObject.vsm_iPickingPeriod;
                            vegetableSpeciesMaster.vsm_iAcreYield           = infoObject.vsm_iAcreYield;
                            vegetableSpeciesMaster.vsm_iPlastochron         = infoObject.vsm_iPlastochron;
                            vegetableSpeciesMaster.vsm_cRemark              = infoObject.vsm_cRemark;
                            vegetableSpeciesMaster.vsm_dLastDate            = DateTime.Now;
                            vegetableSpeciesMaster.vsm_cLast                = infoObject.vsm_cLast;

                            this.UpdateVegetableSpeciesTransactionTime(db, infoObject.VegetableSpeciesTransactionTimes);

                            db.SubmitChanges();

                            isSuccess = true;
                        }
                    }
                }
                catch (Exception Ex)
                {
                    throw Ex;
                }
            }

            return(isSuccess);
        }