Exemplo n.º 1
0
        public ActionResult SaveNewTicket(TicketCreateVM createModel)
        {
            try
            {
                using (var dbContext = new TicketCodeTestDBContext())
                {
                    var dbTicket = new Tticket();
                    var dbCustom = new Tcustomer();
                    var dbBill   = new Tbill();
                    dbCustom.Name       = createModel.custormername;
                    dbCustom.SaleMan    = createModel.saleman;
                    dbCustom.SaleCount  = createModel.salecount;
                    dbCustom.SaleAmount = createModel.saleamount;



                    dbContext.Tcustomer.Add(dbCustom);
                }


                StringBuilder sbr = new StringBuilder();
                DapperWrapper.Insert(sbr.ToString());
                return(Json(new { success = true, msg = "保存成功" }));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    success = false,
                    msg = ex.ToString()
                }));
            }
        }
Exemplo n.º 2
0
        public static void Start()
        {
            One        one    = new One();
            Two        two    = new Two();
            Three      three  = new Three();
            Two_Parent parent = new Two_Parent();

            //以实体类进行操作
            DapperWrapper <Three, Two, One, Two_Parent> dapper1 = new DapperWrapper <Three, Two, One, Two_Parent>("key");

            dapper1.SourceGet(one, two);
            dapper1.SourceGets(one, two);
            dapper1.SourceAdd(three, one, two);
            dapper1.SourcePreDelete(three);
            dapper1.SourceAftDelete(one, two);
            dapper1.SourceModify(three, one, two);

            dapper1.TableGet(one.oid, two.rid);

            //以值进行操作

            DapperWrapper <Three, Two, One> dapper2 = new DapperWrapper <Three, Two, One>("key");

            dapper2.TableGet(one.oid);
            dapper2.TableGets(one.oid);
            dapper2.TableAdd(three.tid, one.oid);
            dapper2.TablePreDelete(three.tid);
            dapper2.TableAftDelete(one.oid);
            dapper2.TableModify(three.tid, one.oid);
        }
Exemplo n.º 3
0
        public static void Start()
        {
            VasilyRunner.Run();

            Console.WriteLine(SqlEntity <One> .Table);
            //table_one

            Console.WriteLine(SqlEntity <One> .Primary);
            //oid

            Console.WriteLine(SqlEntity <One> .SelectAll);
            //SELECT * FROM [table_one]

            Console.WriteLine(SqlEntity <One> .SelectAllByPrimary);
            //SELECT * FROM [table_one] WHERE [oid] = @oid

            Console.WriteLine(SqlEntity <One> .SelectAllIn);
            //SELECT * FROM [table_one] WHERE [oid] IN @keys

            Console.WriteLine(SqlEntity <One> .SelectAllWhere);
            //SELECT * FROM [table_one] WHERE


            Console.WriteLine(SqlEntity <One> .UpdateAllByPrimary);
            //UPDATE [table_one] SET [name]=@name,[create_time]=@create_time,[update_time]=@update_time,[age]=@age,[student_id]=@student_id WHERE [oid]=@oid

            Console.WriteLine(SqlEntity <One> .UpdateAllWhere);
            //UPDATE [table_one] SET [name]=@name,[create_time]=@create_time,[update_time]=@update_time,[age]=@age,[student_id]=@student_id WHERE


            Console.WriteLine(SqlEntity <One> .DeleteByPrimary);
            //DELETE FROM [table_one] WHERE [oid] = @oid

            Console.WriteLine(SqlEntity <One> .DeleteWhere);
            //DELETE FROM [table_one] WHERE


            Console.WriteLine(SqlEntity <One> .InsertAll);
            //INSERT INTO [table_one] ([name],[create_time],[update_time],[age],[student_id])VALUES(@name, @create_time, @update_time, @age, @student_id)

            Console.WriteLine(SqlEntity <One> .RepeateCount);
            //SELECT COUNT(*) FROM [table_one] WHERE [student_id] = @student_id

            Console.WriteLine(SqlEntity <One> .RepeateEntities);
            //SELECT * FROM [table_one] WHERE [student_id] = @student_id
            Console.WriteLine(SqlEntity <One> .RepeateId);
            //SELECT [oid] FROM [table_one] WHERE [student_id] = @student_id

            Console.WriteLine(SqlEntity <One> .SelectCount);
            //SELECT Count(*) FROM [table_one]
            Console.WriteLine(SqlEntity <One> .SelectCountWhere);
            //SELECT  Count(*) FROM [table_one] WHERE


            //操作对应的是DapperWrapper<One>
            One one = new One();
            DapperWrapper <One> dapper = new DapperWrapper <One>("key");

            dapper.IsRepeat(one);
        }
