예제 #1
0
        public ActionResult ListGroupBySearch(int ProjectID)
        {
            object objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    StringBuilder strSql = new StringBuilder();
                    strSql.AppendFormat(@"select
                                        o.Id ID,
                                        o.GroupName Name
                                        from GroupInfo o
                                        where (o.IsDel!=1 or o.IsDel is null)
                                        and o.OrgId='{0}'", ProjectID);
                    List <ModelForIDAndName> list = db.Database.SqlQuery <ModelForIDAndName>(strSql.ToString()).ToList();
                    objResult = list;
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #2
0
        public ActionResult List(string Method, string Key)
        {
            object objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    List <ModelForProject> list = new List <ModelForProject>();
                    if (Method == "FirstLoad")
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append(@"select
                                        p.*,
                                        o.Name OrgName,
                                        g.GroupName GroupName
                                        from 
                                        ProjectInfo p
                                        left join GroupInfo g on g.Id=p.GroupId
                                        left join OrgInfo o on o.Id=p.OrgId
                                        where p.IsDel!=1");
                        list = db.Database.SqlQuery <ModelForProject>(strSql.ToString()).ToList();
                    }
                    else if (Method == "SearchLoad")
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.AppendFormat(@"select
                                            p.*,
                                            o.Name OrgName,
                                            g.GroupName GroupName
                                            from 
                                            ProjectInfo p
                                            left join GroupInfo g on g.Id=p.GroupId
                                            left join OrgInfo o on o.Id=p.OrgId
                                            where p.IsDel!=1
                                            and p.ProjectName like '%{0}%'", Key);
                        list = db.Database.SqlQuery <ModelForProject>(strSql.ToString()).ToList();
                    }
                    int    page  = string.IsNullOrWhiteSpace(Request["page"]) ? 1 : Int32.Parse(Request["page"]);
                    int    rows  = string.IsNullOrWhiteSpace(Request["rows"]) ? 1 : Int32.Parse(Request["rows"]);
                    string order = string.IsNullOrWhiteSpace(Request["order"]) ? "DESC" : Request["order"].ToUpper();
                    string sort  = string.IsNullOrWhiteSpace(Request["sort"]) ? "Id" : Request["sort"];
                    IQueryable <ProjectInfo> query = CommonTools.DataSorting <ProjectInfo>(list.AsQueryable(), sort, order).Skip((page - 1) * rows).Take(rows);
                    objResult = new { total = list.Count, rows = query };
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
                //throw;
            }
            return(Json(objResult));
        }
예제 #3
0
        public ActionResult ListOrg()
        {
            object objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    StringBuilder strSql = new StringBuilder();
                    strSql.Append(@"select
                                    o.Id ID,
                                    o.Name Name
                                    from OrgInfo o
                                    where o.IsDel!=1");
                    List <ModelForIDAndName> list = db.Database.SqlQuery <ModelForIDAndName>(strSql.ToString()).ToList();
                    objResult = list;
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #4
0
        public ActionResult List(string Method, string Key)
        {
            object objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    List <ModelForOrgUser> list = new List <ModelForOrgUser>();

                    if (Method == "FirstLoad")
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append(@"select
                                        g.*,
                                        g.Name MgrOrgName
                                        from OrgUser g
                                        where g.IsDel!=1 or g.IsDel is null");
                        list = db.Database.SqlQuery <ModelForOrgUser>(strSql.ToString()).ToList();
                    }
                    else if (Method == "SearchLoad")
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.AppendFormat(@"select
                                            g.*,
                                            g.Name MgrOrgName
                                            from OrgUser g
                                            where (g.IsDel!=1 or g.IsDel is null)
                                            and g.name like '%{0}%'", Key);
                        list = db.Database.SqlQuery <ModelForOrgUser>(strSql.ToString()).ToList();
                    }
                    int    page  = string.IsNullOrWhiteSpace(Request["page"]) ? 1 : Int32.Parse(Request["page"]);
                    int    rows  = string.IsNullOrWhiteSpace(Request["rows"]) ? 1 : Int32.Parse(Request["rows"]);
                    string order = string.IsNullOrWhiteSpace(Request["order"]) ? "DESC" : Request["order"].ToUpper();
                    string sort  = string.IsNullOrWhiteSpace(Request["sort"]) ? "Id" : Request["sort"];
                    IQueryable <ModelForOrgUser> query = CommonTools.DataSorting <ModelForOrgUser>(list.AsQueryable(), sort, order).Skip((page - 1) * rows).Take(rows);
                    objResult = new { total = list.Count, rows = query };
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
                //throw;
            }
            return(Json(objResult));
        }
예제 #5
0
 /// <summary>
 /// Save配置
 /// </summary>
 /// <param name="id"></param>
 /// <param name="IsDouble"></param>
 /// <param name="ScreenCount"></param>
 /// <param name="CardModel"></param>
 /// <param name="CardPointCount"></param>
 public void SaveDev(int id, int IsDouble, int ScreenCount, string CardModel, int CardPointCount)
 {
     using (LedDb db = new LedDb())
     {
         GasCardWithCommInfo aDev = db.GasCardWithCommInfo.Where(p => p.Id == id && p.IsDel != 1).FirstOrDefault();
         if (aDev != null)
         {
             aDev.CardIsDouble    = IsDouble;
             aDev.CardScreenCount = ScreenCount;
             aDev.CardModel       = CardModel;
             aDev.CardPointCount  = CardPointCount;
             db.SaveChanges();
         }
     }
 }
예제 #6
0
        public ActionResult GetGasCardInfo(int id)
        {
            object objResult = null;

            if (!string.IsNullOrWhiteSpace(id.ToString()))
            {
                using (LedDb db = new LedDb())
                {
                    GasCardWithCommInfo aGasCardInfo = db.GasCardWithCommInfo.Where(p => p.Id == id && p.IsDel != 1).FirstOrDefault();
                    if (aGasCardInfo != null)
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Station Information Get Success",
                            Msg    = " Station Information Get Success",
                            Obj    = aGasCardInfo,
                            Ret    = 1,
                            Status = true
                        };
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Status = false,
                            Ret    = -1,
                            Obj    = null,
                            Msg    = "No such record exists",
                            Desc   = "No such record exists"
                        };
                    }
                }
            }
            else
            {
                objResult = new ResultHelper()
                {
                    Status = false,
                    Ret    = -1,
                    Obj    = null,
                    Msg    = "id is null,Please try again later",
                    Desc   = "id is null,Please try again later"
                };
            }
            return(Json(objResult));
        }
