Esempio n. 1
0
        /// <summary>
        /// 通过manager id 获取操作员的姓名与角色名
        /// </summary>
        /// <param name="db">数据库连接实例</param>
        /// <param name="id">manager id</param>
        public static NewBase <string, string> getManagerNameAndRole(EFContext db, string id)
        {
            var name     = string.Empty;
            var roleName = string.Empty;

            if (id.IsNotNull())
            {
                var manager = db.selmanager.FirstOrDefault(a => a.ID == id);
                if (manager != null)
                {
                    name = manager.NickName;
                    var role = (from a in db.selrole
                                join b in db.selmanager_role.Where(t => t.SelManagerID == manager.ID) on a.ID equals b.SelRoleID
                                select a.Title
                                ).FirstOrDefault();
                    if (role != null)
                    {
                        roleName = role;
                    }
                }
            }
            var ba = new NewBase <string, string>();

            ba.Data  = name;
            ba.Data2 = roleName;
            ba.setSuccess("获取数据成功");
            return(ba);
        }
Esempio n. 2
0
        private NewBase <ExOrderLossRateAll> getOrderBase(PaID pa, bool?isCheck = null)
        {
            var ba = new NewBase <ExOrderLossRateAll>();

            try
            {
                Tools.PrintPa <PaID>(pa);
                using (var db = new EFContext())
                {
                    var model = db.swhorderlossrate.FirstOrDefault(a => a.ID == pa.ID);
                    ba.Data = new ExOrderLossRateAll
                    {
                        ID = model.ID,
                        ApproveContents = model.ApproveContents,
                        ApproveTime     = model.ApproveTime,
                        OrderState      = model.OrderState,
                        PriceReal       = model.PriceReal,
                        ApproveSellerID = model.ApproveSellerID,
                        ApplySellerID   = model.ApplySellerID,
                        CreateDate      = model.CreateDate,
                        CreateTime      = model.CreateTime,
                        Introduction    = model.Introduction,
                        ShopID          = model.ShopID,
                        Title           = model.Title,
                        WareHouseID     = model.WareHouseID,
                        WareHouseName   = Tools.getWareHouseName(db, model.WareHouseID)
                    };
                    var n = Tools.getManagerNameAndRole(db, model.ApplySellerID);
                    ba.Data.ApplySellerName = n.Data;
                    ba.Data.ApplySellerRole = n.Data2;

                    if (model.ApproveSellerID.IsNotNull()) //这里都查出来吧
                    {
                        var n2 = Tools.getManagerNameAndRole(db, model.ApproveSellerID);
                        ba.Data.ApplySellerName = n2.Data;
                        ba.Data.ApplySellerRole = n2.Data2;
                        ba.Data.ApproveContents = model.ApproveContents;
                        ba.Data.ApproveTime     = model.ApproveTime;
                    }
                    ba.setSuccess("获取数据成功");
                    return(ba);
                }
            }
            catch (Exception e)
            {
                var m = WebTools.getFinalException(e);
                ba.setFail("获取数据失败", m);
                LogHelper.Error("获取数据失败:" + m);
            }
            return(ba);
        }
Esempio n. 3
0
        public NewBase <decimal> getMoneySumBudget(string id)
        {
            var ba = new NewBase <decimal>();

            try
            {
                using (var db = new EFContext())
                {
                    //通过材料ID获得材料信息
                    var model = db.swhorderlossratedetail.Where(m => m.OrderApplyID == id)
                                .Select(a => new { a.PriceReal, a.CountLoss })
                                .Sum(a => a.PriceReal * a.CountLoss);
                    ba.Data = model;
                    ba.setSuccess("获取数据成功");
                }
            }
            catch (Exception e)
            {
                var m = WebTools.getFinalException(e);
                ba.setFail("操作失败", m);
                LogHelper.Error("getMoneySumBudget:" + m);
            }
            return(ba);
        }