Наследование: System.Web.UI.Page
Пример #1
0
 public string ChangeFormulaYear(string tableName,IList<FormulaYear> deleteItems, IList<FormulaYear> updateItems, IList<FormulaYear> insertItems)
 {
     try
     {
         foreach (var item in deleteItems)
         {
             Delete delete = new Delete(tableName);
             delete.AddCriterions("KeyID","myKeyID", item.KeyID, CriteriaOperator.Equal);
             delete.AddCriterions("ID","myID", item.ID, CriteriaOperator.Equal);
             delete.AddSqlOperator(SqlOperator.AND);
             dataFactory.Remove(delete);
         }
         foreach (var item in updateItems)
         {
             Update<FormulaYear> update = new Update<FormulaYear>(tableName, item);
             update.AddCriterion("KeyID", "myKeyID",item.KeyID, CriteriaOperator.Equal);
             update.AddCriterion("ID", "myID",item.ID, CriteriaOperator.Equal);
             update.AddSqlOperator(SqlOperator.AND);
             update.AddExcludeField("Id");
             dataFactory.Save<FormulaYear>(update);
         }
         foreach (var item in insertItems)
         {
             Insert<FormulaYear> insert = new Insert<FormulaYear>(tableName, item);
             insert.AddExcludeField("Id");
             dataFactory.Save<FormulaYear>(insert);
         }
     }
     catch
     {
         return "0";
     }
     return "1";
 }
Пример #2
0
 public void SavePVFValues(IList<PVFItem> inserted, IList<PVFItem> updated, IList<PVFItem> deleted)
 {
     using (TransactionScope scope = new TransactionScope())
     {
         foreach (var item in inserted)
         {
             Insert<PVFItem> insert = new Insert<PVFItem>("PeakValleyFlat", item);
             insert.AddExcludeField("ID");
             dataFactory.Save<PVFItem>(insert);
         }
         foreach (var item1 in updated)
         {
             Update<PVFItem> update = new Update<PVFItem>("PeakValleyFlat", item1);
             update.AddCriterion("ID", "ID", item1.ID, SqlServerDataAdapter.Infrastruction.CriteriaOperator.Equal);
             update.AddExcludeField("ID");
             dataFactory.Save<PVFItem>(update);
         }
         foreach (var item2 in deleted)
         {
             Delete delete = new Delete("PeakValleyFlat");
             delete.AddCriterions("ID", "ID",item2.ID, SqlServerDataAdapter.Infrastruction.CriteriaOperator.Equal);
             dataFactory.Remove(delete);
         }
         scope.Complete();
     }
 }
Пример #3
0
        public void Insert(Insert value)
        {
#if DEBUG
            //Console.WriteLine("before Insert");
#endif


            WithWriteConnection(
                c =>
                {
                    if (ListMode)
                    {
                        InsertList.Add(value);

                        // garbage collect

                        // lesser values will cause glitches in slower clients
                        // IE for example is not streaming, this will need a longer buffer for reconnects
                        var memento = 64;
                        if (InsertList.Count > memento)
                            InsertList[InsertList.Count - memento] = null;

                        //Console.Title = ("@ " + InsertList.Count);
                        return;
                    };

                    value.ExecuteNonQuery(c);
                }
             );

#if DEBUG
            //Console.WriteLine("after Insert");
#endif
        }
Пример #4
0
 public void Acc_Insert_SimpleWithSelect()
 {
     Insert i = new Insert().Into(Category.Schema)
         .Select(new Select("CategoryName", "Description", "Picture").From(Category.Schema));
     string sql = i.BuildSqlStatement();
     Assert.IsTrue(sql ==
                   "INSERT INTO [Categories](CategoryName,Description,Picture)\r\nSELECT [Categories].[CategoryName], [Categories].[Description], [Categories].[Picture]\r\n FROM [Categories]\r\n\r\n");
 }
Пример #5
0
        public void Acc_Insert_SimpleWithSelectAndSchema()
        {
            Insert i = new Insert().Into(Category.Schema)
                .Select(Select.AllColumnsFrom<Category>());
            string sql = i.BuildSqlStatement();

            Assert.AreEqual(
                "INSERT INTO [Categories](CategoryName,Description,Picture)\r\nSELECT [Categories].[CategoryName], [Categories].[Description], [Categories].[Picture]\r\n FROM [Categories]\r\n\r\n",
                sql);
        }
Пример #6
0
        public void Insert(Insert value, Action<long> yield)
        {
            WithConnection(
             c =>
             {
                 value.ExecuteNonQuery(c);

                 yield(c.LastInsertRowId);
             }
           );
        }
 public Insert2 TrainRegressionModel(ProjectModelId projectModelId, string csvDataPathInStorage)
 {
     Insert insertBody = new Insert
     {
         StorageDataLocation = csvDataPathInStorage,
         Id = projectModelId.ModelId,
         ModelType = "REGRESSION",
     };
     TrainedmodelsResource.InsertRequest insertRequest = PredictionService.Trainedmodels.Insert(insertBody, projectModelId.ProjectNumber);
     Insert2 insertResponse = insertRequest.Execute();
     return insertResponse;
 }
Пример #8
0
        public Task<long> Insert(Insert value)
        {
            var id = -1L;

            WithConnection(
                c =>
                {
                    value.ExecuteNonQuery(c);

                    id = c.LastInsertRowId;
                }
            );

            return Task.FromResult(id);
        }
Пример #9
0
        public void Insert(Insert value, Action<long> yield)
        {
            Console.WriteLine("Insert enter");
            WithWriteConnection(
                c =>
                {
                    Console.WriteLine("Insert before ExecuteNonQuery");
                    value.ExecuteNonQuery(c);

                    yield(c.LastInsertRowId);
                    Console.WriteLine("Insert after ExecuteNonQuery");
                }
             );
            Console.WriteLine("Insert exit");
        }
Пример #10
0
        public long Insert(Insert value)
        {
            var id = -1L;

            WithConnection(
                c =>
                {
                    value.ExecuteNonQuery(c);

                    id = c.LastInsertRowId;
                }
            );

            return id;
        }
Пример #11
0
 public override void Up()
 {
     Insert.IntoTable("CampaignCustomers")
     .InSchema("Marketing")
     .Row(new {
         CampaignId     = 1,
         BranchId       = "FDF",
         CustomerNumber = "123456"
     });
     Insert.IntoTable("CampaignCustomers")
     .InSchema("Marketing")
     .Row(new {
         CampaignId     = 1,
         BranchId       = "FDF",
         CustomerNumber = "123457"
     });
 }
Пример #12
0
        /// <summary>
        /// Builds the insert statement.
        /// </summary>
        /// <returns></returns>
        public override string BuildInsertStatement()
        {
            StringBuilder sb = new StringBuilder();

            //cast it
            Insert i = insert;

            sb.Append(this.sqlFragment.INSERT_INTO);
            sb.Append(i.Table.QualifiedName);
            sb.Append("(");
            sb.Append(i.SelectColumns);
            sb.AppendLine(")");

            //if the values list is set, use that
            if (i.Inserts.Count > 0)
            {
                sb.Append(" VALUES (");
                bool isFirst = true;
                foreach (InsertSetting s in i.Inserts)
                {
                    if (!isFirst)
                    {
                        sb.Append(",");
                    }
                    if (!s.IsExpression)
                    {
                        sb.Append(s.ParameterName);
                    }
                    else
                    {
                        sb.Append(s.Value);
                    }
                    isFirst = false;
                }
                sb.AppendLine(")");
            }
            else
            {
                throw new InvalidOperationException("Need to specify Values or a Select query to insert - can't go on!");
            }

            sb.AppendLine(";");

            sb.AppendFormat("SELECT last_insert_rowid();");
            return(sb.ToString());
        }
