SQLite: sql script demo
如果有成熟的架构,如何根据数据库关系的表、视图等,进行代码生成架构?减少写代码的时间?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | -- 考虑主键外键 -- create database geovindu; use geovindu; --2 create table EnterpriseType ( EnterpriseTypeID INTEGER PRIMARY KEY AUTOINCREMENT, EnterpriseTypeName nvarchar(100) not null --企业类型名称 ); insert into EnterpriseType (EnterpriseTypeName) values (N '分公司' ); insert into EnterpriseType (EnterpriseTypeName) values (N '店铺' ); select * from OperatingUser; -- 3 drop table CompanyBranch; create table CompanyBranch ( CompanyID INTEGER PRIMARY KEY AUTOINCREMENT, CompanyName nvarchar(100) not null , CompanyTypeID int not null , CompanyDate datetime DEFAULT (datetime( 'now' , 'localtime' )), CompanyDesc NVARCHAR(500) null , CompanyTel varchar (100) null , CompanyFax VARCHAR (100) NULL , CompanyAddress NVARCHAR(500) NULL , FOREIGN KEY (CompanyTypeID) REFERENCES EnterpriseType(EnterpriseTypeID) ); insert into CompanyBranch(CompanyName,CompanyTypeID,CompanyTel,CompanyFax,CompanyAddress,CompanyDesc) values ( '六福珠宝营销策划(深圳)有限公司' ,1, '' , '' , '' , '' ); select * from CompanyBranch select * from EnterpriseType drop table OperatingUser; -- 1 create table OperatingUser ( UserID INTEGER PRIMARY KEY AUTOINCREMENT, UserName nvarchar(200) not null , --用户名 RealName NVARCHAR(50) NOT NULL , --真姓名 UserPassword varchar (100) not null , --密码 UserCompanyId int not null , --公司ID UserPasswordProblems nvarchar(100), --找回密码问题 UserMail varchar (100) null , --密码 UserDate datetime DEFAULT (datetime( 'now' , 'localtime' )), --默认日期 FOREIGN KEY (UserCompanyId) REFERENCES CompanyBranch(CompanyID) ); select * from OperatingUser; --4 drop table LoginDiaryList; CREATE TABLE LoginDiaryList ( LoginDiaryID INTEGER PRIMARY KEY AUTOINCREMENT, LoginDiaryUserName nvarchar(50) null , --登錄用戶名 LoginDiaryUserId int not null , --員工ID LoginDiaryBrowser varchar (50) null , --客戶端瀏覽 LoginDiaryScreen varchar (50) null , --显示器大小 LoginDiaryOpertor varchar (50) null , --操作系統 LoginDiaryInput nvarchar(150) null , --輸入法 LoginDiaryDate datetime DEFAULT (datetime( 'now' , 'localtime' )), --日期 FOREIGN KEY (LoginDiaryUserId) REFERENCES OperatingUser(UserID) ); select * from LoginDiaryList; select * from PrintWordDocumentTemplateList; -- 5 create table PrintWordDocumentTemplateList ( PrintWordDocumentId INTEGER PRIMARY KEY AUTOINCREMENT, --PrintWordDocumentUid Uniqueidentifier DEFAULT(NEWID()) PRIMARY KEY, --PrintWordPayTypeUidKey Uniqueidentifier, ---考核類型(試用期,年終,特別) --PrintWordJobTypeUidKey Uniqueidentifier, ---職位類型(文職類,員工類,管理級別類等) PrintWordOnlyPassIs bit default (0), ---通過試用期並成為正式員工 PrintWordPlusSalaryIs bit default (0), ---通過並加薪 PrintWordPromotionIs bit default (0), ---通過晉升 PrintWordExtensionIs bit default (0), --延長試用期 PrintWordDismissIs bit default (0), --解僱 PrintWordDepartmentIs bit default (0), --新部門 PrintWordDocumentName Nvarchar(100) not null , --文檔標題 PrintWordDocumentUrl nvarchar(200) null , --文檔鏈接 PrintWordDocumentContent nvarchar(300) null , --文檔簡要描述 PrintWordDocumentAddDate datetime DEFAULT (datetime( 'now' , 'localtime' )) , PrintWordDocumentByte BLOB null , PrintWordType int default (1) --文檔類型 1.分公司,2.分店 --PrintWordLetterSignature nvarchar(100) null --信函簽名 ); -- 6 -- 客戶表Customer(需方) 名稱,工地名稱 drop table CustomerList; CREATE TABLE CustomerList ( CustomerID INTEGER PRIMARY KEY AUTOINCREMENT, CustomerName NVARCHAR(200) NOT NULL , CustomerNamePin VARCHAR (500) NULL , CustomerContact NVARCHAR(50) NULL , --聯系人 CustomerTel VARCHAR (100) NULL , -- 聯系人電話 CustomerDate datetime DEFAULT (datetime( 'now' , 'localtime' )) ); -- 7表單關聯人類型RelationshipsType: 指定收貨人 跟單業務員 工地驗收人 運輸人 drop table RelationshipsType; CREATE TABLE RelationshipsType ( RelationshipsTypeID INTEGER PRIMARY KEY AUTOINCREMENT, RelationshipsTypeName NVARCHAR(100) NOT NULL , RelationshipsTypePin VARCHAR (500) NULL ); insert into RelationshipsType(RelationshipsTypeName) values ( '指定收货人' ); insert into RelationshipsType(RelationshipsTypeName) values ( '跟单业务员' ); insert into RelationshipsType(RelationshipsTypeName) values ( '工地验收人' ); insert into RelationshipsType(RelationshipsTypeName) values ( '运输人' ); -- 8表單關係人錶RelationshipsPerson drop table RelationshipsPerson; CREATE TABLE RelationshipsPerson ( PersonID INTEGER PRIMARY KEY AUTOINCREMENT, PersonName NVARCHAR(100) NOT NULL , PersonNamePin VARCHAR (500) NULL , PersonTel VARCHAR (100), PersonType int NOT NULL , PersonDate datetime DEFAULT (datetime( 'now' , 'localtime' )), FOREIGN KEY (PersonType) REFERENCES RelationshipsType(RelationshipsTypeID) ); select * from RelationshipsPerson; -- 9產品名稱表 ProductTypeList drop table ProductTypeList; CREATE TABLE ProductTypeList ( ProductTypeID INTEGER PRIMARY KEY AUTOINCREMENT, ProductTypeName NVARCHAR(800) NOT NULL , ProductTypePin VARCHAR (500) NULL --字首字母 ); -- 10單位表 UnitList drop table UnitList; CREATE TABLE UnitList ( UnitID INTEGER PRIMARY KEY AUTOINCREMENT, UnitName NVARCHAR(100) NOT NULL , UnitPin VARCHAR (500) NULL ); select * from UnitList; delete from UnitList where UnitName= '' ; drop table ProductModel; -- 产品规格 CREATE TABLE ProductModel ( ModelID INTEGER PRIMARY KEY AUTOINCREMENT, ModelProductTypeID INT NOT NULL , -- 产品名称ID 外键 ProductTypeList ModelName NVARCHAR(800) NOT NULL , ModelPin VARCHAR (500) NULL , FOREIGN KEY (ModelProductTypeID) REFERENCES ProductTypeList(ProductTypeID) ); drop table UnitPrice; -- 单价表 CREATE TABLE UnitPrice ( UnitPriceID INTEGER PRIMARY KEY AUTOINCREMENT, UnitProductTypeID INT NOT NULL , -- 产品名称ID 外键 ProductTypeList UnitPriceNuber DECIMAL (20,2) NOT NULL , UnitPricePin VARCHAR (500) NULL , FOREIGN KEY (UnitProductTypeID) REFERENCES ProductTypeList(ProductTypeID) ); select * from UnitPrice; drop table CustomerAddress; -- 客户地址表 CREATE TABLE CustomerAddress ( AddressID INTEGER PRIMARY KEY AUTOINCREMENT, AddressName NVARCHAR(100) NOT NULL , AddressPin VARCHAR (500) NULL ); -- 11級別表 LevelList drop table LevelList; CREATE TABLE LevelList ( LevelID INTEGER PRIMARY KEY AUTOINCREMENT, LevelName NVARCHAR(100) NOT NULL , LevelPin VARCHAR (500) NULL ); select * from LevelList; delete from LevelList where LevelName= '' ; -- 12工地名名稱表 建筑工地名Construction site name drop table ConstructionNameList; CREATE TABLE ConstructionNameList ( ConstructionID INTEGER PRIMARY KEY AUTOINCREMENT, ConstructionName VARCHAR (100) NOT NULL , ConstructionPin VARCHAR (500) NULL ); select * from ConstructionNameList; delete from ConstructionNameList where ConstructionName= '' ; -- 訂單產品詳情表 drop table OrderItDetails; CREATE TABLE OrderItDetails ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, OrderDate datetime DEFAULT (datetime( 'now' , 'localtime' )), -- 送货日期 OrderWord VARCHAR (50) NULL , -- 字 OrderNo VARCHAR (100) NULL , -- 号 OrderCustomerId INT NOT NULL , -- 客户名稱 OrderAddressID INT NOT NULL , -- 客户地址名稱 OrderPrepared INT NULL , -- 製單人 OrderBusiness INT NULL , -- 指定收货人 OrderPrintDate datetime DEFAULT (datetime( 'now' , 'localtime' )), --打單時間 FOREIGN KEY (OrderCustomerId) REFERENCES CustomerList(CustomerID), FOREIGN KEY (OrderAddressID) REFERENCES CustomerAddress(AddressID), FOREIGN KEY (OrderPrepared) REFERENCES RelationshipsPerson(PersonID), FOREIGN KEY (OrderBusiness) REFERENCES RelationshipsPerson(PersonID) ); -- 訂單產品詳情 drop table ProductItOrderDetails; CREATE TABLE ProductItOrderDetails ( ProductDetailsId INTEGER PRIMARY KEY AUTOINCREMENT, ProductOrderId INT NOT NULL , -- 產品訂單ID 外錶OrderDetails ProductOrderTypeId INT NOT NULL , --產品名稱 ProductModleId INT , --規格 ProductUnitID INT , -- 單位 ProductQty DECIMAL (18,2) DEFAULT (0), --數量 ProductPriceID INT NOT NULL , --单价 ProductMeters DECIMAL (25,2) DEFAULT (0), --金额 ProductDescription VARCHAR (1000) NULL , --說明 FOREIGN KEY (ProductOrderId) REFERENCES OrderItDetails(OrderID), FOREIGN KEY (ProductOrderTypeId) REFERENCES ProductTypeList(ProductTypeID), FOREIGN KEY (ProductModleId) REFERENCES ProductModel(ModelID), FOREIGN KEY (ProductUnitID) REFERENCES UnitList(UnitID), FOREIGN KEY (ProductPriceID) REFERENCES UnitPrice(UnitPriceID) ); -- 13打單表內容 ProductDetails -- https://www.sqlite.org/datatype3.html drop table OrderDetails; CREATE TABLE OrderDetails ( OrderID INTEGER PRIMARY KEY AUTOINCREMENT, OrderDate datetime DEFAULT (datetime( 'now' , 'localtime' )), --日期 OrderWord NVARCHAR(50) NULL , -- 字 OrderNo NVARCHAR(100) NULL , --号 OrderCustomerId int NOT NULL , --需求方 OrderConstructionId int NOT NULL , --工地名稱 --OrderProductId int NOT NULL, -- 產品訂單詳情ID 外錶ProductOrderDetails OrderAcceptor int NULL , -- 工地驗收人 OrderTransportation INTEGER NULL , -- 運輸人 OrderPrepared int NULL , --製單人 OrderBusiness int NULL , -- 指定業務人 OrderMerchandiser int NULL , --跟單業務員 OrderPrintDate datetime DEFAULT (datetime( 'now' , 'localtime' )), --打單時間 FOREIGN KEY (OrderCustomerId) REFERENCES CustomerList(CustomerID), FOREIGN KEY (OrderConstructionId) REFERENCES ConstructionNameList(ConstructionID), FOREIGN KEY (OrderAcceptor) REFERENCES RelationshipsPerson(PersonID), FOREIGN KEY (OrderTransportation) REFERENCES RelationshipsPerson(PersonID), FOREIGN KEY (OrderPrepared) REFERENCES RelationshipsPerson(PersonID), FOREIGN KEY (OrderBusiness) REFERENCES RelationshipsPerson(PersonID), FOREIGN KEY (OrderMerchandiser) REFERENCES RelationshipsPerson(PersonID) ); -- 14訂單產品詳情表 NUMERIC drop table ProductOrderDetails; CREATE TABLE ProductOrderDetails ( ProductDetailsId INTEGER PRIMARY KEY AUTOINCREMENT, ProductOrderId INT NOT NULL , -- 產品訂單ID 外錶OrderDetails ProductTypeId int NOT NULL , --產品名稱規格 ProductUnitID int NOT NULL , -- 單位 ProductQty DECIMAL (18,2) DEFAULT (0), --數量 ProductLevelID int NOT NULL , --級別 ProductMeters DECIMAL (25,2) DEFAULT (0), --米數 ProductDescription NVARCHAR(1000) NULL , --說明 FOREIGN KEY (ProductOrderId) REFERENCES OrderDetails(OrderID), FOREIGN KEY (ProductTypeId) REFERENCES ProductTypeList(ProductTypeID), FOREIGN KEY (ProductUnitID) REFERENCES UnitList(UnitID), FOREIGN KEY (ProductLevelID) REFERENCES LevelList(LevelID) ); -- 設置移動打印X,Y坐標糾正值 drop table PrintSetNumber; CREATE TABLE PrintSetNumber ( PrintSetId INTEGER PRIMARY KEY AUTOINCREMENT, PrintSetX int DEFAULT (0), --com 列坐标 PrintSetY int DEFAULT (0) , -- row 行坐标 PrintPrinter VARCHAR (200) NULL , --默认打印机名 PrintFont VARCHAR (200) NULL default '宋体' , ---默认字体名 PrintBottom boolean default (0), --底部文字是否双排 TitleFontSize int default (8), -- 标题字体大小 ConFontSize int default (8), -- 内容字体大小 HeadFontSize int default (8), --表头字体大小 BoomFontSize int default (8) -- 表底字体大小 ); --表的描述 drop table DataTableDesc; CREATE TABLE DataTableDesc ( TableId INTEGER PRIMARY KEY AUTOINCREMENT, TableName nvahrcar(100) not null , TableDesc nvarchar(100) null ); --列的列描述 columnName drop table DataColumnDesc; CREATE TABLE DataColumnDesc ( ColumnId INTEGER PRIMARY KEY AUTOINCREMENT, ColumnTableId int not null , ColumnName nvahrcar(100) not null , ColumnDesc nvarchar(100) null , FOREIGN KEY (ColumnTableId) REFERENCES DataTableDesc(TableId) ); select * from DataTableDesc; select * from DataColumnDesc; select * from PrintSetNumber; --视图 CREATE VIEW v_DataTableColumn as select DataColumnDesc.*,DataTableDesc.TableName,DataTableDesc.TableDesc from DataColumnDesc,DataTableDesc where DataTableDesc.TableId=DataColumnDesc.ColumnTableId; CREATE VIEW v_OperatingUser as select OperatingUser.*,CompanyBranch.CompanyName,CompanyBranch.companyTel,CompanyBranch.CompanyFax,CompanyBranch.CompanyAddress from OperatingUser,CompanyBranch where OperatingUser.UserCompanyId=CompanyBranch.CompanyID drop view v_CompanyBranch; --公司 create view v_CompanyBranch as select CompanyBranch.*,EnterpriseType.EnterpriseTypeName from CompanyBranch, EnterpriseType where CompanyBranch.CompanyTypeID=EnterpriseType.EnterpriseTypeID; select CompanyBranch.*,EnterpriseType.EnterpriseTypeName from CompanyBranch, EnterpriseType where CompanyBranch.CompanyTypeID=EnterpriseType.EnterpriseTypeID; select * from v_CompanyBranch; drop view v_OperatingUser; --用户 create view v_OperatingUser as select OperatingUser.*,CompanyBranch.CompanyName,CompanyBranch.companyTel,CompanyBranch.CompanyFax,CompanyBranch.CompanyAddress from OperatingUser,CompanyBranch where OperatingUser.UserCompanyId=CompanyBranch.CompanyID; select * from v_OperatingUser; --錶單用戶視圖 CREATE VIEW view_relationshipsPerson AS select RelationshipsPerson.*,RelationshipsType.RelationshipsTypeName FROM RelationshipsPerson,RelationshipsType WHERE RelationshipsPerson.PersonType=RelationshipsType.RelationshipsTypeID; |
主、外键关联要考虑
实体类层:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | using System; using System.Collections.Generic; using System.Text; using System.Drawing; namespace Geovin.Du.Model { /// <summary> /// ProductTypeList的实体类產品名稱表 ///生成時間2018/9/14 15:11:05 ///塗聚文(Geovin Du) ///</summary> public class ProductTypeListInfo { private int _ProductTypeID; /// <summary> /// ID,主键 /// </summary> public int ProductTypeID { get { return _ProductTypeID; } set {_ProductTypeID = value; } } private string _ProductTypeName; /// <summary> /// 产品名称 /// </summary> public string ProductTypeName { get { return _ProductTypeName; } set {_ProductTypeName = value; } } private string _ProductTypePin; /// <summary> /// 字首字母 /// </summary> public string ProductTypePin { get { return _ProductTypePin; } set {_ProductTypePin = value; } } private List<ProductModelInfo> _ProductModel; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:ProductModel产品规格,外键字段:ModelProductTypeID; ///</summary> public List<ProductModelInfo> ProductModelList { get { return _ProductModel; } set {_ProductModel = value; } } private DataTable _ProductModelData; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:ProductModel产品规格,外键字段:ModelProductTypeID; ///</summary> public DataTable ProductModelData { get { return _ProductModelData; } set {_ProductModelData = value; } } private DataSet _ProductModelDaset; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:ProductModel产品规格,外键字段:ModelProductTypeID; ///</summary> public DataSet ProductModelDaset { get { return _ProductModelDaset; } set {_ProductModelDaset = value; } } private List<UnitPriceInfo> _UnitPrice; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:UnitPrice单价表,外键字段:UnitProductTypeID; ///</summary> public List<UnitPriceInfo> UnitPriceList { get { return _UnitPrice; } set {_UnitPrice = value; } } private DataTable _UnitPriceData; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:UnitPrice单价表,外键字段:UnitProductTypeID; ///</summary> public DataTable UnitPriceData { get { return _UnitPriceData; } set {_UnitPriceData = value; } } private DataSet _UnitPriceDaset; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:UnitPrice单价表,外键字段:UnitProductTypeID; ///</summary> public DataSet UnitPriceDaset { get { return _UnitPriceDaset; } set {_UnitPriceDaset = value; } } private List<ProductItOrderDetailsInfo> _ProductItOrderDetails; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:ProductItOrderDetails,外键字段:ProductTypeId; ///</summary> public List<ProductItOrderDetailsInfo> ProductItOrderDetailsList { get { return _ProductItOrderDetails; } set {_ProductItOrderDetails = value; } } private DataTable _ProductItOrderDetailsData; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:ProductItOrderDetails,外键字段:ProductTypeId; ///</summary> public DataTable ProductItOrderDetailsData { get { return _ProductItOrderDetailsData; } set {_ProductItOrderDetailsData = value; } } private DataSet _ProductItOrderDetailsDaset; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:ProductItOrderDetails,外键字段:ProductTypeId; ///</summary> public DataSet ProductItOrderDetailsDaset { get { return _ProductItOrderDetailsDaset; } set {_ProductItOrderDetailsDaset = value; } } private List<ProductOrderDetailsInfo> _ProductOrderDetails; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:ProductOrderDetails,外键字段:ProductTypeId; ///</summary> public List<ProductOrderDetailsInfo> ProductOrderDetailsList { get { return _ProductOrderDetails; } set {_ProductOrderDetails = value; } } private DataTable _ProductOrderDetailsData; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:ProductOrderDetails,外键字段:ProductTypeId; ///</summary> public DataTable ProductOrderDetailsData { get { return _ProductOrderDetailsData; } set {_ProductOrderDetailsData = value; } } private DataSet _ProductOrderDetailsDaset; /// <summary> /// 主表:ProductTypeList產品名稱表,外键表:ProductOrderDetails,外键字段:ProductTypeId; ///</summary> public DataSet ProductOrderDetailsDaset { get { return _ProductOrderDetailsDaset; } set {_ProductOrderDetailsDaset = value; } } } } |
数据处理层:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 | using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Data.SqlClient; using System.Data.SQLite; using System.Drawing; using Geovin.Du.Commn; using Geovin.Du.Model; using Geovin.Du.Interface; namespace Geovin.Du.SQLiteDAL { /// <summary> /// ProductItOrderDetails数据访问层 ///生成時間2018/9/14 14:36:05 ///塗聚文(Geovin Du) ///</summary> public class ProductItOrderDetailsDAL : IProductItOrderDetails { ///<summary> /// 追加记录 ///</summary> ///<param name="ProductItOrderDetailsInfo"></param> ///<returns></returns> public int InsertProductItOrderDetails(ProductItOrderDetailsInfo productItOrderDetails) { int ret = 0; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "INSERT INTO ProductItOrderDetails([ProductOrderId] ,[ProductTypeId] ,[ProductModleId] ,[ProductUnitID] ,[ProductQty] ,[ProductPriceID] ,[ProductMeters] ,[ProductDescription]" ); strSql.Append( ") VALUES (" ); strSql.Append( "@ProductOrderId ,@ProductTypeId ,@ProductModleId ,@ProductUnitID ,@ProductQty ,@ProductPriceID ,@ProductMeters ,@ProductDescription)" ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductOrderId" ,DbType.Int32,4), new SQLiteParameter( "@ProductTypeId" ,DbType.Int32,4), new SQLiteParameter( "@ProductModleId" ,DbType.Int32,4), new SQLiteParameter( "@ProductUnitID" ,DbType.Int32,4), new SQLiteParameter( "@ProductQty" ,DbType.Decimal,8), new SQLiteParameter( "@ProductPriceID" ,DbType.Int32,4), new SQLiteParameter( "@ProductMeters" ,DbType.Decimal,8), new SQLiteParameter( "@ProductDescription" ,DbType.String,1000), }; par[0].Value = productItOrderDetails.ProductOrderId; par[1].Value = productItOrderDetails.ProductTypeId; par[2].Value = productItOrderDetails.ProductModleId; par[3].Value = productItOrderDetails.ProductUnitID; par[4].Value = productItOrderDetails.ProductQty; par[5].Value = productItOrderDetails.ProductPriceID; par[6].Value = productItOrderDetails.ProductMeters; par[7].Value = productItOrderDetails.ProductDescription; ret = SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text, par); } catch (SQLiteException ex) { throw ex; } return ret; } ///<summary> /// 追加记录返回值 ///</summary> ///<param name="ProductItOrderDetailsInfo"></param> ///<returns></returns> public int InsertProductItOrderDetailsOutput (ProductItOrderDetailsInfo productItOrderDetails, out int productDetailsId) { int ret = 0; productDetailsId= 0; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "INSERT INTO ProductItOrderDetails([ProductOrderId] ,[ProductTypeId] ,[ProductModleId] ,[ProductUnitID] ,[ProductQty] ,[ProductPriceID] ,[ProductMeters] ,[ProductDescription]" ); strSql.Append( ") VALUES (" ); strSql.Append( "@ProductOrderId ,@ProductTypeId ,@ProductModleId ,@ProductUnitID ,@ProductQty ,@ProductPriceID ,@ProductMeters ,@ProductDescription)" ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductOrderId" ,DbType.Int32,4), new SQLiteParameter( "@ProductTypeId" ,DbType.Int32,4), new SQLiteParameter( "@ProductModleId" ,DbType.Int32,4), new SQLiteParameter( "@ProductUnitID" ,DbType.Int32,4), new SQLiteParameter( "@ProductQty" ,DbType.Decimal,8), new SQLiteParameter( "@ProductPriceID" ,DbType.Int32,4), new SQLiteParameter( "@ProductMeters" ,DbType.Decimal,8), new SQLiteParameter( "@ProductDescription" ,DbType.String,1000), new SQLiteParameter( "@ProductDetailsId" ,DbType.Int32,8), }; par[0].Value = productItOrderDetails.ProductOrderId; par[1].Value = productItOrderDetails.ProductTypeId; par[2].Value = productItOrderDetails.ProductModleId; par[3].Value = productItOrderDetails.ProductUnitID; par[4].Value = productItOrderDetails.ProductQty; par[5].Value = productItOrderDetails.ProductPriceID; par[6].Value = productItOrderDetails.ProductMeters; par[7].Value = productItOrderDetails.ProductDescription; //par[8].Direction = ParameterDirection.Output; ret = SQLiteHelper.ExecuteSql(strSql.ToString(), out productDetailsId, par); if (ret>0) { //productDetailsId=(int)par[8].Value; } } catch (SQLiteException ex) { throw ex; } return ret; } ///<summary> ///修改记录 ///</summary> ///<param name="ProductItOrderDetailsInfo"></param> ///<returns></returns> public int UpdateProductItOrderDetails(ProductItOrderDetailsInfo productItOrderDetails) { int ret = 0; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "UPDATE ProductItOrderDetails SET " ); strSql.Append( "[ProductOrderId]=@ProductOrderId ," ); strSql.Append( "[ProductTypeId]=@ProductTypeId ," ); strSql.Append( "[ProductModleId]=@ProductModleId ," ); strSql.Append( "[ProductUnitID]=@ProductUnitID ," ); strSql.Append( "[ProductQty]=@ProductQty ," ); strSql.Append( "[ProductPriceID]=@ProductPriceID ," ); strSql.Append( "[ProductMeters]=@ProductMeters ," ); strSql.Append( "[ProductDescription]=@ProductDescription" ); strSql.Append( " where " ); strSql.Append( "[ProductDetailsId]=@ProductDetailsId" ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductOrderId" ,DbType.Int32,4), new SQLiteParameter( "@ProductTypeId" ,DbType.Int32,4), new SQLiteParameter( "@ProductModleId" ,DbType.Int32,4), new SQLiteParameter( "@ProductUnitID" ,DbType.Int32,4), new SQLiteParameter( "@ProductQty" ,DbType.Decimal,8), new SQLiteParameter( "@ProductPriceID" ,DbType.Int32,4), new SQLiteParameter( "@ProductMeters" ,DbType.Decimal,8), new SQLiteParameter( "@ProductDescription" ,DbType.String,1000), new SQLiteParameter( "@ProductDetailsId" ,DbType.Int32), }; par[0].Value = productItOrderDetails.ProductOrderId; par[1].Value = productItOrderDetails.ProductTypeId; par[2].Value = productItOrderDetails.ProductModleId; par[3].Value = productItOrderDetails.ProductUnitID; par[4].Value = productItOrderDetails.ProductQty; par[5].Value = productItOrderDetails.ProductPriceID; par[6].Value = productItOrderDetails.ProductMeters; par[7].Value = productItOrderDetails.ProductDescription; par[8].Value = productItOrderDetails.ProductDetailsId; ret = SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text, par); } catch (SQLiteException ex) { throw ex; } return ret; } ///<summary> /// 删除记录 ///</summary> ///<param name="productDetailsIdInfo"></param> ///<returns></returns> public bool DeleteProductItOrderDetails( int productDetailsId) { bool ret = false ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "delete from productItOrderDetails" ); strSql.Append( " where ProductDetailsId=" ); strSql.Append( "@ProductDetailsId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductDetailsId" ,productDetailsId) }; int temp = 0 ; temp = SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text, par); if (temp!=0) { ret = true ; } } catch (SQLiteException ex) { throw ex; } return ret; } /// <summary> /// 删除外键的记录,当此关联的主键表要删除记录,外键记录要删除 /// </summary> /// <param name="tableId"></param> /// <returns></returns> public bool DeleteProductPriceID( int productPriceID) { bool ret = false ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "delete from ProductItOrderDetails" ); strSql.Append( " where ProductPriceID=" ); strSql.Append( "@ProductPriceID " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductPriceID" ,productPriceID) } int temp = 0; temp = SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text, par); if (temp != 0) { ret = true ; } } catch (SQLiteException ex) { throw ex; } return ret; } /// <summary> /// 删除外键的记录,当此关联的主键表要删除记录,外键记录要删除 /// </summary> /// <param name="tableId"></param> /// <returns></returns> public bool DeleteProductUnitID( int productUnitID) { bool ret = false ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "delete from ProductItOrderDetails" ); strSql.Append( " where ProductUnitID=" ); strSql.Append( "@ProductUnitID " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductUnitID" ,productUnitID) } int temp = 0; temp = SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text, par); if (temp != 0) { ret = true ; } } catch (SQLiteException ex) { throw ex; } return ret; } /// <summary> /// 删除外键的记录,当此关联的主键表要删除记录,外键记录要删除 /// </summary> /// <param name="tableId"></param> /// <returns></returns> public bool DeleteProductModleId( int productModleId) { bool ret = false ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "delete from ProductItOrderDetails" ); strSql.Append( " where ProductModleId=" ); strSql.Append( "@ProductModleId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductModleId" ,productModleId) } int temp = 0; temp = SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text, par); if (temp != 0) { ret = true ; } } catch (SQLiteException ex) { throw ex; } return ret; } /// <summary> /// 删除外键的记录,当此关联的主键表要删除记录,外键记录要删除 /// </summary> /// <param name="tableId"></param> /// <returns></returns> public bool DeleteProductTypeId( int productTypeId) { bool ret = false ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "delete from ProductItOrderDetails" ); strSql.Append( " where ProductTypeId=" ); strSql.Append( "@ProductTypeId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductTypeId" ,productTypeId) } int temp = 0; temp = SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text, par); if (temp != 0) { ret = true ; } } catch (SQLiteException ex) { throw ex; } return ret; } /// <summary> /// 删除外键的记录,当此关联的主键表要删除记录,外键记录要删除 /// </summary> /// <param name="tableId"></param> /// <returns></returns> public bool DeleteProductOrderId( int productOrderId) { bool ret = false ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "delete from ProductItOrderDetails" ); strSql.Append( " where ProductOrderId=" ); strSql.Append( "@ProductOrderId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductOrderId" ,productOrderId) } int temp = 0; temp = SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text, par); if (temp != 0) { ret = true ; } } catch (SQLiteException ex) { throw ex; } return ret; } ///<summary> /// 查询记录 ///</summary> ///<param name="productDetailsIdInfo"></param> ///<returns></returns> public ProductItOrderDetailsInfo SelectProductItOrderDetails( int productDetailsId) { ProductItOrderDetailsInfo productItOrderDetails = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from productItOrderDetails" ); strSql.Append( " where ProductDetailsId=" ); strSql.Append( "@ProductDetailsId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductDetailsId" ,productDetailsId) }; using (SQLiteDataReader reader = SQLiteHelper.GetReader(strSql.ToString(), CommandType.Text, par)) { if (reader.Read()) { productItOrderDetails = new ProductItOrderDetailsInfo(); productItOrderDetails.ProductDetailsId =(! object .Equals(reader[ "ProductDetailsId" ], null ))? int .Parse(reader[ "ProductDetailsId" ].ToString()):0; productItOrderDetails.ProductOrderId =(! object .Equals(reader[ "ProductOrderId" ], null ))? int .Parse(reader[ "ProductOrderId" ].ToString()):0; productItOrderDetails.ProductTypeId =(! object .Equals(reader[ "ProductTypeId" ], null ))? int .Parse(reader[ "ProductTypeId" ].ToString()):0; productItOrderDetails.ProductModleId =(! object .Equals(reader[ "ProductModleId" ], null ))? int .Parse(reader[ "ProductModleId" ].ToString()):0; productItOrderDetails.ProductUnitID =(! object .Equals(reader[ "ProductUnitID" ], null ))? int .Parse(reader[ "ProductUnitID" ].ToString()):0; productItOrderDetails.ProductQty = (Decimal) reader[ "ProductQty" ]; productItOrderDetails.ProductPriceID =(! object .Equals(reader[ "ProductPriceID" ], null ))? int .Parse(reader[ "ProductPriceID" ].ToString()):0; productItOrderDetails.ProductMeters = (Decimal) reader[ "ProductMeters" ]; productItOrderDetails.ProductDescription =(! object .Equals(reader[ "ProductDescription" ], null ))? ( string ) reader[ "ProductDescription" ]: "" ; } } } catch (SQLiteException ex) { throw ex; } return productItOrderDetails; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductPriceID">外键ID</param> /// <returns></returns> public List<ProductItOrderDetailsInfo> SelectListProductItOrderDetailsProductPriceID( int productPriceID) { List<ProductItOrderDetailsInfo> list = new List<ProductItOrderDetailsInfo>(); ProductItOrderDetailsInfo productItOrderDetails = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductPriceID=" ); strSql.Append( "@ProductPriceID " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductPriceID" ,productPriceID) }; using (SQLiteDataReader reader = SQLiteHelper.GetReader(strSql.ToString(), CommandType.Text, par)) { while (reader.Read()) { productItOrderDetails = new ProductItOrderDetailsInfo(); productItOrderDetails.ProductDetailsId =(! object .Equals(reader[ "ProductDetailsId" ], null ))? int .Parse(reader[ "ProductDetailsId" ].ToString()):0; productItOrderDetails.ProductOrderId =(! object .Equals(reader[ "ProductOrderId" ], null ))? int .Parse(reader[ "ProductOrderId" ].ToString()):0; productItOrderDetails.ProductTypeId =(! object .Equals(reader[ "ProductTypeId" ], null ))? int .Parse(reader[ "ProductTypeId" ].ToString()):0; productItOrderDetails.ProductModleId =(! object .Equals(reader[ "ProductModleId" ], null ))? int .Parse(reader[ "ProductModleId" ].ToString()):0; productItOrderDetails.ProductUnitID =(! object .Equals(reader[ "ProductUnitID" ], null ))? int .Parse(reader[ "ProductUnitID" ].ToString()):0; productItOrderDetails.ProductQty = (Decimal) reader[ "ProductQty" ]; productItOrderDetails.ProductPriceID =(! object .Equals(reader[ "ProductPriceID" ], null ))? int .Parse(reader[ "ProductPriceID" ].ToString()):0; productItOrderDetails.ProductMeters = (Decimal) reader[ "ProductMeters" ]; productItOrderDetails.ProductDescription =(! object .Equals(reader[ "ProductDescription" ], null ))? ( string ) reader[ "ProductDescription" ]: "" ; list.Add(productItOrderDetails); } } } catch (SQLiteException ex) { throw ex; } return list; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductPriceID">外键ID</param> /// <returns></returns> public DataTable SelectProductItOrderDetailsProductPriceID( int productPriceID) { DataTable dt = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductPriceID=" ); strSql.Append( "@ProductPriceID " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductPriceID" ,productPriceID) }; using (DataTable reader = SQLiteHelper.GetTable(strSql.ToString(), CommandType.Text, par)) { dt = reader; } } catch (SQLiteException ex) { throw ex; } return dt; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductUnitID">外键ID</param> /// <returns></returns> public List<ProductItOrderDetailsInfo> SelectListProductItOrderDetailsProductUnitID( int productUnitID) { List<ProductItOrderDetailsInfo> list = new List<ProductItOrderDetailsInfo>(); ProductItOrderDetailsInfo productItOrderDetails = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductUnitID=" ); strSql.Append( "@ProductUnitID " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductUnitID" ,productUnitID) }; using (SQLiteDataReader reader = SQLiteHelper.GetReader(strSql.ToString(), CommandType.Text, par)) { while (reader.Read()) { productItOrderDetails = new ProductItOrderDetailsInfo(); productItOrderDetails.ProductDetailsId =(! object .Equals(reader[ "ProductDetailsId" ], null ))? int .Parse(reader[ "ProductDetailsId" ].ToString()):0; productItOrderDetails.ProductOrderId =(! object .Equals(reader[ "ProductOrderId" ], null ))? int .Parse(reader[ "ProductOrderId" ].ToString()):0; productItOrderDetails.ProductTypeId =(! object .Equals(reader[ "ProductTypeId" ], null ))? int .Parse(reader[ "ProductTypeId" ].ToString()):0; productItOrderDetails.ProductModleId =(! object .Equals(reader[ "ProductModleId" ], null ))? int .Parse(reader[ "ProductModleId" ].ToString()):0; productItOrderDetails.ProductUnitID =(! object .Equals(reader[ "ProductUnitID" ], null ))? int .Parse(reader[ "ProductUnitID" ].ToString()):0; productItOrderDetails.ProductQty = (Decimal) reader[ "ProductQty" ]; productItOrderDetails.ProductPriceID =(! object .Equals(reader[ "ProductPriceID" ], null ))? int .Parse(reader[ "ProductPriceID" ].ToString()):0; productItOrderDetails.ProductMeters = (Decimal) reader[ "ProductMeters" ]; productItOrderDetails.ProductDescription =(! object .Equals(reader[ "ProductDescription" ], null ))? ( string ) reader[ "ProductDescription" ]: "" ; list.Add(productItOrderDetails); } } } catch (SQLiteException ex) { throw ex; } return list; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductUnitID">外键ID</param> /// <returns></returns> public DataTable SelectProductItOrderDetailsProductUnitID( int productUnitID) { DataTable dt = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductUnitID=" ); strSql.Append( "@ProductUnitID " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductUnitID" ,productUnitID) }; using (DataTable reader = SQLiteHelper.GetTable(strSql.ToString(), CommandType.Text, par)) { dt = reader; } } catch (SQLiteException ex) { throw ex; } return dt; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductModleId">外键ID</param> /// <returns></returns> public List<ProductItOrderDetailsInfo> SelectListProductItOrderDetailsProductModleId( int productModleId) { List<ProductItOrderDetailsInfo> list = new List<ProductItOrderDetailsInfo>(); ProductItOrderDetailsInfo productItOrderDetails = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductModleId=" ); strSql.Append( "@ProductModleId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductModleId" ,productModleId) }; using (SQLiteDataReader reader = SQLiteHelper.GetReader(strSql.ToString(), CommandType.Text, par)) { while (reader.Read()) { productItOrderDetails = new ProductItOrderDetailsInfo(); productItOrderDetails.ProductDetailsId =(! object .Equals(reader[ "ProductDetailsId" ], null ))? int .Parse(reader[ "ProductDetailsId" ].ToString()):0; productItOrderDetails.ProductOrderId =(! object .Equals(reader[ "ProductOrderId" ], null ))? int .Parse(reader[ "ProductOrderId" ].ToString()):0; productItOrderDetails.ProductTypeId =(! object .Equals(reader[ "ProductTypeId" ], null ))? int .Parse(reader[ "ProductTypeId" ].ToString()):0; productItOrderDetails.ProductModleId =(! object .Equals(reader[ "ProductModleId" ], null ))? int .Parse(reader[ "ProductModleId" ].ToString()):0; productItOrderDetails.ProductUnitID =(! object .Equals(reader[ "ProductUnitID" ], null ))? int .Parse(reader[ "ProductUnitID" ].ToString()):0; productItOrderDetails.ProductQty = (Decimal) reader[ "ProductQty" ]; productItOrderDetails.ProductPriceID =(! object .Equals(reader[ "ProductPriceID" ], null ))? int .Parse(reader[ "ProductPriceID" ].ToString()):0; productItOrderDetails.ProductMeters = (Decimal) reader[ "ProductMeters" ]; productItOrderDetails.ProductDescription =(! object .Equals(reader[ "ProductDescription" ], null ))? ( string ) reader[ "ProductDescription" ]: "" ; list.Add(productItOrderDetails); } } } catch (SQLiteException ex) { throw ex; } return list; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductModleId">外键ID</param> /// <returns></returns> public DataTable SelectProductItOrderDetailsProductModleId( int productModleId) { DataTable dt = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductModleId=" ); strSql.Append( "@ProductModleId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductModleId" ,productModleId) }; using (DataTable reader = SQLiteHelper.GetTable(strSql.ToString(), CommandType.Text, par)) { dt = reader; } } catch (SQLiteException ex) { throw ex; } return dt; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductTypeId">外键ID</param> /// <returns></returns> public List<ProductItOrderDetailsInfo> SelectListProductItOrderDetailsProductTypeId( int productTypeId) { List<ProductItOrderDetailsInfo> list = new List<ProductItOrderDetailsInfo>(); ProductItOrderDetailsInfo productItOrderDetails = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductTypeId=" ); strSql.Append( "@ProductTypeId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductTypeId" ,productTypeId) }; using (SQLiteDataReader reader = SQLiteHelper.GetReader(strSql.ToString(), CommandType.Text, par)) { while (reader.Read()) { productItOrderDetails = new ProductItOrderDetailsInfo(); productItOrderDetails.ProductDetailsId =(! object .Equals(reader[ "ProductDetailsId" ], null ))? int .Parse(reader[ "ProductDetailsId" ].ToString()):0; productItOrderDetails.ProductOrderId =(! object .Equals(reader[ "ProductOrderId" ], null ))? int .Parse(reader[ "ProductOrderId" ].ToString()):0; productItOrderDetails.ProductTypeId =(! object .Equals(reader[ "ProductTypeId" ], null ))? int .Parse(reader[ "ProductTypeId" ].ToString()):0; productItOrderDetails.ProductModleId =(! object .Equals(reader[ "ProductModleId" ], null ))? int .Parse(reader[ "ProductModleId" ].ToString()):0; productItOrderDetails.ProductUnitID =(! object .Equals(reader[ "ProductUnitID" ], null ))? int .Parse(reader[ "ProductUnitID" ].ToString()):0; productItOrderDetails.ProductQty = (Decimal) reader[ "ProductQty" ]; productItOrderDetails.ProductPriceID =(! object .Equals(reader[ "ProductPriceID" ], null ))? int .Parse(reader[ "ProductPriceID" ].ToString()):0; productItOrderDetails.ProductMeters = (Decimal) reader[ "ProductMeters" ]; productItOrderDetails.ProductDescription =(! object .Equals(reader[ "ProductDescription" ], null ))? ( string ) reader[ "ProductDescription" ]: "" ; list.Add(productItOrderDetails); } } } catch (SQLiteException ex) { throw ex; } return list; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductTypeId">外键ID</param> /// <returns></returns> public DataTable SelectProductItOrderDetailsProductTypeId( int productTypeId) { DataTable dt = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductTypeId=" ); strSql.Append( "@ProductTypeId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductTypeId" ,productTypeId) }; using (DataTable reader = SQLiteHelper.GetTable(strSql.ToString(), CommandType.Text, par)) { dt = reader; } } catch (SQLiteException ex) { throw ex; } return dt; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductOrderId">外键ID</param> /// <returns></returns> public List<ProductItOrderDetailsInfo> SelectListProductItOrderDetailsProductOrderId( int productOrderId) { List<ProductItOrderDetailsInfo> list = new List<ProductItOrderDetailsInfo>(); ProductItOrderDetailsInfo productItOrderDetails = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductOrderId=" ); strSql.Append( "@ProductOrderId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductOrderId" ,productOrderId) }; using (SQLiteDataReader reader = SQLiteHelper.GetReader(strSql.ToString(), CommandType.Text, par)) { while (reader.Read()) { productItOrderDetails = new ProductItOrderDetailsInfo(); productItOrderDetails.ProductDetailsId =(! object .Equals(reader[ "ProductDetailsId" ], null ))? int .Parse(reader[ "ProductDetailsId" ].ToString()):0; productItOrderDetails.ProductOrderId =(! object .Equals(reader[ "ProductOrderId" ], null ))? int .Parse(reader[ "ProductOrderId" ].ToString()):0; productItOrderDetails.ProductTypeId =(! object .Equals(reader[ "ProductTypeId" ], null ))? int .Parse(reader[ "ProductTypeId" ].ToString()):0; productItOrderDetails.ProductModleId =(! object .Equals(reader[ "ProductModleId" ], null ))? int .Parse(reader[ "ProductModleId" ].ToString()):0; productItOrderDetails.ProductUnitID =(! object .Equals(reader[ "ProductUnitID" ], null ))? int .Parse(reader[ "ProductUnitID" ].ToString()):0; productItOrderDetails.ProductQty = (Decimal) reader[ "ProductQty" ]; productItOrderDetails.ProductPriceID =(! object .Equals(reader[ "ProductPriceID" ], null ))? int .Parse(reader[ "ProductPriceID" ].ToString()):0; productItOrderDetails.ProductMeters = (Decimal) reader[ "ProductMeters" ]; productItOrderDetails.ProductDescription =(! object .Equals(reader[ "ProductDescription" ], null ))? ( string ) reader[ "ProductDescription" ]: "" ; list.Add(productItOrderDetails); } } } catch (SQLiteException ex) { throw ex; } return list; } /// <summary> /// 查询外键ID的所有记录 /// </summary> /// <param name="ProductOrderId">外键ID</param> /// <returns></returns> public DataTable SelectProductItOrderDetailsProductOrderId( int productOrderId) { DataTable dt = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from ProductItOrderDetails" ); strSql.Append( " where ProductOrderId=" ); strSql.Append( "@ProductOrderId " ); SQLiteParameter[] par = new SQLiteParameter[]{ new SQLiteParameter( "@ProductOrderId" ,productOrderId) }; using (DataTable reader = SQLiteHelper.GetTable(strSql.ToString(), CommandType.Text, par)) { dt = reader; } } catch (SQLiteException ex) { throw ex; } return dt; } ///<summary> /// 查询所有记录 ///</summary> ///<returns></returns> public List<ProductItOrderDetailsInfo> SelectProductItOrderDetailsAll() { List<ProductItOrderDetailsInfo> list = new List<ProductItOrderDetailsInfo>(); ProductItOrderDetailsInfo productItOrderDetails = null ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from productItOrderDetails" ); using (SQLiteDataReader reader = SQLiteHelper.GetReader(strSql.ToString(),CommandType.Text, null )) { while (reader.Read()) { productItOrderDetails = new ProductItOrderDetailsInfo(); productItOrderDetails.ProductDetailsId =(! object .Equals(reader[ "ProductDetailsId" ], null ))? int .Parse(reader[ "ProductDetailsId" ].ToString()):0; productItOrderDetails.ProductOrderId =(! object .Equals(reader[ "ProductOrderId" ], null ))? int .Parse(reader[ "ProductOrderId" ].ToString()):0; productItOrderDetails.ProductTypeId =(! object .Equals(reader[ "ProductTypeId" ], null ))? int .Parse(reader[ "ProductTypeId" ].ToString()):0; productItOrderDetails.ProductModleId =(! object .Equals(reader[ "ProductModleId" ], null ))? int .Parse(reader[ "ProductModleId" ].ToString()):0; productItOrderDetails.ProductUnitID =(! object .Equals(reader[ "ProductUnitID" ], null ))? int .Parse(reader[ "ProductUnitID" ].ToString()):0; productItOrderDetails.ProductQty = (Decimal) reader[ "ProductQty" ]; productItOrderDetails.ProductPriceID =(! object .Equals(reader[ "ProductPriceID" ], null ))? int .Parse(reader[ "ProductPriceID" ].ToString()):0; productItOrderDetails.ProductMeters = (Decimal) reader[ "ProductMeters" ]; productItOrderDetails.ProductDescription =(! object .Equals(reader[ "ProductDescription" ], null ))? ( string ) reader[ "ProductDescription" ]: "" ; list.Add(productItOrderDetails); } } } catch (SQLiteException ex) { throw ex; } return list; } ///<summary> /// 查询所有记录 ///</summary> ///<returns></returns> public DataTable SelectProductItOrderDetailsDataTableAll() { DataTable dt = new DataTable(); try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * from productItOrderDetails" ); using (DataTable reader = SQLiteHelper.GetTable(strSql.ToString(), CommandType.Text, null )) { dt = reader; } } catch (SQLiteException ex) { throw ex; } return dt; } ///<summary> ///SQL脚本 删除多条记录 ///</summary> ///<param name="productDetailsIdInfo"></param> ///<returns></returns> public bool DeleteProductItOrderDetailsId( string productDetailsId) { bool ret = false ; try { StringBuilder strSql = new StringBuilder(); strSql.Append( "delete from productItOrderDetails" ); strSql.Append( " where ProductDetailsId in (" ); strSql.Append( "@ProductDetailsId )" ); //SQLiteParameter[] par = new SQLiteParameter[]{}; SQLiteParameter par = new SQLiteParameter( "@ProductDetailsId" ,productDetailsId); int temp = 0 ; temp = SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text, par); if (temp!=0) { ret = true ; } } catch (SQLiteException ex) { throw ex; } return ret; } /// <summary> /// SQL script查询分页 /// </summary> /// <param name="pageSize">每页页数</param> /// <param name="currentPage">当前页码</param> /// <param name="strWhere">查询的条件</param> /// <param name="filedOrder">排序字段</param> /// <param name="recordCount">每页的记录数</param> /// <returns></returns> public DataSet GetPageList( int pageSize, int currentPage, string strWhere, string filedOrder, out int recordCount) { int topNum = pageSize * currentPage; StringBuilder strSql = new StringBuilder(); strSql.Append( "select * FROM ProductItOrderDetails" ); if (strWhere.Trim() != "" ) { strSql.Append( " where " + strWhere); } recordCount = Convert.ToInt32(SQLiteHelper.GetSingle(PagingHelper.CreateCountingSql(strSql.ToString()))); return SQLiteHelper.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, currentPage, strSql.ToString(), filedOrder)); } /// <summary> /// SQL语句分页 /// </summary> /// <param name="pageSize">每页页数</param> /// <param name="pageIndex">当前页码</param> /// <param name="filedOrder">排序字段</param> /// <param name="recordCount">返回每页的记录数</param> /// <returns></returns> public DataSet GetPageList( int pageSize, int pageIndex, string filedOrder, out int recordCount) { StringBuilder strSql = new StringBuilder(); strSql.Append( "select * FROM ProductItOrderDetails" ); recordCount = Convert.ToInt32(SQLiteHelper.GetSingle(PagingHelper.CreateCountingSql(strSql.ToString()))); return SQLiteHelper.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, strSql.ToString(), filedOrder));分页弄错了。这是sql sever,Access的分页 } /// <summary> /// SQL语句分页 /// </summary> /// <param name="pageSize">每页页数</param> /// <param name="pageIndex">当前页码</param> /// <param name="recordCount">返回每页的记录数</param> /// <returns></returns> public DataSet GetPageList( int pageSize, int pageIndex, out int recordCount) { string filedOrder = " order by ProductDetailsId desc" ; StringBuilder strSql = new StringBuilder(); strSql.Append( "select * FROM ProductItOrderDetails" ); recordCount = Convert.ToInt32(SQLiteHelper.GetSingle(PagingHelper.CreateCountingSql(strSql.ToString()))); return SQLiteHelper.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, strSql.ToString(), filedOrder)); } /// <summary> ///SQL脚本 模糊查询 /// </summary> /// <param name="filedlist">显示字段列表</param> /// <param name="strkey">输入的关键字</param> /// <returns></returns> public DataTable GetDataTableProductItOrderDetailsFuzzySearch( string filedlist, string strkey) { DataTable dt = new DataTable(); try { StringBuilder strSql = new StringBuilder(); strSql.Append( "select " ); if ( string .IsNullOrEmpty(filedlist)) { strSql.Append( " * " ); } else { strSql.Append( " from ProductItOrderDetails" ); } if (! string .IsNullOrEmpty(strkey)) { strSql.Append( " where " + StringConvert.getStrWhere( "ProductDescription" ,strkey)); } dt = SQLiteHelper.Query(strSql.ToString()).Tables[0]; } catch (SQLiteException ex) { throw ex; } return dt; } /// <summary> ///SQL脚本 是否存在该记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Exists( int id) { StringBuilder strSql = new StringBuilder(); strSql.Append( "select count(1) from ProductItOrderDetails" ); strSql.Append( " where ProductDetailsId=@ProductDetailsId " ); SQLiteParameter[] parameters = { new SQLiteParameter( "@ProductDetailsId" , DbType.Int32,4)}; parameters[0].Value = id; return SQLiteHelper.Exists(strSql.ToString(), parameters); } /// <summary> /// 是否存在该记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool ExistsId( int id) { StringBuilder strSql = new StringBuilder(); strSql.Append( "select count(1) from ProductItOrderDetails" ); strSql.Append( " where ProductDetailsId=@ProductDetailsId " ); SQLiteParameter[] parameters = { new SQLiteParameter( "@ProductDetailsId" , DbType.Int32,10)}; parameters[0].Value = id; return SQLiteHelper.Exists(strSql.ToString(), parameters); } /// <summary> /// 检查单位名是否存在 /// </summary> /// <param name="Name"></param> /// <returns></returns> public bool ExistsName( string columnName) { StringBuilder strSql = new StringBuilder(); strSql.Append( "select count(1) from ProductItOrderDetails" ); strSql.Append( " where ColumnName=@ColumnName " ); SQLiteParameter[] parameters = { new SQLiteParameter( "@ColumnName" , DbType.String,100)}; parameters[0].Value = columnName; return SQLiteHelper.Exists(strSql.ToString(), parameters); } /// <summary> /// 找到名称ID /// </summary> /// <param name="Name"></param> /// <returns></returns> public int GetName( string name) { int name = 0; StringBuilder strSql = new StringBuilder(); strSql.Append( "select ProductDetailsId from ProductItOrderDetails" ); strSql.Append( " where ColumnName=@ColumnName " ); SQLiteParameter[] parameters = { new SQLiteParameter( "@ColumnName" , DbType.String,100) }; parameters[0].Value = name; name = Convert.ToInt32(SQLiteHelper.GetSingle(strSql.ToString(), parameters)); return name; } /// <summary> ///SQL脚本 返回视图数据总数 /// </summary> /// <param name="strWhere"></param> /// <returns></returns> public int GetCountView( string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append( "select count(*) as H " ); strSql.Append( " from ProductItOrderDetailsView" ); if (strWhere.Trim() != "" ) { strSql.Append( " where " + strWhere); } return Convert.ToInt32(SQLiteHelper.GetSingle(strSql.ToString())); } /// <summary> ///SQL脚本 返回数据总数 /// </summary> /// <param name="strWhere"></param> /// <returns></returns> public int GetCount( string strWhere) { StringBuilder strSql = new StringBuilder(); strSql.Append( "select count(*) as H " ); strSql.Append( " from ProductItOrderDetails" ); if (strWhere.Trim() != "" ) { strSql.Append( " where " + strWhere); } return Convert.ToInt32(SQLiteHelper.GetSingle(strSql.ToString())); } /// <summary> ///SQL脚本 修改一列数据 /// </summary> /// <param name="id"></param> /// <param name="strValue"></param> /// <returns></returns> public int UpdateField( int Id, string fieldValue) { StringBuilder strSql = new StringBuilder(); strSql.Append( "update ProductItOrderDetails set @fieldValue" ); strSql.Append( " where ProductDetailsId= @Id" ); SQLiteParameter[] parameters = { new SQLiteParameter( "@fieldValue" , DbType.String), new SQLiteParameter( "@ProductDetailsId" , DbType.Int32,8), }; parameters[0].Value = Id; parameters[1].Value = fieldValue; return SQLiteHelper.ExecuteSql(strSql.ToString(), CommandType.Text,parameters); } /// <summary> ///SQL脚本 返回指字字段的字串 /// </summary> /// <param name="id"></param> /// <param name="fieldName"></param> /// <returns></returns> public string GetTitle( int Id, string fieldName) { StringBuilder strSql = new StringBuilder(); strSql.Append( "select top 1 " + fieldName + " from ProductItOrderDetails" ); strSql.Append( " where ProductDetailsId=" + Id); string title = Convert.ToString(SQLiteHelper.GetSingle(strSql.ToString())); if ( string .IsNullOrEmpty(title)) { return string .Empty; } return title; } } } |
用于UI层要操作:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 | using System; using System.Collections.Generic; using System.Text; using System.Data; using System.Windows.Forms; using System.Drawing; using System.Text.RegularExpressions; using Geovin.Du.Model; using Geovin.Du.Commn; using Geovin.Du.BasicUI; using Geovin.Du.BLL; namespace Geovin.Du.CommnUI { /// <summary> /// ProductTypeList表產品名稱表Windows窗体数据处理 ///生成時間2018/9/14 15:11:06 ///塗聚文(Geovin Du) ///</summary> public class ProductTypeListControl { ProductTypeListBLL dal = new ProductTypeListBLL(); ///<summary> /// 追加记录 ///</summary> ///<param name="ProductTypeList">输入参数:ProductTypeListInfo</param> ///<returns>返回添加的记录条数</returns> public int Add(ProductTypeListInfo productTypeList) { return dal.InsertProductTypeList(productTypeList); } ///<summary> /// 追加记录返回值 ///</summary> ///<param name="ProductTypeList">输入参数:ProductTypeListInfo</param> ///<param name="ProductTypeID">返回参数:ProductTypeID</param> ///<returns>返回是否添加的个数</returns> public int AddOutput(ProductTypeListInfo productTypeList, out int productTypeID) { return dal.InsertProductTypeListOutput(productTypeList, out productTypeID); } ///<summary> ///修改记录 ///</summary> ///<param name="ProductTypeList">输入参数:ProductTypeListInfo</param> ///<returns>返回修改的多少记录数</returns> public int Edit(ProductTypeListInfo productTypeList) { return dal.UpdateProductTypeList(productTypeList); } ///<summary> /// 删除记录 ///</summary> ///<param name="productTypeID">输入参数:ProductTypeID</param> ///<returns>返回删除记录条数</returns> public bool Del( int productTypeID) { bool isdel = dal.DeleteProductTypeList(productTypeID); if (isdel) { //删除关联的外键记录 ProductModelBLL productModelbll = new ProductModelBLL(); productModelbll.DeleteModelProductTypeID( int .Parse(productTypeID)); //删除关联的外键记录 UnitPriceBLL unitPricebll = new UnitPriceBLL(); unitPricebll.DeleteUnitProductTypeID( int .Parse(productTypeID)); //删除关联的外键记录 ProductItOrderDetailsBLL productItOrderDetailsbll = new ProductItOrderDetailsBLL(); productItOrderDetailsbll.DeleteProductTypeId( int .Parse(productTypeID)); //删除关联的外键记录 ProductOrderDetailsBLL productOrderDetailsbll = new ProductOrderDetailsBLL(); productOrderDetailsbll.DeleteProductTypeId( int .Parse(productTypeID)); } return isdel; } ///<summary> /// 删除多条记录 ///</summary> ///<param name="productTypeID">输入参数:ProductTypeID</param> ///<returns>返回删除多少记录</returns> public bool DelId( string productTypeID) { bool isdel = dal.DeleteProductTypeListId(productTypeID); if (isdel) { //删除关联的外键记录,要考虑 string [] sArray = tableId.Split( new string [] { "," , "," }, StringSplitOptions.RemoveEmptyEntries); foreach ( string tid in sArray) { ProductModelBLL productModelbll = new ProductModelBLL(); productModelbll.DeleteModelProductTypeID( int .Parse(productTypeID)); UnitPriceBLL unitPricebll = new UnitPriceBLL(); unitPricebll.DeleteUnitProductTypeID( int .Parse(productTypeID)); ProductItOrderDetailsBLL productItOrderDetailsbll = new ProductItOrderDetailsBLL(); productItOrderDetailsbll.DeleteProductTypeId( int .Parse(productTypeID)); ProductOrderDetailsBLL productOrderDetailsbll = new ProductOrderDetailsBLL(); productOrderDetailsbll.DeleteProductTypeId( int .Parse(productTypeID)); } } return isdel; } ///<summary> /// 查询记录 ///</summary> ///<param name="productTypeID">输入参数:ProductTypeID</param> ///<returns>返回ProductTypeListInfo</returns> public ProductTypeListInfo Select( int productTypeID) { DataTableDescInfo info = dal.SelectProductTypeList(productTypeID); //根据主键所涉涉及子表的做为外键的查询 ProductModelBLL productModelbll = new ProductModelBLL(); info.ProductModelData = productModelbll.SelectDataProductModelModelProductTypeID(productTypeID); info.ProductModelList = productModelbll.SelectListProductModelModelProductTypeID(productTypeID); //根据主键所涉涉及子表的做为外键的查询 UnitPriceBLL unitPricebll = new UnitPriceBLL(); info.UnitPriceData = unitPricebll.SelectDataUnitPriceUnitProductTypeID(productTypeID); info.UnitPriceList = unitPricebll.SelectListUnitPriceUnitProductTypeID(productTypeID); //根据主键所涉涉及子表的做为外键的查询 ProductItOrderDetailsBLL productItOrderDetailsbll = new ProductItOrderDetailsBLL(); info.ProductItOrderDetailsData = productItOrderDetailsbll.SelectDataProductItOrderDetailsProductTypeId(productTypeID); info.ProductItOrderDetailsList = productItOrderDetailsbll.SelectListProductItOrderDetailsProductTypeId(productTypeID); //根据主键所涉涉及子表的做为外键的查询 ProductOrderDetailsBLL productOrderDetailsbll = new ProductOrderDetailsBLL(); info.ProductOrderDetailsData = productOrderDetailsbll.SelectDataProductOrderDetailsProductTypeId(productTypeID); info.ProductOrderDetailsList = productOrderDetailsbll.SelectListProductOrderDetailsProductTypeId(productTypeID); return info; } ///<summary> /// 查询所有记录 ///</summary> ///<param name="productTypeID">无输入参数</param> ///<returns>返回表所有记录(List)ProductTypeListInfo</returns> public List<ProductTypeListInfo> SelectAll() { return dal.SelectProductTypeListAll(); } ///<summary> /// 查询所有记录 ///</summary> ///<param name="productTypeID">无输入参数</param> ///<returns>返回(DataTable)ProductTypeList表所有记录</returns> public DataTable SelectDataTableAll() { return dal.SelectProductTypeListDataTableAll(); } /// <summary> /// SQL script查询分页 /// </summary> /// <param name="pageSize">每页页数</param> /// <param name="currentPage">当前页码</param> /// <param name="strWhere">查询的条件</param> /// <param name="filedOrder">排序字段</param> /// <param name="recordCount">每页的记录数</param> /// <returns></returns> public DataSet GetPageList( int pageSize, int currentPage, string strWhere, string filedOrder, out int recordCount) { return dal.GetPageList(pageSize, currentPage, strWhere, filedOrder, out recordCount); } /// <summary> /// SQL script查询分页无查询条件无排序 /// </summary> /// <param name="pageSize">每页页数</param> /// <param name="currentPage">当前页码</param> /// <param name="recordCount">每页的记录数</param> /// <returns></returns> public DataSet GetPageList( int pageSize, int currentPage, out int recordCount) { return dal.GetPageList(pageSize, currentPage, out recordCount); } /// <summary> /// SQL script查询分页无排序 /// </summary> /// <param name="pageSize">每页页数</param> /// <param name="currentPage">当前页码</param> /// <param name="strWhere">查询的条件</param> /// <param name="recordCount">每页的记录数</param> /// <returns></returns> public DataSet GetPageList( int pageSize, int currentPage, string strWhere, out int recordCount) { return dal.GetPageList(pageSize, currentPage, strWhere, out recordCount); } /// <summary> /// 模糊查询 /// </summary> /// <param name="filedlist">显示字段列表</param> /// <param name="strkey">输入的关键字</param> /// <returns></returns> public DataTable GetDataTableFuzzySearch( string filedlist, string strkey) { return dal.GetDataTableProductTypeListFuzzySearch(filedlist, strkey); } /// <summary> /// 是否存在该记录 /// </summary> /// <param name="Id"></param> /// <returns></returns> public bool Exists( int Id) { return dal.Exists(Id); } /// <summary> /// 是否存在该记录 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool ExistsId( int id) { return dal.ExistsId(id); } /// <summary> /// 检查单位名是否存在 /// </summary> /// <param name="levelName"></param> /// <returns></returns> public bool ExistsName( string columnName) { return dal.ExistsName(columnName); } /// <summary> /// 找到名称ID /// </summary> /// <param name="unitName"></param> /// <returns></returns> public int GetName( string columnName) { return dal.GetName(columnName); } /// <summary> /// 返回数据总数 /// </summary> /// <param name="strWhere">查询条件</param> /// <returns></returns> public int GetCount( string where ) { return dal.GetCount( where ); } /// <summary> /// 返回视图数据总数 /// </summary> /// <param name="strWhere">查询条件</param> /// <returns></returns> public int GetCountView( string where ) { return dal.GetCountView( where ); } /// <summary> /// 更新一列数据 /// </summary> /// <param name="Id"></param> /// <param name="strValue">字段名=值</param> /// <returns></returns> public int UpdateField( int Id, string fieldValue) { return dal.UpdateField(Id, fieldValue); } /// <summary> /// 返回指字字段的字串 /// </summary> /// <param name="Id"></param> /// <param name="fieldName">字段名</param> /// <returns></returns> public string GetTitle( int Id, string fieldName) { return dal.GetTitle(Id, fieldName); } /// <summary> /// Combox绑定 /// </summary> /// <param name="comb"></param> public void SetCombox(ComboBox comb) { SetComBoxDataBinding.setComboList(comb, "id" , "typename" , dal.SelectProductTypeListDataTableAll()); } /// <summary> /// DataGridView绑定 /// </summary> /// <param name="dataGridView1"></param> /// <param name="dt"></param> /// <param name="bindingSource1"></param> /// <param name="bindingNavigator1"></param> private void SetDataGridView(DataGridView dataGridView1, DataTable dt, BindingSource bindingSource1, BindingNavigator bindingNavigator1) { SetDataGridViewBindingSourceNavigatorAll set = new SetDataGridViewBindingSourceNavigatorAll(); dataGridView1.DataSource = null ; set .SetDataGridViewBindingSourceNavigatorBinds(dataGridView1, dt, bindingSource1, bindingNavigator1); } /// <summary> /// /// </summary> /// <param name="dataGridView1"></param> /// <param name="dt"></param> private void SetDataGridView(DataGridView dataGridView1, DataTable dt) { dataGridView1.DataSource = null ; dataGridView1.DataSource = dt; } /// <summary> /// sql 查询分页无搜条件和排序 /// </summary> /// <param name="dataGridView1">DataGridView控件</param> /// <param name="pagerControl1">PagerControl分页控件</param> /// <param name="Index"></param> public void setBindDataSqlPage(DataGridView dataGridView1, PagerControl pagerControl1, int Index) { int Count = 0; pagerControl1.PageIndex = Index; //pagerControl1.PageSize = 20; dataGridView1.DataSource = dal.GetPageList(Index, pagerControl1.PageSize, out Count).Tables[0]; //获取并设置总记录数 pagerControl1.RecordCount = Count; pagerControl1.DrawControl(Count); } /// <summary> /// sql 查询分页 无排序 /// </summary> /// <param name="dataGridView1">DataGridView控件</param> /// <param name="pagerControl1">PagerControl分页控件</param> /// <param name="Index">当前页</param> /// <param name="strWhere">查询关键字</param> public void setBindDataSqlPage(DataGridView dataGridView1, PagerControl pagerControl1, int Index, string strWhere) { int Count = 0; pagerControl1.PageIndex = Index; //pagerControl1.PageSize = 20; dataGridView1.DataSource = GetPageList(Index, pagerControl1.PageSize, strWhere, out Count).Tables[0]; //获取并设置总记录数 pagerControl1.RecordCount = Count; pagerControl1.DrawControl(Count); } /// <summary> /// sql 查询分页 /// </summary> /// <param name="dataGridView1">DataGridView控件</param> /// <param name="pagerControl1">PagerControl分页控件</param> /// <param name="Index">当前页</param> /// <param name="strWhere">查询关键字</param> /// <param name="filedOrder">排序字段名</param> public void setBindDataSqlPage(DataGridView dataGridView1, PagerControl pagerControl1, int Index, string strWhere, string filedOrder) { int Count = 0; pagerControl1.PageIndex = Index; //pagerControl1.PageSize = 20; dataGridView1.DataSource = GetPageList(Index, pagerControl1.PageSize, strWhere, filedOrder, out Count).Tables[0]; //获取并设置总记录数 pagerControl1.RecordCount = Count; pagerControl1.DrawControl(Count); } /// <summary> /// sql 查询分页 无查询条件无排序 /// </summary> /// <param name="dataGridView1">DataGridView控件</param> /// <param name="pagerControl1">PagerControl自定义分页控件</param> /// <param name="bindingSource1">BindingSource控件</param> /// <param name="bindingNavigator1">BindingNavigator控件</param> /// <param name="Index">当前页</param> public void setBindDataSqlPage(DataGridView dataGridView1, PagerControl pagerControl1, BindingSource bindingSource1, BindingNavigator bindingNavigator1, int Index) { int Count = 0; pagerControl1.PageIndex = Index; //pagerControl1.PageSize = 20; dataGridView1.DataSource = GetPageList(Index, pagerControl1.PageSize, out Count).Tables[0]; //获取并设置总记录数 pagerControl1.RecordCount = Count; pagerControl1.DrawControl(Count); bindingSource1.DataSource = GetPageList(Index, pagerControl1.PageSize, out Count).Tables[0]; bindingNavigator1.BindingSource = bindingSource1; dataGridView1.DataSource = bindingSource1; } /// <summary> /// sql 查询分页 無排序 /// </summary> /// <param name="dataGridView1">DataGridView控件</param> /// <param name="pagerControl1">PagerControl自定义分页控件</param> /// <param name="bindingSource1">BindingSource控件</param> /// <param name="bindingNavigator1">BindingNavigator控件</param> /// <param name="Index">当前页</param> /// <param name="strWhere">查询条件关键字</param> public void setBindDataSqlPage(DataGridView dataGridView1, PagerControl pagerControl1, BindingSource bindingSource1, BindingNavigator bindingNavigator1, int Index, string strWhere) { int Count = 0; pagerControl1.PageIndex = Index; //pagerControl1.PageSize = 20; dataGridView1.DataSource = GetPageList(Index, pagerControl1.PageSize, strWhere, out Count).Tables[0]; //获取并设置总记录数 pagerControl1.RecordCount = Count; pagerControl1.DrawControl(Count); bindingSource1.DataSource = GetPageList(Index, pagerControl1.PageSize, strWhere, out Count); bindingNavigator1.BindingSource = bindingSource1; dataGridView1.DataSource = bindingSource1; } /// <summary> /// sql 查询分页 無排序 /// </summary> /// <param name="dataGridView1">DataGridView控件</param> /// <param name="pagerControl1">PagerControl自定义分页控件</param> /// <param name="bindingSource1">BindingSource控件</param> /// <param name="bindingNavigator1">BindingNavigator控件</param> /// <param name="Index">当前页</param> /// <param name="strWhere">查询条件关键字</param> /// <param name="filedOrder">排序字段</param> public void setBindDataSqlPage(DataGridView dataGridView1, PagerControl pagerControl1, BindingSource bindingSource1, BindingNavigator bindingNavigator1, int Index, string strWhere, string filedOrder) { int Count = 0; pagerControl1.PageIndex = Index; //pagerControl1.PageSize = 20; dataGridView1.DataSource = GetPageList(Index, pagerControl1.PageSize, strWhere, filedOrder, out Count).Tables[0]; //获取并设置总记录数 pagerControl1.RecordCount = Count; pagerControl1.DrawControl(Count); bindingSource1.DataSource = GetPageList(Index, pagerControl1.PageSize, strWhere, out Count); bindingNavigator1.BindingSource = bindingSource1; dataGridView1.DataSource = bindingSource1; } /// <summary> /// DataGridView顯示語言類型 /// </summary> /// <param name="dv"></param> /// <param name="lname"></param> public void setGridViewName(DataGridView dv, ChangeLanguage.LanguageName lname) { DataGridViewCellStyle date5 = new DataGridViewCellStyle(); date5.Format = "yyyy-MM-dd HH:mm:ss" ; DataGridViewCellStyle date4 = new DataGridViewCellStyle(); date4.Format = "yyyy-MM-dd" ; switch (lname) { case ChangeLanguage.LanguageName.GBK: dv.Columns[ "ProductTypeID" ].HeaderText = "ID,主键" ; dv.Columns[ "ProductTypeName" ].HeaderText = "产品名称" ; dv.Columns[ "ProductTypePin" ].HeaderText = "字首字母" ; break ; case ChangeLanguage.LanguageName.GBig: dv.Columns[ "ProductTypeID" ].HeaderText = "ID,主鍵" ; dv.Columns[ "ProductTypeName" ].HeaderText = "產品名稱" ; dv.Columns[ "ProductTypePin" ].HeaderText = "字首字母" ; break ; case ChangeLanguage.LanguageName.USEN: dv.Columns[ "ProductTypeID" ].HeaderText = "ProductTypeID" ; dv.Columns[ "ProductTypeName" ].HeaderText = "ProductTypeName" ; dv.Columns[ "ProductTypePin" ].HeaderText = "ProductTypePin" ; break ; default : dv.Columns[ "ProductTypeID" ].HeaderText = "ID,主键" ; dv.Columns[ "ProductTypeName" ].HeaderText = "产品名称" ; dv.Columns[ "ProductTypePin" ].HeaderText = "字首字母" ; break ; } } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | /// <summary> /// MetaDataCollections MetaData集合 /// </summary> /// <returns></returns> DataTable getSchema( string connString) { DataTable dt = new DataTable(); dt.Columns.Add( "id" , typeof ( int )); dt.Columns.Add( "CollectionName" , typeof ( string )); dt.Columns.Add( "NumberOfRestrictions" , typeof ( string )); dt.Columns.Add( "NumberOfIdentifierParts" , typeof ( string )); using (SQLiteConnection conn = new SQLiteConnection(connString)) { conn.Open(); //http://www.devart.com/dotconnect/sqlite/docs/MetaData.html //Catalogs,Columns,DatasourceInformation,DataTypes,ForeignKeyColumns,ForeignKeys,IndexColumns,Indexes,MetaDataCollections,PrimaryKeys,ReservedWords,Restrictions,Tables,UniqueKeys,ViewColumns,Views DataTable schemaTable = conn.GetSchema( "MetaDataCollections" ); // conn.GetSchema()和conn.GetSchema("MetaDataCollections")效果是一样的 int i = 1; foreach (DataRow row in schemaTable.Rows) { dt.Rows.Add(i,row[ "CollectionName" ], row[ "NumberOfRestrictions" ].ToString(), row[ "NumberOfIdentifierParts" ].ToString()); i++; } } return dt; } |
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
2012-09-14 csharp: winform using Microsoft.Ink(Tablet PC API) create Signature image
2010-09-14 AJAX Framework四个框架:AJAX Control Toolkit,MagicAjax.NET,Anthem.NET,Ajax.NET Professional
2009-09-14 aspx net.2.0 C#获取IP,URL,浏览器,操作系统