예제 #7
0
        public bool SendCMD(int id, string value)
        {
            bool bSend = false;

            if (!string.IsNullOrWhiteSpace(id.ToString()))
            {
                using (LedDb db = new LedDb())
                {
                    string strError = string.Empty;
                    GlareSysEfDbAndModels.CmdLogs aLog = new GlareSysEfDbAndModels.CmdLogs()
                    {
                        CardInfoId = id,
                        CmdInfo    = value,
                        CmdType    = GlareLedSysDefPub.CmdDefSetOilValue,
                        CommDevId  = id,
                        CreateTime = DateTime.Now,
                        IsDetele   = 0,
                        Result     = 0,
                        ResultInfo = "",
                        UpdateTime = DateTime.Now
                    };
                    bSend = CmdLogsBll.AddCommDevInfo(ref aLog, out strError);

                    bSend = InsertCmdToMemcached(aLog.Id);
                    if (bSend)
                    {
                        for (int i = 1; i < 10; i++)
                        {
                            Thread.Sleep(1000);
                            if (RemoveCmdHandledInMemcached(aLog.Id))
                            {
                                bSend = true;
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                bSend = false;
            }
            return(bSend);
        }
        public ActionResult List(string Method, string Key)
        {
            object objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    List <SuperUser> list = new List <SuperUser>();

                    if (Method == "FirstLoad")
                    {
                        list = db.SuperUser.Where(p => p.IsDel != 1 || p.IsDel == null).ToList();
                    }
                    else if (Method == "SearchLoad")
                    {
                        list = db.SuperUser.Where(p => p.Name.Contains(Key) && p.IsDel != 1).ToList();
                    }
                    int    page  = string.IsNullOrWhiteSpace(Request["page"]) ? 1 : Int32.Parse(Request["page"]);
                    int    rows  = string.IsNullOrWhiteSpace(Request["rows"]) ? 1 : Int32.Parse(Request["rows"]);
                    string order = string.IsNullOrWhiteSpace(Request["order"]) ? "DESC" : Request["order"].ToUpper();
                    string sort  = string.IsNullOrWhiteSpace(Request["sort"]) ? "Id" : Request["sort"];
                    IQueryable <SuperUser> query = CommonTools.DataSorting <SuperUser>(list.AsQueryable(), sort, order).Skip((page - 1) * rows).Take(rows);
                    objResult = new { total = list.Count, rows = query };
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
                //throw;
            }
            return(Json(objResult));
        }
예제 #9
0
        public ActionResult Modify(GroupUser subject)
        {
            ResultHelper objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        GroupUser aSubject = db.GroupUser.Where(p => p.Id == subject.Id).FirstOrDefault();
                        //aSubject.CardName = subject.CardName;
                        //aSubject.CardModel = subject.CardModel;
                        //aSubject.ScreenCount = subject.ScreenCount;
                        //aSubject.ScreenNams = subject.ScreenNams;
                        aSubject          = subject;
                        aSubject.UpdateDt = DateTime.Now;
                        if (db.SaveChanges() > 0)
                        {
                            objResult = new ResultHelper()
                            {
                                Status = true,
                                Ret    = 0,
                                Obj    = subject,
                                Msg    = "Edit Success!",
                                Desc   = "Edit Success!"
                            };
                        }
                        else
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = "Edit Faile,please try again.",
                                Msg    = "Edit Faile,please try again.",
                                Obj    = null,
                                Ret    = -1,
                                Status = false
                            };
                        }
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #10
0
        public ActionResult SendCMD(int id, string value)
        {
            object objResult = null;

            if (!string.IsNullOrWhiteSpace(id.ToString()))
            {
                using (LedDb db = new LedDb())
                {
                    string strError = string.Empty;
                    GlareSysEfDbAndModels.CmdLogs aLog = new GlareSysEfDbAndModels.CmdLogs()
                    {
                        CardInfoId = id,
                        CmdInfo    = value,
                        CmdType    = GlareLedSysDefPub.CmdDefSetOilValue,
                        CommDevId  = id,
                        CreateTime = DateTime.Now,
                        IsDetele   = 0,
                        Result     = 0,
                        ResultInfo = "",
                        UpdateTime = DateTime.Now
                    };
                    bool bSend = CmdLogsBll.AddCommDevInfo(ref aLog, out strError);

                    bSend = InsertCmdToMemcached(aLog.Id);
                    bool bRecived = false;
                    if (bSend)
                    {
                        for (int i = 1; i < 10; i++)
                        {
                            Thread.Sleep(1000);
                            if (RemoveCmdHandledInMemcached(aLog.Id))
                            {
                                bRecived = true;
                                break;
                            }
                        }
                    }

                    if (bRecived)
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = "Command issued Success",
                            Msg    = "Command issued Success",
                            Obj    = aLog,
                            Ret    = 1,
                            Status = true
                        };
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Status = false,
                            Ret    = -1,
                            Obj    = null,
                            Msg    = strError,
                            Desc   = strError
                        };
                    }
                }
            }
            else
            {
                objResult = new ResultHelper()
                {
                    Status = false,
                    Ret    = -1,
                    Obj    = null,
                    Msg    = "id is null,Please try again later",
                    Desc   = "id is null,Please try again later"
                };
            }
            return(Json(objResult));
        }