Пример #13
0
        public override void Up()
        {
            this.CreateTableWithId64("Groups", "GroupId", s => s
                                     .WithColumn("GroupName").AsString(50).NotNullable());

            this.CreateTableWithId64("GroupUsers", "GroupUserId", s => s
                                     .WithColumn("GroupId").AsInt64().NotNullable()
                                     .ForeignKey("FK_GroupUsers_GroupId", "Groups", "GroupId")
                                     .WithColumn("UserId").AsInt32().NotNullable()
                                     .ForeignKey("FK_GroupUsers_UserId", "Users", "UserId"));

            Create.Index("UQ_GroupUsers_GroupId_UserId")
            .OnTable("GroupUsers")
            .OnColumn("GroupId").Ascending()
            .OnColumn("UserId").Ascending()
            .WithOptions().Unique();

            Create.Index("UQ_GroupUsers_UserId_GroupId")
            .OnTable("GroupUsers")
            .OnColumn("UserId").Ascending()
            .OnColumn("GroupId").Ascending()
            .WithOptions().Unique();

            this.CreateTableWithId64("Status", "StatusId", s => s
                                     .WithColumn("StatusName").AsString(50).NotNullable());

            Insert.IntoTable("Status").Row(new
            {
                StatusName = "Không nghe máy"
            });

            Insert.IntoTable("Status").Row(new
            {
                StatusName = "Không có nhu cầu"
            });

            Insert.IntoTable("Status").Row(new
            {
                StatusName = "Đồng ý mua hàng"
            });

            Insert.IntoTable("Status").Row(new
            {
                StatusName = "Hẹn gọi lại"
            });
        }
Пример #14
0
        protected OrganizationUnitMaintBase()
        {
            EmployeesAccessor.Cache.AllowInsert = false;
            EmployeesAccessor.Cache.AllowDelete = false;
            EmployeesAccessor.Cache.AllowUpdate = false;
            PXUIFieldAttribute.SetDisplayName <Contact.salutation>(Caches[typeof(Contact)], CR.Messages.Attention);

            PXUIFieldAttribute.SetEnabled <Contact.fullName>(Caches[typeof(Contact)], null);

            bool branchFeatureEnabled = PXAccess.FeatureInstalled <FeaturesSet.branch>();

            Next.SetVisible(branchFeatureEnabled);
            Prev.SetVisible(branchFeatureEnabled);
            Last.SetVisible(branchFeatureEnabled);
            First.SetVisible(branchFeatureEnabled);
            Insert.SetVisible(branchFeatureEnabled);
        }
Пример #15
0
            public void It_generates_correct_insert_for_multi_objects_with_identity_column_and_nesting()
            {
                var peter = new Person {
                    Name = "Peter"
                };
                var roger = new Person {
                    Name = "Roger"
                };
                var query = new Insert <Person>()
                            .Add(peter)
                            .Add(roger)
                            .ToQuery();

                Assert.Equal("INSERT INTO [Person] ([Name]) SELECT @p0; INSERT INTO [Person] ([Name]) SELECT @p1; ", query.QueryText);
                Assert.Equal("Peter", ((IDictionary <string, object>)((dynamic)query).Parameters)["p0"]);
                Assert.Equal("Roger", ((IDictionary <string, object>)((dynamic)query).Parameters)["p1"]);
            }
Пример #16
0
        public void DropTable()
        {
            //Open Connect to DataBase
            DataBase db        = Connect();
            var      generator = new OKHOSTING.Sql.MySql.SqlGenerator();

            //define table song
            Table table = new Table("Song");

            table.Columns.Add(new Column()
            {
                Name = "Id", DbType = DbType.Int32, IsPrimaryKey = true, IsAutoNumber = true, Table = table
            });
            table.Columns.Add(new Column()
            {
                Name = "Name", DbType = DbType.AnsiString, Length = 100, IsNullable = false, Table = table
            });
            table.Columns.Add(new Column()
            {
                Name = "Sing", DbType = DbType.AnsiString, Length = 120, IsNullable = false, Table = table
            });

            //create table song
            var sql = generator.Create(table);

            db.Execute(sql);
            Assert.IsTrue(db.ExistsTable(table.Name));

            //insert values into song
            Insert insert = new Insert();

            insert.Table = table;
            insert.Values.Add(new ColumnValue(table["Id"], 1));
            insert.Values.Add(new ColumnValue(table["Name"], "More than words"));
            insert.Values.Add(new ColumnValue(table["Sing"], "Extreme"));

            sql = generator.Insert(insert);
            int affectedRows = db.Execute(sql);

            Assert.AreEqual(affectedRows, 1);

            //drop table song
            sql = generator.Drop(table);
            db.Execute(sql);
            Assert.IsFalse(db.ExistsTable(table.Name));
        }
Пример #17
0
 public override void Up()
 {
     Insert.IntoTable("HistoryDetails")
     .InSchema("List")
     .Row(new {
         HeaderId    = 1,
         LineNumber  = 1,
         ItemNumber  = "123456",
         Each        = true,
         CatalogId   = "FRT",
         CreatedUtc  = new DateTime(2017, 6, 30, 15, 15, 0, DateTimeKind.Utc),
         ModifiedUtc = new DateTime(2017, 6, 30, 15, 16, 0, DateTimeKind.Utc)
     });
     Insert.IntoTable("HistoryDetails")
     .InSchema("List")
     .Row(new {
         HeaderId    = 1,
         LineNumber  = 2,
         ItemNumber  = "234567",
         Each        = false,
         CatalogId   = "FRT",
         CreatedUtc  = new DateTime(2017, 6, 30, 15, 15, 0, DateTimeKind.Utc),
         ModifiedUtc = new DateTime(2017, 6, 30, 15, 16, 0, DateTimeKind.Utc)
     });
     Insert.IntoTable("HistoryDetails")
     .InSchema("List")
     .Row(new {
         HeaderId    = 1,
         LineNumber  = 3,
         ItemNumber  = "345678",
         Each        = true,
         CatalogId   = "FRT",
         CreatedUtc  = new DateTime(2017, 6, 30, 15, 15, 0, DateTimeKind.Utc),
         ModifiedUtc = new DateTime(2017, 6, 30, 15, 16, 0, DateTimeKind.Utc)
     });
     Insert.IntoTable("HistoryDetails")
     .InSchema("List")
     .Row(new {
         HeaderId    = 1,
         LineNumber  = 4,
         ItemNumber  = "456789",
         CreatedUtc  = new DateTime(2017, 6, 30, 15, 15, 0, DateTimeKind.Utc),
         ModifiedUtc = new DateTime(2017, 6, 30, 15, 16, 0, DateTimeKind.Utc)
     });
 }
