예제 #1
0
        public IEnumerable <DataModels.Npaper> GetPapersList(int year, int month, long start, long limit, out int qty)
        {
            limit = (start + limit);
            using (var db = new PapersDB())
            {
                int index = 1;
                var ps    = db.Npapers.Where(w => w.PublicationDate.Value.Year == year && w.PublicationDate.Value.Month == month).ToList()
                            .Select(
                    x => new DataModels.Npaper
                {
                    Ps = index++,
                    CorrectionGoods     = x.CorrectionGoods,
                    DeliveryNewsPaper   = x.DeliveryNewsPaper,
                    LayoutNewsPaper     = x.LayoutNewsPaper,
                    PaperId             = x.PaperId,
                    PaperName           = x.PaperName,
                    PrintingNewsPaper   = x.PrintingNewsPaper,
                    PrintPrepareAndSign = x.PrintPrepareAndSign,
                    PublicationDate     = x.PublicationDate,
                    QtyPages            = x.QtyPages,
                    ReconcilementArtQty = x.ReconcilementArtQty,
                    SellAproveGoods     = x.SellAproveGoods,
                    StartGoodPrepare    = x.StartGoodPrepare,
                    StartQtyPages       = x.StartQtyPages,
                    StopAgreement       = x.StopAgreement
                }
                    ).ToList();

                qty = ps.Count();

                return(ps.Where(w => w.Ps >= start && w.Ps <= limit).ToList());
            }
        }
예제 #2
0
 public IEnumerable <DataModels.GoodsSizes> GetGoodsSizes()
 {
     using (var db = new PapersDB())
     {
         return(db.GoodsSizes.OrderBy(o => o.SizeId).ToList());
     }
 }
예제 #3
0
 public int GetGoodsCount()
 {
     using (var db = new PapersDB())
     {
         return(db.GoodsTemplate.Count());
     }
 }
예제 #4
0
 public DataModels.Npaper GetPaperById(long paperId)
 {
     using (var db = new PapersDB())
     {
         return(db.Npapers.Where(w => w.PaperId == paperId).FirstOrDefault());
     }
 }
예제 #5
0
 public VGoodsTemplate GetGoodTmpById(long GoodTmpId)
 {
     using (var db = new PapersDB())
     {
         return(db.VGoodsTemplate.Where(w => w.GoodtmpId == GoodTmpId).FirstOrDefault());
     }
 }
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="userId"></param>
 public void Delete(int userId)
 {
     using (var db = new PapersDB())
     {
         db.Users.Delete(o => o.UserId == userId);
     }
 }
예제 #7
0
 public IEnumerable <Cell> GetCellsListByPageId(long page_id)
 {
     using (var db = new PapersDB())
     {
         return(db.Cells.Where(w => w.PageId == page_id).OrderBy(o => o.PagePosition).ToList());
     }
 }
예제 #8
0
 public long GetUserByLogin(string login)
 {
     using (var db = new PapersDB())
     {
         return(db.VUsers.Where(w => w.Login == login).FirstOrDefault().UserId);
     }
 }
예제 #9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public long CreateUser(DataModels.User user)
        {
            using (var db = new PapersDB())
            {
                long st = db.GetTable <DataModels.User>().Insert(() => new DataModels.User {
                    Name1    = user.Name1,
                    Name2    = user.Name2,
                    Name3    = user.Name3,
                    Login    = user.Login,
                    AccessId = user.AccessId,
                    OtdId    = user.OtdId,
                    Ps       = 0,
                    Password = user.Password
                });

                return(db.Users.Where(w => w.Login == user.Login).FirstOrDefault().UserId);

                //db.GetTable<Cell>().Insert(() => new Cell {
                //    Advantage = "",
                //    Artlst = "214234",
                //    CompensationSp = "sdvf"

                //    db.Users.Where(w => w.UserId == user.UserId)
                //        .Set(p => p.AccessId, user.AccessId)
                //        //.Set(p => p.accessid18EBB, user.accessid18EBB)
                //        .Set(p => p.Login, user.Login)
                //        .Set(p => p.Name1, user.Name1)
                //        .Set(p => p.Name2, user.Name2)
                //        .Set(p => p.Name3, user.Name3)
                //        .Set(p => p.OtdId, user.OtdId)
                //        //.Set(p => p.otdid17F790F, user.otdid17F790F)
                //        .Set(p => p.UserId, user.UserId).Update();
                //}
            }
        }