예제 #11
0
        public ActionResult Delete(string ProjectIds)
        {
            ResultHelper objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        string[] Id     = ProjectIds.Split(',');
                        string   strMsg = string.Empty;
                        for (int i = 0; i < Id.Length; i++)
                        {
                            ProjectBll.DeleteAProject(int.Parse(Id[i]), out strMsg);
                        }
                        objResult = new ResultHelper()
                        {
                            Status = true,
                            Ret    = 0,
                            Obj    = ProjectIds,
                            Msg    = strMsg,
                            Desc   = strMsg
                        };
                        //StringBuilder strSql = new StringBuilder();
                        //strSql.AppendFormat(@"UPDATE ProjectInfo SET IsDel = 1 WHERE Id IN ({0})", ProjectIds);
                        //if (db.Database.ExecuteSqlCommand(strSql.ToString()) > 0)
                        //{

                        //    objResult = new ResultHelper()
                        //    {
                        //        Status = true,
                        //        Ret = 0,
                        //        Obj = ProjectIds,
                        //        Msg = "Delete Success!",
                        //        Desc = "Delete Success!"
                        //    };
                        //}
                        //else
                        //{
                        //    objResult = new ResultHelper()
                        //    {
                        //        Desc = "Delete Faile,please try again.",
                        //        Msg = "Delete Faile,please try again.",
                        //        Obj = null,
                        //        Ret = -1,
                        //        Status = false
                        //    };
                        //}
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #12
0
        public ActionResult Modify(GlareSysEfDbAndModels.ProjectInfo subject)
        {
            ResultHelper objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        ProjectInfo aSubject = db.ProjectInfo.Where(p => p.Id == subject.Id).FirstOrDefault();
                        aSubject.ProjectName = subject.ProjectName;
                        aSubject.ManagerName = subject.ManagerName;
                        aSubject.Address     = subject.Address;
                        aSubject.ManagerTel  = subject.ManagerTel;
                        aSubject.OrgId       = subject.OrgId;
                        aSubject.GroupId     = subject.GroupId;
                        aSubject.UpdateDt    = DateTime.Now;
                        string strMsg = string.Empty;
                        bool   b      = ProjectBll.UpdateProejct(ref subject, out strMsg);
                        if (b)
                        {
                            objResult = new ResultHelper()
                            {
                                Status = true,
                                Ret    = 0,
                                Obj    = subject,
                                Msg    = strMsg,
                                Desc   = strMsg
                            };
                        }
                        else
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = strMsg,
                                Msg    = strMsg,
                                Obj    = null,
                                Ret    = -1,
                                Status = false
                            };
                        }
                        //if (db.SaveChanges() > 0)
                        //{

                        //    objResult = new ResultHelper()
                        //    {
                        //        Status = true,
                        //        Ret = 0,
                        //        Obj = subject,
                        //        Msg = "Edit Success!",
                        //        Desc = "Edit Success!"
                        //    };
                        //}
                        //else
                        //{
                        //    objResult = new ResultHelper()
                        //    {
                        //        Desc = "Edit Faile,please try again.",
                        //        Msg = "Edit Faile,please try again.",
                        //        Obj = null,
                        //        Ret = -1,
                        //        Status = false
                        //    };
                        //}
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #13
0
        public ActionResult Add(GlareSysEfDbAndModels.ProjectInfo subject)
        {
            ResultHelper objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        subject.UpdateDt = DateTime.Now;
                        subject.CreateDt = DateTime.Now;
                        subject.IsDel    = 0;

                        subject.UpdateDt = DateTime.Now;
                        subject.CreateDt = DateTime.Now;
                        subject.IsDel    = 0;
                        string strMsg = string.Empty;
                        bool   b      = ProjectBll.AddAProject(ref subject, out strMsg);
                        if (b)
                        {
                            objResult = new ResultHelper()
                            {
                                Status = true,
                                Ret    = 0,
                                Obj    = subject,
                                Msg    = strMsg,
                                Desc   = strMsg
                            };
                        }
                        else
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = strMsg,
                                Msg    = strMsg,
                                Obj    = null,
                                Ret    = -1,
                                Status = false
                            };
                        }
                        //db.ProjectInfo.Add(subject);
                        //if (db.SaveChanges() > 0)
                        //{

                        //    objResult = new ResultHelper()
                        //    {
                        //        Status = true,
                        //        Ret = 0,
                        //        Obj = subject,
                        //        Msg = "Add  Success!",
                        //        Desc = "Add  Success!"
                        //    };
                        //}
                        //else
                        //{
                        //    objResult = new ResultHelper()
                        //    {
                        //        Desc = "Add  Faile,please try again.",
                        //        Msg = "Add  Faile,please try again.",
                        //        Obj = null,
                        //        Ret = -1,
                        //        Status = false
                        //    };
                        //}
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #14
0
        public ActionResult Setcfg(int id, int IsDouble, int ScreenCount, string CardModel, int CardPointCount)
        {
            object objResult = null;

            if (!string.IsNullOrWhiteSpace(id.ToString()))
            {
                using (LedDb db = new LedDb())
                {
                    string strError = string.Empty;

                    //1             //双面显示(单面为0x00)  isdouble
                    //3             //一面三个牌 screencount
                    //5             //每个牌5个8(包含小8) 价格数字的数量(CardModel,例如:GL-88888,那就填写5,GL-88888-8(上标小字),填写6
                    //0             //是否显示9/10(如果是GL-888-8-910,则为1,否则为0)
                    //8             //亮度等级,永远写8
                    string CmdInfo = "";
                    if (IsDouble == 1)//双面显示
                    {
                        CmdInfo = "1";
                    }
                    else
                    {
                        CmdInfo = "0x00";
                    }
                    CmdInfo = CmdInfo + "-" + ScreenCount.ToString();//screencount

                    string strEightModel = CardModel.Replace("GL", "").Replace("-", "");
                    int    iEightCount   = strEightModel.Length;
                    CmdInfo = CmdInfo + "-" + iEightCount.ToString(); //每个牌5个8(包含小8)

                    if (CardModel.Contains("910"))                    //是否显示9/10
                    {
                        CmdInfo = CmdInfo + "-1";
                    }
                    else
                    {
                        CmdInfo = CmdInfo + "-0";
                    }
                    CmdInfo = CmdInfo + "-8";//亮度
                    GlareSysEfDbAndModels.CmdLogs cmd = new GlareSysEfDbAndModels.CmdLogs()
                    {
                        CardInfoId = id,
                        CmdInfo    = CmdInfo,
                        CmdType    = GlareLedSysDefPub.CmdDefSetOilCfg,
                        CommDevId  = id,
                        CreateTime = DateTime.Now,
                        Id         = 0,
                        IsDetele   = 0,
                        Result     = 0,
                        ResultInfo = "",
                        UpdateTime = DateTime.Now
                    };
                    CmdLogsBll.AddCommDevInfo(ref cmd, out strError);

                    bool bSend    = InsertCmdToMemcached(cmd.Id);
                    bool bRecived = false;
                    if (bSend)
                    {
                        for (int i = 1; i < 10; i++)
                        {
                            Thread.Sleep(1000);
                            if (RemoveCmdHandledInMemcached(cmd.Id))
                            {
                                bRecived = true;
                                break;
                            }
                        }
                    }

                    if (bRecived)
                    {
                        bool bSetPoint = SetPoint(id, IsDouble, ScreenCount, CardModel, CardPointCount);
                        if (bSetPoint)
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = "Command issued Success",
                                Msg    = "Command issued Success",
                                Obj    = cmd,
                                Ret    = 1,
                                Status = true
                            };
                        }
                        else
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = "Setcfg Success,Command issued Faile,please try again",
                                Msg    = "Setcfg Success,Command issued Faile,please try again",
                                Obj    = cmd,
                                Ret    = -1,
                                Status = false
                            };
                        }
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Status = false,
                            Ret    = -1,
                            Obj    = null,
                            Msg    = strError,
                            Desc   = strError
                        };
                    }
                }
            }
            else
            {
                objResult = new ResultHelper()
                {
                    Status = false,
                    Ret    = -1,
                    Obj    = null,
                    Msg    = "id is null,Please try again later",
                    Desc   = "id is null,Please try again later"
                };
            }
            return(Json(objResult));
        }