Пример #18
0
        /// <summary>
        /// Migrates up current module.
        /// </summary>
        public override void Up()
        {
            var dateNow = DateTime.Now;

            var options = new
            {
                ResultsCount =
                    new
                {
                    Id             = "6E0949B4-3339-4984-8103-D98F3FBC031D",
                    Version        = 1,
                    IsDeleted      = false,
                    CreatedOn      = dateNow,
                    CreatedByUser  = BetterCmsUserName,
                    ModifiedOn     = dateNow,
                    ModifiedByUser = BetterCmsUserName,
                    ContentId      = "663A1D0C-FADA-4ACC-A34F-7437523AE65B",
                    Key            = SearchModuleConstants.WidgetOptionNames.ResultsCount,
                    Type           = 2,       // Integer
                    DefaultValue   = SearchModuleConstants.DefaultSearchResultsCount,
                    IsDeletable    = false
                },
                ShowTotalResults =
                    new
                {
                    Id             = "33384E55-1B47-4040-A104-165F2979A7A0",
                    Version        = 1,
                    IsDeleted      = false,
                    CreatedOn      = dateNow,
                    CreatedByUser  = BetterCmsUserName,
                    ModifiedOn     = dateNow,
                    ModifiedByUser = BetterCmsUserName,
                    ContentId      = "663A1D0C-FADA-4ACC-A34F-7437523AE65B",
                    Key            = SearchModuleConstants.WidgetOptionNames.ShowTotalResults,
                    Type           = 5,       // Boolean
                    DefaultValue   = "true",
                    IsDeletable    = false
                }
            };

            // Add widget options.
            Insert.IntoTable("ContentOptions").InSchema(rootSchemaName)
            .Row(options.ResultsCount)
            .Row(options.ShowTotalResults);
        }
        public override void Up()
        {
            Insert.IntoTable("Permission")
            .Row(new { Name = "auth-edit-self-personal-data", Description = "Permission to edit own personal data" })
            .Row(new { Name = "auth-edit-self-contacts", Description = "Permission to edit own contacts" });

            Execute.WithConnection((connection, transaction) =>
            {
                var adminUserId = Query.Conn(connection, transaction).Select <int>("Id").From("Role")
                                  .Where("Name", "Admin")
                                  .Run().Single();

                var portalAdminUserId = Query.Conn(connection, transaction).Select <int>("Id").From("Role")
                                        .Where("Name", "PortalAdmin")
                                        .Run().Single();

                var registeredUserId = Query.Conn(connection, transaction).Select <int>("Id").From("Role")
                                       .Where("Name", "RegisteredUser")
                                       .Run().Single();

                var verifiedUserId = Query.Conn(connection, transaction).Select <int>("Id").From("Role")
                                     .Where("Name", "VerifiedUser")
                                     .Run().Single();

                var permissionEditSelfPersonalData = Query.Conn(connection, transaction).Select <int>("Id")
                                                     .From("Permission")
                                                     .Where("Name", "auth-edit-self-personal-data")
                                                     .Run().Single();

                var permissionEditSelfContacts = Query.Conn(connection, transaction).Select <int>("Id")
                                                 .From("Permission")
                                                 .Where("Name", "auth-edit-self-contacts")
                                                 .Run().Single();

                Query.Conn(connection, transaction).Insert("Role_Permission")
                .Row(new { RoleId = adminUserId, PermissionId = permissionEditSelfPersonalData })
                .Row(new { RoleId = adminUserId, PermissionId = permissionEditSelfContacts })
                .Row(new { RoleId = portalAdminUserId, PermissionId = permissionEditSelfPersonalData })
                .Row(new { RoleId = portalAdminUserId, PermissionId = permissionEditSelfContacts })
                .Row(new { RoleId = registeredUserId, PermissionId = permissionEditSelfPersonalData })
                .Row(new { RoleId = registeredUserId, PermissionId = permissionEditSelfContacts })
                .Row(new { RoleId = verifiedUserId, PermissionId = permissionEditSelfContacts })
                .Run();
            });
        }
Пример #20
0
        /// <summary>
        /// Generates a project with the given GenerateablePageMacros
        /// </summary>
        /// <param name="projectLinkFilePath">EPLAN project file (*.elk)</param>
        /// <param name="projectTemplateFilePath">EPLAN template project (*.zw9)</param>
        /// <param name="generatablePageMacros">List of GeneratablePageMaros</param>
        public static void Generate(string projectLinkFilePath, string projectTemplateFilePath,
                                    List <GeneratablePageMacro> generatablePageMacros)
        {
            var project = Create(projectLinkFilePath, projectTemplateFilePath, false);

            project.RemoveAllPages();

            Insert insert    = new Insert();
            var    pageCount = project.Pages.Length; // needed cause of overwrite

            foreach (var generatablePageMacro in generatablePageMacros)
            {
                // Load pages from macro
                PageMacro pageMacro = new PageMacro();
                pageMacro.Open(generatablePageMacro.Filename, project);
                foreach (var page in pageMacro.Pages)
                {
                    // Rename
                    pageCount++;

                    PagePropertyList pagePropertyList = page.NameParts;
                    if (generatablePageMacro.LocationIdentifierIdentifier != null)
                    {
                        pagePropertyList[Properties.Page.DESIGNATION_FUNCTIONALASSIGNMENT] =
                            generatablePageMacro.LocationIdentifierIdentifier.FunctionAssignment;
                        pagePropertyList[Properties.Page.DESIGNATION_PLANT] =
                            generatablePageMacro.LocationIdentifierIdentifier.Plant;
                        pagePropertyList[Properties.Page.DESIGNATION_PLACEOFINSTALLATION] =
                            generatablePageMacro.LocationIdentifierIdentifier.PlaceOfInstallation;
                        pagePropertyList[Properties.Page.DESIGNATION_LOCATION] =
                            generatablePageMacro.LocationIdentifierIdentifier.Location;
                        pagePropertyList[Properties.Page.DESIGNATION_USERDEFINED] =
                            generatablePageMacro.LocationIdentifierIdentifier.UserDefinied;
                    }

                    pagePropertyList[Properties.Page.PAGE_COUNTER] = pageCount;
                    page.NameParts = pagePropertyList;

                    new NameService(page).EvaluateAndSetAllNames();
                }

                // Insert pagemacro
                insert.PageMacro(pageMacro, project, null, PageMacro.Enums.NumerationMode.Number);
            }
        }
        public static void Main(string[] args)
        {
            using (SqlSugarClient db = new SqlSugarClient("server=.;uid=sa;pwd=sasa;database=SqlSugarTest"))
            {
                var dt = db.GetDataTable("select * from student where id=@id", new { id = 1 });

                //设置执行的DEMO
                string switch_on = "Select";

                IDemos demo = null;
                switch (switch_on)
                {
                //ADO.NET基本功能
                case "Ado": demo = new Ado(); break;

                //查询
                case "Select": demo = new Select(); break;

                //插入
                case "Insert": demo = new Insert(); break;

                //更新
                case "Update": demo = new Update(); break;

                //删除
                case "Delete": demo = new Delete(); break;

                //事务
                case "Tran": demo = new Tran(); break;

                //生成实体
                case "CreateClass": demo = new CreateClass(); break;

                //枚举类型的支持
                case "EnumType": demo = new EnumType(); break;

                    //除了多库并行计算外的所有功能都已经移植成功更多例子请关注我的博客
                }
                //执行DEMO
                demo.Init();

                Console.WriteLine("执行成功请关闭窗口");
                Console.ReadKey();
            }
        }
        public override void Up()
        {
            this.CreateTableWithId32("Users", "UserId", s => s
                                     .WithColumn("Username").AsString(100).NotNullable()
                                     .WithColumn("DisplayName").AsString(100).NotNullable()
                                     .WithColumn("Email").AsString(100).Nullable()
                                     .WithColumn("Source").AsString(4).NotNullable()
                                     .WithColumn("PasswordHash").AsString(86).NotNullable()
                                     .WithColumn("PasswordSalt").AsString(10).NotNullable()
                                     .WithColumn("LastDirectoryUpdate").AsDateTime().Nullable()
                                     .WithColumn("UserImage").AsString(100).Nullable()
                                     .WithColumn("InsertDate").AsDateTime().NotNullable()
                                     .WithColumn("InsertUserId").AsInt32().NotNullable()
                                     .WithColumn("UpdateDate").AsDateTime().Nullable()
                                     .WithColumn("UpdateUserId").AsInt32().Nullable()
                                     .WithColumn("IsActive").AsInt16().NotNullable().WithDefaultValue(1));

            Insert.IntoTable("Users").Row(new {
                Username     = "******",
                DisplayName  = "admin",
                Email        = "*****@*****.**",
                Source       = "site",
                PasswordHash = "rfqpSPYs0ekFlPyvIRTXsdhE/qrTHFF+kKsAUla7pFkXL4BgLGlTe89GDX5DBysenMDj8AqbIZPybqvusyCjwQ",
                PasswordSalt = "hJf_F",
                InsertDate   = new DateTime(2014, 1, 1),
                InsertUserId = 1,
                IsActive     = 1
            });

            this.CreateTableWithId32("Languages", "Id", s => s
                                     .WithColumn("LanguageId").AsString(10).NotNullable()
                                     .WithColumn("LanguageName").AsString(50).NotNullable());

            Insert.IntoTable("Languages").Row(new
            {
                LanguageId   = "en",
                LanguageName = "English"
            });

            Insert.IntoTable("Languages").Row(new
            {
                LanguageId   = "fr_FR",
                LanguageName = "French"
            });
        }