예제 #10
0
 public IEnumerable <Depart> GetDepartList()
 {
     using (var db = new PapersDB())
     {
         return(db.Departs.OrderBy(o => o.DepartId).ToList());
     }
 }
예제 #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="start"></param>
        /// <param name="limit"></param>
        /// <returns></returns>
        public IEnumerable <DataModels.User> GetUserList(int start, int limit)
        {
            using (var db = new PapersDB())
            {
                var index = 1;
                var users = db.Users.ToList().Select(
                    x => new DataModels.User
                {
                    Ps             = index++,
                    AccessId       = x.AccessId,
                    Login          = x.Login,
                    Name1          = x.Name1,
                    Name2          = x.Name2,
                    Name3          = x.Name3,
                    OtdId          = x.OtdId,
                    Password       = x.Password,
                    tokensToTables = x.tokensToTables,
                    UserId         = x.UserId,
                    accessid18EBB  = x.accessid18EBB,
                    otdid17F790F   = x.otdid17F790F
                }).ToList();

                return(users);
            }
        }
예제 #12
0
 public IEnumerable <Access> GetAccessList()
 {
     using (var db = new PapersDB())
     {
         return(db.Accesses.OrderBy(o => o.AccessId).ToList());
     }
 }
예제 #13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="login"></param>
 /// <returns></returns>
 public DataModels.User LoginVerificated(string login)
 {
     using (var db = new PapersDB())
     {
         return(db.Users.Where(w => w.Login == login).FirstOrDefault());
     }
 }
예제 #14
0
        public void SetCell(Cell c)
        {
            using (var db = new PapersDB())
            {
                //ITable<Cell> cell = db.GetTable<Cell>();

                db.Cells.Where(w => w.GlobalCellId == c.GlobalCellId)
                .Set(p => p.Artlst, c.Artlst)
                .Set(p => p.Advantage, c.Advantage)
                .Set(p => p.CompensationSp, c.CompensationSp)
                .Set(p => p.CompetitiveProduct, c.CompetitiveProduct)
                .Set(p => p.Competitors, c.Competitors)
                .Set(p => p.CompetitorsPrice, c.CompetitorsPrice)
                .Set(p => p.DepartId, c.DepartId)
                .Set(p => p.DiffCompetitorPrice, c.DiffCompetitorPrice)
                .Set(p => p.DiffCompetitorPricePrc, c.DiffCompetitorPricePrc)
                .Set(p => p.DiffPrice, c.DiffPrice)
                .Set(p => p.ForecastProfit, c.ForecastProfit)
                .Set(p => p.ForecastProfitAct, c.ForecastProfitAct)
                .Set(p => p.Garant, c.Garant)
                .Set(p => p.Inventory, c.Inventory)
                .Set(p => p.Isfill, c.Isfill)
                .Set(p => p.Madein, c.Madein)
                .Set(p => p.Manager, c.Manager)
                .Set(p => p.Margin, c.Margin)
                .Set(p => p.Number, c.Number)
                .Set(p => p.OtdId, c.OtdId)
                .Set(p => p.PageId, c.PageId)
                .Set(p => p.PagePosition, c.PagePosition)
                .Set(p => p.PathPhoto, c.PathPhoto)
                .Set(p => p.PlacementType, c.PlacementType)
                .Set(p => p.PriceAct, c.PriceAct)
                .Set(p => p.PriceAfterAct, c.PriceAfterAct)
                .Set(p => p.PriceBeforeAct, c.PriceBeforeAct)
                .Set(p => p.PriceBuy, c.PriceBuy)
                .Set(p => p.PriceStart, c.PriceStart)
                .Set(p => p.Producer, c.Producer)
                .Set(p => p.ProducktCategory, c.ProducktCategory)
                .Set(p => p.ProfitProcent, c.ProfitProcent)
                .Set(p => p.ShortName, c.ShortName)
                .Set(p => p.Specifiacations, c.Specifiacations)
                .Set(p => p.SpecilPlacement, c.SpecilPlacement)
                .Set(p => p.Unit, c.Unit)
                .Update();

                //db.Update(c);

                //db.Users.DataContext..Cells.Where(w => w.GlobalCellId == c.GlobalCellId)
                //db.GetTable<Cell>()

                //db.GetTable<Cell>().Insert(() => new Cell {
                //    Advantage = "",
                //    Artlst = "214234",
                //    CompensationSp = "sdvf"

                //});
                //var i = db.Cells.Insert(cell.);
            }
        }