Exemplo n.º 4
0
        public static void Start()
        {
            VasilyRunner.Run();
            Connector.Add <SqlConnection>("key", "链接字符串");
            Connector.Add <SqlConnection>("key-wr", "读-链接字符串", "写-链接字符串");
            Connector.AddRead <SqlConnection>("read1", "读-链接字符串");
            Connector.AddWrite <SqlConnection>("write2", "写-链接字符串");

            //创建driver的三种方式
            //wrapper = wrapper1 = wrapper2


            DapperWrapper <One> wrapper  = new DapperWrapper <One>("key");
            DapperWrapper <One> wrapper1 = "key";
            var wrapper2 = DapperWrapper <One> .UseKey("key");

            //wrapper4 = wrapper5 = wrapper6 = wrapper7
            DapperWrapper <One> wrapper4 = new DapperWrapper <One>("read1", "write2");
            DapperWrapper <One> wrapper5 = "key-wr | write2          ";
            var wrapper6 = DapperWrapper <One> .UseKey("key-wr", "write2");

            var wrapper7 = DapperWrapper <One> .UseKey("key-wr");



            One one  = new One();
            One one1 = new One();
            One one2 = new One();


            //两种调用方式

            //指定操作方式,RequestType赋值一次即可。
            //RequestType默认为 Complete;
            wrapper.RequestType = VasilyRequestType.Complete;
            wrapper.GetAll();

            //使用属性调用
            wrapper.Complete.GetAll();

            //获取所有元素
            wrapper.GetAll();
            wrapper.GetByPrimary(one);
            wrapper.GetsIn(1, 2, 3, 4);
            wrapper.GetIn(1);
            wrapper.IsRepeat(one);
            wrapper.NoRepeateAdd(one);
            wrapper.GetNoRepeateId <int>(one);
            wrapper.GetRepeates(one);
            wrapper.ModifyByPrimary(one, one1, one2);
            wrapper.Add(one, one1, one2);
            wrapper.SingleDeleteByPrimary(1);
            wrapper.EntitiesDeleteByPrimary(one, one1, one2);

            //SafeInsert = NoRepeateInsert + GetNoRepeateId
            wrapper.SafeAdd(one);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 静态创建一个Link对象
        /// </summary>
        /// <param name="handler">DapperWrapper对象</param>
        /// <returns></returns>
        public static SqlLink <T> Load(DapperWrapper <T> handler)
        {
            SqlLink <T> instance = new SqlLink <T>();

            instance._handler = handler;
            instance._model   = SqlModel <T> .CopyInstance();

            return(instance);
        }
Exemplo n.º 6
0
        public ActionResult GetSupplierName()
        {
            var ret         = new List <object>();
            var sql         = "select distinct(orderstatus) from dbo.TSupplier";
            var orderStatus = DapperWrapper.GetAll <int>(sql);

            foreach (var item in orderStatus)
            {
                ret.Add(new { id = item, name = MapOrderStatus(item) });
            }
            return(Json(ret));
        }
Exemplo n.º 7
0
        public ActionResult GetSupplierType()
        {
            var ret             = new List <object>();
            var sql             = "select distinct(suppliertype) from dbo.supplier";
            var dbSupplierTypes = DapperWrapper.GetAll <int>(sql);

            foreach (var type in dbSupplierTypes)
            {
                ret.Add(new { id = type, name = type });
            }
            return(Json(ret));
        }
Exemplo n.º 8
0
        public ActionResult QueryFinanceList(FinanceQueryViewModel queryModel)
        {
            var           results = new List <FinanceViewModel>();
            StringBuilder sbr     = new StringBuilder();

            if (queryModel.customname != null)
            {
                sbr.Append(" customname=" + queryModel.customname + " and");
            }
            if (queryModel.batchnumber != null)
            {
                sbr.Append(" batchnumber=" + queryModel.batchnumber + " and");
            }
            if (queryModel.returnpaystatus > 0)
            {
                sbr.Append(" returnpaystatus=" + "'" + queryModel.returnpaystatus + "'" + " and");
            }
            if (queryModel.billstatus > 0)
            {
                sbr.Append(" billstatus=" + "'" + queryModel.billstatus + "'" + " and");
            }
            var condition = sbr.ToString();
            var sql       = "select * from dbo.financeinfo";

            if (!string.IsNullOrEmpty(condition))
            {
                sql += " where ";
                sql += condition;
                if (sql.Contains("and"))
                {
                    var charArray = new char[] { 'a', 'n', 'd' };
                    sql = sql.TrimEnd(charArray);
                }
            }
            var dbFinances = DapperWrapper.GetAll <Tfinance>(sql);

            foreach (var item in dbFinances)
            {
                var financeVM = new FinanceViewModel();
                #region convert db to viewmodel
                var checkrow = "<a href=\"#\" onclick=\"checkFinance(this)\">查看</a>";
                var editrow  = "<a href=\"#\" onclick=\"editFinance(this)\">编辑</a>";
                financeVM.operation = checkrow + " " + editrow;
                #endregion
                results.Add(financeVM);
            }
            return(Json(results));
        }
Exemplo n.º 9
0
        public static void Start()
        {
            VasilyRunner.Run();

            Console.WriteLine(RelationSql <Two, Two, One, Two_Parent> .Table);
            //table_relation

            Console.WriteLine(RelationSql <Two, Two, One, Two_Parent> .Primary);
            //rid


            Console.WriteLine(RelationSql <Two, Two, One, Two_Parent> .AddFromSource);
            //INSERT INTO [table_relation] ([rid],[one_id],[parent_id])VALUES(@rid, @oid, @rid)

            Console.WriteLine(RelationSql <Two, Two, One, Two_Parent> .AddFromTable);
            //INSERT INTO [table_relation] ([rid],[one_id],[parent_id])VALUES(@rid, @one_id, @parent_id)

            Console.WriteLine(RelationSql <Three, Two, One, Two_Parent> .DeleteAftFromSource);
            //DELETE FROM [table_relation] WHERE [one_id] = @oid AND [parent_id] = @rid

            Console.WriteLine(RelationSql <Three, Two, One, Two_Parent> .DeleteAftFromTable);
            //DELETE FROM [table_relation] WHERE [one_id] = @one_id AND [parent_id] = @parent_id

            Console.WriteLine(RelationSql <Three, Two, One, Two_Parent> .DeletePreFromSource);
            //DELETE FROM [table_relation] WHERE [three_id] = @tid

            Console.WriteLine(RelationSql <Three, Two, One, Two_Parent> .DeletePreFromTable);
            //DELETE FROM [table_relation] WHERE [three_id] = @three_id


            Console.WriteLine(RelationSql <Three, Two, One, Two_Parent> .GetFromSource);
            //SELECT [three_id] FROM [table_relation] WHERE [one_id] = @oid AND [parent_id] = @rid

            Console.WriteLine(RelationSql <Three, Two, One, Two_Parent> .GetFromTable);
            //SELECT [three_id] FROM [table_relation] WHERE [one_id] = @one_id AND [parent_id] = @parent_id

            Console.WriteLine(RelationSql <Three, Two, One, Two_Parent> .ModifyFromSource);
            //UPDATE [table_relation] SET [three_id] = @tid WHERE [one_id] = @oid AND [parent_id] = @rid

            Console.WriteLine(RelationSql <Three, Two, One, Two_Parent> .ModifyFromTable);
            //UPDATE [table_relation] SET [three_id] = @three_id WHERE [one_id] = @one_id AND [parent_id] = @parent_id


            //操作对应的是DapperWrapper<Three, Two, One, Two_Parent>
            DapperWrapper <Three, Two, One, Two_Parent> dapper = new DapperWrapper <Three, Two, One, Two_Parent>("key");
        }
Exemplo n.º 10
0
 public VasilyController(string reader, string writter) : this()
 {
     driver = new DapperWrapper <T>(reader, writter);
     c      = new SqlCondition <T>();
 }
Exemplo n.º 11
0
 public VasilyController(string key) : this()
 {
     driver = new DapperWrapper <T>(key);
     c      = new SqlCondition <T>();
 }
Exemplo n.º 12
0
 public VasilyController(string reader, string writter) : base()
 {
     driver = new DapperWrapper <T, R, S1>(reader, writter);
 }
Exemplo n.º 13
0
 public VasilyController(string key) : base()
 {
     driver = new DapperWrapper <T, R, S1>(key);
 }
Exemplo n.º 14
0
        public ActionResult QueryTicketList(TicketQueryVM queryModel)
        {
            var           results = new List <TicketViewModel>();
            StringBuilder sbr     = new StringBuilder();

            if (queryModel.customername != null)
            {
                sbr.Append(" customername=" + queryModel.customername + " and");
            }
            if (queryModel.batchnumber != null)
            {
                sbr.Append(" batchnumber=" + queryModel.batchnumber + " and");
            }
            if (queryModel.ticketnumber != null)
            {
                sbr.Append(" ticketnumber=" + "'" + queryModel.ticketnumber + "'" + " and");
            }
            if (queryModel.ticketstatus != null)
            {
                sbr.Append(" ticketstatus=" + "'" + queryModel.ticketstatus + "'" + " and");
            }
            var condition = sbr.ToString();
            var sql       = "select * from dbo.ticketinfo";

            if (!string.IsNullOrEmpty(condition))
            {
                sql += " where ";
                sql += condition;
                if (sql.Contains("and"))
                {
                    var charArray = new char[] { 'a', 'n', 'd' };
                    sql = sql.TrimEnd(charArray);
                }
            }
            var dbTickets = DapperWrapper.GetAll <Tticket>(sql);

            foreach (var item in dbTickets)
            {
                var orderVM = new TicketViewModel();
                #region convert db to viewmodel
                using (var dbContext = new TicketCodeTestDBContext())
                {
                    var efCustom = dbContext.Tcustomer.ToList().FirstOrDefault(n => n.Code == item.CustomerCode);
                    orderVM.customername = efCustom.Name;
                    orderVM.saleman      = efCustom.SaleMan;
                    orderVM.batchnumber  = item.Batch;
                    orderVM.salecount    = efCustom.SaleCount.ToString();
                    orderVM.price        = efCustom.Price.ToString();
                    orderVM.amount       = efCustom.SaleAmount.ToString();
                }
                orderVM.ordertime     = item.CreateTime.ToString();
                orderVM.validitytime  = item.ValidityStartTime.ToString() + item.ValidityEndTime.ToString();
                orderVM.ticketnumbers = item.CouponRange;
                orderVM.ticketstatus  = MapTicketStatus(item.Status);
                orderVM.operatorname  = item.Operator;
                var checkrow  = "<a href=\"#\" onclick=\"checkTicket(this)\">查看</a>";
                var editrow   = "<a href=\"#\" onclick=\"editTicket(this)\">编辑</a>";
                var managerow = "<a href=\"#\" onclick=\"manageTicket(this)\">管理劵码</a>";
                orderVM.operation = checkrow + " " + editrow + " " + managerow;
                #endregion
                results.Add(orderVM);
            }
            return(Json(results));
        }