public ActionResult Save(int id)
 {
     try
     {
         Insemination insemination = new Insemination();
         // insemination.EarNum = id;
         UpdateModel <Insemination>(insemination);
         Cow cow = bllCow.GetCowInfo(insemination.EarNum);
         int s   = insemination.EarNum;
         //根据用户输入的配种信息,判断是否存在此头牛的信息,如果不存在弹框提示
         if (cow.FarmCode == null)
         {
             return(RedirectToAction("../Index/List"));
         }
         else
         {
             //ToDo:将insemination对象的数据保存到数据库中
             bool isInsemExist = bllInsemination.IsInsemExist(insemination.EarNum, insemination.InseminationNum);
             if (isInsemExist == true)
             {
                 //bllInsemination.UpdateInseminationInfo(insemination);
             }
             else
             {
                 bllInsemination.InsertInseminationInfo(insemination);
             }
             return(RedirectToAction("../Index/List"));
         }
     }
     catch (Exception e)
     {
         return(View());
     }
 }
        public bool UpdateInsemination(int id, string date)
        {
            Insemination insemination = inseminationDAL.GetByID(id);

            insemination.Date = DateTime.ParseExact(date, "MM/dd/yyyy", CultureInfo.InvariantCulture);
            return(inseminationDAL.Update(insemination) > 0);
        }
        public bool CancelInsemination(int id)
        {
            Insemination insemination = inseminationDAL.GetByID(id);

            insemination.Result = false;
            return(inseminationDAL.Update(insemination) > 0);
        }
 public ActionResult AddInsemination(Insemination insemination)
 {
     if (!new BLL.InseminationController().AddInseminationForCattle(insemination))
     {
         return(HttpNotFound());
     }
     return(RedirectToAction("Index", "Cattle", new { new BLL.CattleController().GetCattleByEarringNumber(insemination.CattleID).CattleTypeID }));
 }
Esempio n. 5
0
        /// <summary>
        /// 获取最新配种信息
        /// </summary>
        /// <param name="earNum">耳号</param>
        /// <returns></returns>
        public Insemination GetLatestInsemination(int earNum)
        {
            Insemination inseminationInfo = new Insemination();
            DataRow      datInsemination  = this.dalInsemination.GetLatestInsemination(earNum);

            if (datInsemination != null)
            {
                inseminationInfo = WrapInseminationItem(datInsemination);
            }
            return(inseminationInfo);
        }
Esempio n. 6
0
        public Insemination GetInseminationInfo(int earNum, int parityNum, int inseminationNum)
        {
            Insemination inseminationInfo = new Insemination();
            DataTable    datInsemination  = this.dalInsemination.GetInseminationList(earNum, inseminationNum);

            if (datInsemination != null && datInsemination.Rows.Count == 1)
            {
                inseminationInfo = WrapInseminationItem(datInsemination.Rows[0]);
            }
            return(inseminationInfo);
        }
 public ActionResult Edit(string id)
 {
     if (id == null)
     {
         //ViewBag.Insemination = Utility.JsonSerialize(insem);
         ViewBag.EarNum           = "0";
         ViewBag.ParityNum        = 0;
         ViewBag.InseminationNum  = 0;
         ViewBag.SemenNum         = "";
         ViewBag.SemenType        = 0;
         ViewBag.EstrusFindType   = 0;
         ViewBag.OperateDate      = DateTime.Today.ToShortDateString().ToString();
         ViewBag.Operator         = "";
         ViewBag.Description      = "";
         ViewBag.EstrusDate       = DateTime.Today.ToShortDateString().ToString();
         ViewBag.EstrusType       = 0;
         ViewBag.EstrusFindPerson = "";
         return(View("~/Views/Breed/Insemination/Edit.cshtml"));
     }
     else
     {
         Insemination insemination = bllInsemination.GetInseminationInfo(Convert.ToInt32(id));
         if (insemination == null)
         {
             ViewBag.EarNum           = "0";
             ViewBag.InseminationNum  = 0;
             ViewBag.SemenNum         = "";
             ViewBag.SemenType        = 0;
             ViewBag.EstrusFindType   = 0;
             ViewBag.OperateDate      = DateTime.Today.ToShortDateString().ToString();
             ViewBag.Operator         = "";
             ViewBag.Description      = "";
             ViewBag.EstrusDate       = DateTime.Today.ToShortDateString().ToString();
             ViewBag.EstrusType       = 0;
             ViewBag.EstrusFindPerson = "";
         }
         else
         {
             ViewBag.EarNum           = id;
             ViewBag.InseminationNum  = insemination.InseminationNum;
             ViewBag.SemenNum         = insemination.SemenNum;
             ViewBag.SemenType        = insemination.SemenType;
             ViewBag.EstrusFindType   = insemination.EstrusFindType;
             ViewBag.OperateDate      = insemination.OperateDate;
             ViewBag.Operator         = UserBLL.Instance.CurrentUser.Name; // insemination.OperatorID;
             ViewBag.Description      = insemination.Description;
             ViewBag.EstrusDate       = insemination.EstrusDate;
             ViewBag.EstrusType       = insemination.EstrusType;
             ViewBag.EstrusFindPerson = insemination.EstrusFindPerson;
         }
         return(View("~/Views/Breed/Insemination/Edit.cshtml"));
     }
 }