예제 #15
0
 public IEnumerable <DataModels.VGoodsTemplate> GetGoodsTemplateList(long start, long limit)
 {
     limit = (start + limit);
     using (var db = new PapersDB())
     {
         return(db.VGoodsTemplate.Where(w => w.Number >= start && w.Number <= limit).ToList());
     }
 }
예제 #16
0
 public void SetRequest(string request)
 {
     using (var db = new PapersDB())
     {
         db.Requests.Insert(() => new Request {
             Request_Column = request
         });
     }
 }
예제 #17
0
 public void SetGoodTmp(VGoodsTemplate good)
 {
     using (var db = new PapersDB())
     {
         db.GoodsTemplate.Where(w => w.GoodtmpId == good.GoodtmpId)
         .Set(p => p.Name, good.Name)
         .Set(p => p.Keywords, good.Keywords)
         .Set(p => p.SizeId, good.SizeId)
         .Update();
     }
 }
예제 #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="login"></param>
        /// <returns></returns>
        public string[] GetRoleNamesByLogin(string login)
        {
            using (var db = new PapersDB())
            {
                var           user   = db.Users.Where(w => w.Login == login).FirstOrDefault();
                var           access = db.Accesses.Where(w => w.AccessId == user.AccessId).FirstOrDefault();
                List <string> lst    = new List <string>();
                lst.Add(access.Name);

                return(lst.ToArray());
            }
        }
예제 #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="pwd"></param>
        public void UpdPwd(int userId, string pwd)
        {
            using (Cryptor cryptor = new Cryptor())
            {
                Guid gpwd = new Guid(cryptor.Crypt(pwd));

                using (var db = new PapersDB())
                {
                    db.Users.Where(o => o.UserId == userId).Set(
                        p => p.Password, gpwd
                        ).Update();
                }
            }
        }
예제 #20
0
 public IEnumerable <Otd> GetOtdList(int id)
 {
     using (var db = new PapersDB())
     {
         if (id == 0)
         {
             return(db.Otds.Where(w => w.OtdId != 726).Where(w => w.OtdId != 1000).OrderBy(o => o.OtdId).ToList());
         }
         else
         {
             return(db.Otds.OrderBy(o => o.OtdId).ToList());
         }
     }
 }
예제 #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="sessionId"></param>
 /// <returns></returns>
 public string GetNewToken(long userId, string source)
 {
     using (Cryptor cryptor = new Cryptor())
     {
         string token = cryptor.Crypt(source);
         using (var db = new PapersDB())
         {
             db.Tokens.Insert(() => new DataModels.Token {
                 UserId  = userId,
                 Created = DateTime.Now,
                 Value   = token
             });
             return(token);
         }
     }
 }
예제 #22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="user"></param>
 public void SetUser(DataModels.User user)
 {
     using (var db = new PapersDB())
     {
         db.Users.Where(w => w.UserId == user.UserId)
         //.Set(p => p.AccessId, user.AccessId)
         //.Set(p => p.accessid18EBB, user.accessid18EBB)
         .Set(p => p.Login, user.Login)
         .Set(p => p.Name1, user.Name1)
         .Set(p => p.Name2, user.Name2)
         .Set(p => p.Name3, user.Name3)
         .Set(p => p.OtdId, user.OtdId)
         //.Set(p => p.otdid17F790F, user.otdid17F790F)
         .Set(p => p.AccessId, user.AccessId).Update();
     }
 }