Пример #23
0
        public override void Up()
        {
            Insert.IntoTable("Resource")
            .Row(new
            {
                Name                    = "offline_access",
                Description             = "Enable client to use refresh token",
                Required                = false,
                ShowInDiscoveryDocument = false,
                Discriminator           = "IdentityResource"
            });

            Execute.WithConnection((connection, transaction) =>
            {
                var clientIds = Query.Conn(connection, transaction).Select <int>("Id").From("Client")
                                .Run();

                var resourceIdOfflineAccess = Query.Conn(connection, transaction).Select <int>("Id").From("Resource")
                                              .Where("Name", "offline_access")
                                              .Run().Single();

                var claimTypeEnumId = Query.Conn(connection, transaction).Select <int>("Id").From("ClaimTypeEnum")
                                      .Where("Name", "String")
                                      .Run().Single();

                var insertResourceToClientQuery = Query.Conn(connection, transaction).Insert("Client_IdentityResource");
                foreach (var clientId in clientIds)
                {
                    insertResourceToClientQuery.Row(new { ClientId = clientId, IdentityResourceId = resourceIdOfflineAccess });
                }
                insertResourceToClientQuery.Run();

                Query.Conn(connection, transaction).Insert("ClaimType")
                .Row(new { Name = "offline_access", Description = "offline_access claim", ClaimTypeEnumId = claimTypeEnumId })
                .Run();

                var claimTypeIdOfflineAccess = Query.Conn(connection, transaction).Select <int>("Id").From("ClaimType")
                                               .Where("Name", "offline_access")
                                               .Run().Single();

                Query.Conn(connection, transaction).Insert("Resource_ClaimType")
                .Row(new { ResourceId = resourceIdOfflineAccess, ClaimTypeId = claimTypeIdOfflineAccess })
                .Run();
            });
        }
Пример #24
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     //提交
     try
     {
         if (TextBox1.Text.Trim() == "" || TextBox1.Text.Trim() == null || TextBox2.Text.Trim() == "" || TextBox2.Text.Trim() == null)
         {
             Response.Write("<script>alert('用户名和密码不能为空!')</script>");
         }
         else
         {
             int power = 0;
             if (RadioButton1.Checked == true)
             {
                 power = 3;
             }
             else
             {
                 power = 2;
             }
             string name    = TextBox1.Text;
             string pwd     = TextBox2.Text;
             string factory = DropDownList1.SelectedItem.Text;
             string depart  = TextBox4.Text;
             string tel     = TextBox6.Text;
             string mail    = TextBox7.Text;
             string context = TextBox5.Text;
             Insert ise     = new Insert();
             bool   b       = ise.addsys(name, pwd, power, factory, depart, context, tel, mail);
             if (b == true)
             {
                 Response.Write("<script>alert('注册成功!')</script>");
             }
             else
             {
                 Response.Write("<script>alert('注册失败!')</script>");
             }
         }
     }
     catch (Exception ex)
     {
         //抛出异常
         Response.Write(ex.ToString());
     }
 }
Пример #25
0
        public override void Up()
        {
            Create.Table(Tables.Category)
            .WithColumn("id").AsInt32().PrimaryKey().Identity()
            .WithColumn("name").AsString(500).NotNullable()
            .WithColumn("arabic_name").AsString(500).NotNullable();

            Insert.IntoTable(Tables.Category)
            .Row(new { name = ProjectCategories.Residential, arabic_name = "سكني" })
            .Row(new { name = ProjectCategories.Admin, arabic_name = "إداري" })
            .Row(new { name = ProjectCategories.Complex, arabic_name = "مبنى متعدد الأغراض" })
            .Row(new { name = ProjectCategories.Medical, arabic_name = "طبي" })
            .Row(new { name = ProjectCategories.Commercial, arabic_name = "تجاري" })
            .Row(new { name = ProjectCategories.ResidentialAndCommercial, arabic_name = "سكنى& تجارى" })
            .Row(new { name = ProjectCategories.ResidentialAndAmin, arabic_name = "سكني&إداري" })
            .Row(new { name = ProjectCategories.CommercialAndAdmin, arabic_name = "تجارى&إدارى" })
            .Row(new { name = ProjectCategories.CommercialAndMedical, arabic_name = "تجاري&طبي" });
        }
Пример #26
0
        public override void Up()
        {
            Create.Table("User")
            .WithColumn("Id").AsInt32().Identity().PrimaryKey()
            .WithColumn("Username").AsString(50).Indexed()
            .WithColumn("DisplayName").AsString(100);

            Insert.IntoTable("User").Row(new { Username = "", DisplayName = "Unassigned" });

            Alter.Table("Todo")
            .AddColumn("AssignedToUserId").AsInt32().Nullable();

            Update.Table("Todo")
            .Set(new { AssignedToUserId = 1 }).AllRows();

            Alter.Table("Todo")
            .AlterColumn("AssignedToUserId").AsInt32().NotNullable().ForeignKey("User", "Id");
        }
 public override void Up()
 {
     Insert.IntoTable("Setting").InSchema("App")
     .Row(new
     {
         Key   = "VaBank.Core.Processing.CardTransferSettings",
         Value = JsonConvert.SerializeObject(new
         {
             MinimalAmounts = new Dictionary <string, decimal>
             {
                 { "USD", 5 },
                 { "EUR", 3 },
                 { "BYR", 10000 },
                 { "RUB", 40 }
             }
         })
     });
 }
Пример #28
0
 /// <summary>
 /// Ups this instance.
 /// </summary>
 public override void Up()
 {
     // Create custom option for selecting a media folder
     Insert
     .IntoTable("CustomOptions").InSchema(rootModuleSchemaName)
     .Row(new
     {
         Id             = new Guid("d88604ee-d3d5-4e0c-b071-984143a9ed74"),
         Version        = 1,
         CreatedOn      = DateTime.Now,
         ModifiedOn     = DateTime.Now,
         CreatedByUser  = "******",
         ModifiedByUser = "******",
         IsDeleted      = 0,
         Identifier     = "media-images-url",
         Title          = "Image URL"
     });
 }
Пример #29
0
        private void Criar_TABELA_MERCADO()
        {
            Create.Table(TABELA_MERCADO)
            .WithColumn(CODIGO_MERCADO).AsInt32()
            .PrimaryKey($"PK_{TABELA_MERCADO}")
            .WithColumn("DESCRICAO_MERCADO").AsAnsiString(100, collationName);

            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "010", DESCRICAO_MERCADO = "VISTA" });
            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "012", DESCRICAO_MERCADO = "EXERCÍCIO DE OPÇÕES DE COMPRA" });
            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "013", DESCRICAO_MERCADO = "EXERCÍCIO DE OPÇÕES DE VENDA" });
            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "017", DESCRICAO_MERCADO = "LEILÃO" });
            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "020", DESCRICAO_MERCADO = "FRACIONÁRIO" });
            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "030", DESCRICAO_MERCADO = "TERMO" });
            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "050", DESCRICAO_MERCADO = "FUTURO COM RETENÇÃO DE GANHO" });
            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "060", DESCRICAO_MERCADO = "FUTURO COM MOVIMENTAÇÃO CONTÍNUA" });
            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "070", DESCRICAO_MERCADO = "OPÇÕES DE COMPRA" });
            Insert.IntoTable(TABELA_MERCADO).Row(new { CODIGO_MERCADO = "080", DESCRICAO_MERCADO = "OPÇÕES DE VENDA" });
        }
Пример #30
0
        private void SaveHyperlink(Guid bulkEmailId, HyperlinkData hyperlink)
        {
            var url            = UtmHelper.RemoveUtmFromUri(hyperlink.Url);
            var query          = GetParams(url);
            var bpmTrackId     = GetIntParameterValue(query, _trackIdQueryParameterName);
            var bpmReplicaMask = GetIntParameterValue(query, _replicaQueryParameterName);
            var caption        = string.IsNullOrEmpty(hyperlink.Caption) ? url : hyperlink.Caption;
            var insert         = new Insert(_userConnection)
                                 .Into(_bulkEmailHyperlinkTableName)
                                 .Set("BulkEmailId", Column.Parameter(bulkEmailId))
                                 .Set("Caption", Column.Parameter(caption))
                                 .Set("Url", Column.Parameter(url))
                                 .Set("BpmReplicaMask", Column.Parameter(bpmReplicaMask))
                                 .Set("BpmTrackId", Column.Parameter(bpmTrackId));

            SetAdditionalColumns(insert, hyperlink.AdditionalColumns);
            insert.Execute();
        }
