Exemplo n.º 1
0
 /// <summary>
 /// 设置角色
 /// </summary>
 /// <param name="userid"></param>
 /// <param name="roleid"></param>
 /// <param name="db"></param>
 public static void SetRole(Guid userid, Guid roleid, Guid?tenantid, Guid?creator, Zippy.Data.IDalProvider db)
 {
     if (!db.Exists <UserRole>("UserID=@UserID and RoleID=@RoleID", db.CreateParameter("UserID", userid), db.CreateParameter("RoleID", roleid)))
     {
         UserRole ur = new UserRole();
         ur.RoleID   = roleid;
         ur.UserID   = userid;
         ur.TenantID = tenantid;
         ur.Creator  = creator;
         db.Insert(ur);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="tenantID"></param>
        /// <param name="userID"></param>
        /// <param name="oStatus">用户指定的状态</param>
        /// <param name="paidAmount">支付金额</param>
        /// <param name="bankID">银行</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool Pay(Guid tenantID, Guid userID, EAP.Logic.Z10.OrderStatus oStatus, decimal paidAmount, long?bankID)
        {
            int orderSts = Z10Order.OrderStatus ?? 0;

            if ((orderSts & (int)EAP.Logic.Z10.OrderStatus.Paid) == (int)EAP.Logic.Z10.OrderStatus.Paid ||
                (orderSts & (int)EAP.Logic.Z10.OrderStatus.Finished) == (int)EAP.Logic.Z10.OrderStatus.Finished ||
                (orderSts & (int)EAP.Logic.Z10.OrderStatus.Archived) == (int)EAP.Logic.Z10.OrderStatus.Archived)
            {
                throw new Exception("已经支付的订单,已经结束的订单和已经存档的订单不能支付。");
            }

            Zippy.Data.IDalProvider db = Zippy.Data.StaticDB.DB;

            Z10Order xorder = new Z10Order();

            xorder.OrderID = Z10Order.OrderID;
            xorder.FeePaid = Z10Order.FeePaid + paidAmount;

            if (oStatus == OrderStatus.Paid)
            {
                xorder.OrderStatus = orderSts & ~(int)OrderStatus.PaidSome;
                xorder.OrderStatus = (xorder.OrderStatus ?? 0) | (int)oStatus;
            }
            else
            {
                //throw new Exception(orderSts.ToString() + "  -- " + oStatus + " -- " + ((Z10Order.OrderStatus ?? 0) | (int)oStatus));
                xorder.OrderStatus = orderSts | (int)oStatus;
            }

            db.Update(xorder);

            Z01Beetle.Entity.Z01FinancialFlow dflow = new Z01Beetle.Entity.Z01FinancialFlow();

            dflow.FlowID   = null;
            dflow.OrderID  = Z10Order.OrderID;
            dflow.Amount   = paidAmount;
            dflow.Creator  = userID;
            dflow.TenantID = tenantID;
            dflow.BankID   = bankID;
            dflow.Currency = Z10Order.Currency;
            db.Insert(dflow);


            //string sqlUpdateStatus = "update Z10Order set OrderStatus=OrderStatus|@paid where OrderID=@orderid ";
            //Zippy.Data.StaticDB.DB.ExecuteNonQuery(sqlUpdateStatus,
            //    Zippy.Data.StaticDB.DB.CreateParameter("paid", (int)EAP.Logic.Z10.OrderStatus.Paid),
            //    Zippy.Data.StaticDB.DB.CreateParameter("orderid", Z10Order.OrderID ?? 0));


            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 增加一种权限
        /// </summary>
        /// <param name="roleID"></param>
        /// <param name="permissionID"></param>
        /// <param name="permissionType"></param>
        /// <param name="tenantID"></param>
        /// <param name="optUser"></param>
        /// <param name="db"></param>
        public static void SetPermission(Guid roleID, long permissionID, int permissionType, Guid?tenantID, Guid?optUser, Zippy.Data.IDalProvider db)
        {
            RolePermission rp = db.FindUnique <RolePermission>("RoleID=@RoleID and PermissionID=@PermissionID and TenantID=@TenantID",
                                                               db.CreateParameter("RoleID", roleID), db.CreateParameter("PermissionID", permissionID), db.CreateParameter("TenantID", tenantID));

            if (rp == null)
            {
                rp                = new RolePermission();
                rp.RoleID         = roleID;
                rp.PermissionID   = permissionID;
                rp.PermissionType = permissionType;
                rp.TenantID       = tenantID;
                rp.Creator        = optUser;
                db.Insert(rp);
            }
            else
            {
                rp.PermissionType = rp.PermissionType | permissionType;
                rp.Updater        = optUser;
                rp.UpdateDate     = DateTime.Now;
                db.Update(rp);
            }
        }
Exemplo n.º 4
0
        public static int Insert(Zippy.Data.IDalProvider db, Z30Communication entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 5
0
        public static int Insert(Zippy.Data.IDalProvider db, Z01CustomerInCategory entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 6
0
        public static int Insert(Zippy.Data.IDalProvider db, RolePermission entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 7
0
        public static int Insert(Zippy.Data.IDalProvider db, Z01UserInfo entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 8
0
        public static int Insert(Zippy.Data.IDalProvider db, PropertyTemplate entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 9
0
        public static int Insert(Zippy.Data.IDalProvider db, TextResource entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 10
0
        public static int Insert(Zippy.Data.IDalProvider db, Z01FinancialCategory entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 11
0
        public static int Insert(Zippy.Data.IDalProvider db, TenantApplication entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 12
0
        public static int Insert(Zippy.Data.IDalProvider db, Z10DepotFlow entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 13
0
        public static int Insert(Zippy.Data.IDalProvider db, Z01ProductExtValue entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 14
0
        public static int Insert(Zippy.Data.IDalProvider db, Z10OrderItem entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 采购出入库
        /// </summary>
        /// <param name="tenantID">租户</param>
        /// <param name="userID">操作者</param>
        /// <param name="oStatus">当前状态</param>
        /// <param name="hsItemCount">各个商品的具体入库数量</param>
        /// <param name="db"></param>
        /// <returns></returns>
        public bool InOutDepot(Guid tenantID, Guid userID, EAP.Logic.Z10.OrderStatus oStatus, Hashtable hsItemCount, Zippy.Data.IDalProvider db)
        {
            throw new Exception("这个入库方式需要商榷。");
            int orderSts = Z10Order.OrderStatus ?? 0;

            if ((orderSts & (int)EAP.Logic.Z10.OrderStatus.Outted) == (int)EAP.Logic.Z10.OrderStatus.Inned ||
                (orderSts & (int)EAP.Logic.Z10.OrderStatus.Finished) == (int)EAP.Logic.Z10.OrderStatus.Finished ||
                (orderSts & (int)EAP.Logic.Z10.OrderStatus.Archived) == (int)EAP.Logic.Z10.OrderStatus.Archived)
            {
                throw new Exception("已经出入库的订单,已经结束的订单和已经存档的订单不能出入库。");
            }


            Z10Order xorder = new Z10Order();

            xorder.OrderID = Z10Order.OrderID;

            if (oStatus == OrderStatus.Inned && ((Z10Order.OrderStatus ?? 0) & (int)OrderStatus.InnedSome) == (int)OrderStatus.InnedSome)
            {
                oStatus            = oStatus & (~OrderStatus.InnedSome);
                xorder.OrderStatus = (Z10Order.OrderStatus ?? 0) & (~(int)OrderStatus.InnedSome);
                xorder.OrderStatus = (xorder.OrderStatus ?? 0) | (int)oStatus;
            }
            else if (oStatus == OrderStatus.Outted && ((Z10Order.OrderStatus ?? 0) & (int)OrderStatus.OuttedSome) == (int)OrderStatus.OuttedSome)
            {
                oStatus            = oStatus & (~OrderStatus.OuttedSome);
                xorder.OrderStatus = (Z10Order.OrderStatus ?? 0) & (~(int)OrderStatus.OuttedSome);
                xorder.OrderStatus = (xorder.OrderStatus ?? 0) | (int)oStatus;
            }
            else
            {
                xorder.OrderStatus = (Z10Order.OrderStatus ?? 0) | (int)oStatus;
            }

            db.Update(xorder);

            Z10DepotFlow dflow = new Z10DepotFlow();

            foreach (Z10OrderItem item in Items)
            {
                decimal itemHappened = hsItemCount[item.ItemID].ToDecimal();

                if ((oStatus & OrderStatus.Outted) == OrderStatus.Outted || (oStatus & OrderStatus.OuttedSome) == OrderStatus.OuttedSome)
                {
                    db.ColAdd <Z10OrderItem>("CountHappend2", itemHappened, item.ItemID);
                }
                else
                {
                    db.ColAdd <Z10OrderItem>("CountHappend", itemHappened, item.ItemID);
                }

                if (item.CountHappend != 0 || item.CountHappend2 != 0)
                {
                    dflow.FlowID    = null;
                    dflow.OrderID   = Z10Order.OrderID;
                    dflow.Count     = itemHappened;
                    dflow.DepotID   = item.DepotID;
                    dflow.Creator   = userID;
                    dflow.ProductID = item.ProductID;
                    dflow.TenantID  = tenantID;
                    db.Insert(dflow);

                    if (!db.Exists <Z10DepotProduct>("ProductID=@ProductID and DepotID=@DepotID and TenantID=@TenantID",
                                                     db.CreateParameter("ProductID", item.ProductID), db.CreateParameter("DepotID", item.DepotID), db.CreateParameter("TenantID", tenantID)))
                    {
                        Z10DepotProduct xProduct = new Z10DepotProduct();
                        xProduct.TenantID  = tenantID;
                        xProduct.ProductID = item.ProductID;
                        xProduct.DepotID   = item.DepotID;
                        xProduct.StockSum  = itemHappened;
                        db.Insert(xProduct);
                    }
                    else
                    {
                        string sqlUpdateDepot = "update Z10DepotProduct set StockSum=StockSum + @itemHappened, InSum=InSum + @itemHappened" +
                                                " where ProductID=@ProductID and DepotID=@DepotID";
                        db.ExecuteNonQuery(sqlUpdateDepot, db.CreateParameter("itemHappened", itemHappened),
                                           db.CreateParameter("ProductID", item.ProductID), db.CreateParameter("DepotID", item.DepotID));
                    }
                }
            }
            return(true);
        }
Exemplo n.º 16
0
 public static int Insert(Zippy.Data.IDalProvider db, UserGroup entity)
 {
     int rtn = db.Insert(entity);
     return rtn;
 }
Exemplo n.º 17
0
        public static int Insert(Zippy.Data.IDalProvider db, Culture entity)
        {
            int rtn = db.Insert(entity);

            return(rtn);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 将订单保存到数据库
        /// </summary>
        /// <param name="tenantID"></param>
        /// <param name="db"></param>
        /// <param name="oid"></param>
        public void Save(Guid tenantID, Zippy.Data.IDalProvider db, long?oid)
        {
            long orderID = 0;

            Z10Order.Total    = Items.Sum(s => s.Total);
            Z10Order.TenantID = tenantID;
            try
            {
                // 此处应该加入事务
                db.BeginTransaction();
                if (Z10Order.OrderID.HasValue && Z10Order.OrderID > 0)
                {
                    orderID = Z10Order.OrderID.Value;
                    db.Update(Z10Order);
                }
                else
                {
                    orderID = db.Insert(Z10Order);

                    Z10Order zorder = new Z10Order();

                    if (!oid.HasValue)
                    {
                        zorder.OrderID = orderID;
                        zorder.OriID   = orderID;
                    }
                    else
                    {
                        zorder.OriID = oid;
                    }

                    //zorder.FeeShould = this.CalFeeShould();

                    db.Update(zorder);
                }

                foreach (Z10OrderItem item in Items)
                {
                    item.ItemStatus = 1;
                    item.TenantID   = tenantID;
                    item.Total      = (item.Price ?? 0) * (item.CountShould ?? 0);
                    if (item.ItemID.HasValue && item.ItemID > 0 && item.OrderID == orderID)
                    {
                        db.Update(item);
                    }
                    else
                    {
                        item.OrderID = orderID;
                        var itemID = db.Insert(item);
                        item.ItemID = itemID;
                    }
                }

                Z10Order.OrderID = orderID;
                db.Commit();
            }
            catch (Exception ex)
            {
                db.RollbackTransaction();
                throw ex;
            }
        }