예제 #23
0
 public void UpdatePaper(DataModels.Npaper paper)
 {
     using (var db = new PapersDB())
     {
         db.Npapers.Where(w => w.PaperId == paper.PaperId)
         .Set(p => p.CorrectionGoods, paper.CorrectionGoods)
         .Set(p => p.DeliveryNewsPaper, paper.DeliveryNewsPaper)
         .Set(p => p.LayoutNewsPaper, paper.LayoutNewsPaper)
         .Set(p => p.PaperName, paper.PaperName)
         .Set(p => p.PrintingNewsPaper, paper.PrintingNewsPaper)
         .Set(p => p.PrintPrepareAndSign, paper.PrintPrepareAndSign)
         .Set(p => p.PublicationDate, paper.PublicationDate)
         .Set(p => p.ReconcilementArtQty, paper.ReconcilementArtQty)
         .Set(p => p.SellAproveGoods, paper.SellAproveGoods)
         .Set(p => p.StartGoodPrepare, paper.StartGoodPrepare)
         .Set(p => p.StopAgreement, paper.StopAgreement)
         .Update();
     }
 }
예제 #24
0
        public long CreateGoodTmp(DataModels.VGoodsTemplate good)
        {
            using (var db = new PapersDB())
            {
                //long id = db.GetTable<GoodsTemplate>().Insert(() => new GoodsTemplate
                //{
                //    Keywords = good.Keywords,
                //    Name = good.Name,
                //    SizeId = good.SizeId
                //});
                DataModels.GoodsTemplate g = new DataModels.GoodsTemplate {
                    Keywords = good.Keywords,
                    Name     = good.Name,
                    SizeId   = good.SizeId
                };

                long id = Convert.ToInt64(db.InsertWithIdentity(g));
                return(id);
            }
        }
예제 #25
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="login"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public bool Autentificate(string login, string password)
        {
            using (var db = new PapersDB())
            {
                var user = db.Users.Where(w => w.Login == login).FirstOrDefault();

                if (user == null)
                {
                    return(false);
                }

                if (user.Password == new Guid(password))
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
예제 #26
0
 public long CreatePaper(DataModels.Npaper paper)
 {
     using (var db = new PapersDB())
     {
         var o = db.Npapers.InsertWithIdentity(
             () => new DataModels.Npaper
         {
             CorrectionGoods     = paper.CorrectionGoods,
             DeliveryNewsPaper   = paper.DeliveryNewsPaper,
             LayoutNewsPaper     = paper.LayoutNewsPaper,
             PaperName           = paper.PaperName,
             PrintingNewsPaper   = paper.PrintingNewsPaper,
             PrintPrepareAndSign = paper.PrintPrepareAndSign,
             PublicationDate     = paper.PublicationDate,
             ReconcilementArtQty = paper.ReconcilementArtQty,
             SellAproveGoods     = paper.SellAproveGoods,
             StartGoodPrepare    = paper.StartGoodPrepare,
             StartQtyPages       = paper.StartQtyPages,
             StopAgreement       = paper.StopAgreement
         });
         return(Convert.ToInt64(o));
     }
 }
예제 #27
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public VUsers GetUserByToken(string token)
 {
     using (var db = new PapersDB())
     {
         Token t = db.Tokens.Where(w => w.Value == token).FirstOrDefault();
         if (t != null)
         {
             if (t.Created.AddHours(2) >= DateTime.Now)
             {
                 var user = db.VUsers.Where(w => w.UserId == t.UserId).FirstOrDefault();
                 db.Tokens.Where(w => w.UserId == user.UserId).Set(p => p.Created, DateTime.Now).Update();
                 return(user);
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
 }