Пример #31
0
        public void TestInsert()
        {
            Insert ins = Qb.Insert("Customers")
                         .Values(
                Value.New("FirstName", "Pavel"),
                Value.New("LastName", "Pavel")
                );

            Renderer.SqlServerRenderer renderer = new Renderer.SqlServerRenderer();
            string sql = renderer.RenderInsert(ins);

            ins = Qb.Insert("Customers", "rem")
                  .Values(
                Value.New("FirstName", "Pavel"),
                Value.New("LastName", "Pavel")
                );
            sql = renderer.RenderInsert(ins);
        }
Пример #32
0
        public Form1()
        {
            InitializeComponent();
            this.DoubleBuffered = true;
            this.MouseWheel += Form1_MouseWheel;

            mInsert = Insert.None;
            mTimeSpace = new TimeSpace();

            mMouse = new Mouse();
            initMouseShift();
            mMouse.mOnWheelMove = onWheelMove;
            mMouse.mLeft = new ButtonStateVar(MouseButtons.Left, null);
            mMouse.mLeft.mOnClick = onClickL;
            mMouse.mLeft.mOnStartDrag = onStartDragL;
            mMouse.mRight = new ButtonStateVar(MouseButtons.Right, null);
            mMouse.mRight.mOnStartDrag = onStartDragR;
        }
        private static void ApplyChanges(XmlDocument xmlDoc, Insert insert, StringBuilder resultingText, int resultingLength, long endingTimestamp)
        {
            insert.Text       = resultingText.ToString();
            insert.Length     = resultingLength;
            insert.Timestamp2 = endingTimestamp;

            XmlElement insertElement = Event.FindCorrespondingXmlElementFromXmlDocument(xmlDoc, insert);   // should be in there!

            insertElement.FirstChild.FirstChild.Value = resultingText.ToString();
            insertElement.Attributes["length"].Value  = resultingLength.ToString();
            XmlAttribute timestamp2Attr = insertElement.Attributes["timestamp2"];

            if (timestamp2Attr == null)
            {
                timestamp2Attr = xmlDoc.CreateAttribute("timestamp2");
            }
            timestamp2Attr.Value = endingTimestamp.ToString();
        }
Пример #34
0
        public StorableObject[] InsertPageMacro(string macroFullPath, Page insertAfterPage, Project targetProject)
        {
            try
            {
                Insert macroInsert     = new Insert();
                var    storableObjects = macroInsert.PageMacro(macroFullPath, insertAfterPage, targetProject, true);

                MessageBox.Show("페이지 매크로가 성공적으로 배치되었습니다.", "페이지 매크로", MessageBoxButtons.OK, MessageBoxIcon.Information);

                return(storableObjects);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "페이지 매크로 에러", MessageBoxButtons.OK, MessageBoxIcon.Error);

                throw ex;
            }
        }
Пример #35
0
        protected void cmdSubmit_Click(object sender, EventArgs e)
        {
            string ProductName = txtPname.Text;
            int    len         = imgProduct.PostedFile.ContentLength;

            byte[] img = new byte[len];
            imgProduct.PostedFile.InputStream.Read(img, 0, len);
            int res = Insert.ProductAddData(ProductName, img, double.Parse(TxtPrice.Text), int.Parse(TxtQuantity.Text));

            if (res == 0)
            {
                txtMsg.Text = "Product Not Added.";
            }
            else
            {
                txtMsg.Text = "Product Added Successfully.";
            }
        }
Пример #36
0
        public override void Up()
        {
            Alter.Table("Users").AddColumn("IsBetaUser").AsBoolean().Nullable();
            Update.Table("Users").Set(new { IsBetaUser = false }).AllRows();
            Alter.Table("Users").AlterColumn("IsBetaUser").AsBoolean().NotNullable();

            Create.Table("BetaKeys")
            .WithColumn("Id").AsInt32().PrimaryKey().Identity()
            .WithColumn("Code").AsString(255).NotNullable().Unique()
            .WithColumn("IsUsed").AsBoolean().NotNullable();


            for (int i = 0; i < 100; i++)
            {
                string betaKey = System.Guid.NewGuid().ToString();
                Insert.IntoTable("BetaKeys").Row(new { Code = betaKey, IsUsed = false });
            }
        }
Пример #37
0
        public override void Up()
        {
            Create.Table("TollFee")
            .WithColumn("Id").AsInt64().PrimaryKey().Identity()
            .WithColumn("From").AsDateTime().NotNullable()
            .WithColumn("To").AsDateTime().NotNullable()
            .WithColumn("Fee").AsDecimal().NotNullable();

            Insert.IntoTable("TollFee").Row(new { From = DateTime.Parse("1901-01-01 06:00"), To = DateTime.Parse("1901-01-01 06:29"), Fee = 8 });
            Insert.IntoTable("TollFee").Row(new { From = DateTime.Parse("1901-01-01 06:30"), To = DateTime.Parse("1901-01-01 06:29"), Fee = 13 });
            Insert.IntoTable("TollFee").Row(new { From = DateTime.Parse("1901-01-01 07:00"), To = DateTime.Parse("1901-01-01 07:59"), Fee = 18 });
            Insert.IntoTable("TollFee").Row(new { From = DateTime.Parse("1901-01-01 08:00"), To = DateTime.Parse("1901-01-01 08:29"), Fee = 13 });
            Insert.IntoTable("TollFee").Row(new { From = DateTime.Parse("1901-01-01 08:30"), To = DateTime.Parse("1901-01-01 14:59"), Fee = 8 });
            Insert.IntoTable("TollFee").Row(new { From = DateTime.Parse("1901-01-01 15:00"), To = DateTime.Parse("1901-01-01 15:29"), Fee = 13 });
            Insert.IntoTable("TollFee").Row(new { From = DateTime.Parse("1901-01-01 15:30"), To = DateTime.Parse("1901-01-01 16:59"), Fee = 18 });
            Insert.IntoTable("TollFee").Row(new { From = DateTime.Parse("1901-01-01 17:00"), To = DateTime.Parse("1901-01-01 17:59"), Fee = 13 });
            Insert.IntoTable("TollFee").Row(new { From = DateTime.Parse("1901-01-01 18:00"), To = DateTime.Parse("1901-01-01 18:29"), Fee = 8 });
        }
Пример #38
0
        public override void Up()
        {
            Create.Table("Usuario")
            .WithColumn("UsuarioId").AsInt16().PrimaryKey().Identity().NotNullable()
            .WithColumn("Nome").AsString(50);


            Execute.Sql("SET IDENTITY_INSERT Usuario ON");

            Insert.IntoTable("Usuario").Row(new { UsuarioId = 1, Nome = "CARLOS SULZER" });
            Insert.IntoTable("Usuario").Row(new { UsuarioId = 2, Nome = "VALDINEI REIS" });
            Insert.IntoTable("Usuario").Row(new { UsuarioId = 3, Nome = "MARCOS RAMPINELLI" });
            Insert.IntoTable("Usuario").Row(new { UsuarioId = 4, Nome = "TARITON NEVES" });
            Insert.IntoTable("Usuario").Row(new { UsuarioId = 5, Nome = "MAYARA MERLIN" });
            Insert.IntoTable("Usuario").Row(new { UsuarioId = 6, Nome = "MARIANA ROCHA" });

            Execute.Sql("SET IDENTITY_INSERT Usuario OFF");
        }
Пример #39
0
        public override void Up()
        {
            Create.Table("TestResolvers")
            .WithColumn("TestResolverId").AsInt32().PrimaryKey().Identity()
            .WithColumn("ResolverValue").AsString().Nullable();

            Create.Table("test_resolvers")
            .WithColumn("test_resolver_id").AsInt32().PrimaryKey().Identity()
            .WithColumn("resolver_value").AsString().Nullable();

            Insert.IntoTable("TestResolvers")
            .Row(new { ResolverValue = "Default" });
            Insert.IntoTable("test_resolvers")
            .Row(new Dictionary <string, object>()
            {
                { "resolver_value", "Underscore" }
            });
        }
