예제 #1
0
        /// <summary>
        /// 开启关闭申报系列表新增
        /// </summary>
        /// <param name="DeclareSeriesID"></param>
        /// <param name="DeclareGradeID"></param>
        /// <param name="DeclareYearID"></param>
        /// <param name="Explain"></param>
        /// <returns></returns>
        public ActionResult InsertUnitDeclare(int DeclareSeriesID, int DeclareGradeID, int DeclareYearID, string Explain)
        {
            string strMsg = "fail";

            try
            {
                int oldUnitDeclare = (from tbUnitDeclare in myModels.B_UnitDeclare
                                      where
                                      tbUnitDeclare.DeclareSeriesID == DeclareSeriesID &&
                                      tbUnitDeclare.DeclareGradeID == DeclareGradeID &&
                                      tbUnitDeclare.Explain == Explain &&
                                      tbUnitDeclare.DeclareYearID == DeclareYearID
                                      select tbUnitDeclare).Count();
                if (oldUnitDeclare == 0)
                {
                    B_UnitDeclare myUnitDeclare = new B_UnitDeclare();
                    myUnitDeclare.DeclareSeriesID = DeclareSeriesID;
                    myUnitDeclare.DeclareGradeID  = DeclareGradeID;
                    myUnitDeclare.Explain         = Explain;
                    myUnitDeclare.DeclareYearID   = DeclareYearID;
                    myModels.B_UnitDeclare.Add(myUnitDeclare);
                    if (myModels.SaveChanges() > 0)
                    {
                        strMsg = "success";
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(Json(strMsg, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="unitDeclareId"></param>
        /// <returns></returns>
        public ActionResult DeleteUnitDeclareState(int unitDeclareId)
        {
            ReturnJsonVo returnJson = new ReturnJsonVo();

            try
            {
                B_UnitDeclare dbunitDeclare = (from tbUnitDeclare in myModels.B_UnitDeclare
                                               where tbUnitDeclare.UnitDeclareID == unitDeclareId
                                               select tbUnitDeclare).Single();
                myModels.B_UnitDeclare.Remove(dbunitDeclare);
                if (myModels.SaveChanges() > 0)
                {
                    returnJson.State = true;
                    returnJson.Text  = "删除成功";
                }
                else
                {
                    returnJson.State = false;
                    returnJson.Text  = "删除失败";
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                returnJson.State = false;
                returnJson.Text  = "数据异常";
            }
            return(Json(returnJson, JsonRequestBehavior.AllowGet));
        }