Beispiel #1
0
        public static bool VersionInc(ref int iNewVer)
        {
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                CfgVersion mdyMod = (from c in ent.CfgVersion select c).FirstOrDefault();
                if (mdyMod == null)
                {
                    mdyMod = new CfgVersion()
                    {
                        Id       = 0,
                        UpdateDt = DateTime.Now,
                        Version  = 1
                    };
                    ent.CfgVersion.Add(mdyMod);
                    ent.SaveChanges();
                    iNewVer = 1;
                    return(true);
                }

                mdyMod.Version  = mdyMod.Version + 1;
                iNewVer         = mdyMod.Version.Value;
                mdyMod.UpdateDt = DateTime.Now;
                ent.SaveChanges();
                return(true);
            }
        }
Beispiel #2
0
 public static bool AddVersion(ref CfgVersion model, out string strError)
 {
     strError = "";
     try
     {
         using (GLedDbEntities ent = new GLedDbEntities())
         {
             CfgVersion newinfo = new CfgVersion()
             {
                 Id       = model.Id,
                 UpdateDt = DateTime.Now,
                 Version  = model.Version
             };
             ent.CfgVersion.Add(newinfo);
             ent.SaveChanges();
             model.Id = newinfo.Id;
             return(true);
         }
     }
     catch (System.Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
        public static bool UpdateDev(GasCardWithCommInfo model, out string strError)
        {
            strError = "";
            try
            {
                using (GLedDbEntities ent = new GLedDbEntities())
                {
                    var oldinfo = (from c in ent.GasCardWithCommInfo where c.Id == model.Id select c).FirstOrDefault();
                    if (oldinfo == null)
                    {
                        strError = ConstDefineBll.InfoCanNotFind;
                        return(false);
                    }
                    oldinfo.Id                = model.Id;
                    oldinfo.DefName           = model.DefName;
                    oldinfo.DefPassword       = model.DefPassword;
                    oldinfo.Name              = model.Name;
                    oldinfo.Password          = model.Password;
                    oldinfo.CityId            = model.CityId;
                    oldinfo.Address           = model.Address;
                    oldinfo.PosLongitude      = model.PosLongitude;
                    oldinfo.PosLatitude       = model.PosLatitude;
                    oldinfo.ProjectId         = model.ProjectId;
                    oldinfo.GroupId           = model.GroupId;
                    oldinfo.OrgId             = model.OrgId;
                    oldinfo.CommType          = model.CommType;
                    oldinfo.ProtocolType      = model.ProtocolType;
                    oldinfo.CommServerIp      = model.CommServerIp;
                    oldinfo.CommServerPort    = model.CommServerPort;
                    oldinfo.CommServerSn      = model.CommServerSn;
                    oldinfo.CommSerialPort    = model.CommSerialPort;
                    oldinfo.CommSerialBaud    = model.CommSerialBaud;
                    oldinfo.CommSerialDataBit = model.CommSerialDataBit;
                    oldinfo.CommSerialStopBit = model.CommSerialStopBit;
                    oldinfo.CommSerialParity  = model.CommSerialParity;
                    oldinfo.CommTimeoutMs     = model.CommTimeoutMs;
                    oldinfo.CommExtConnInfo   = model.CommExtConnInfo;
                    oldinfo.BEnable           = model.BEnable;
                    oldinfo.CardBrightness    = model.CardBrightness;
                    oldinfo.CardContext       = model.CardContext;
                    oldinfo.CardIsDouble      = model.CardIsDouble;
                    oldinfo.CardModel         = model.CardModel;
                    oldinfo.CardNumberCount   = model.CardNumberCount;
                    oldinfo.CardPointCount    = model.CardPointCount;
                    oldinfo.CardScreenCount   = model.CardScreenCount;
                    oldinfo.IsDel             = model.IsDel;

                    oldinfo.Comment  = model.Comment;
                    oldinfo.UpdateDt = DateTime.Now;
                    ent.SaveChanges();
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
        }
Beispiel #4
0
        // todo get all

        public static bool AddUser(ref ProjectUser model, out string strErrorMsg)
        {
            strErrorMsg = "";
            if (IsUserNameExist(model.Name))
            {
                strErrorMsg = ConstDefineBll.NameExist;
                return(false);
            }

            using (GLedDbEntities ent = new GLedDbEntities())
            {
                ProjectUser newinfo = new ProjectUser()
                {
                    Id           = model.Id,
                    MgrProjectId = model.MgrProjectId,
                    Name         = model.Name,
                    Password     = model.Password,
                    RefOrgId     = model.RefOrgId,
                    RefGroupId   = model.RefGroupId,
                    CreateDt     = DateTime.Now,
                    UpdateDt     = DateTime.Now
                };
                ent.ProjectUser.Add(newinfo);
                ent.SaveChanges();
                model.Id = newinfo.Id;
            }
            return(true);
        }
Beispiel #5
0
        public static bool UpdateProejct(ref OrgInfo model, out string strError)
        {
            strError = "";
            try
            {
                using (GLedDbEntities ent = new GLedDbEntities())
                {
                    int     id     = model.Id;
                    OrgInfo mdyMod = (from c in ent.OrgInfo where c.Id == id select c).FirstOrDefault();
                    if (mdyMod == null)
                    {
                        strError = ConstDefineBll.InfoCanNotFind;
                        return(false);
                    }

                    mdyMod.Name       = model.Name;
                    mdyMod.Address    = model.Address;
                    mdyMod.ManageName = model.ManageName;
                    mdyMod.ManageTel  = model.ManageTel;
                    mdyMod.UpdateDt   = DateTime.Now;
                    ent.SaveChanges();
                    return(true);
                }
            }
            catch (System.Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
        }
        public static bool UpdateDefNamePassword(int Id, string strName, string strPassword, out string strError)
        {
            strError = "";
            try
            {
                using (GLedDbEntities ent = new GLedDbEntities())
                {
                    var oldinfo = (from c in ent.GasCardWithCommInfo where c.Id == Id select c).FirstOrDefault();
                    if (oldinfo == null)
                    {
                        strError = ConstDefineBll.InfoCanNotFind;
                        return(false);
                    }
                    oldinfo.Password = strPassword;
                    oldinfo.Name     = strPassword;
                    oldinfo.UpdateDt = DateTime.Now;
                    ent.SaveChanges();
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                strError = ex.Message;
                return(false);
            }
        }
        public static bool AddUser(ref SuperUser model, out string strErrorMsg)
        {
            strErrorMsg = "";
            if (IsUserNameExist(model.Name))
            {
                strErrorMsg = ConstDefineBll.NameExist;
                return(false);
            }

            using (GLedDbEntities ent = new GLedDbEntities())
            {
                SuperUser newinfo = new SuperUser()
                {
                    Id         = model.Id,
                    EnableTime = model.EnableTime,
                    UserType   = model.UserType,
                    Name       = model.Name,
                    Password   = model.Password,
                    CreateDt   = DateTime.Now,
                    UpdateDt   = DateTime.Now
                };
                ent.SuperUser.Add(newinfo);
                ent.SaveChanges();
                model.Id = newinfo.Id;
            }
            return(true);
        }
Beispiel #8
0
 public static bool AddCommDevInfo(ref CmdLogs model, out string strError)
 {
     strError = "";
     try
     {
         using (GLedDbEntities ent = new GLedDbEntities())
         {
             CmdLogs newinfo = new CmdLogs()
             {
                 Id         = model.Id,
                 CardInfoId = model.CardInfoId,
                 CmdInfo    = model.CmdInfo,
                 CmdType    = model.CmdType,
                 CommDevId  = model.CommDevId,
                 CreateTime = DateTime.Now,
                 IsDetele   = 0,
                 Result     = 0,
                 ResultInfo = model.ResultInfo,
                 UpdateTime = DateTime.Now
             };
             ent.CmdLogs.Add(newinfo);
             ent.SaveChanges();
             model.Id = newinfo.Id;
             return(true);
         }
     }
     catch (System.Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
 public static bool AddDev(ref GasCardWithCommInfo model, out string strError)
 {
     strError = "";
     try
     {
         using (GLedDbEntities ent = new GLedDbEntities())
         {
             GasCardWithCommInfo newinfo = new GasCardWithCommInfo()
             {
                 Id                = model.Id,
                 DefName           = model.DefName,
                 DefPassword       = model.DefPassword,
                 Name              = model.Name,
                 Password          = model.Password,
                 CityId            = model.CityId,
                 Address           = model.Address,
                 PosLongitude      = model.PosLongitude,
                 PosLatitude       = model.PosLatitude,
                 ProjectId         = model.ProjectId,
                 GroupId           = model.GroupId,
                 OrgId             = model.OrgId,
                 CommType          = model.CommType,
                 ProtocolType      = model.ProtocolType,
                 CommServerIp      = model.CommServerIp,
                 CommServerPort    = model.CommServerPort,
                 CommServerSn      = model.CommServerSn,
                 CommSerialPort    = model.CommSerialPort,
                 CommSerialBaud    = model.CommSerialBaud,
                 CommSerialDataBit = model.CommSerialDataBit,
                 CommSerialStopBit = model.CommSerialStopBit,
                 CommSerialParity  = model.CommSerialParity,
                 CommTimeoutMs     = model.CommTimeoutMs,
                 CommExtConnInfo   = model.CommExtConnInfo,
                 BEnable           = model.BEnable,
                 CardBrightness    = model.CardBrightness,
                 CardContext       = model.CardContext,
                 CardIsDouble      = model.CardIsDouble,
                 CardModel         = model.CardModel,
                 CardNumberCount   = model.CardNumberCount,
                 CardPointCount    = model.CardPointCount,
                 CardScreenCount   = model.CardScreenCount,
                 IsDel             = 0,
                 ScreenNams        = model.ScreenNams,
                 Comment           = model.Comment,
                 UpdateDt          = DateTime.Now,
                 CreateDt          = DateTime.Now
             };
             ent.GasCardWithCommInfo.Add(newinfo);
             ent.SaveChanges();
             model.Id = newinfo.Id;
             return(true);
         }
     }
     catch (System.Exception ex)
     {
         strError = ex.Message;
         return(false);
     }
 }
Beispiel #10
0
        public static bool DelUser(int id)
        {
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                var delItem = (from c in ent.ProjectUser where c.Id == id select c).FirstOrDefault();
                if (delItem == null)
                {
                    return(true);
                }

                ent.ProjectUser.Remove(delItem);
                ent.SaveChanges();
                return(true);
            }
        }
        public static bool DelDev(int Id)
        {
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                var delItem = (from c in ent.GasCardWithCommInfo where c.Id == Id select c).FirstOrDefault();
                if (delItem == null)
                {
                    return(true);
                }

                ent.GasCardWithCommInfo.Remove(delItem);
                ent.SaveChanges();
                return(true);
            }
        }
Beispiel #12
0
        public static bool DeleteAOrg(int id, out string strError)
        {
            strError = "";
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                var delItem = (from c in ent.OrgInfo where c.Id == id select c).FirstOrDefault();
                if (delItem == null)
                {
                    return(true);
                }

                ent.OrgInfo.Remove(delItem);
                ent.SaveChanges();
                return(true);
            }
        }
Beispiel #13
0
        public static bool UpdateACmdResult(int id, int iResult, string strResultInfo)
        {
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                CmdLogs mdyMod = (from c in ent.CmdLogs where c.Id == id select c).FirstOrDefault();
                if (mdyMod == null)
                {
                    return(false);
                }

                mdyMod.Result     = iResult;
                mdyMod.ResultInfo = strResultInfo;
                mdyMod.UpdateTime = DateTime.Now;
                ent.SaveChanges();
                return(true);
            }
        }
Beispiel #14
0
        public static bool UpdateUser(OrgUser model, out string strErrMsg)
        {
            strErrMsg = "";
            using (GLedDbEntities ent = new GLedDbEntities())
            {
                var oldinfo = (from c in ent.OrgUser where c.Id == model.Id select c).FirstOrDefault();
                if (oldinfo == null)
                {
                    strErrMsg = ConstDefineBll.InfoCanNotFind;
                    return(false);
                }

                oldinfo.MgrOrgId = model.MgrOrgId;
                oldinfo.Name     = model.Name;
                oldinfo.Password = model.Password;
                oldinfo.UpdateDt = DateTime.Now;
                ent.SaveChanges();
            }
            return(true);
        }
Beispiel #15
0
        public static bool AddAProject(ref ProjectInfo model, out string strErrInfo)
        {
            strErrInfo = "";
            if (IsNameExist(model.ProjectName))
            {
                strErrInfo = "名字已经存在";
                return(false);
            }

            using (GLedDbEntities ent = new GLedDbEntities())
            {
                ProjectInfo newModel = new ProjectInfo()
                {
                    Id          = 0,
                    ProjectName = model.ProjectName,
                    Address     = model.Address,
                    ManagerName = model.ManagerName,
                    ManagerTel  = model.ManagerTel,
                    GroupId     = model.GroupId,
                    OrgId       = model.OrgId,
                    CreateDt    = DateTime.Now,
                    UpdateDt    = DateTime.Now
                };

                try
                {
                    ent.ProjectInfo.Add(newModel);
                    ent.SaveChanges();
                    model.Id = newModel.Id;
                    return(true);
                }
                catch (System.Exception ex)
                {
                    LogMgr.WriteErrorDefSys("Add Project Ex:" + ex.Message);
                }

                return(true);
            }
        }
Beispiel #16
0
        public static bool AddAGroup(ref GroupInfo model, out string strErrInfo)
        {
            strErrInfo = "";
            if (IsNameExist(model.GroupName))
            {
                strErrInfo = ConstDefineBll.NameExist;
                return(false);
            }

            using (GLedDbEntities ent = new GLedDbEntities())
            {
                GroupInfo newModel = new GroupInfo()
                {
                    Id           = 0,
                    GroupName    = model.GroupName,
                    ManageName   = model.ManageName,
                    ManageTel    = model.ManageTel,
                    GroupAddress = model.GroupAddress,
                    OrgId        = model.OrgId,
                    CreateDt     = DateTime.Now,
                    UpdateDt     = DateTime.Now
                };

                try
                {
                    ent.GroupInfo.Add(newModel);
                    ent.SaveChanges();
                    model.Id = newModel.Id;
                    return(true);
                }
                catch (System.Exception ex)
                {
                    LogMgr.WriteErrorDefSys("Add Org Ex:" + ex.Message);
                }

                return(true);
            }
        }