Пример #40
0
 /// <summary>
 /// Ups this instance.
 /// </summary>
 public override void Up()
 {
     // Create custom option for selecting a media folder
     Insert
     .IntoTable("CustomOptions").InSchema(rootModuleSchemaName)
     .Row(new
     {
         Id             = new Guid("FB118858-CD1F-4CC6-8C22-177652EEB2A7"),
         Version        = 1,
         CreatedOn      = DateTime.Now,
         ModifiedOn     = DateTime.Now,
         CreatedByUser  = "******",
         ModifiedByUser = "******",
         IsDeleted      = 0,
         Identifier     = "media-images-folder",
         Title          = "Image Folder"
     });
 }
Пример #41
0
        private void CreateTestOperatorsList()
        {
            for (var i = 8000; i <= 9000; i++)
            {
                var userId = Guid.NewGuid();
                Insert.IntoTable("operator").Row(new
                {
                    id           = userId,
                    extension    = i.ToString(),
                    user_name    = $"Тестовый оператор {i}",
                    case_type_id = AddCaseTableAndCaseTemplateTable.CaseTypeId112,
                    is_test      = true
                });

                Insert.IntoTable("inbox_user")
                .Row(new { inbox_id = AddInbox.InboxId112, user_id = userId });
            }
        }
Пример #42
0
        public void Add(Insert value)
        {
            WithConnection(
                  c =>
                  {
                      Console.WriteLine("before Add");

                      var cmd = value.Command(c);

                      cmd.Parameters.AddWithValue(
                           value
                      );

                      cmd.ExecuteNonQuery();


                      Console.WriteLine("after Add");
                  }
             );
        }
Пример #43
0
		public FormCloneInsert(Insert originalInsert)
		{
			InitializeComponent();
			_originalInsert = originalInsert;
			labelControlFlightDates.Text = _originalInsert.Parent.Parent.FlightDates;
			laOriginalDate.Text = _originalInsert.Date.HasValue ? _originalInsert.Date.Value.ToString(@"ddd, MM/dd/yy") : String.Empty;
			laOriginalRate.Text = _originalInsert.FinalRate.ToString(@"$#,##0.00");
			checkEditHighlightWeekdays.Text = _originalInsert.Date.HasValue ? String.Format(checkEditHighlightWeekdays.Text, _originalInsert.Date.Value.ToString("dddd")) : String.Empty;
			buttonXAddAllWeekdays.Text = _originalInsert.Date.HasValue ? String.Format(buttonXAddAllWeekdays.Text, _originalInsert.Date.Value.ToString("dddd")) : String.Empty;
			checkEditColorRate.Visible = _originalInsert.Parent.ColorOption != ColorOptions.BlackWhite;
			monthCalendarClone.ActiveMonth.Month = _originalInsert.Date.HasValue ? _originalInsert.Date.Value.Month : 1;
			monthCalendarClone.ActiveMonth.Year = _originalInsert.Date.HasValue ? _originalInsert.Date.Value.Year : 1;
			monthCalendarClone.Header.TextColor = Color.Black;

			UpdateTotals();

			if ((base.CreateGraphics()).DpiX > 96)
			{
				laOriginalDate.Font = new Font(laOriginalDate.Font.FontFamily, laOriginalDate.Font.Size - 4, laOriginalDate.Font.Style);
				laOriginalRate.Font = new Font(laOriginalRate.Font.FontFamily, laOriginalRate.Font.Size - 3, laOriginalRate.Font.Style);
				laOptionsTitle.Font = new Font(laOptionsTitle.Font.FontFamily, laOptionsTitle.Font.Size - 2, laOptionsTitle.Font.Style);
				labelControlDayTitle.Font = new Font(labelControlDayTitle.Font.FontFamily, labelControlDayTitle.Font.Size - 2, labelControlDayTitle.Font.Style);
				labelControlFlightDates.Font = new Font(labelControlFlightDates.Font.FontFamily, labelControlFlightDates.Font.Size - 2, labelControlFlightDates.Font.Style);
				labelControlClonedNumber.Font = new Font(labelControlClonedNumber.Font.FontFamily, labelControlClonedNumber.Font.Size - 2, labelControlClonedNumber.Font.Style);
				labelControlClonedRate.Font = new Font(labelControlClonedRate.Font.FontFamily, labelControlClonedRate.Font.Size - 2, labelControlClonedRate.Font.Style);
				checkEditColorRate.Font = new Font(checkEditColorRate.Font.FontFamily, checkEditColorRate.Font.Size - 2, checkEditColorRate.Font.Style);
				checkEditComment.Font = new Font(checkEditComment.Font.FontFamily, checkEditComment.Font.Size - 2, checkEditComment.Font.Style);
				checkEditDeadline.Font = new Font(checkEditDeadline.Font.FontFamily, checkEditDeadline.Font.Size - 2, checkEditDeadline.Font.Style);
				checkEditDiscount.Font = new Font(checkEditDiscount.Font.FontFamily, checkEditDiscount.Font.Size - 2, checkEditDiscount.Font.Style);
				checkEditPCIRate.Font = new Font(checkEditPCIRate.Font.FontFamily, checkEditPCIRate.Font.Size - 2, checkEditPCIRate.Font.Style);
				checkEditSections.Font = new Font(checkEditSections.Font.FontFamily, checkEditSections.Font.Size - 2, checkEditSections.Font.Style);
				checkEditMechanicals.Font = new Font(checkEditMechanicals.Font.FontFamily, checkEditMechanicals.Font.Size - 2, checkEditMechanicals.Font.Style);
				checkEditHighlightWeekdays.Font = new Font(checkEditHighlightWeekdays.Font.FontFamily, checkEditHighlightWeekdays.Font.Size - 2, checkEditHighlightWeekdays.Font.Style);
				buttonXCancel.Font = new Font(buttonXCancel.Font.FontFamily, buttonXCancel.Font.Size - 2, buttonXCancel.Font.Style);
				buttonXAddAllWeekdays.Font = new Font(buttonXAddAllWeekdays.Font.FontFamily, buttonXAddAllWeekdays.Font.Size - 2, buttonXAddAllWeekdays.Font.Style);
				buttonXClearAll.Font = new Font(buttonXClearAll.Font.FontFamily, buttonXClearAll.Font.Size - 2, buttonXClearAll.Font.Style);
				buttonXOK.Font = new Font(buttonXOK.Font.FontFamily, buttonXOK.Font.Size - 2, buttonXOK.Font.Style);
			}
		}
Пример #44
0
        public void Insert(Insert content, Action<string> key)
        {
            Trace.w("Insert... " + new { content.AppSnapshotContent.Length });

            // "C:\util\xampp-win32-1.8.0-VC9\xampp\mysql\bin\my.ini"

            //Caused by: java.lang.RuntimeException: Packet for query is too large (1199750 > 1048576). You can change this value on the server by setting the max_allowed_packet' variable.
            //        at ScriptCoreLibJava.BCLImplementation.System.Data.SQLite.__SQLiteCommand.ExecuteNonQuery(__SQLiteCommand.java:275)
            // Caused by: java.sql.SQLException: Data truncation: Data too long for column 'AppSnapshotContent' at row 1
            // http://stackoverflow.com/questions/8878779/sql-error-1406-data-too-long-for-column

            WithConnection(
                c =>
                {
                    content.ExecuteNonQuery(c);

                    var LastInsertRowId = "" + c.LastInsertRowId;

                    Trace.w("Insert " + new { LastInsertRowId });

                    key(LastInsertRowId);
                }
            );
        }