예제 #15
0
        public ActionResult Save(GasCardWithCommInfo subject)
        {
            ResultHelper objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        GasCardWithCommInfo aSubject = db.GasCardWithCommInfo.Where(p => p.Id == subject.Id).FirstOrDefault();
                        aSubject.Name            = subject.Name;
                        aSubject.CommServerSn    = subject.CommServerSn;
                        aSubject.CardModel       = subject.CardModel;
                        aSubject.CardPointCount  = subject.CardPointCount;
                        aSubject.CardIsDouble    = subject.CardIsDouble;
                        aSubject.CardScreenCount = subject.CardScreenCount;
                        aSubject.CardContext     = subject.CardContext;
                        aSubject.UpdateDt        = DateTime.Now;
                        if (db.SaveChanges() > 0)
                        {
                            objResult = new ResultHelper()
                            {
                                Status = true,
                                Ret    = 0,
                                Obj    = subject,
                                Msg    = "Edit Success!",
                                Desc   = "Edit Success!"
                            };
                        }
                        else
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = "Edit Faile,please try again.",
                                Msg    = "Edit Faile,please try again.",
                                Obj    = null,
                                Ret    = -1,
                                Status = false
                            };
                        }
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #16
0
        public ActionResult Delete(string SubjectIDs)
        {
            ResultHelper objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.AppendFormat(@"UPDATE GroupUser SET IsDel = 1 WHERE Id IN ({0})", SubjectIDs);
                        if (db.Database.ExecuteSqlCommand(strSql.ToString()) > 0)
                        {
                            objResult = new ResultHelper()
                            {
                                Status = true,
                                Ret    = 0,
                                Obj    = SubjectIDs,
                                Msg    = "Delete Success!",
                                Desc   = "Delete Success!"
                            };
                        }
                        else
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = "Delete Faile,please try again.",
                                Msg    = "Delete Faile,please try again.",
                                Obj    = null,
                                Ret    = -1,
                                Status = false
                            };
                        }
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #17
0
        public ActionResult SaveBatchOilPrice(string Price1, string Price2, string Price3, string Price4,
                                              string Price5, string Price6, string Price7, string Price8, string Price9, string Price10,
                                              string Price11, string Price12, string BatchIds)
        {
            ResultHelper objResult = null;

            try
            {
                string Context = Price1 + "-" + Price2 + "-" + Price3 + "-" + Price4 + "-" + Price5 + "-" + Price6 + "-"
                                 + Price7 + "-" + Price8 + "-" + Price9 + "-" + Price10 + "-" + Price11 + "-" + Price12;
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.AppendFormat(@"UPDATE GasCardWithCommInfo SET CardContext = {0} WHERE Id IN ({1})", Context, BatchIds);
                        if (db.Database.ExecuteSqlCommand(strSql.ToString()) > 0)
                        {
                            objResult = new ResultHelper()
                            {
                                Status = true,
                                Ret    = 0,
                                Obj    = BatchIds,
                                Msg    = "Batch Upadate  Success!",
                                Desc   = "Batch Upadate  Success!"
                            };
                            string[] id = BatchIds.Split(',');
                            for (int i = 0; i < id.Length; i++)
                            {
                                int iID = DataFormat.ConvertDBNullToInt32(id[i]);
                                SendCMD(iID, Context);
                            }
                        }
                        else
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = "Batch Upadate  Faile,please try again.",
                                Msg    = "Batch Upadate  Faile,please try again.",
                                Obj    = null,
                                Ret    = -1,
                                Status = false
                            };
                        }
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #18
0
        public ActionResult Add(GroupUser subject)
        {
            ResultHelper objResult = null;

            try
            {
                using (LedDb db = new LedDb())
                {
                    if (ModelState.IsValid)
                    {
                        subject.UpdateDt = DateTime.Now;
                        subject.CreateDt = DateTime.Now;
                        subject.IsDel    = 0;
                        db.GroupUser.Add(subject);
                        if (db.SaveChanges() > 0)
                        {
                            objResult = new ResultHelper()
                            {
                                Status = true,
                                Ret    = 0,
                                Obj    = subject,
                                Msg    = "Add  Success!",
                                Desc   = "Add  Success!"
                            };
                        }
                        else
                        {
                            objResult = new ResultHelper()
                            {
                                Desc   = "Add  Faile,please try again.",
                                Msg    = "Add  Faile,please try again.",
                                Obj    = null,
                                Ret    = -1,
                                Status = false
                            };
                        }
                    }
                    else
                    {
                        objResult = new ResultHelper()
                        {
                            Desc   = " Faile,please try again",
                            Msg    = " Faile,please try again",
                            Obj    = null,
                            Ret    = -1,
                            Status = false
                        };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
            }
            return(Json(objResult));
        }
예제 #19
0
        public ActionResult List(string Method, string Key, string NodeId)
        {
            object objResult = null;

            try
            {
                List <ModelForGasCardWithCommInfo> list = new List <ModelForGasCardWithCommInfo>();
                if (string.IsNullOrWhiteSpace(NodeId))
                {
                    list = DataLoader.GetAllGasCardWithCommInfoList();
                    int    page  = string.IsNullOrWhiteSpace(Request["page"]) ? 1 : Int32.Parse(Request["page"]);
                    int    rows  = string.IsNullOrWhiteSpace(Request["rows"]) ? 1 : Int32.Parse(Request["rows"]);
                    string order = string.IsNullOrWhiteSpace(Request["order"]) ? "DESC" : Request["order"].ToUpper();
                    string sort  = string.IsNullOrWhiteSpace(Request["sort"]) ? "Id" : Request["sort"];
                    IQueryable <GasCardWithCommInfo> query = CommonTools.DataSorting <GasCardWithCommInfo>(list.AsQueryable(), sort, order).Skip((page - 1) * rows).Take(rows);
                    objResult = new { total = list.Count, rows = query };
                }
                else
                {
                    string[] strNodeIdSplit = NodeId.Split('_');
                    string   strType        = strNodeIdSplit[0];

                    string strId = strNodeIdSplit[1];
                    int    iId   = DataFormat.ConvertDBNullToInt32(strId);
                    using (LedDb db = new LedDb())
                    {
                        if (Method == "FirstLoad")
                        {
                            if (string.IsNullOrWhiteSpace(NodeId))
                            {
                                list = DataLoader.GetAllGasCardWithCommInfoList();
                            }
                            else
                            {
                                if (strType == "org")
                                {
                                    list = DataLoader.GetGasCardWithCommInfoByOrgId(strId);
                                }
                                else if (strType == "group")
                                {
                                    list = DataLoader.GetGasCardWithCommInfoByGorupID(strId);
                                }
                                else if (strType == "project")
                                {
                                    list = DataLoader.GetGasCardWithCommInfoByProjectID(strId);
                                }
                            }
                        }
                        else if (Method == "SearchLoad")
                        {
                            //list = db.GasCardWithCommInfo.Where(p => p.Name.Contains(Key) && p.IsDel != 1).ToList();
                        }
                        int    page  = string.IsNullOrWhiteSpace(Request["page"]) ? 1 : Int32.Parse(Request["page"]);
                        int    rows  = string.IsNullOrWhiteSpace(Request["rows"]) ? 1 : Int32.Parse(Request["rows"]);
                        string order = string.IsNullOrWhiteSpace(Request["order"]) ? "DESC" : Request["order"].ToUpper();
                        string sort  = string.IsNullOrWhiteSpace(Request["sort"]) ? "Id" : Request["sort"];
                        IQueryable <GasCardWithCommInfo> query = CommonTools.DataSorting <GasCardWithCommInfo>(list.AsQueryable(), sort, order).Skip((page - 1) * rows).Take(rows);
                        objResult = new { total = list.Count, rows = query };
                    }
                }
            }
            catch (Exception ex)
            {
                objResult = new ResultHelper()
                {
                    Desc   = ex.Message,
                    Msg    = ex.Message,
                    Obj    = null,
                    Ret    = -1,
                    Status = false
                };
                //throw;
            }
            return(Json(objResult));
        }