Esempio n. 8
0
        public List <Insemination> GetInseminationList()
        {
            List <Insemination> lstInsemination = new List <Insemination>();
            DataTable           datInsemination = this.dalInsemination.GetInseminationList();

            foreach (DataRow drInsemination in datInsemination.Rows)
            {
                Insemination inseminationItem = WrapInseminationItem(drInsemination);
                lstInsemination.Add(inseminationItem);
            }
            return(lstInsemination);
        }
Esempio n. 9
0
        private Insemination WrapInseminationItem(DataRow inseminationRow)
        {
            Insemination inseminationItem = new Insemination();

            if (inseminationRow != null)
            {
                if (Convert.ToInt32(inseminationRow["ID"]) != 0)
                {
                    inseminationItem.ID = Convert.ToInt32(inseminationRow["ID"]);
                }
                inseminationItem.EarNum = Convert.ToInt32(inseminationRow["EarNum"]);
                if (inseminationRow["InseminationNum"] != null && !string.IsNullOrWhiteSpace(inseminationRow["InseminationNum"].ToString()))
                {
                    inseminationItem.InseminationNum = Convert.ToInt32(inseminationRow["InseminationNum"]);
                }
                inseminationItem.SemenNum = inseminationRow["SemenNum"].ToString();
                if (inseminationRow["SemenType"] != null && !string.IsNullOrWhiteSpace(inseminationRow["SemenType"].ToString()))
                {
                    inseminationItem.SemenType = Convert.ToInt32(inseminationRow["SemenType"]);
                }
                if (inseminationRow["EstrusFindType"] != null && !string.IsNullOrWhiteSpace(inseminationRow["EstrusFindType"].ToString()))
                {
                    inseminationItem.EstrusFindType = Convert.ToInt32(inseminationRow["EstrusFindType"]);
                }

                if (inseminationRow["OperateDate"] != DBNull.Value)
                {
                    inseminationItem.OperateDate = Convert.ToDateTime(inseminationRow["OperateDate"]);
                }

                //inseminationItem.Operator = inseminationRow["Operator"].ToString();
                inseminationItem.Description = inseminationRow["Description"].ToString();

                if (inseminationRow["EstrusDate"] != DBNull.Value)
                {
                    inseminationItem.EstrusDate = Convert.ToDateTime(inseminationRow["EstrusDate"]);
                }

                if (inseminationRow["EstrusType"] != DBNull.Value && string.IsNullOrWhiteSpace(inseminationRow["EstrusType"].ToString()))
                {
                    inseminationItem.EstrusType = Convert.ToInt32(inseminationRow["EstrusType"]);
                }
                if (inseminationRow["EstrusFindPerson"] != DBNull.Value)
                {
                    inseminationItem.EstrusFindPerson = inseminationRow["EstrusFindPerson"].ToString();
                }
            }
            return(inseminationItem);
        }
        public ActionResult SaveTask(string id)
        {
            try
            {
                string displayEarNum = Request.Form["DisplayEarNum"];
                string startDate     = Request.Form["start"];
                string endDate       = Request.Form["end"];
                string operatorID    = Request.Form["operatorName"]; //@德华 怀疑有错
                string knownWay      = Request.Form["knownWay"];
                string semenNum      = Request.Form["semNum"];
                string semenCount    = Request.Form["semCount"];
                string desc          = Request.Form["description"];

                Insemination i = new Insemination();
                i.EstrusDate      = DateTime.Parse(startDate);
                i.OperateDate     = DateTime.Parse(endDate);
                i.EarNum          = CowBLL.ConvertDislayEarNumToEarNum(displayEarNum, UserBLL.Instance.CurrentUser.Pasture.ID);
                i.operatorID      = Convert.ToInt32(operatorID);
                i.EstrusFindType  = Convert.ToInt32(knownWay);
                i.SemenNum        = semenNum;
                i.InseminationNum = Convert.ToInt32(semenCount);
                i.Description     = desc;

                DairyTask task = new DairyTask();
                task.TaskType     = TaskType.InseminationTask;
                task.EarNum       = CowBLL.ConvertDislayEarNumToEarNum(displayEarNum, UserBLL.Instance.CurrentUser.Pasture.ID);
                task.ArrivalTime  = DateTime.Parse(startDate);
                task.CompleteTime = DateTime.Parse(endDate);
                task.DeadLine     = DateTime.Parse(endDate);
                task.RoleID       = UserBLL.Instance.CurrentUser.Role.ID;
                task.PastureID    = UserBLL.Instance.CurrentUser.Pasture.ID;
                task.OperatorID   = Convert.ToInt32(operatorID);

                bllTask.CompleteInsemination(task, i);

                return(View("~/Views/Task/Index.cshtml"));
            }
            catch (Exception)
            {
                return(View("~/Views/Task/TaskError.cshtml"));
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 点击[繁殖-发情配种],增加发情/配种任务
        /// </summary>
        public void CompleteInsemination(DairyTask task, Insemination insemination)
        {
            CowInfo cow = new CowInfo(insemination.EarNum);

            // 添加任务记录,添加即已完成 Todo
            task.Status    = DairyTaskStatus.Completed;
            task.InputTime = DateTime.Now;
            taskDAL.InsertTask(task);

            // 删除无效的妊检任务单
            RemovePreviousInspectionTasks(insemination.EarNum, true);
            RemovePreviousInspectionTasks(insemination.EarNum, false);

            // 产生新妊检任务单
            DairyTask initialInspectionTask = new DairyTask();

            initialInspectionTask.TaskType    = TaskType.InitialInspectionTask;
            initialInspectionTask.Status      = DairyTaskStatus.Initial;
            initialInspectionTask.ArrivalTime = task.CompleteTime.AddDays(DairyParameterBLL.GetCurrentParameterDictionary(cow.FarmCode)[FarmInfo.PN_DAYSOFINITIALINSPECTION]);

            // 3 days to complete task
            initialInspectionTask.DeadLine = initialInspectionTask.ArrivalTime.AddDays(3.0);
            initialInspectionTask.EarNum   = insemination.EarNum;

            // 分配配种员
            initialInspectionTask.OperatorID = AssignTask(task.PastureID, task.EarNum, Role.FARM_INSEMINATOR_ID);

            initialInspectionTask.RoleID    = task.RoleID;
            initialInspectionTask.PastureID = task.PastureID;
            initialInspectionTask.InputTime = DateTime.Now;
            taskDAL.InsertTask(initialInspectionTask);

            // 添加配种记录
            InseminationBLL insemBLL = new InseminationBLL();

            insemBLL.InsertInseminationInfo(insemination);

            // 更新牛繁殖状态
            CowBLL cowBLL = new CowBLL();

            cowBLL.UpdateCowBreedStatus(insemination.EarNum, "已配未检");
        }
Esempio n. 12
0
        /// <summary>
        /// 插入假配种记录,为入群用
        /// </summary>
        /// <param name="earNum"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public int InsertFakeInsemination(int earNum, DateTime date)
        {
            Insemination i = new Insemination();

            i.EarNum      = earNum;
            i.OperateDate = date;
            CowBLL      cb   = new CowBLL();
            CowGroupBLL gBLL = new CowGroupBLL();

            i.operatorID       = 0;//gBLL.GetCowGroupInfo(cb.GetCowInfo(earNum).GroupID).InsemOperatorID;
            i.InseminationNum  = 1;
            i.EstrusFindPerson = "孙悟空";
            i.EstrusDate       = date;
            i.EstrusFindType   = 0;
            i.Description      = "";
            i.SemenNum         = "NA";
            i.SemenType        = 0;
            i.Description      = "";
            i.EstrusType       = 0;
            return(InsertInseminationInfo(i));
        }
Esempio n. 13
0
 public int Add(Insemination insemination)
 {
     db.Entry(insemination).State = EntityState.Added;
     return(db.SaveChanges());
 }
Esempio n. 14
0
 public int Update(Insemination insemination)
 {
     db.Entry(insemination).State = EntityState.Modified;
     return(db.SaveChanges());
 }
Esempio n. 15
0
 public int Delete(Insemination insemination)
 {
     db.Entry(insemination).State = EntityState.Deleted;
     return(db.SaveChanges());
 }
 public bool AddInseminationForCattle(Insemination insemination)
 {
     return(inseminationDAL.Add(insemination) > 0);
 }
Esempio n. 17
0
 /// <summary>
 /// 插入配种记录
 /// </summary>
 /// <param name="ii"></param>
 /// <returns></returns>
 public int InsertInseminationInfo(Insemination ii)
 {
     return(dalInsemination.InsertInseminationInfo(ii.EarNum, ii.InseminationNum, ii.SemenNum, ii.SemenType, ii.EstrusDate, ii.EstrusType, ii.EstrusFindType, ii.EstrusFindPerson, ii.OperateDate, ii.Description, ii.operatorID));
 }