Пример #45
0
        public void Insert(Insert value, Action<long> yield)
        {
            //enter upload
            //enter upload
            //{ ContentType = image/jpeg, FileName = emspectrum.jpg, ContentLength = 82548, Length = 82548 }
            //{ ContentType = image/jpeg, FileName = emspectrum.jpg, ContentLength = 82548, Length = 82548 }
            //before insert { ManagedThreadId = 34 }
            //before insert { ManagedThreadId = 13 }
            //AsWithConnection... error: { ex = System.Data.SQLite.SQLiteBusyException (0x80004005)
            //   at System.Data.SQLite.SQLiteCommand.ExecuteStatement(Vdbe pStmt, Int32& cols, IntPtr& pazValue, IntPtr& pazColName)
            //   at System.Data.SQLite.SQLiteCommand.ExecuteStatement(Vdbe pStmt)
            //   at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior, Boolean want_results, Int32& rows_affected)
            //   at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
            //   at DropFileIntoSQLite.Schema.Table1Extensions.ExecuteNonQuery(Insert , IDbConnection )

            WithConnection(
             c =>
             {
                 value.ExecuteNonQuery(c);

                 yield(c.LastInsertRowId);
             }
           );
        }
Пример #46
0
 /// <summary>
 /// Sets the insert query.
 /// </summary>
 /// <param name="q">The q.</param>
 public void SetInsertQuery(Insert q)
 {
     insert = q;
 }
Пример #47
0
 public void Add(Report entity)
 {
     Insert<Report> insert = new Insert<Report>("Report", entity);
     dataFactory.Save<Report>(insert);
 }
Пример #48
0
        public string SaveAnotherFormulaYear(string tableName,IList<FormulaYear> childrenValues, TZ tzValue)
        {
            Guid newKeyID = Guid.NewGuid();
            using (TransactionScope scope = new TransactionScope())
            {
                foreach (var item in childrenValues)
                {
                    item.KeyID = newKeyID;
                    Insert<FormulaYear> insert = new Insert<FormulaYear>(tableName, item);
                    insert.AddExcludeField("Id");
                    dataFactory.Save<FormulaYear>(insert);
                }
                tzValue.KeyID = newKeyID;
                Insert<TZ> insertTz = new Insert<TZ>("TZ", tzValue);
                insertTz.AddExcludeField("Id");
                dataFactory.Save<TZ>(insertTz);

                scope.Complete();
            }

            return "1";
        }
Пример #49
0
 public void Acc_Insert_Simple()
 {
     Insert i = new Insert().Into(Category.Schema).Values("Test", "TestDescription", DBNull.Value);
     string sql = i.BuildSqlStatement();
     Assert.AreEqual(sql, "INSERT INTO [Categories](CategoryName,Description,Picture)\r\n VALUES ([PARM__ins_CategoryName],[PARM__ins_Description],[PARM__ins_Picture])\r\n");
 }
Пример #50
0
        ButtonStateVar.DragRezult onStartDragL(Vec posScreen)
        {
            switch (mInsert)
            {
                case Insert.Line:
                    {
                        Vec world = mTimeSpace.getWorldFromScreen(posScreen);
                        Line line = new Line(world, world.plus(new Vec(20, 20)), Color.Black);
                        insert(line);
                        mInsert = Insert.None;

                        return new ButtonStateVar.DragRezult(
                            delegate(Vec posScreenNew)
                            {
                                Vec world2 = mTimeSpace.getWorldFromScreen(posScreenNew);
                                line.mPos1 = world2;
                                Invalidate();
                            },
                            null,
                            null);

                    }
                case Insert.LineLight:
                    {
                        Vec world = mTimeSpace.getWorldFromScreen(posScreen);
                        Line line = new Line(world, world.plus(new Vec(20, 20)), Color.Orange);
                        mTimeSpace.add(line);
                        mInsert = Insert.None;
                        Invalidate();

                        return new ButtonStateVar.DragRezult(
                            delegate(Vec posScreenNew)
                            {
                                Vec delta = posScreenNew.minus(posScreen);
                                delta.lightCorect();
                                Vec world2 = mTimeSpace.getWorldFromScreen(posScreen.plus(delta));
                                line.mPos1 = world2;
                                Invalidate();
                            },
                            null,
                            null);
                    }
                case Insert.Invariant:
                    {
                        mInsert = Insert.None;
                        Invalidate();

                        return new ButtonStateVar.DragRezult(
                            delegate(Vec posScreenNew)
                            {
                                Invalidate();
                            },
                            delegate(Vec posScreenNew)
                            {
                                Invalidate();
                            },
                            delegate(Vec posScreenNew, DrawInfo di)
                            {
                                Pen pen = new Pen(Color.LimeGreen);
                                pen.Width = 1;
                                di.drawLine(pen, posScreen, posScreenNew);

                                Vec world = mTimeSpace.getWorldFromScreen(posScreen);
                                Vec worldNew = mTimeSpace.getWorldFromScreen(posScreenNew);
                                double invariant = mTimeSpace.getInvariant(world, worldNew) / (GRID*GRID);
                                di.drawText(invariant.ToString(), posScreenNew.plus(new Vec(10, -10)));
                            });
                    }
                default:
                    return new ButtonStateVar.DragRezult(true);
            }
        }
Пример #51
0
 public void Add(ProductLine entity)
 {
     Insert<ProductLine> insert = new Insert<ProductLine>("ProductLine", entity);
     dataFactory.Save<ProductLine>(insert);
 }
        public void VerifyInsertDelegateAfterItemInLinkList()
        {
            var simpleLinkList = new SimpleLinkList<int> {2, 3, 4};
            var del = new Insert<int>(simpleLinkList.InsertItem);
            del(2, 5, false);

            CollectionAssert.AreEqual(new[] {4, 3, 2, 5}, simpleLinkList);
        }
Пример #53
0
      /// <summary>
      /// Generates a project with the given GenerateablePageMacros
      /// </summary>
      /// <param name="projectLinkFilePath">EPLAN project file (*.elk)</param>
      /// <param name="projectTemplateFilePath">EPLAN template project (*.zw9)</param>
      /// <param name="generatablePageMacros">List of GeneratablePageMaros</param>
      public static void Generate(string projectLinkFilePath, string projectTemplateFilePath,
         List<GeneratablePageMacro> generatablePageMacros)
      {
         var project = Create(projectLinkFilePath, projectTemplateFilePath, false);
         project.RemoveAllPages();

         Insert insert = new Insert();
         var pageCount = project.Pages.Length; // needed cause of overwrite
         foreach (var generatablePageMacro in generatablePageMacros)
         {
            // Load pages from macro
            PageMacro pageMacro = new PageMacro();
            pageMacro.Open(generatablePageMacro.Filename, project);
            foreach (var page in pageMacro.Pages)
            {
               // Rename
               pageCount++;

               PagePropertyList pagePropertyList = page.NameParts;
               if (generatablePageMacro.LocationIdentifierIdentifier != null)
               {
                  pagePropertyList[Properties.Page.DESIGNATION_FUNCTIONALASSIGNMENT] =
                     generatablePageMacro.LocationIdentifierIdentifier.FunctionAssignment;
                  pagePropertyList[Properties.Page.DESIGNATION_PLANT] =
                     generatablePageMacro.LocationIdentifierIdentifier.Plant;
                  pagePropertyList[Properties.Page.DESIGNATION_PLACEOFINSTALLATION] =
                     generatablePageMacro.LocationIdentifierIdentifier.PlaceOfInstallation;
                  pagePropertyList[Properties.Page.DESIGNATION_LOCATION] =
                     generatablePageMacro.LocationIdentifierIdentifier.Location;
                  pagePropertyList[Properties.Page.DESIGNATION_USERDEFINED] =
                     generatablePageMacro.LocationIdentifierIdentifier.UserDefinied;
               }

               pagePropertyList[Properties.Page.PAGE_COUNTER] = pageCount;
               page.NameParts = pagePropertyList;

               new NameService(page).EvaluateAndSetAllNames();
            }

            // Insert pagemacro
            insert.PageMacro(pageMacro, project, null, PageMacro.Enums.NumerationMode.Number);
         }
      }
Пример #54
0
        //指定制御点の前後どちらかに制御点を挿入
        private ControlPoint InsertControlPoint(ControlPoint point, Insert position)
        {
            Debug.Assert(point != null);

            //挿入位置の制御点は配列の何番目か検索
            int index = controlPointList.IndexOf(point);
            Debug.Assert(index != -1);

            ControlPoint newControlPoint = null;

            //リストに制御点を挿入(前or後)
            switch (position)
            {
            case Insert.Before:
                //制御点を追加する座標を算出して作成(挿入元から30mm左上の位置にハードコード)
                newControlPoint = new ControlPoint(point.NativeX - 30, point.NativeY + 30, this);
                controlPointList.Insert(index, newControlPoint);
                break;

            case Insert.After:
                //制御点を追加する座標を算出して作成(挿入元から30mm右下の位置にハードコード)
                newControlPoint = new ControlPoint(point.NativeX + 30, point.NativeY - 30, this);
                controlPointList.Insert(index + 1, newControlPoint);
                break;

            default:
                Debug.Assert(false);
                break;
            }

            //コンテキストメニューを設定
            newControlPoint.ContextMenuStrip = controlPointMenu;

            //制御点を画面に反映
            this.containerPanel.Controls.Add(newControlPoint);
            newControlPoint.BringToFront();

            return newControlPoint;
        }
Пример #55
0
        public void Insert(Insert value, Action<long> yield)
        {
            //{ Message = "Attempt to write a read-only database\r\nattempt to write a readonly database", StackTrace = "   at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)\r\n   at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt)\r\n   at System.Data.SQLite.SQLiteDataReader.NextResult()\r\n   at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)\r\n   at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)\r\n   at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()\r\n   at SQLiteWithDataGridView.Schema.TheGridTableExtensions.ExecuteNonQuery(Insert , SQLiteConnection )\r\n   at SQLiteWithDataGridView.Schema.TheGridTable.<>c__DisplayClass13.<Insert>b__12(SQLiteConnection c) in x:\\jsc.svn\\examples\\javascript\\forms\\SQLiteWithDataGridView\\SQLiteWithDataGridView\\Schema\\TheGridTable.cs:line 95\r\n   at SQLiteWithDataGridView.Schema.XX.<>c__DisplayClass1.<AsWithConnection>b__0(Action`1 y) in x:\\jsc.svn\\examples\\javascript\\forms\\SQLiteWithDataGridView\\SQLiteWithDataGridView\\Schema\\TheGridTable.cs:line 161" }


            //WithConnection(
            WithWriteConnection(
                c =>
                {
                    value.ExecuteNonQuery(c);

                    yield(c.LastInsertRowId);
                }
             );
        }
Пример #56
0
        /// <summary>
        /// Builds the insert SQL.
        /// </summary>
        /// <returns></returns>
        protected void InsertRecord()
        {
            Insert qryInsert = new Insert(TableSchema, false);
            foreach(TableSchema.TableColumn col in TableSchema.Columns)
            {
                if(!col.AutoIncrement && !col.IsReadOnly)
                {
                    Control ctrl = FindControl(col.IsPrimaryKey ? PK_ID + col.ColumnName : col.ColumnName);
                    if(ctrl == null && col.IsPrimaryKey)
                        ctrl = FindControl(PK_ID);

                    if(ctrl != null)
                    {
                        object oVal = Utility.GetDefaultControlValue(col, ctrl, true, true);
                        bool insertValue = true;
                        if(col.DataType == DbType.Guid)
                        {
                            if(!Utility.IsMatch(col.DefaultSetting, SqlSchemaVariable.DEFAULT))
                            {
                                bool isEmptyGuid = Utility.IsMatch(oVal.ToString(), Guid.Empty.ToString());

                                if(col.IsNullable && isEmptyGuid)
                                    oVal = null;
                                else if(col.IsPrimaryKey && isEmptyGuid)
                                    oVal = Guid.NewGuid();
                            }
                            else
                            {
                                oVal = null;
                                insertValue = false;
                            }
                        }
                        else
                            oVal = TransformBooleanAndDateValues(oVal, col.DataType);

                        if(oVal == null)
                            oVal = DBNull.Value;

                        if(insertValue)
                            qryInsert.Value(col, oVal);
                    }
                }

                //if (col.DataType != DbType.Binary && col.DataType != DbType.Byte && Utility.IsWritableColumn(col))
                //{
                //    if (!col.AutoIncrement && !(col.IsPrimaryKey && col.DataType == DbType.Guid))
                //    {
                //        Control ctrl = FindControl(col.ColumnName);
                //        if (ctrl != null)
                //        {
                //            object oVal = Utility.GetDefaultControlValue(col, ctrl, true, true);
                //            qryInsert.Value(col, oVal);
                //        }
                //    }
                //}
            }
            qryInsert.Execute();
        }
Пример #57
0
        /// <summary>
        /// Saves the many to many.
        /// </summary>
        private void SaveManyToMany()
        {
            foreach(TableSchema.ManyToManyRelationship m2m in ManyToManyCollection)
            {
                TableSchema.Table mapTable = DataService.GetSchema(m2m.MapTableName, ProviderName);

                CheckBoxList chk = (CheckBoxList)FindControl(mapTable.ClassName);
                if(chk != null)
                {
                    ListItemCollection listItems = new ListItemCollection();
                    foreach(ListItem item in chk.Items)
                    {
                        if(item.Selected)
                            listItems.Add(item);
                    }
                    //using(TransactionScope ts = new TransactionScope())
                    //{
                    //    using(SharedDbConnectionScope connScope = new SharedDbConnectionScope())
                    //    {
                    SqlQuery qryDelete = new Delete().From(mapTable).Where(m2m.MapTableLocalTableKeyColumn).IsEqualTo(PrimaryKeyControlValue);
                    qryDelete.Execute();

                    foreach(ListItem selectedItem in listItems)
                    {
                        Insert qryInsert = new Insert(mapTable, false);
                        qryInsert.Value(mapTable.GetColumn(m2m.MapTableLocalTableKeyColumn), PrimaryKeyControlValue);
                        qryInsert.Value(mapTable.GetColumn(m2m.MapTableForeignTableKeyColumn), selectedItem.Value);
                        qryInsert.Execute();
                    }
                    //    }
                    //    ts.Complete();
                    //}
                }
            }
        }
Пример #58
0
 public void Insert_Simple()
 {
     Insert i = new Insert().Into(Category.Schema).Values("Test", "TestDescription", DBNull.Value);
     string sql = i.BuildSqlStatement();
     Assert.IsTrue(sql == "INSERT INTO [dbo].[Categories](CategoryName,Description,Picture)\r\n VALUES (@ins_CategoryName,@ins_Description,@ins_Picture)\r\n");
 }
Пример #59
0
        /// <summary>
        /// Generates the SQL statements that inserts the row described by
        /// the specified <paramref name="insert"/> object into the database.
        /// </summary>
        /// <param name="insert">The insert containing the row to insert.</param>
        /// <returns>The SQL statements.</returns>
        protected virtual IEnumerable<string> Insert(Insert insert)
        {
            //
            // Stringify column names and values
            //
            string[] columnNames = new string[insert.Row.Count];
            string[] columnValues = new string[insert.Row.Count];

            int i = 0;
            foreach (var key in insert.Row.Keys)
            {
                columnNames[i] = EscapeColumnName(key);
                columnValues[i++] = FormatValue(insert.Row[key]);
            }

            //
            // Build up command
            //
            yield return string.Format("INSERT INTO {0} ({1}) VALUES({2});",
                EscapeTableName(insert.Table.Name),
                string.Join(", ", columnNames), string.Join(", ", columnValues)
            );
        }
        public void VerifyInsertDelegateBeforeItemInLinkList()
        {
            var simpleLinkList = new SimpleLinkList<int>();
            simpleLinkList.Add(2);
            simpleLinkList.Add(3);
            simpleLinkList.Add(4);
            Insert<int> del = new Insert<int>(simpleLinkList.InsertItem);
            del(2, 5, true);

            CollectionAssert.AreEqual(new[] { 4, 3, 5, 2 }, simpleLinkList);
        }