public StringBuilder CreateACSXChiTiet1Bang(DBTable table) { StringBuilder sbClass=new StringBuilder(); sbClass.AppendFormat("<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"{0}_VIEW.ascx.cs\" Inherits=\"mojoPortal.Web.Modules.{0}_VIEW\" %>\r\n", table.Name); sbClass.Append("<%@ Import Namespace=\"System.Globalization\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Business\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Business.WebHelpers\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web.Framework\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web.Controls\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web.UI\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web.Editor\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Net\" %>\r\n"); sbClass.Append("<portal:OuterWrapperPanel ID=\"pnlOuterWrap\" runat=\"server\">\r\n"); sbClass.Append("<mp:CornerRounderTop id=\"ctop1\" runat=\"server\" />\r\n"); sbClass.Append("<portal:InnerWrapperPanel ID=\"pnlInnerWrap\" runat=\"server\" CssClass=\"panelwrapper mymodule\">\r\n"); sbClass.Append("<asp:UpdatePanel ID=\"upGallery\" UpdateMode=\"Conditional\" runat=\"server\">\r\n"); sbClass.Append("<ContentTemplate >\r\n"); sbClass.Append("<portal:ModuleTitleControl id=\"Title1\" runat=\"server\" />\r\n"); sbClass.Append("<portal:OuterBodyPanel ID=\"pnlOuterBody\" runat=\"server\">\r\n"); sbClass.Append("<portal:InnerBodyPanel ID=\"pnlInnerBody\" runat=\"server\" CssClass=\"modulecontent\">\r\n"); sbClass.AppendFormat("<h2>Chi tiết {0}</h2>\r\n", table.Name); foreach (DBField f in table.Fields) { sbClass.AppendFormat("<portal:mojoLabel ID=\"lbl{0}\" runat=\"server\" Text=\"{1}\" ></portal:mojoLabel>\r\n", f.Name,f.Description); sbClass.AppendFormat("<portal:mojoLabel ID=\"{0}\" runat=\"server\" Text=\"\" ></portal:mojoLabel> <br />\r\n", f.Name); } sbClass.AppendFormat("<br /><br /><asp:HyperLink ID=\"linkTroLaiDanhSach\" runat=\"server\" NavigateUrl=\"~/{0}_LIST.aspx\">Trở lại</asp:HyperLink>\r\n", table.Name); sbClass.Append("</portal:InnerBodyPanel>\r\n"); sbClass.Append("</portal:OuterBodyPanel>\r\n"); sbClass.Append("</ContentTemplate>\r\n"); sbClass.Append("</asp:UpdatePanel>\r\n"); sbClass.Append("<portal:EmptyPanel id=\"divCleared\" runat=\"server\" CssClass=\"cleared\" SkinID=\"cleared\" ></portal:EmptyPanel>\r\n"); sbClass.Append("</portal:InnerWrapperPanel>\r\n"); sbClass.Append("<mp:CornerRounderBottom id=\"cbottom1\" runat=\"server\" />\r\n"); sbClass.Append("</portal:OuterWrapperPanel>\r\n"); return sbClass; }
public StringBuilder CreateClassDesigner_ListSelectDetail(DBTable table) { StringBuilder sbClass=new StringBuilder(); sbClass.AppendFormat(" namespace {0}\r\n",txtNameSpace.Text); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" partial class frm{0}list\r\n",table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" /// <summary> \r\n"); sbClass.AppendFormat(" /// Required designer variable. \r\n"); sbClass.AppendFormat(" /// </summary> \r\n"); sbClass.AppendFormat(" private System.ComponentModel.IContainer components = null; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" /// <summary> \r\n"); sbClass.AppendFormat(" /// Clean up any resources being used. \r\n"); sbClass.AppendFormat(" /// </summary> \r\n"); sbClass.AppendFormat(" /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param> \r\n"); sbClass.AppendFormat(" protected override void Dispose(bool disposing) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (disposing && (components != null)) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" components.Dispose(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" base.Dispose(disposing); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" #region Windows Form Designer generated code \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" /// <summary> \r\n"); sbClass.AppendFormat(" /// Required method for Designer support - do not modify \r\n"); sbClass.AppendFormat(" /// the contents of this method with the code editor. \r\n"); sbClass.AppendFormat(" /// </summary> \r\n"); sbClass.AppendFormat(" private void InitializeComponent() \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" this.components = new System.ComponentModel.Container(); \r\n"); int ifi = 0; foreach (DBField fi in table.Fields) { sbClass.AppendFormat(" DevComponents.DotNetBar.SuperGrid.GridColumn gridColumn{0} = new DevComponents.DotNetBar.SuperGrid.GridColumn();\r\n",(++ifi)); } sbClass.AppendFormat(" this.gLocDuLieu = new DevComponents.DotNetBar.Controls.GroupPanel(); \r\n"); foreach (DBField fi in table.Fields) { sbClass.AppendFormat(" this.txt{0} = new DevComponents.DotNetBar.tTextBox();\r\n",fi.Name); } sbClass.AppendFormat(" this.btnThoat = new DevComponents.DotNetBar.ButtonX(); \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet = new DevComponents.DotNetBar.ButtonX(); \r\n"); sbClass.AppendFormat(" this.btnThemMoi = new DevComponents.DotNetBar.ButtonX(); \r\n"); sbClass.AppendFormat(" this.gList = new DevComponents.DotNetBar.tGrid(); \r\n"); sbClass.AppendFormat(" this.mnuChuotPhai = new System.Windows.Forms.ContextMenuStrip(this.components); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XemChiTiet = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.lblPhimTat = new DevComponents.DotNetBar.LabelX(); \r\n"); sbClass.AppendFormat(" this.bwLoadData = new System.ComponentModel.BackgroundWorker(); \r\n"); sbClass.AppendFormat(" this.menuPhimTat = new System.Windows.Forms.MenuStrip(); \r\n"); sbClass.AppendFormat(" this.phimTat = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.phimTat_XemChiTiet = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.phimTat_Excel = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.proLoad = new DevComponents.DotNetBar.Controls.ProgressBarX(); \r\n"); sbClass.AppendFormat(" this.bsList = new System.Windows.Forms.BindingSource(this.components); \r\n"); sbClass.AppendFormat(" this.btnInAn = new DevComponents.DotNetBar.ButtonX(); \r\n"); sbClass.AppendFormat(" this.CONTENT.SuspendLayout(); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.SuspendLayout(); \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.SuspendLayout(); \r\n"); sbClass.AppendFormat(" this.mnuChuotPhai.SuspendLayout(); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.SuspendLayout(); \r\n"); sbClass.AppendFormat(" ((System.ComponentModel.ISupportInitialize)(this.bsList)).BeginInit(); \r\n"); sbClass.AppendFormat(" this.SuspendLayout(); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // TITLE \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.TITLE.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" this.TITLE.Text = \"DANH SÁCH {0}\";\r\n",table.Name.ToUpper()); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // CONTENT \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.CONTENT.Controls.Add(this.proLoad); \r\n"); sbClass.AppendFormat(" this.CONTENT.Controls.Add(this.gList); \r\n"); sbClass.AppendFormat(" this.CONTENT.Controls.Add(this.lblPhimTat); \r\n"); sbClass.AppendFormat(" this.CONTENT.Controls.Add(this.gLocDuLieu); \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.Alignment = System.Drawing.StringAlignment.Center; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.GradientAngle = 90; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // pBOTTOM \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.Add(this.btnInAn); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.Add(this.btnThemMoi); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.Add(this.btnXemChiTiet); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.Add(this.btnThoat); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.Alignment = System.Drawing.StringAlignment.Center; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.GradientAngle = 90; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // gLocDuLieu \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.CanvasColor = System.Drawing.SystemColors.Control; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; \r\n"); foreach (DBField fi in table.Fields) { sbClass.AppendFormat(" this.gLocDuLieu.Controls.Add(this.txt{0});\r\n",fi.Name); } sbClass.AppendFormat(" this.gLocDuLieu.Dock = System.Windows.Forms.DockStyle.Top; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Location = new System.Drawing.Point(2, 2); \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Name = \"gLocDuLieu\"; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Size = new System.Drawing.Size(780, 47); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BackColorGradientAngle = 90; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderBottomWidth = 1; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderLeftWidth = 1; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderRightWidth = 1; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderTopWidth = 1; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.CornerDiameter = 4; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.TabIndex = 0; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Text = \"Lọc dữ liệu\"; \r\n"); int ifi1 = 0; foreach (DBField fi in table.Fields) { sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // txt{0}\r\n",fi.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.txt{0}.BắtBuộc = false;\r\n", fi.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.txt{0}.Border.Class = \"TextBoxBorder\";\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.Location = new System.Drawing.Point({1}, 5);\r\n", fi.Name,6+(ifi1+1)*110); sbClass.AppendFormat(" this.txt{0}.Name = \"txt{0}\";\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.Size = new System.Drawing.Size(100, 20);\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.TabIndex = {1};\r\n", fi.Name, ifi1+1); sbClass.AppendFormat(" this.txt{0}.Tag = \"{0}\";\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.WatermarkText = \"{1}\";\r\n", fi.Name, string.IsNullOrEmpty(fi.Description) ? fi.Name : fi.Description); sbClass.AppendFormat(" this.txt{0}.TextChanged += new System.EventHandler(this.txtFilter_TextChanged);\r\n", fi.Name); ifi1 = ifi1 + 1; } sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // btnThoat \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.btnThoat.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; \r\n"); sbClass.AppendFormat(" this.btnThoat.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); \r\n"); sbClass.AppendFormat(" this.btnThoat.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; \r\n"); sbClass.AppendFormat(" this.btnThoat.Location = new System.Drawing.Point(705, 4); \r\n"); sbClass.AppendFormat(" this.btnThoat.Name = \"btnThoat\"; \r\n"); sbClass.AppendFormat(" this.btnThoat.Size = new System.Drawing.Size(75, 23); \r\n"); sbClass.AppendFormat(" this.btnThoat.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.btnThoat.TabIndex = 0; \r\n"); sbClass.AppendFormat(" this.btnThoat.Text = \"&Thoát\"; \r\n"); sbClass.AppendFormat(" this.btnThoat.Click += new System.EventHandler(this.btnThoat_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // btnXemChiTiet \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet.Location = new System.Drawing.Point(12, 4); \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet.Name = \"btnXemChiTiet\"; \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet.Size = new System.Drawing.Size(97, 23); \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet.TabIndex = 1; \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet.Text = \"Xem chi tiết (F1)\"; \r\n"); sbClass.AppendFormat(" this.btnXemChiTiet.Click += new System.EventHandler(this.btnXemChiTiet_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // btnThemMoi \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.btnThemMoi.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; \r\n"); sbClass.AppendFormat(" this.btnThemMoi.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; \r\n"); sbClass.AppendFormat(" this.btnThemMoi.Location = new System.Drawing.Point(129, 4); \r\n"); sbClass.AppendFormat(" this.btnThemMoi.Name = \"btnThemMoi\"; \r\n"); sbClass.AppendFormat(" this.btnThemMoi.Size = new System.Drawing.Size(87, 23); \r\n"); sbClass.AppendFormat(" this.btnThemMoi.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.btnThemMoi.TabIndex = 2; \r\n"); sbClass.AppendFormat(" this.btnThemMoi.Text = \"Thêm mới\"; \r\n"); sbClass.AppendFormat(" this.btnThemMoi.Click += new System.EventHandler(this.btnThemMoi_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // gList \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gList.ContextMenuStrip = this.mnuChuotPhai; \r\n"); sbClass.AppendFormat(" this.gList.Dock = System.Windows.Forms.DockStyle.Fill; \r\n"); sbClass.AppendFormat(" this.gList.FilterExprColors.SysFunction = System.Drawing.Color.DarkRed; \r\n"); sbClass.AppendFormat(" this.gList.LicenseKey = \"F962CEC7-CD8F-4911-A9E9-CAB39962FC1F\"; \r\n"); sbClass.AppendFormat(" this.gList.Location = new System.Drawing.Point(2, 69); \r\n"); sbClass.AppendFormat(" this.gList.Name = \"gList\"; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.AutoGenerateColumns = false; \r\n"); int ifi2 = 0; foreach (DBField fi in table.Fields) { ifi2 = ifi2 + 1; sbClass.AppendFormat(" gridColumn{0}.DataPropertyName = \"{1}\";\r\n", ifi2, fi.Name); sbClass.AppendFormat(" gridColumn{0}.HeaderText = \"{1}\";\r\n", ifi2,string.IsNullOrEmpty(fi.Description)? fi.Name:fi.Description); sbClass.AppendFormat(" gridColumn{0}.Name = \"{1}\";\r\n", ifi2,fi.Name); sbClass.AppendFormat(" this.gList.PrimaryGrid.Columns.Add(gridColumn{0});\r\n", ifi2); } sbClass.AppendFormat(" this.gList.PrimaryGrid.MultiSelect = false; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.ReadOnly = true; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.RowHeaderIndexOffset = 1; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.SelectionGranularity = DevComponents.DotNetBar.SuperGrid.SelectionGranularity.RowWithCellHighlight; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.ShowRowGridIndex = true; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.UseAlternateRowStyle = true; \r\n"); sbClass.AppendFormat(" this.gList.Size = new System.Drawing.Size(780, 432); \r\n"); sbClass.AppendFormat(" this.gList.TabIndex = 1; \r\n"); sbClass.AppendFormat(" this.gList.Text = \"Danh sách\"; \r\n"); sbClass.AppendFormat(" this.gList.CellDoubleClick += new System.EventHandler<DevComponents.DotNetBar.SuperGrid.GridCellDoubleClickEventArgs>(this.gList_CellDoubleClick); \r\n"); sbClass.AppendFormat(" this.gList.RowHeaderClick += new System.EventHandler<DevComponents.DotNetBar.SuperGrid.GridRowHeaderClickEventArgs>(this.gList_RowHeaderClick); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // mnuChuotPhai \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.Append(" this.mnuChuotPhai.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { \r\n"); sbClass.AppendFormat(" this.chuotPhai_XemChiTiet, \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong, \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong, \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet, \r\n"); sbClass.Append(" this.chuotPhai_XuatExcel}); \r\n"); sbClass.Append(" this.mnuChuotPhai.Name = \"mnuChuotPhai\"; \r\n"); sbClass.AppendFormat(" this.mnuChuotPhai.Size = new System.Drawing.Size(155, 114); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_XemChiTiet \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_XemChiTiet.Name = \"chuotPhai_XemChiTiet\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XemChiTiet.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XemChiTiet.Text = \"Xem chi tiết (F1)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XemChiTiet.Click += new System.EventHandler(this.chuotPhai_XemChiTiet_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_CopyDong \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong.Name = \"chuotPhai_CopyDong\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong.Text = \"Copy dòng (F5)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong.Click += new System.EventHandler(this.chuotPhai_CopyDong_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_XoaDong \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong.Name = \"chuotPhai_XoaDong\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong.Text = \"Xóa dòng (F8)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong.Click += new System.EventHandler(this.chuotPhai_XoaDong_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_XoaHet \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet.Name = \"chuotPhai_XoaHet\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet.Text = \"Xóa hết (F11)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet.Click += new System.EventHandler(this.chuotPhai_XoaHet_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_XuatExcel \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel.Name = \"chuotPhai_XuatExcel\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel.Text = \"Xuất Excel (F12)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel.Click += new System.EventHandler(this.chuotPhai_XuatExcel_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // lblPhimTat \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.lblPhimTat.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Dock = System.Windows.Forms.DockStyle.Top; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Location = new System.Drawing.Point(2, 49); \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Name = \"lblPhimTat\"; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.PaddingLeft = 5; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Size = new System.Drawing.Size(780, 20); \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.TabIndex = 6; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Text = \"F1: Xem chi tiết F5: Copy dòng F8: Xóa dòng F11: Xóa hết F12: Excel\"; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // bwLoadData \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.bwLoadData.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bwLoadData_DoWork); \r\n"); sbClass.AppendFormat(" this.bwLoadData.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bwLoadData_RunWorkerCompleted); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // menuPhimTat \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.Append(" this.menuPhimTat.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { \r\n"); sbClass.Append(" this.phimTat}); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Location = new System.Drawing.Point(0, 0); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Name = \"menuPhimTat\"; \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Size = new System.Drawing.Size(784, 24); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.TabIndex = 4; \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Text = \"menuStrip1\"; \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Visible = false; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.Append(" this.phimTat.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { \r\n"); sbClass.AppendFormat(" this.phimTat_XemChiTiet, \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong, \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong, \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet, \r\n"); sbClass.Append(" this.phimTat_Excel}); \r\n"); sbClass.AppendFormat(" this.phimTat.Name = \"phimTat\"; \r\n"); sbClass.AppendFormat(" this.phimTat.Size = new System.Drawing.Size(59, 20); \r\n"); sbClass.AppendFormat(" this.phimTat.Text = \"PhimTat\"; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_XemChiTiet \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_XemChiTiet.Name = \"phimTat_XemChiTiet\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XemChiTiet.ShortcutKeys = System.Windows.Forms.Keys.F1; \r\n"); sbClass.AppendFormat(" this.phimTat_XemChiTiet.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_XemChiTiet.Text = \"XemChiTiet\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XemChiTiet.Click += new System.EventHandler(this.phimTat_XemChiTiet_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_CopyDong \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.Name = \"phimTat_CopyDong\"; \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.ShortcutKeys = System.Windows.Forms.Keys.F5; \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.Text = \"CopyDong\"; \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.Click += new System.EventHandler(this.phimTat_CopyDong_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_XoaDong \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.Name = \"phimTat_XoaDong\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.ShortcutKeys = System.Windows.Forms.Keys.F8; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.Text = \"XoaDong\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.Click += new System.EventHandler(this.phimTat_XoaDong_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_XoaHet \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.Name = \"phimTat_XoaHet\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.ShortcutKeys = System.Windows.Forms.Keys.F11; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.Text = \"XoaHet\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.Click += new System.EventHandler(this.phimTat_XoaHet_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_Excel \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.Name = \"phimTat_Excel\"; \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.ShortcutKeys = System.Windows.Forms.Keys.F12; \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.Text = \"Excel\"; \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.Click += new System.EventHandler(this.phimTat_Excel_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // proLoad \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.proLoad.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" this.proLoad.Location = new System.Drawing.Point(37, 157); \r\n"); sbClass.AppendFormat(" this.proLoad.Name = \"proLoad\"; \r\n"); sbClass.AppendFormat(" this.proLoad.ProgressType = DevComponents.DotNetBar.eProgressItemType.Marquee; \r\n"); sbClass.AppendFormat(" this.proLoad.Size = new System.Drawing.Size(231, 23); \r\n"); sbClass.AppendFormat(" this.proLoad.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.proLoad.TabIndex = 7; \r\n"); sbClass.AppendFormat(" this.proLoad.Text = \"Đang xử lý...\"; \r\n"); sbClass.AppendFormat(" this.proLoad.TextVisible = true; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // btnInAn \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.btnInAn.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; \r\n"); sbClass.AppendFormat(" this.btnInAn.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; \r\n"); sbClass.AppendFormat(" this.btnInAn.Location = new System.Drawing.Point(236, 5); \r\n"); sbClass.AppendFormat(" this.btnInAn.Name = \"btnInAn\"; \r\n"); sbClass.AppendFormat(" this.btnInAn.Size = new System.Drawing.Size(87, 23); \r\n"); sbClass.AppendFormat(" this.btnInAn.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.btnInAn.TabIndex = 3; \r\n"); sbClass.AppendFormat(" this.btnInAn.Text = \"In ấn\"; \r\n"); sbClass.AppendFormat(" this.btnInAn.Click += new System.EventHandler(this.btnInAn_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // frm{0}list\r\n",table.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.ClientSize = new System.Drawing.Size(784, 565); \r\n"); sbClass.AppendFormat(" this.Controls.Add(this.menuPhimTat); \r\n"); sbClass.AppendFormat(" this.MainMenuStrip = this.menuPhimTat; \r\n"); sbClass.AppendFormat(" this.Name = \"frm{0}list\";\r\n",table.Name); sbClass.AppendFormat(" this.Text = \"Danh sách {0}\";\r\n", table.Name); sbClass.AppendFormat(" this.WindowState = System.Windows.Forms.FormWindowState.Maximized; \r\n"); sbClass.AppendFormat(" this.Load += new System.EventHandler(this.frm{0}list_Load);\r\n", table.Name); sbClass.AppendFormat(" this.Controls.SetChildIndex(this.menuPhimTat, 0); \r\n"); sbClass.AppendFormat(" this.Controls.SetChildIndex(this.TITLE, 0); \r\n"); sbClass.AppendFormat(" this.Controls.SetChildIndex(this.pBOTTOM, 0); \r\n"); sbClass.AppendFormat(" this.Controls.SetChildIndex(this.CONTENT, 0); \r\n"); sbClass.AppendFormat(" this.CONTENT.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.mnuChuotPhai.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.PerformLayout(); \r\n"); sbClass.AppendFormat(" ((System.ComponentModel.ISupportInitialize)(this.bsList)).EndInit(); \r\n"); sbClass.AppendFormat(" this.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.PerformLayout(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" #endregion \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private Controls.GroupPanel gLocDuLieu; \r\n"); sbClass.AppendFormat(" private tGrid gList; \r\n"); sbClass.AppendFormat(" private ButtonX btnThemMoi; \r\n"); sbClass.AppendFormat(" private ButtonX btnXemChiTiet; \r\n"); sbClass.AppendFormat(" private ButtonX btnThoat; \r\n"); sbClass.AppendFormat(" private LabelX lblPhimTat; \r\n"); sbClass.AppendFormat(" private System.ComponentModel.BackgroundWorker bwLoadData; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.MenuStrip menuPhimTat; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_XemChiTiet; \r\n"); sbClass.AppendFormat(" private Controls.ProgressBarX proLoad; \r\n"); foreach (DBField fi in table.Fields) { sbClass.AppendFormat(" private tTextBox txt{0};\r\n",fi.Name); } sbClass.AppendFormat(" private System.Windows.Forms.BindingSource bsList; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ContextMenuStrip mnuChuotPhai; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_XemChiTiet; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_CopyDong; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_XoaDong; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_XoaHet; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_XuatExcel; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_CopyDong; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_XoaDong; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_XoaHet; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_Excel; \r\n"); sbClass.AppendFormat(" private ButtonX btnInAn; \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); return sbClass; }
public StringBuilder CreateClassControler_EditList(DBTable table) { StringBuilder sbClass = new StringBuilder(); sbClass.AppendFormat("using DevComponents.DotNetBar.SuperGrid; \r\n"); sbClass.AppendFormat("using DevComponents.DotNetBar; \r\n"); sbClass.AppendFormat("using DevComponents.DotNetBar.Controls; \r\n"); sbClass.AppendFormat("using System; \r\n"); sbClass.AppendFormat("using System.Collections.Generic; \r\n"); sbClass.AppendFormat("using System.ComponentModel; \r\n"); sbClass.AppendFormat("using System.Data; \r\n"); sbClass.AppendFormat("using System.Drawing; \r\n"); sbClass.AppendFormat("using System.Text; \r\n"); sbClass.AppendFormat("using System.Windows.Forms; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat("namespace {0}\r\n", txtNameSpace.Text); sbClass.Append("{ \r\n"); sbClass.AppendFormat(" public partial class frm{0}_EditList : tForm\r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" private DataTable DATA = default(DataTable); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" public frm{0}_EditList()\r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" InitializeComponent(); \r\n"); sbClass.AppendFormat(" proLoad.SendToBack(); \r\n"); sbClass.AppendFormat(" Control.CheckForIllegalCrossThreadCalls = false; \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void frm{0}list_Load(object sender, EventArgs e)\r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bwLoadData.IsBusy == false) bwLoadData.RunWorkerAsync(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" proLoad.BringToFront(); \r\n"); sbClass.AppendFormat(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" this.DATA = mainDB.{0}s.GetList(\"\");\r\n", table.Name); sbClass.AppendFormat(" //System.Threading.Thread.Sleep(1000); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void bwLoadData_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)\r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" bsList.DataSource = this.DATA; \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.DataSource = bsList; \r\n"); sbClass.AppendFormat(" proLoad.SendToBack(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_XemChiTiet_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" btnXemChiTiet.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnXemChiTiet_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (gList.PrimaryGrid.DataSource == null) return; \r\n"); sbClass.AppendFormat(" if (gList.PrimaryGrid.SelectedRows == null) return; \r\n"); sbClass.AppendFormat(" if (gList.PrimaryGrid.GetSelectedRows().Count < 1) return; \r\n"); sbClass.AppendFormat(" GridElement ele = gList.PrimaryGrid.GetSelectedRows()[0]; \r\n"); sbClass.AppendFormat(" GridRow currentRow = ele as GridRow; \r\n"); sbClass.AppendFormat(" if (currentRow == null) return; \r\n"); string strKeyName = ""; foreach (DBField fi in table.Fields) { if (fi.IsKey == false) continue; sbClass.AppendFormat(" GridCell cellID = currentRow[\"{0}\"];\r\n", fi.Name); strKeyName = fi.Name; break; } sbClass.AppendFormat(" int currentID = -1; \r\n"); sbClass.AppendFormat(" currentID = Convert.ToInt32(cellID.Value); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" frm{0} f = new frm{0}(currentID);\r\n", table.Name); sbClass.AppendFormat(" if (f.IsDisposed == false) st.myMDIMain.LoadFormF(f, false); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnThoat_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" this.Close(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void gList_CellDoubleClick(object sender, GridCellDoubleClickEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" btnXemChiTiet.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void gList_RowHeaderClick(object sender, GridRowHeaderClickEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (e.GridRow == null) return; \r\n"); sbClass.AppendFormat(" btnXemChiTiet.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void txtFilter_TextChanged(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" tTextBox txt = sender as tTextBox; \r\n"); sbClass.AppendFormat(" if(txt==null) return; \r\n"); sbClass.Append(" bsList.Filter = string.Format(\"{0} LIKE '%{1}%'\", txt.Tag, txt.Text); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_CopyDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bsList.Current == null) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.FlushActiveRow(); \r\n"); sbClass.AppendFormat(" gList.CopyRow(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" ThemDuLieu(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_XoaDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bsList.Current == null) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.FlushActiveRow(); \r\n"); sbClass.AppendFormat(" gList.DeleteCurrentRow(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" XoaDuLieu(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_XoaHet_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (this.DATA == null) return; \r\n"); sbClass.AppendFormat(" if (this.DATA == default(DataTable)) return; \r\n"); sbClass.AppendFormat(" if (this.DATA.Rows.Count < 1) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.FlushActiveRow(); \r\n"); sbClass.AppendFormat(" gList.DeleteAllRow(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" XoaDuLieu(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void XoaDuLieu() \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (this.DATA == default(DataTable)) return; \r\n"); sbClass.AppendFormat(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" //Xử lý xóa \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.PurgeDeletedRows(); \r\n"); sbClass.AppendFormat(" DataTable delTable = this.DATA.GetChanges(DataRowState.Deleted); \r\n"); sbClass.AppendFormat(" if (delTable != null && delTable.Rows.Count > 0) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" delTable = clsAll.DataTableOriginal(delTable); \r\n"); sbClass.AppendFormat(" List<{0}> delObj = clsAll.DataTable2ListObjects<{0}>(delTable);\r\n", table.Name); sbClass.AppendFormat(" mainDB.{0}s.DeleteAllOnSubmit(delObj);\r\n", table.Name); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" mainDB.SubmitAllChange(); \r\n"); sbClass.AppendFormat(" this.DATA.AcceptChanges(); \r\n"); sbClass.AppendFormat(" this.tShow1(\"Xóa thành công\"); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void ThemDuLieu() \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (this.DATA == default(DataTable)) return; \r\n"); sbClass.AppendFormat(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" //Xử lý thêm mới \r\n"); sbClass.AppendFormat(" DataTable addedTable = this.DATA.GetChanges(DataRowState.Added); \r\n"); sbClass.AppendFormat(" if (addedTable != null && addedTable.Rows.Count > 0) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" string strMaxKey = mainDB.{0}s.Max(\"{1}\");\r\n", table.Name, strKeyName); sbClass.AppendFormat(" if (string.IsNullOrEmpty(strMaxKey) == true) strMaxKey = \"0\"; \r\n"); sbClass.AppendFormat(" int intMaxKey = Convert.ToInt32(strMaxKey); \r\n"); sbClass.AppendFormat(" foreach (DataRow r in addedTable.Rows) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" r[\"{0}\"] = ++intMaxKey;\r\n", strKeyName); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" List<{0}> addObj = clsAll.DataTable2ListObjects<{0}>(addedTable);\r\n", table.Name); sbClass.AppendFormat(" mainDB.{0}s.InsertAllOnSubmit(addObj);\r\n", table.Name); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" mainDB.SubmitAllChange(); \r\n"); sbClass.AppendFormat(" this.DATA.AcceptChanges(); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_Excel_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (this.DATA == null) return; \r\n"); sbClass.AppendFormat(" if (this.DATA == default(DataTable)) return; \r\n"); sbClass.AppendFormat(" if (this.DATA.Rows.Count < 1) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.ExportExcel(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XemChiTiet_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_XemChiTiet.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_CopyDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_CopyDong.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XoaDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_XoaDong.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XoaHet_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_XoaHet.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XuatExcel_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_Excel.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnThemMoi_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" frm{0} f = new frm{0}();\r\n", table.Name); sbClass.AppendFormat(" f.Tag = this; \r\n"); sbClass.AppendFormat(" if (f.IsDisposed == false) st.myMDIMain.LoadFormF(f,false); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" public void OnDataChanged() \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bwLoadData.IsBusy == false) bwLoadData.RunWorkerAsync(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnInAn_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.Append("}\r\n"); return sbClass; }
private void PopulateTables() { OleDbConnection con = null; SqlConnection conSQL = null; SQLiteConnection conSQLite = null; OracleConnection conOracle = null; if (rdbAccess.Checked) { con = OpenOleConnection(txtFileName.Text); if (con == null) return; } else if (rdbSQL.Checked) { conSQL = OpenSQLConnection(); if (conSQL == null) return; } else if (rdbSQLite.Checked) { conSQLite = OpenSQLiteConnection(txtFileName.Text); if (conSQLite == null) return; } else if (rdbOracle.Checked) { conOracle = OpenOracleConnection(); if (conOracle == null) return; } try { DataTable schemaTable = null; DataRow[] schemaRows = null; string user=""; if (rdbAccess.Checked) { schemaTable = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, null }); schemaRows = schemaTable.Select("1 = 1", "TABLE_TYPE, TABLE_NAME"); } else if (rdbSQL.Checked) { schemaTable = conSQL.GetSchema("Tables"); schemaRows = schemaTable.Select("1 = 1", "TABLE_TYPE, TABLE_NAME"); } else if (rdbSQLite.Checked) { schemaTable = conSQLite.GetSchema("Tables"); schemaRows = schemaTable.Select("1 = 1", "TABLE_TYPE, TABLE_NAME"); } else if (rdbOracle.Checked) { schemaTable = conOracle.GetSchema("Tables"); int i1 = conOracle.ConnectionString.IndexOf("User Id=") + 8; int i2 = conOracle.ConnectionString.IndexOf(";") ; int l = i2 - i1; user = conOracle.ConnectionString.Substring(i1, l); schemaRows = schemaTable.Select(string.Format("OWNER = '{0}'",user), "TYPE, TABLE_NAME"); //foreach (DataRow r in schemaTable.Rows) //{ // if( r[""] //} } if (rdbAccess.Checked || rdbSQL.Checked || rdbSQLite.Checked) { #region Xử lý cho access, SQL, SQLite foreach (DataRow row in schemaRows) { DBTable table = new DBTable(); table.Name = row["TABLE_NAME"].ToString(); table.Type = row["TABLE_TYPE"].ToString().Replace("BASE ", string.Empty); table.IsView = "VIEW".Equals(table.Type, StringComparison.CurrentCultureIgnoreCase); // table.IsFull = chkIsFull.Checked; bool IsTable = table.Type.Equals("TABLE", StringComparison.CurrentCultureIgnoreCase); if (IsTable || table.IsView) { if (!(bsTables.Contains(table) || bsClasses.Contains(table))) bsTables.Add(table); string[] objTable; string[] objKeys; objTable = new string[] { null, null, table.Name, null }; objKeys = new string[] { null, null, table.Name }; DataTable tableSchema = null; if (rdbAccess.Checked) tableSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Columns, objTable); else if (rdbSQL.Checked) tableSchema = clsDalADO.GetTableSchema(table.Name, conSQL); else tableSchema = clsDalADOLite.GetTableSchema(table.Name); List<string> htKeys = new List<string>(); if (IsTable) { if (rdbAccess.Checked) { DataTable tableKey = null; tableKey = con.GetOleDbSchemaTable(OleDbSchemaGuid.Primary_Keys, objKeys); foreach (DataRow fieldrow in tableKey.Rows) { htKeys.Add(fieldrow["COLUMN_NAME"].ToString()); } } else if (rdbSQL.Checked) { DataRow[] drs = tableSchema.Select("ISPK=1", "ORDINAL_POSITION ASC"); foreach (DataRow fieldrow in drs) { htKeys.Add(fieldrow["COLUMN_NAME"].ToString()); } } else { //tableKey = conSQLite.GetSchema("ForeignKeys", objKeys); } } foreach (DataRow fieldrow in tableSchema.Select("1 = 1", "ORDINAL_POSITION ASC")) { DBField Field = new DBField(); Field.Name = fieldrow["COLUMN_NAME"].ToString(); Field.DBType = fieldrow["DATA_TYPE"].ToString(); Field.IsNullAble = clsAll.ConvertToBool(fieldrow["IS_NULLABLE"].ToString()); ; //TuyenHM: Chỉnh sửa, vẫn phải sử dụng kiểu bit cho phép null //if (Field.DBType == "bit") // Field.IsNullAble = false; if (rdbAccess.Checked) Field.DBTypeName = clsDalOLE.GetOleDbType(Field.DBType).ToString(); else if (rdbSQL.Checked) Field.DBTypeName = clsDalADO.GetSqlDbType(Field.DBType).ToString(); else if (rdbSQLite.Checked) Field.DBTypeName = clsDalADOLite.GetDbType(Field.DBType).ToString(); Field.MaxLength = fieldrow["CHARACTER_MAXIMUM_LENGTH"].ToString(); Field.Type = GetFieldTypeName(Field.DBType, Field.IsNullAble, Field.MaxLength); Field.HasDefault = clsAll.ConvertToBool(fieldrow["COLUMN_HASDEFAULT"].ToString()); Field.Default = fieldrow["COLUMN_DEFAULT"].ToString().Replace("(", string.Empty).Replace(")", string.Empty).Replace("N'", string.Empty).Replace("'", string.Empty); if ((Field.DBType == "11" || Field.DBType == "bit") && Field.HasDefault) Field.Default = clsAll.ConvertToBool(Field.Default).ToString().ToLower(); Field.Description = fieldrow["DESCRIPTION"].ToString(); if (rdbAccess.Checked) { Field.IsAuto = false; //(Field.OleType == 3 && Field.OleFlag == 122); } else { Field.IsAuto = clsAll.ConvertToBool(fieldrow["ISIDENTITY"].ToString()); if (!Field.IsAuto) Field.IsAuto = clsAll.ConvertToBool(fieldrow["ISCOMPUTED"].ToString()); } if (IsTable) Field.IsKey = htKeys.Contains(Field.Name); else Field.IsKey = false; table.AddField(Field); } } } #endregion } else { #region Xử lý cho Oracle foreach (DataRow row in schemaRows) { //BỎ QUA NHỮNG TABLE CỦA HỆ THỐNG if (row["TABLE_NAME"].ToString().IndexOf("$")>-1) continue; DBTable table = new DBTable(); table.Name = row["TABLE_NAME"].ToString(); table.Type = row["TYPE"].ToString().Replace("BASE ", string.Empty); table.IsView = "VIEW".Equals(table.Type, StringComparison.CurrentCultureIgnoreCase); //table.IsFull = chkIsFull.Checked; bool IsTable = table.Type.Equals("USER", StringComparison.CurrentCultureIgnoreCase); if (IsTable || table.IsView) { if (!(bsTables.Contains(table) || bsClasses.Contains(table))) bsTables.Add(table); string[] objTable; string[] objKeys; objTable = new string[] { null, null, table.Name, null }; objKeys = new string[] { null, null, table.Name }; DataTable tableSchema = null; if (rdbOracle.Checked) tableSchema = clsDalORACLE.GetTableSchema(table.Name,user, conOracle); List<string> htKeys = new List<string>(); if (IsTable) { if (rdbOracle.Checked) { DataRow[] drs = tableSchema.Select("ISPK=1", "ORDINAL_POSITION ASC"); foreach (DataRow fieldrow in drs) { htKeys.Add(fieldrow["COLUMN_NAME"].ToString()); } } else { //tableKey = conSQLite.GetSchema("ForeignKeys", objKeys); } } foreach (DataRow fieldrow in tableSchema.Select("1 = 1", "ORDINAL_POSITION ASC")) { DBField Field = new DBField(); Field.Name = fieldrow["COLUMN_NAME"].ToString(); Field.DBType = fieldrow["DATA_TYPE"].ToString(); Field.IsNullAble = clsAll.ConvertToBool(fieldrow["IS_NULLABLE"].ToString()); ; //TuyenHM: Chỉnh sửa, vẫn phải sử dụng kiểu bit cho phép null //if (Field.DBType == "bit") // Field.IsNullAble = false; if (rdbOracle.Checked) Field.DBTypeName = clsDalORACLE.GetOracleType(Field.DBType).ToString(); Field.MaxLength = fieldrow["CHARACTER_MAXIMUM_LENGTH"].ToString(); Field.Type = GetFieldTypeName(Field.DBType, Field.IsNullAble, Field.MaxLength); Field.HasDefault = clsAll.ConvertToBool(fieldrow["COLUMN_HASDEFAULT"].ToString()); Field.Default = fieldrow["COLUMN_DEFAULT"].ToString().Replace("(", string.Empty).Replace(")", string.Empty).Replace("N'", string.Empty).Replace("'", string.Empty); if ((Field.DBType == "11" || Field.DBType == "bit") && Field.HasDefault) Field.Default = clsAll.ConvertToBool(Field.Default).ToString().ToLower(); Field.Description = fieldrow["DESCRIPTION"].ToString(); //if (rdbAccess.Checked) //{ // Field.IsAuto = false; //(Field.OleType == 3 && Field.OleFlag == 122); //} //else //{ // Field.IsAuto = clsAll.ConvertToBool(fieldrow["ISIDENTITY"].ToString()); // if (!Field.IsAuto) Field.IsAuto = clsAll.ConvertToBool(fieldrow["ISCOMPUTED"].ToString()); //} //TUYENHM //CHƯA CHƠI ĐƯỢC TỰ TĂNG VỚI ORACLE Field.IsAuto = false; if (IsTable) Field.IsKey = htKeys.Contains(Field.Name); else Field.IsKey = false; table.AddField(Field); } } } #endregion } //if (rdbSQL.Checked) // PopulateSPs(conSQL); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { if (con != null) con.Close(); if (conSQL != null) conSQL.Close(); if (conSQLite != null) conSQLite.Close(); if (conOracle != null) conOracle.Close(); } }
private void PopulateSPs(SqlConnection conSQL) { DataTable tableSchema = null; tableSchema = clsDalADO.GetSPParams(conSQL); DBTable sp = null; string SPName = string.Empty; foreach (DataRow fieldrow in tableSchema.Rows) { string spN = fieldrow["SPECIFIC_NAME"].ToString(); if (!spN.Equals(SPName, StringComparison.CurrentCultureIgnoreCase)) { if (sp != null) GetSPSchema(conSQL, sp); SPName = spN; sp = new DBTable(); sp.Name = SPName; sp.Type = "SP"; sp.IsView = false; sp.IsSP = true; // sp.IsFull = chkIsFull.Checked; if (!(bsTables.Contains(sp) || bsClasses.Contains(sp))) bsTables.Add(sp); } DBField Param = new DBField(); Param.Name = fieldrow["PARAMETER_NAME"].ToString().Replace("@", string.Empty); Param.IsNullAble = true; Param.DBType = fieldrow["DATA_TYPE"].ToString(); Param.DBTypeName = clsDalADO.GetSqlDbType(Param.DBType).ToString(); Param.Mode = fieldrow["PARAMETER_MODE"].ToString(); Param.MaxLength = fieldrow["CHARACTER_MAXIMUM_LENGTH"].ToString(); Param.Type = GetFieldTypeName(Param.DBType, Param.IsNullAble, Param.MaxLength); sp.AddParam(Param); } if (sp != null) GetSPSchema(conSQL, sp); }
private void GetSPSchema(SqlConnection conSQL, DBTable sp) { List<IDbDataParameter> lstParam=new List<IDbDataParameter>(); foreach (DBField f in sp.Params) { ParameterDirection drt = ParameterDirection.Input; switch (f.Mode.ToUpper()) { case "IN": drt = ParameterDirection.Input; break; case "OUT": drt = ParameterDirection.Output; break; case "INOUT": drt = ParameterDirection.InputOutput; break; } IDbDataParameter param = clsDalADO.CreateParameter(f.Name, f.DBTypeName, DBNull.Value, drt); lstParam.Add(param); } DataTable dtShema = clsDalADO.GetSPSchema(sp.Name, conSQL, lstParam); if (dtShema != null && dtShema.Rows.Count > 0) { foreach (DataRow fieldrow in dtShema.Rows) { DBField field = new DBField(); field.Name = fieldrow["ColumnName"].ToString(); field.IsNullAble = true; field.DBType = fieldrow["DataTypeName"].ToString(); field.DBTypeName = clsDalADO.GetSqlDbType(field.DBType).ToString(); field.MaxLength = fieldrow["ColumnSize"].ToString(); field.Type = GetFieldTypeName(field.DBType, field.IsNullAble, field.MaxLength); sp.AddField(field); } } }
public StringBuilder CreateClassControlerType2(DBTable table) { StringBuilder sbClass = new StringBuilder(); sbClass.AppendFormat("using DevComponents.DotNetBar.SuperGrid; \r\n"); sbClass.AppendFormat("using System; \r\n"); sbClass.AppendFormat("using System.Collections.Generic; \r\n"); sbClass.AppendFormat("using System.ComponentModel; \r\n"); sbClass.AppendFormat("using System.Data; \r\n"); sbClass.AppendFormat("using System.Drawing; \r\n"); sbClass.AppendFormat("using System.Text; \r\n"); sbClass.AppendFormat("using System.Windows.Forms; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat("namespace {0}\r\n", txtNameSpace.Text); sbClass.Append("{ \r\n"); sbClass.AppendFormat(" public partial class frm{0}list : tForm\r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" private DataTable DATA = default(DataTable); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" public frm{0}list()\r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" InitializeComponent(); \r\n"); sbClass.AppendFormat(" proLoad.SendToBack();\r\n"); sbClass.AppendFormat(" Control.CheckForIllegalCrossThreadCalls = false; \r\n"); sbClass.AppendFormat(" LoadDanhMuc();\r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" private void LoadDanhMuc() \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void frm{0}list_Load(object sender, EventArgs e)\r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bwLoadData.IsBusy == false) bwLoadData.RunWorkerAsync(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" proLoad.BringToFront(); \r\n"); sbClass.AppendFormat(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" this.DATA = mainDB.{0}s.GetList(\"\");\r\n", table.Name); sbClass.AppendFormat(" //System.Threading.Thread.Sleep(1000); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void bwLoadData_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)\r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" bsList.DataSource = this.DATA; \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.DataSource = bsList; \r\n"); sbClass.AppendFormat(" proLoad.SendToBack(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_GhiDuLieu_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" btnGhiDuLieu.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnGhiDuLieu_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" try\r\n"); sbClass.Append(" {\r\n"); sbClass.Append(" GhiDuLieu();\r\n"); sbClass.Append(" }\r\n"); sbClass.Append(" catch (Exception ex)\r\n"); sbClass.Append(" {\r\n"); sbClass.Append(" clsMx.Show(ex, this.Name);\r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" private void GhiDuLieu()\r\n"); sbClass.Append(" {\r\n"); sbClass.Append(" gList.PrimaryGrid.FlushActiveRow();\r\n"); sbClass.Append(" if (this.DATA == default(DataTable)) return;\r\n"); sbClass.Append(" using (tDBContext mainDB = new tDBContext())\r\n"); sbClass.Append(" {\r\n"); sbClass.Append(" //Xử lý xóa\r\n"); sbClass.Append(" gList.PrimaryGrid.PurgeDeletedRows();\r\n"); sbClass.Append(" DataTable delTable = this.DATA.GetChanges(DataRowState.Deleted);\r\n"); sbClass.Append(" if (delTable != null && delTable.Rows.Count > 0)\r\n"); sbClass.Append(" {\r\n"); sbClass.Append(" delTable = clsAll.DataTableOriginal(delTable);\r\n"); sbClass.AppendFormat(" List<{0}> delObj = clsAll.DataTable2ListObjects<{0}>(delTable);\r\n", table.Name); sbClass.AppendFormat(" mainDB.{0}s.DeleteAllOnSubmit(delObj);",table.Name); sbClass.Append(" }\r\n"); sbClass.Append(" \r\n"); sbClass.Append(" //Xử lý thêm mới\r\n"); sbClass.Append(" DataTable addedTable = this.DATA.GetChanges(DataRowState.Added);\r\n"); sbClass.Append(" if (addedTable != null && addedTable.Rows.Count > 0)\r\n"); sbClass.Append(" {\r\n"); sbClass.AppendFormat(" List<{0}> addObj = clsAll.DataTable2ListObjects<{0}>(addedTable);\r\n",table.Name); sbClass.AppendFormat(" mainDB.{0}s.InsertAllOnSubmit(addObj);",table.Name); sbClass.Append(" }\r\n"); sbClass.Append(" \r\n"); sbClass.Append(" //Xử lý sửa\r\n"); sbClass.Append(" DataTable modifiedTable = this.DATA.GetChanges(DataRowState.Modified);\r\n"); sbClass.Append(" if (modifiedTable != null && modifiedTable.Rows.Count > 0)\r\n"); sbClass.Append(" {\r\n"); sbClass.AppendFormat(" List<{0}> changeObj = clsAll.DataTable2ListObjects<{0}>(modifiedTable);\r\n",table.Name); sbClass.AppendFormat(" mainDB.{0}s.UpdateAllOnSubmit(changeObj);",table.Name); sbClass.Append(" }\r\n"); sbClass.Append(" \r\n"); sbClass.Append(" mainDB.SubmitAllChange();\r\n"); sbClass.Append(" this.DATA.AcceptChanges();\r\n"); sbClass.Append(" }\r\n"); sbClass.Append(" \r\n"); sbClass.Append(" this.tShow1(\"Ghi thành công\");\r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnThoat_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" this.Close(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void gList_CellDoubleClick(object sender, GridCellDoubleClickEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void gList_RowHeaderClick(object sender, GridRowHeaderClickEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (e.GridRow == null) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void txtFilter_TextChanged(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" tTextBox txt = sender as tTextBox; \r\n"); sbClass.AppendFormat(" if(txt==null) return; \r\n"); sbClass.Append(" bsList.Filter = string.Format(\"{0} LIKE '%{1}%'\", txt.Tag, txt.Text); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_CopyDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bsList.Current == null) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.FlushActiveRow(); \r\n"); sbClass.AppendFormat(" gList.CopyRow(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_XoaDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bsList.Current == null) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.FlushActiveRow(); \r\n"); sbClass.AppendFormat(" gList.DeleteCurrentRow(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_XoaHet_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (this.DATA == null) return; \r\n"); sbClass.AppendFormat(" if (this.DATA == default(DataTable)) return; \r\n"); sbClass.AppendFormat(" if (this.DATA.Rows.Count < 1) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.FlushActiveRow(); \r\n"); sbClass.AppendFormat(" gList.DeleteAllRow(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_Excel_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (this.DATA == null) return; \r\n"); sbClass.AppendFormat(" if (this.DATA == default(DataTable)) return; \r\n"); sbClass.AppendFormat(" if (this.DATA.Rows.Count < 1) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.ExportExcel(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_GhiDuLieu_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_GhiDuLieu.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_CopyDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_CopyDong.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XoaDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_XoaDong.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XoaHet_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_XoaHet.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XuatExcel_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_Excel.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" public void OnDataChanged() \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bwLoadData.IsBusy == false) bwLoadData.RunWorkerAsync(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnInAn_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.Append("}\r\n"); return sbClass; }
private void btnGenFormChiTiet2bang_Click(object sender, EventArgs e) { if (bsClasses.Count == 0) { MessageBox.Show("Chọn bảng cần tạo!"); return; } txtDBName.Text = txtDBName.Text.Trim(); txtNameSpace.Text = txtNameSpace.Text.Trim(); if (string.IsNullOrEmpty(txtDBName.Text)) { MessageBox.Show("Phải nhập [Tên Base]!"); txtDBName.Focus(); return; } if (string.IsNullOrEmpty(txtOutputDir.Text)) { MessageBox.Show("Phải chọn thư mục!"); btnDirBrowser.Focus(); return; } if (!Directory.Exists(txtOutputDir.Text)) { try { Directory.CreateDirectory(txtOutputDir.Text); } catch { MessageBox.Show(string.Format("Không tạo được thư mục [{0}]!", txtOutputDir.Text)); btnDirBrowser.Focus(); return; } } DBTable[] arr = new DBTable[3]; int ii = 0; foreach (object key in bsClasses.List) { DBTable tbl = key as DBTable; arr.SetValue(tbl, ii); ++ii; } CreateFile(string.Format("frm{0}", arr[0].Name), CreateClassControlerFormChiTiet(arr[0], arr[1], null)); CreateFile(string.Format("frm{0}.Designer", arr[0].Name), CreateClassDesignerFormChiTiet(arr[0], arr[1], null)); try { clsAll.SetRegValue("OUTPUT_DIR_FORM", txtOutputDir.Text); clsAll.SetRegValue("OUTPUT_NAMESPACE_FORM", txtNameSpace.Text); clsAll.SetRegValue("OUTPUT_CONTEXTNAME_FORM", txtDBName.Text); } catch { } MessageBox.Show("Đã xong!"); }
public StringBuilder CreateCSFormChiTiet1Bang(DBTable table) { StringBuilder sbClass = new StringBuilder(); sbClass.Append(" using System; \r\n"); sbClass.Append(" using System.Collections.Generic; \r\n"); sbClass.Append(" using System.Globalization; \r\n"); sbClass.Append(" using System.Linq; \r\n"); sbClass.Append(" using System.Web; \r\n"); sbClass.Append(" using System.Web.UI; \r\n"); sbClass.Append(" using System.Web.UI.WebControls; \r\n"); sbClass.Append(" using mojoPortal.Web.Framework; \r\n"); sbClass.Append(" using t; \r\n"); sbClass.Append(" \r\n"); sbClass.Append(" namespace mojoPortal.Web.Modules \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" public partial class {0}_ADDEDIT : SiteModuleControl \r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.Append(" protected override void OnInit(EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" base.OnInit(e); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" \r\n"); sbClass.Append(" protected void Page_Load(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" LoadSettings(); \r\n"); sbClass.Append(" PopulateLabels(); \r\n"); sbClass.Append(" if (!Page.IsPostBack) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" PopulateControls(); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" if(Page.IsPostBack==false) LoadData(); \r\n"); sbClass.Append(" } \r\n"); DBField fKey = default(DBField);//chi ho tro 1 key thoi//webform chi the thoi foreach (DBField f in table.Fields) { if (f.IsKey == false) continue; fKey = f; } sbClass.Append(" private void LoadData() \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" int intKEY = WebUtils.ParseInt32FromQueryString(\"{0}\", -1);\r\n", fKey.Name); sbClass.AppendFormat(" if (intKEY < 0) return; \r\n", fKey.Name); sbClass.AppendFormat(" {0} o = default({0}); \r\n", table.Name); sbClass.Append(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" string strWhere = string.Format(\"{0} ={{0}}\", intKEY); \r\n", fKey.Name); sbClass.AppendFormat(" o = mainDB.{0}s.GetObject(strWhere); \r\n", table.Name); sbClass.Append(" } \r\n"); sbClass.Append(" if (o == null) return; \r\n"); sbClass.Append(" clsAll.BindData(pnlInnerBody, o); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" protected void btnGhi_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" Page.Validate(\"GHIDULIEU\"); \r\n"); sbClass.Append(" if (Page.IsValid == false) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" lblMSG.Text = \"Có một số dữ liệu chưa đúng. Vui lòng xem lại dữ liệu.\"; \r\n"); sbClass.Append(" return; \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" try \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" {0} o = new {0}(); \r\n",table.Name); sbClass.Append(" clsAll.CopyData(pnlInnerBody, o); \r\n"); sbClass.Append(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (o.{0} < 0)//them moi \r\n",fKey.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" string strMaxKey = mainDB.{0}s.Max(\"{1}\"); \r\n",table.Name,fKey.Name); sbClass.Append(" if (string.IsNullOrEmpty(strMaxKey) == true) strMaxKey = \"0\"; \r\n"); sbClass.Append(" int intMaxKey = Convert.ToInt32(strMaxKey) + 1; \r\n"); sbClass.AppendFormat(" o.{0} = intMaxKey; \r\n",fKey.Name); sbClass.Append(" o.DataStatus = DBStatus.Inserted; \r\n"); sbClass.AppendFormat(" mainDB.{0}s.InsertOnSubmit(o); \r\n",table.Name); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" else//o.{0} >= 0 update \r\n",fKey.Name); sbClass.Append(" { \r\n"); sbClass.Append(" o.DataStatus = DBStatus.Updated; \r\n"); sbClass.AppendFormat(" mainDB.{0}s.UpdateOnSubmit(o); \r\n",table.Name); sbClass.Append(" } \r\n"); sbClass.Append(" mainDB.SubmitAllChange(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" {0}.Text = string.Format(\"{{0}}\",o.{0}); \r\n",fKey.Name); sbClass.Append(" lblMSG.Text = string.Format(\"Ghi thành công lúc: {0}h{1} {2}giây\",DateTime.Now.Hour,DateTime.Now.Minute,DateTime.Now.Second); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" catch (Exception ex) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" lblMSG.Text = string.Format(\"Xảy ra lỗi: {0}\",ex.Message); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" private void PopulateControls() \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" private void PopulateLabels() \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" lblMSG.Text = \"\"; \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" private void LoadSettings() \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" // TODO: if your feature has an edit page link to it here \r\n"); sbClass.Append(" Title1.Visible = !this.RenderInWebPartMode; \r\n"); sbClass.Append(" if (this.ModuleConfiguration != null) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" this.Title = this.ModuleConfiguration.ModuleTitle; \r\n"); sbClass.Append(" this.Description = this.ModuleConfiguration.FeatureName; \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); return sbClass; }
public StringBuilder CreateDesignCSFormChiTiet1Bang(DBTable table) { StringBuilder sbClass = new StringBuilder(); sbClass.Append(" namespace mojoPortal.Web.Modules \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" public partial class {0}_ADDEDIT : SiteModuleControl \r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.Append("protected global::mojoPortal.Web.UI.OuterWrapperPanel pnlOuterWrap;\r\n"); sbClass.Append("protected global::mojoPortal.Web.Controls.CornerRounderTop ctop1;\r\n"); sbClass.Append("protected global::mojoPortal.Web.UI.InnerWrapperPanel pnlInnerWrap;\r\n"); sbClass.Append("protected global::System.Web.UI.UpdatePanel upGallery;\r\n"); sbClass.Append("protected global::mojoPortal.Web.UI.ModuleTitleControl Title1;\r\n"); sbClass.Append("protected global::mojoPortal.Web.UI.OuterBodyPanel pnlOuterBody;\r\n"); sbClass.Append("protected global::mojoPortal.Web.UI.InnerBodyPanel pnlInnerBody;\r\n"); //foreach (DBField f in table.Fields) //{ // sbClass.AppendFormat("protected global::mojoPortal.Web.UI.mojoLabel lbl{0};\r\n", f.Name); // sbClass.AppendFormat("protected global::mojoPortal.Web.UI.mojoLabel {0};\r\n", f.Name); //} sbClass.Append("protected global::System.Web.UI.WebControls.HyperLink linkTroLaiDanhSach;\r\n"); sbClass.Append("protected global::mojoPortal.Web.UI.EmptyPanel divCleared;\r\n"); sbClass.Append("protected global::mojoPortal.Web.Controls.CornerRounderBottom cbottom1;\r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); return sbClass; }
public StringBuilder CreateCSChiTiet1Bang(DBTable table) { StringBuilder sbClass = new StringBuilder(); sbClass.Append(" using System; \r\n"); sbClass.Append(" using System.Collections.Generic; \r\n"); sbClass.Append(" using System.Globalization; \r\n"); sbClass.Append(" using System.Linq; \r\n"); sbClass.Append(" using System.Web; \r\n"); sbClass.Append(" using System.Web.UI; \r\n"); sbClass.Append(" using System.Web.UI.WebControls; \r\n"); sbClass.Append(" using mojoPortal.Web.Framework; \r\n"); sbClass.Append(" using t; \r\n"); sbClass.Append(" \r\n"); sbClass.Append(" namespace mojoPortal.Web.Modules \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" public partial class {0}_VIEW : SiteModuleControl \r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.Append(" protected override void OnInit(EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" base.OnInit(e); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" \r\n"); sbClass.Append(" protected void Page_Load(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" LoadSettings(); \r\n"); sbClass.Append(" PopulateLabels(); \r\n"); sbClass.Append(" if (!Page.IsPostBack) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" PopulateControls(); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" if(Page.IsPostBack==false) LoadData(); \r\n"); sbClass.Append(" } \r\n"); DBField fKey=default(DBField);//chi ho tro 1 key thoi//webform chi the thoi foreach (DBField f in table.Fields) { if (f.IsKey == false) continue; fKey = f; } sbClass.Append(" private void LoadData() \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" int intKEY = WebUtils.ParseInt32FromQueryString(\"{0}\", -1);\r\n",fKey.Name); sbClass.AppendFormat(" if (intKEY < 0) return; \r\n", fKey.Name); sbClass.AppendFormat(" {0} o = default({0}); \r\n", table.Name); sbClass.Append(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" string strWhere = string.Format(\"{0} ={{0}}\", intKEY); \r\n", fKey.Name); sbClass.AppendFormat(" o = mainDB.{0}s.GetObject(strWhere); \r\n", table.Name); sbClass.Append(" } \r\n"); sbClass.Append(" if (o == null) return; \r\n"); sbClass.Append(" clsAll.BindData(pnlInnerBody, o); \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" protected void Button1_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" private void PopulateControls() \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" private void PopulateLabels() \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" private void LoadSettings() \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" // TODO: if your feature has an edit page link to it here \r\n"); sbClass.Append(" Title1.Visible = !this.RenderInWebPartMode; \r\n"); sbClass.Append(" if (this.ModuleConfiguration != null) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" this.Title = this.ModuleConfiguration.ModuleTitle; \r\n"); sbClass.Append(" this.Description = this.ModuleConfiguration.FeatureName; \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); return sbClass; }
public StringBuilder CreateClassControlerFormChiTiet(DBTable table, DBTable table1, DBTable table2) { StringBuilder sbClass = new StringBuilder(); sbClass.AppendFormat(" using DevComponents.DotNetBar; \r\n"); sbClass.AppendFormat(" using DevComponents.DotNetBar.SuperGrid; \r\n"); sbClass.AppendFormat(" using System; \r\n"); sbClass.AppendFormat(" using System.Collections.Generic; \r\n"); sbClass.AppendFormat(" using System.ComponentModel; \r\n"); sbClass.AppendFormat(" using System.Data; \r\n"); sbClass.AppendFormat(" using System.Drawing; \r\n"); sbClass.AppendFormat(" using System.Text; \r\n"); sbClass.AppendFormat(" using System.Windows.Forms; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" namespace {0}\r\n",txtNameSpace.Text); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" public partial class frm{0} : tForm \r\n", table.Name); sbClass.Append(" { \r\n"); if(table1!=null) sbClass.AppendFormat(" private DataTable DATA = default(DataTable); \r\n"); sbClass.AppendFormat(" public frm{0}() \r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" InitializeComponent(); \r\n"); if (table1 != null) { sbClass.AppendFormat(" FormatColumns();\r\n"); sbClass.AppendFormat(" proLoad.SendToBack();\r\n"); } sbClass.AppendFormat(" Control.CheckForIllegalCrossThreadCalls = false;\r\n"); sbClass.AppendFormat(" LoadDanhMuc();\r\n"); sbClass.AppendFormat(" bsChungTu.DataSource = new {0}(); \r\n", table.Name); if (table1 != null) { sbClass.Append(" using (tDBContext mainDB = new tDBContext())\r\n"); sbClass.Append(" {\r\n"); sbClass.AppendFormat(" this.DATA = mainDB.{0}s.GetList(\"1<>1\");\r\n",table1.Name); sbClass.Append(" bsList.DataSource = this.DATA;\r\n"); sbClass.Append(" gList.PrimaryGrid.DataSource = bsList;\r\n"); sbClass.Append(" };\r\n"); } sbClass.AppendFormat(" clsAll.SetBindingSource(this.CONTENT, bsChungTu); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); if (table1 != null) { sbClass.Append(" private void FormatColumns()\r\n"); sbClass.Append(" {\r\n"); foreach (DBField f in table1.Fields) { if (f.IsKey == true) continue; if (f.DBTypeName == "Numeric" || f.DBTypeName == "Single" || f.DBTypeName == "Double") { sbClass.AppendFormat(" ((GridDoubleInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].RenderControl).DisplayFormat = st.DecimalFormat;\r\n",f.Name); sbClass.AppendFormat(" ((GridDoubleInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].EditControl).DisplayFormat = st.DecimalFormat;\r\n", f.Name); //Chỉ hỗ trợ 20.8 (20 số trước dấu phẩy và 8 số lẻ sau dấu phẩy khi là decimal) if (f.DBTypeName == "Numeric") { //sbClass.AppendFormat(" ((GridDoubleInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].EditControl).MaxValue = new decimal(new int[] {{\r\n", f.Name); //sbClass.AppendFormat(" 268435455,\r\n"); //sbClass.AppendFormat(" 1042612833,\r\n"); //sbClass.AppendFormat(" 542101086,\r\n"); //sbClass.Append(" 524288});\r\n"); //sbClass.AppendFormat(" ((GridDoubleInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].EditControl).MinValue = new decimal(new int[] {{\r\n", f.Name); //sbClass.AppendFormat(" 268435455,\r\n"); //sbClass.AppendFormat(" 1042612833,\r\n"); //sbClass.AppendFormat(" 542101086,\r\n"); //sbClass.Append(" -2146959360});\r\n"); sbClass.AppendFormat(" ((GridDoubleInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].EditControl).MaxValue = 100000000000000d;\r\n", f.Name); sbClass.AppendFormat(" ((GridDoubleInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].EditControl).MinValue = -100000000000000d;\r\n", f.Name); } }else if (f.DBTypeName == "SmallInt" || f.DBTypeName == "Integer") { sbClass.AppendFormat(" ((GridIntegerInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].RenderControl).DisplayFormat = st.IntegerFormat;\r\n", f.Name); if (f.DBTypeName == "SmallInt") { sbClass.AppendFormat(" ((GridIntegerInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].EditControl).MaxValue = 32767;\r\n", f.Name); sbClass.AppendFormat(" ((GridIntegerInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].EditControl).MinValue = -32768;\r\n", f.Name); } if (f.DBTypeName == "Integer") { sbClass.AppendFormat(" ((GridIntegerInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].EditControl).MaxValue = 2147483647;\r\n", f.Name); sbClass.AppendFormat(" ((GridIntegerInputEditControl)gList.PrimaryGrid.Columns[\"{0}\"].EditControl).MinValue = -2147483648;\r\n", f.Name); } } } sbClass.Append(" }\r\n"); } sbClass.Append(" private void LoadDanhMuc()"); sbClass.Append(" {\r\n"); sbClass.Append(" \r\n"); sbClass.Append(" }\r\n"); List<DBField> listKey = new List<DBField>(); string strListAcgumentKey = ""; foreach (DBField f in table.Fields) { if (f.IsKey == false) continue; sbClass.AppendFormat(" int {0} = 0;//Bộ key\r\n", f.Name); listKey.Add(f); strListAcgumentKey +=string.Format("int {0},", f.Name) ; } strListAcgumentKey = strListAcgumentKey.Substring(0, strListAcgumentKey.Length - 1);//bỏ dấy phẩy ở cuối cùng sbClass.AppendFormat(" public frm{0}({1}):this()\r\n", table.Name, strListAcgumentKey); sbClass.Append(" { \r\n"); foreach (DBField f in listKey) { sbClass.AppendFormat(" this.{0} = {0};\r\n",f.Name); } sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void frm{0}_Load(object sender, EventArgs e)\r\n", table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" bwLoadData.RunWorkerAsync(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnGhi_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bsChungTu.DataSource == null) return; \r\n"); sbClass.Append(" if (clsAll.ValidateControls(this.CONTENT) == false)\r\n"); sbClass.Append(" {\r\n"); sbClass.Append(" this.tShow1(\"Còn một số chỉ tiêu nhập liệu chưa đúng.\\r\\nVui lòng kiểm tra các ô màu da cam.\");\r\n"); sbClass.Append(" return;\r\n"); sbClass.Append(" }\r\n"); sbClass.AppendFormat(" {0} ct = bsChungTu.DataSource as {0};\r\n", table.Name); sbClass.AppendFormat(" if (ct == null) return; \r\n"); sbClass.AppendFormat(" \r\n"); if (table1 != null) { sbClass.Append(" gList.PrimaryGrid.FlushActiveRow();\r\n"); } sbClass.AppendFormat(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); string strIfListKeyLonHonKhong = ""; foreach (DBField f in listKey) { strIfListKeyLonHonKhong += string.Format("ct.{0}>0 && ", f.Name); } strIfListKeyLonHonKhong = strIfListKeyLonHonKhong.Substring(0, strIfListKeyLonHonKhong.Length - 3);//bỏ && cuối cùng sbClass.AppendFormat(" if ({0})//update data\r\n", strIfListKeyLonHonKhong); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" mainDB.{0}s.UpdateOnSubmit(ct);\r\n", table.Name); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" else \r\n"); sbClass.Append(" { \r\n"); for (int i = 1; i <= listKey.Count; i++) { sbClass.AppendFormat(" string strMaxID{1} = mainDB.{0}s.Max(\"{2}\");\r\n", table.Name,i,listKey[i-1].Name); sbClass.AppendFormat(" if (string.IsNullOrEmpty(strMaxID{0}) == true) strMaxID{0} = \"0\";\r\n",i); sbClass.AppendFormat(" int intMaxID{0} = Convert.ToInt32(strMaxID{0});\r\n",i); sbClass.AppendFormat(" ct.{1} = ++intMaxID{0};\r\n", i, listKey[i - 1].Name); } sbClass.AppendFormat(" mainDB.{0}s.InsertOnSubmit(ct);\r\n", table.Name); sbClass.Append(" } \r\n"); if (table1 != null) { sbClass.Append(" if(this.DATA!=default(DataTable)){\r\n"); sbClass.Append(" //Xử lý xóa\r\n"); sbClass.Append(" gList.PrimaryGrid.PurgeDeletedRows();\r\n"); sbClass.Append(" DataTable delTable = this.DATA.GetChanges(DataRowState.Deleted);\r\n"); sbClass.Append(" if (delTable != null && delTable.Rows.Count > 0)\r\n"); sbClass.Append(" {\r\n"); sbClass.Append(" delTable = clsAll.DataTableOriginal(delTable);\r\n"); sbClass.AppendFormat(" List<{0}> delObj = clsAll.DataTable2ListObjects<{0}>(delTable);\r\n", table1.Name); sbClass.AppendFormat(" mainDB.{0}s.DeleteAllOnSubmit(delObj);", table1.Name); sbClass.Append(" }\r\n"); sbClass.Append(" \r\n"); sbClass.Append(" //Xử lý thêm mới\r\n"); sbClass.Append(" DataTable addedTable = this.DATA.GetChanges(DataRowState.Added);\r\n"); sbClass.Append(" if (addedTable != null && addedTable.Rows.Count > 0)\r\n"); sbClass.Append(" {\r\n"); sbClass.AppendFormat(" List<{0}> addObj = clsAll.DataTable2ListObjects<{0}>(addedTable);\r\n", table1.Name); sbClass.AppendFormat(" string strMaxID2 = mainDB.{0}s.Max(\"HAG_ID\");\r\n",table1.Name); sbClass.AppendFormat(" if (string.IsNullOrEmpty(strMaxID2) == true) strMaxID2 = \"0\";\r\n"); sbClass.AppendFormat(" int intMaxID2 = Convert.ToInt32(strMaxID2);\r\n"); sbClass.AppendFormat(" foreach ({0} h in addObj)\r\n",table1.Name); sbClass.Append(" {\r\n"); foreach (DBField f in table.Fields) { if (f.IsKey == false) continue; sbClass.AppendFormat(" h.{0} = ct.{0};\r\n",f.Name); } sbClass.Append(" h.HAG_ID = ++intMaxID2;\r\n"); sbClass.Append(" }\r\n"); sbClass.AppendFormat(" mainDB.{0}s.InsertAllOnSubmit(addObj);", table1.Name); sbClass.Append(" }\r\n"); sbClass.Append(" \r\n"); sbClass.Append(" //Xử lý sửa\r\n"); sbClass.Append(" DataTable modifiedTable = this.DATA.GetChanges(DataRowState.Modified);\r\n"); sbClass.Append(" if (modifiedTable != null && modifiedTable.Rows.Count > 0)\r\n"); sbClass.Append(" {\r\n"); sbClass.AppendFormat(" List<{0}> changeObj = clsAll.DataTable2ListObjects<{0}>(modifiedTable);\r\n", table1.Name); sbClass.AppendFormat(" mainDB.{0}s.UpdateAllOnSubmit(changeObj);", table1.Name); sbClass.Append(" }\r\n"); sbClass.Append(" }\r\n"); } sbClass.AppendFormat(" mainDB.SubmitAllChange(); \r\n"); if (table1 != null) sbClass.Append(" if(this.DATA!=null) this.DATA.AcceptChanges();\r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" this.tShow1(\"Ghi dữ liệu thành công!\"); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnTaoMoi_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); foreach (DBField f in listKey) { sbClass.AppendFormat(" this.{0} = 0;\r\n",f.Name); } sbClass.AppendFormat(" bsChungTu.DataSource = new {0}();\r\n", table.Name); if (table1 != null) { sbClass.Append(" using (tDBContext mainDB = new tDBContext())\r\n"); sbClass.Append(" {\r\n"); sbClass.AppendFormat(" this.DATA = mainDB.{0}s.GetList(\"1<>1\");\r\n", table1.Name); sbClass.Append(" bsList.DataSource = this.DATA;\r\n"); sbClass.Append(" gList.PrimaryGrid.DataSource = bsList;\r\n"); sbClass.Append(" };\r\n"); } sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnInAn_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void btnXoa_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bsChungTu.DataSource == null) return; \r\n"); sbClass.AppendFormat(" {0} ct = bsChungTu.DataSource as {0};\r\n", table.Name); sbClass.AppendFormat(" if (ct == null) return; \r\n"); foreach (DBField f in listKey) { sbClass.AppendFormat(" if (ct.{0} < 1) return;\r\n",f.Name); } sbClass.AppendFormat(" DialogResult r = MessageBoxEx.Show(\"Bạn có thực sự muốn xóa?\", \"Hỏi\", MessageBoxButtons.YesNo); \r\n"); sbClass.AppendFormat(" if (r != System.Windows.Forms.DialogResult.Yes) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" mainDB.{0}s.DeleteOnSubmit(ct);\r\n", table.Name); sbClass.AppendFormat(" mainDB.SubmitAllChange(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" this.tShow1(\"Xóa thành công!\"); \r\n"); sbClass.AppendFormat(" this.Close(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void bwLoadData_DoWork(object sender, DoWorkEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (this.{0} < 1) return;\r\n",listKey[0].Name); if (table1 != null) { sbClass.AppendFormat(" proLoad.BringToFront(); \r\n"); } sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" using (tDBContext mainDB = new tDBContext()) \r\n"); sbClass.Append(" { \r\n"); string strWhere = ""; foreach (DBField f in listKey) { strWhere += string.Format(" {0}={{0}} AND",f.Name); } strWhere = strWhere.Substring(0, strWhere.Length - 3);//Bỏ AND cuối cùng strWhere = string.Format("\"{0}\"", strWhere); foreach (DBField f in listKey) { strWhere += string.Format(" , this.{0}",f.Name); } sbClass.AppendFormat(" string strWhere = string.Format({0});\r\n",strWhere); sbClass.AppendFormat(" bsChungTu.DataSource = mainDB.{0}s.GetObject(strWhere);\r\n", table.Name); if (table1 != null) { sbClass.AppendFormat(" this.DATA = mainDB.{0}s.GetList(strWhere);\r\n", table1.Name); sbClass.AppendFormat(" //System.Threading.Thread.Sleep(1000); \r\n"); } sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void bwLoadData_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" \r\n"); if (table1 != null) { sbClass.AppendFormat(" bsList.DataSource = this.DATA; \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.DataSource = bsList; \r\n"); sbClass.AppendFormat(" proLoad.SendToBack(); \r\n"); } sbClass.Append(" } \r\n"); if (table1 != null) { sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void txtFilter_TextChanged(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" tTextBox txt = sender as tTextBox; \r\n"); sbClass.AppendFormat(" if(txt==null) return; \r\n"); sbClass.Append(" try\r\n"); sbClass.Append(" {\r\n"); sbClass.Append(" bsList.Filter = string.Format(\"{0} LIKE '%{1}%'\", txt.Tag, txt.Text); \r\n"); sbClass.Append(" }\r\n"); sbClass.Append(" catch { }\r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); } sbClass.Append(" private void gList_CellDoubleClick(object sender, GridCellDoubleClickEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" private void gList_RowHeaderClick(object sender, GridRowHeaderClickEventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.Append(" if (e.GridRow == null) return; \r\n"); sbClass.Append(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_GhiDuLieu_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" btnGhi.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); if (table1 != null) { sbClass.AppendFormat(" private void phimTat_CopyDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bsList.Current == null) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.FlushActiveRow(); \r\n"); sbClass.AppendFormat(" gList.CopyRow(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_XoaDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bsList.Current == null) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.FlushActiveRow(); \r\n"); sbClass.AppendFormat(" gList.DeleteCurrentRow(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_XoaHet_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (this.DATA == null) return; \r\n"); sbClass.AppendFormat(" if (this.DATA == default(DataTable)) return; \r\n"); sbClass.AppendFormat(" if (this.DATA.Rows.Count < 1) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.PrimaryGrid.FlushActiveRow(); \r\n"); sbClass.AppendFormat(" gList.DeleteAllRow(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void phimTat_Excel_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (this.DATA == null) return; \r\n"); sbClass.AppendFormat(" if (this.DATA == default(DataTable)) return; \r\n"); sbClass.AppendFormat(" if (this.DATA.Rows.Count < 1) return; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" gList.ExportExcel(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_GhiDuLieu_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_GhiDuLieu.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_CopyDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_CopyDong.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XoaDong_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_XoaDong.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XoaHet_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_XoaHet.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" private void chuotPhai_XuatExcel_Click(object sender, EventArgs e) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" phimTat_Excel.PerformClick(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" public void OnDataChanged() \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (bwLoadData.IsBusy == false) bwLoadData.RunWorkerAsync(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); } sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); return sbClass; }
public StringBuilder CreateACSXFormChiTiet1Bang(DBTable table) { StringBuilder sbClass = new StringBuilder(); sbClass.AppendFormat("<%@ Control Language=\"C#\" AutoEventWireup=\"true\" CodeBehind=\"{0}_ADDEDIT.ascx.cs\" Inherits=\"mojoPortal.Web.Modules.{0}_ADDEDIT\" %>\r\n", table.Name); sbClass.Append("<%@ Import Namespace=\"System.Globalization\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Business\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Business.WebHelpers\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web.Framework\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web.Controls\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web.UI\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Web.Editor\" %>\r\n"); sbClass.Append("<%@ Import Namespace=\"mojoPortal.Net\" %>\r\n"); sbClass.Append("<portal:OuterWrapperPanel ID=\"pnlOuterWrap\" runat=\"server\">\r\n"); sbClass.Append("<mp:CornerRounderTop id=\"ctop1\" runat=\"server\" />\r\n"); sbClass.Append("<portal:InnerWrapperPanel ID=\"pnlInnerWrap\" runat=\"server\" CssClass=\"panelwrapper mymodule\">\r\n"); sbClass.Append("<asp:UpdatePanel ID=\"upGallery\" UpdateMode=\"Conditional\" runat=\"server\">\r\n"); sbClass.Append("<ContentTemplate >\r\n"); sbClass.Append("<portal:ModuleTitleControl id=\"Title1\" runat=\"server\" />\r\n"); sbClass.Append("<portal:OuterBodyPanel ID=\"pnlOuterBody\" runat=\"server\">\r\n"); sbClass.Append("<portal:InnerBodyPanel ID=\"pnlInnerBody\" runat=\"server\" CssClass=\"modulecontent\">\r\n"); sbClass.AppendFormat("<h2>Chi tiết {0}</h2>\r\n", table.Name); foreach (DBField f in table.Fields) { sbClass.AppendFormat("<portal:mojoLabel ID=\"lbl{0}\" runat=\"server\" Text=\"{1}\" ></portal:mojoLabel>\r\n", f.Name, f.Description); if (f.IsKey == true) { sbClass.AppendFormat( "<portal:mojoLabel ID=\"{0}\" runat=\"server\" Text=\"-1\" ></portal:mojoLabel> <br />\r\n", f.Name); continue; } if (f.DBTypeName == "Date") { sbClass.AppendFormat( "<portal:jDatePicker ID=\"{0}\" runat=\"server\"></portal:jDatePicker>\r\n", f.Name); if (f.IsNullAble == false) { sbClass.AppendFormat("<asp:RequiredFieldValidator ID=\"r{0}\" ControlToValidate=\"{0}\" ErrorMessage=\"{1} bắt buộc nhập\" Font-Bold=\"True\" ForeColor=\"Red\" ToolTip=\"Dữ liệu bắt buộc nhập\" ValidationGroup=\"GHIDULIEU\" runat=\"server\" Display=\"Dynamic\" >*</asp:RequiredFieldValidator>\r\n", f.Name, f.Description); } sbClass.Append("<br />\r\n"); continue; } if (f.DBTypeName == "SmallInt" || f.DBTypeName == "Integer" || f.DBTypeName == "Numeric" || f.DBTypeName == "Single" || f.DBTypeName == "Double") { sbClass.AppendFormat( "<mp:WatermarkTextBox ID=\"{0}\" runat=\"server\" Watermark=\"{1}\" UseWatermark=\"False\" ValidationGroup=\"GHIDULIEU\" Width=\"200px\"></mp:WatermarkTextBox> \r\n", f.Name, f.Description); sbClass.AppendFormat( "<ajaxToolkit:FilteredTextBoxExtender ValidChars=\".,\" runat=\"server\" Enabled=\"True\" TargetControlID=\"{0}\" ID=\"{0}_FilteredTextBoxExtender\" FilterType=\"Numbers, Custom\"></ajaxToolkit:FilteredTextBoxExtender> \r\n", f.Name); if (f.IsNullAble == false) { sbClass.AppendFormat("<asp:RequiredFieldValidator ID=\"r{0}\" ControlToValidate=\"{0}\" ErrorMessage=\"{1} bắt buộc nhập\" Font-Bold=\"True\" ForeColor=\"Red\" ToolTip=\"Dữ liệu bắt buộc nhập\" ValidationGroup=\"GHIDULIEU\" runat=\"server\" Display=\"Dynamic\" >*</asp:RequiredFieldValidator>\r\n", f.Name, f.Description); } sbClass.Append("<br />\r\n"); continue; } sbClass.AppendFormat( "<mp:WatermarkTextBox ID=\"{0}\" runat=\"server\" Watermark=\"{1}\" UseWatermark=\"False\" ValidationGroup=\"GHIDULIEU\" Width=\"200px\"></mp:WatermarkTextBox> \r\n", f.Name, f.Description); if (f.IsNullAble == false) { sbClass.AppendFormat("<asp:RequiredFieldValidator ID=\"r{0}\" ControlToValidate=\"{0}\" ErrorMessage=\"{1} bắt buộc nhập\" Font-Bold=\"True\" ForeColor=\"Red\" ToolTip=\"Dữ liệu bắt buộc nhập\" ValidationGroup=\"GHIDULIEU\" runat=\"server\" Display=\"Dynamic\" >*</asp:RequiredFieldValidator>\r\n", f.Name,f.Description); } sbClass.Append("<br />\r\n"); } sbClass.AppendFormat("<br /><portal:mojoButton ID=\"btnGhi\" Text=\"Ghi dữ liệu\" OnClick=\"btnGhi_Click\" runat=\"server\" ValidationGroup=\"GHIDULIEU\" />\r\n"); sbClass.AppendFormat("<br /><br /><asp:HyperLink ID=\"linkTroLaiDanhSach\" runat=\"server\" NavigateUrl=\"~/{0}_LIST.aspx\">Trở lại</asp:HyperLink>\r\n", table.Name); sbClass.AppendFormat("<br /><asp:Label ID=\"lblMSG\" runat=\"server\" Text=\"\" BackColor=\"Yellow\"></asp:Label>\r\n", table.Name); sbClass.Append("<asp:ValidationSummary ID=\"ValidationSummary1\" runat=\"server\" ValidationGroup=\"GHIDULIEU\" />\r\n"); sbClass.Append("</portal:InnerBodyPanel>\r\n"); sbClass.Append("</portal:OuterBodyPanel>\r\n"); sbClass.Append("</ContentTemplate>\r\n"); sbClass.Append("</asp:UpdatePanel>\r\n"); sbClass.Append("<portal:EmptyPanel id=\"divCleared\" runat=\"server\" CssClass=\"cleared\" SkinID=\"cleared\" ></portal:EmptyPanel>\r\n"); sbClass.Append("</portal:InnerWrapperPanel>\r\n"); sbClass.Append("<mp:CornerRounderBottom id=\"cbottom1\" runat=\"server\" />\r\n"); sbClass.Append("</portal:OuterWrapperPanel>\r\n"); return sbClass; }
public StringBuilder CreateClassDesignerFormChiTiet(DBTable table, DBTable table1, DBTable table2) { StringBuilder sbClass = new StringBuilder(); sbClass.AppendFormat("using DevComponents.DotNetBar.SuperGrid; \r\n"); sbClass.AppendFormat("using DevComponents.DotNetBar; \r\n"); sbClass.AppendFormat("using DevComponents.DotNetBar.Controls; \r\n"); sbClass.AppendFormat(" namespace {0}\r\n",txtNameSpace.Text); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" partial class frm{0}\r\n",table.Name); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" /// <summary> \r\n"); sbClass.AppendFormat(" /// Required designer variable. \r\n"); sbClass.AppendFormat(" /// </summary> \r\n"); sbClass.AppendFormat(" private System.ComponentModel.IContainer components = null; \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" /// <summary> \r\n"); sbClass.AppendFormat(" /// Clean up any resources being used. \r\n"); sbClass.AppendFormat(" /// </summary> \r\n"); sbClass.AppendFormat(" /// <param name=\"disposing\">true if managed resources should be disposed; otherwise, false.</param> \r\n"); sbClass.AppendFormat(" protected override void Dispose(bool disposing) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" if (disposing && (components != null)) \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" components.Dispose(); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" base.Dispose(disposing); \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" #region Windows Form Designer generated code \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" /// <summary> \r\n"); sbClass.AppendFormat(" /// Required method for Designer support - do not modify \r\n"); sbClass.AppendFormat(" /// the contents of this method with the code editor. \r\n"); sbClass.AppendFormat(" /// </summary> \r\n"); sbClass.AppendFormat(" private void InitializeComponent() \r\n"); sbClass.Append(" { \r\n"); sbClass.AppendFormat(" this.components = new System.ComponentModel.Container(); \r\n"); sbClass.AppendFormat(" this.btnGhi = new DevComponents.DotNetBar.ButtonX(); \r\n"); sbClass.AppendFormat(" this.btnTaoMoi = new DevComponents.DotNetBar.ButtonX(); \r\n"); sbClass.AppendFormat(" this.btnInAn = new DevComponents.DotNetBar.ButtonX(); \r\n"); sbClass.AppendFormat(" this.btnXoa = new DevComponents.DotNetBar.ButtonX(); \r\n"); sbClass.AppendFormat(" this.bsChungTu = new System.Windows.Forms.BindingSource(this.components); \r\n"); sbClass.AppendFormat(" this.menuPhimTat = new System.Windows.Forms.MenuStrip(); \r\n"); sbClass.AppendFormat(" this.phimTat = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); foreach (DBField f in table.Fields) { if (f.IsKey == true) continue; sbClass.AppendFormat(" this.lbl{0} = new System.Windows.Forms.Label();\r\n", f.Name); if (f.DBTypeName == "Date") { sbClass.AppendFormat(" this.{0} = new NSW.tMaskedTextBox();\r\n", f.Name); continue; } if (f.DBTypeName == "SmallInt" || f.DBTypeName == "Integer") { sbClass.AppendFormat(" this.{0} = new NSW.tIntegerInput();\r\n", f.Name); continue; } if (f.DBTypeName == "Numeric" || f.DBTypeName == "Single" || f.DBTypeName == "Double") { sbClass.AppendFormat(" this.{0} = new NSW.tDecimalInput();\r\n", f.Name); } if (f.DBTypeName == "WChar") { sbClass.AppendFormat(" this.{0} = new NSW.tTextBox();\r\n", f.Name); } } sbClass.AppendFormat(" this.phimTat_GhiDuLieu = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); if (table1 != null) { int ifi = 0; foreach (DBField fi in table1.Fields) { sbClass.AppendFormat(" DevComponents.DotNetBar.SuperGrid.GridColumn gridColumn{0} = new DevComponents.DotNetBar.SuperGrid.GridColumn();\r\n", (++ifi)); } sbClass.AppendFormat(" this.lblPhimTat = new DevComponents.DotNetBar.LabelX(); \r\n"); sbClass.AppendFormat(" this.gLocDuLieu = new DevComponents.DotNetBar.Controls.GroupPanel(); \r\n"); sbClass.AppendFormat(" this.proLoad = new DevComponents.DotNetBar.Controls.ProgressBarX(); \r\n"); sbClass.AppendFormat(" this.bsList = new System.Windows.Forms.BindingSource(this.components); \r\n"); sbClass.AppendFormat(" this.gList = new tGrid(); \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.phimTat_Excel = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.mnuChuotPhai = new System.Windows.Forms.ContextMenuStrip(this.components); \r\n"); sbClass.AppendFormat(" this.chuotPhai_GhiDuLieu = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel = new System.Windows.Forms.ToolStripMenuItem(); \r\n"); foreach (DBField fi in table1.Fields) { if (fi.IsKey == true) continue; sbClass.AppendFormat(" this.txt{0} = new tTextBox();\r\n", fi.Name); } } sbClass.AppendFormat(" this.bwLoadData = new System.ComponentModel.BackgroundWorker(); \r\n"); sbClass.AppendFormat(" this.pThongTinChung = new DevComponents.DotNetBar.Controls.GroupPanel(); \r\n"); sbClass.AppendFormat(" this.CONTENT.SuspendLayout(); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.SuspendLayout(); \r\n"); if (table1 != null) { sbClass.AppendFormat(" this.gLocDuLieu.SuspendLayout(); \r\n"); } sbClass.AppendFormat(" ((System.ComponentModel.ISupportInitialize)(this.bsChungTu)).BeginInit(); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.SuspendLayout(); \r\n"); sbClass.AppendFormat(" this.pThongTinChung.SuspendLayout(); \r\n"); if (table1 != null) { sbClass.AppendFormat(" this.mnuChuotPhai.SuspendLayout(); \r\n"); } sbClass.AppendFormat(" this.SuspendLayout(); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // TITLE \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.TITLE.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" this.TITLE.Text = \"{0}\";\r\n",table.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // CONTENT \r\n"); sbClass.AppendFormat(" // \r\n"); if (table1 != null) { sbClass.AppendFormat(" this.CONTENT.Controls.Add(this.proLoad);\r\n"); sbClass.AppendFormat(" this.CONTENT.Controls.Add(this.gList);\r\n"); sbClass.AppendFormat(" this.CONTENT.Controls.Add(this.lblPhimTat);\r\n"); sbClass.AppendFormat(" this.CONTENT.Controls.Add(this.gLocDuLieu); \r\n"); } sbClass.AppendFormat(" this.CONTENT.Controls.Add(this.pThongTinChung); \r\n"); sbClass.AppendFormat(" this.pThongTinChung.CanvasColor = System.Drawing.SystemColors.Control; \r\n"); sbClass.AppendFormat(" this.pThongTinChung.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.pThongTinChung.Dock = System.Windows.Forms.DockStyle.Top; \r\n"); sbClass.AppendFormat(" this.pThongTinChung.Location = new System.Drawing.Point(2, 2); \r\n"); sbClass.AppendFormat(" this.pThongTinChung.Name = \"pThongTinChung\"; \r\n"); sbClass.AppendFormat(" this.pThongTinChung.Size = new System.Drawing.Size(780, 309); \r\n"); sbClass.Append(" this.pThongTinChung.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BackColorGradientAngle = 90; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BorderBottomWidth = 1; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BorderLeftWidth = 1; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BorderRightWidth = 1; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.Append(" this.pThongTinChung.Style.BorderTopWidth = 1; \r\n"); sbClass.Append(" this.pThongTinChung.Style.CornerDiameter = 4; \r\n"); sbClass.Append(" this.pThongTinChung.Style.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.Append(" this.pThongTinChung.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; \r\n"); sbClass.Append(" this.pThongTinChung.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near; \r\n"); sbClass.Append(" this.pThongTinChung.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.Append(" this.pThongTinChung.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.Append(" this.pThongTinChung.TabIndex = 28; \r\n"); sbClass.Append(" this.pThongTinChung.Text = \"Thông tin chung\"; \r\n"); foreach (DBField f in table.Fields) { if (f.IsKey == true) continue; sbClass.AppendFormat(" this.pThongTinChung.Controls.Add(this.{0});\r\n", f.Name); sbClass.AppendFormat(" this.pThongTinChung.Controls.Add(this.lbl{0});\r\n", f.Name); } sbClass.AppendFormat(" this.CONTENT.Style.Alignment = System.Drawing.StringAlignment.Center; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; \r\n"); sbClass.AppendFormat(" this.CONTENT.Style.GradientAngle = 90; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // pBOTTOM \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.Add(this.btnXoa); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.Add(this.btnInAn); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.Add(this.btnTaoMoi); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.Add(this.btnGhi); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.Alignment = System.Drawing.StringAlignment.Center; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.BackColor1.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.BackColor2.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.Border = DevComponents.DotNetBar.eBorderType.SingleLine; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.BorderColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.ForeColor.ColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Style.GradientAngle = 90; \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.SetChildIndex(this.btnThoatRoot, 0); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.SetChildIndex(this.btnGhi, 0); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.SetChildIndex(this.btnTaoMoi, 0); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.SetChildIndex(this.btnInAn, 0); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.Controls.SetChildIndex(this.btnXoa, 0); \r\n"); if (table1 != null) { sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // gLocDuLieu \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.CanvasColor = System.Drawing.SystemColors.Control; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; \r\n"); foreach (DBField fi in table1.Fields) { if (fi.IsKey == true) continue; sbClass.AppendFormat(" this.gLocDuLieu.Controls.Add(this.txt{0});\r\n", fi.Name); } sbClass.AppendFormat(" this.gLocDuLieu.Dock = System.Windows.Forms.DockStyle.Top; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Font = new System.Drawing.Font(\"Microsoft Sans Serif\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Location = new System.Drawing.Point(2, 2); \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Name = \"gLocDuLieu\"; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Size = new System.Drawing.Size(780, 47); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BackColorGradientAngle = 90; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderBottomWidth = 1; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderLeftWidth = 1; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderRightWidth = 1; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.BorderTopWidth = 1; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.CornerDiameter = 4; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Style.TextLineAlignment = DevComponents.DotNetBar.eStyleTextAlignment.Near; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.TabIndex = 0; \r\n"); sbClass.AppendFormat(" this.gLocDuLieu.Text = \"Lọc dữ liệu\"; \r\n"); int ifi1 = 0; foreach (DBField fi in table1.Fields) { if (fi.IsKey == true) continue; sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // txt{0}\r\n", fi.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.txt{0}.BắtBuộc = false;\r\n", fi.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.txt{0}.Border.Class = \"TextBoxBorder\";\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.Location = new System.Drawing.Point({1}, 5);\r\n", fi.Name, 6 + (ifi1) * 110); sbClass.AppendFormat(" this.txt{0}.Name = \"txt{0}\";\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.Size = new System.Drawing.Size(100, 20);\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.TabIndex = {1};\r\n", fi.Name, ifi1 + 1); sbClass.AppendFormat(" this.txt{0}.Tag = \"{0}\";\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.WatermarkText = \"{1}\";\r\n", fi.Name, string.IsNullOrEmpty(fi.Description) ? fi.Name : fi.Description); sbClass.AppendFormat(" this.txt{0}.TextChanged += new System.EventHandler(this.txtFilter_TextChanged);\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.TựĐộngBindingTheoTên = false;\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.FocusHighlightEnabled = true;\r\n", fi.Name); sbClass.AppendFormat(" this.txt{0}.AutoSelectAll = true;\r\n", fi.Name); ifi1 = ifi1 + 1; } } //gList if (table1 != null) { sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // gList \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.gList.ContextMenuStrip = this.mnuChuotPhai; \r\n"); sbClass.AppendFormat(" this.gList.Dock = System.Windows.Forms.DockStyle.Fill; \r\n"); sbClass.AppendFormat(" this.gList.FilterExprColors.SysFunction = System.Drawing.Color.DarkRed; \r\n"); sbClass.AppendFormat(" this.gList.LicenseKey = \"F962CEC7-CD8F-4911-A9E9-CAB39962FC1F\"; \r\n"); sbClass.AppendFormat(" this.gList.Location = new System.Drawing.Point(2, 69); \r\n"); sbClass.AppendFormat(" this.gList.Name = \"gList\"; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.AutoGenerateColumns = false; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.AllowRowDelete = true;\r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.AllowRowInsert = true;\r\n"); int ifi2 = 0; foreach (DBField fi in table1.Fields) { ifi2 = ifi2 + 1; sbClass.AppendFormat(" gridColumn{0}.DataPropertyName = \"{1}\";\r\n", ifi2, fi.Name); sbClass.AppendFormat(" gridColumn{0}.HeaderText = \"{1}\";\r\n", ifi2, string.IsNullOrEmpty(fi.Description) ? fi.Name : fi.Description); sbClass.AppendFormat(" gridColumn{0}.Name = \"{1}\";\r\n", ifi2, fi.Name); if (fi.IsKey == true) { sbClass.AppendFormat(" gridColumn{0}.Visible = false;\r\n", ifi2); } if (fi.DBTypeName == "Numeric" || fi.DBTypeName == "Single" || fi.DBTypeName == "Double") { sbClass.AppendFormat(" gridColumn{0}.EditorType = typeof(DevComponents.DotNetBar.SuperGrid.GridDoubleInputEditControl);\r\n", ifi2); }else if (fi.DBTypeName == "SmallInt" || fi.DBTypeName == "Integer") { sbClass.AppendFormat(" gridColumn{0}.EditorType = typeof(DevComponents.DotNetBar.SuperGrid.GridIntegerInputEditControl);\r\n", ifi2); } sbClass.AppendFormat(" this.gList.PrimaryGrid.Columns.Add(gridColumn{0});\r\n", ifi2); } sbClass.AppendFormat(" this.gList.PrimaryGrid.KeyboardEditMode = DevComponents.DotNetBar.SuperGrid.KeyboardEditMode.EditOnEntry;\r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.MouseEditMode = DevComponents.DotNetBar.SuperGrid.MouseEditMode.SingleClick;\r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.MultiSelect = false; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.ReadOnly = false; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.ShowInsertRow = true;\r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.ShowRowGridIndex = true;\r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.RowHeaderIndexOffset = 1; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.ShowRowGridIndex = true; \r\n"); sbClass.AppendFormat(" this.gList.PrimaryGrid.UseAlternateRowStyle = true; \r\n"); sbClass.AppendFormat(" this.gList.Size = new System.Drawing.Size(780, 432); \r\n"); sbClass.AppendFormat(" this.gList.TabIndex = 1; \r\n"); sbClass.AppendFormat(" this.gList.Text = \"Danh sách\"; \r\n"); sbClass.AppendFormat(" this.gList.CellDoubleClick += new System.EventHandler<DevComponents.DotNetBar.SuperGrid.GridCellDoubleClickEventArgs>(this.gList_CellDoubleClick); \r\n"); sbClass.AppendFormat(" this.gList.RowHeaderClick += new System.EventHandler<DevComponents.DotNetBar.SuperGrid.GridRowHeaderClickEventArgs>(this.gList_RowHeaderClick); \r\n"); List<string> rc = new List<string>(); foreach (DBField f in table1.Fields) { if (f.IsKey == true) continue; if (f.IsNullAble == false) { rc.Add(f.Name); } } if (rc.Count > 0) { sbClass.Append(" this.gList.RequiredColumns = new string[] {\r\n"); for (int l = 0; l < rc.ToArray().Length;l++ ) { if (l == 0) { sbClass.AppendFormat(" \"{0}\"\r\n", rc.ToArray()[l]); }else sbClass.AppendFormat(" ,\"{0}\"\r\n", rc.ToArray()[l]); } sbClass.Append(" };\r\n"); } sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // mnuChuotPhai \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.Append(" this.mnuChuotPhai.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { \r\n"); sbClass.AppendFormat(" this.chuotPhai_GhiDuLieu, \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong, \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong, \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet, \r\n"); sbClass.Append(" this.chuotPhai_XuatExcel}); \r\n"); sbClass.Append(" this.mnuChuotPhai.Name = \"mnuChuotPhai\"; \r\n"); sbClass.AppendFormat(" this.mnuChuotPhai.Size = new System.Drawing.Size(155, 114); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_GhiDuLieu \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_GhiDuLieu.Name = \"chuotPhai_GhiDuLieu\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_GhiDuLieu.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_GhiDuLieu.Text = \"Ghi dữ liệu (F1)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_GhiDuLieu.Click += new System.EventHandler(this.chuotPhai_GhiDuLieu_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_CopyDong \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong.Name = \"chuotPhai_CopyDong\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong.Text = \"Copy dòng (F5)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_CopyDong.Click += new System.EventHandler(this.chuotPhai_CopyDong_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_XoaDong \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong.Name = \"chuotPhai_XoaDong\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong.Text = \"Xóa dòng (F8)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaDong.Click += new System.EventHandler(this.chuotPhai_XoaDong_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_XoaHet \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet.Name = \"chuotPhai_XoaHet\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet.Text = \"Xóa hết (F11)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XoaHet.Click += new System.EventHandler(this.chuotPhai_XoaHet_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // chuotPhai_XuatExcel \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel.Name = \"chuotPhai_XuatExcel\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel.Size = new System.Drawing.Size(154, 22); \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel.Text = \"Xuất Excel (F12)\"; \r\n"); sbClass.AppendFormat(" this.chuotPhai_XuatExcel.Click += new System.EventHandler(this.chuotPhai_XuatExcel_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // lblPhimTat \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.lblPhimTat.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Dock = System.Windows.Forms.DockStyle.Top; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Font = new System.Drawing.Font(\"Microsoft Sans Serif\", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Location = new System.Drawing.Point(2, 49); \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Name = \"lblPhimTat\"; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.PaddingLeft = 5; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Size = new System.Drawing.Size(780, 20); \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.TabIndex = 6; \r\n"); sbClass.AppendFormat(" this.lblPhimTat.Text = \"Ctrl+S: Ghi dữ liệu F5: Copy dòng F8: Xóa dòng F11: Xóa hết F12: Excel\"; \r\n"); } sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // menuPhimTat \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.Append(" this.menuPhimTat.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { \r\n"); sbClass.Append(" this.phimTat}); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Location = new System.Drawing.Point(0, 0); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Name = \"menuPhimTat\"; \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Size = new System.Drawing.Size(784, 24); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.TabIndex = 4; \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Text = \"menuStrip1\"; \r\n"); sbClass.AppendFormat(" this.menuPhimTat.Visible = false; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.Append(" this.phimTat.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { \r\n"); sbClass.AppendFormat(" this.phimTat_GhiDuLieu \r\n"); if (table1 != null) { sbClass.AppendFormat(" ,this.phimTat_CopyDong \r\n"); sbClass.AppendFormat(" ,this.phimTat_XoaDong \r\n"); sbClass.AppendFormat(" ,this.phimTat_XoaHet \r\n"); sbClass.Append(" ,this.phimTat_Excel\r\n"); } sbClass.Append(" });\r\n"); sbClass.AppendFormat(" this.phimTat.Name = \"phimTat\"; \r\n"); sbClass.AppendFormat(" this.phimTat.Size = new System.Drawing.Size(59, 20); \r\n"); sbClass.AppendFormat(" this.phimTat.Text = \"PhimTat\"; \r\n"); sbClass.AppendFormat(" this.phimTat.Visible = false; \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_GhiDuLieu \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_GhiDuLieu.Name = \"phimTat_GhiDuLieu\"; \r\n"); sbClass.AppendFormat(" this.phimTat_GhiDuLieu.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S)));\r\n"); sbClass.AppendFormat(" this.phimTat_GhiDuLieu.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_GhiDuLieu.Text = \"GhiDuLieu\"; \r\n"); sbClass.AppendFormat(" this.phimTat_GhiDuLieu.Click += new System.EventHandler(this.phimTat_GhiDuLieu_Click); \r\n"); if (table1 != null) { sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_CopyDong \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.Name = \"phimTat_CopyDong\"; \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.ShortcutKeys = System.Windows.Forms.Keys.F5; \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.Text = \"CopyDong\"; \r\n"); sbClass.AppendFormat(" this.phimTat_CopyDong.Click += new System.EventHandler(this.phimTat_CopyDong_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_XoaDong \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.Name = \"phimTat_XoaDong\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.ShortcutKeys = System.Windows.Forms.Keys.F8; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.Text = \"XoaDong\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaDong.Click += new System.EventHandler(this.phimTat_XoaDong_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_XoaHet \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.Name = \"phimTat_XoaHet\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.ShortcutKeys = System.Windows.Forms.Keys.F11; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.Text = \"XoaHet\"; \r\n"); sbClass.AppendFormat(" this.phimTat_XoaHet.Click += new System.EventHandler(this.phimTat_XoaHet_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // phimTat_Excel \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.Name = \"phimTat_Excel\"; \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.ShortcutKeys = System.Windows.Forms.Keys.F12; \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.Size = new System.Drawing.Size(149, 22); \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.Text = \"Excel\"; \r\n"); sbClass.AppendFormat(" this.phimTat_Excel.Click += new System.EventHandler(this.phimTat_Excel_Click); \r\n"); } sbClass.AppendFormat(" this.btnThoatRoot.Visible = true;\r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // btnGhi \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.btnGhi.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; \r\n"); sbClass.AppendFormat(" this.btnGhi.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; \r\n"); sbClass.AppendFormat(" this.btnGhi.Location = new System.Drawing.Point(6, 5); \r\n"); sbClass.AppendFormat(" this.btnGhi.Name = \"btnGhi\"; \r\n"); sbClass.AppendFormat(" this.btnGhi.Size = new System.Drawing.Size(75, 23); \r\n"); sbClass.AppendFormat(" this.btnGhi.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.btnGhi.TabIndex = 0; \r\n"); sbClass.AppendFormat(" this.btnGhi.Text = \"&Ghi\"; \r\n"); sbClass.AppendFormat(" this.btnGhi.Click += new System.EventHandler(this.btnGhi_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // btnTaoMoi \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.btnTaoMoi.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; \r\n"); sbClass.AppendFormat(" this.btnTaoMoi.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; \r\n"); sbClass.AppendFormat(" this.btnTaoMoi.Location = new System.Drawing.Point(91, 5); \r\n"); sbClass.AppendFormat(" this.btnTaoMoi.Name = \"btnTaoMoi\"; \r\n"); sbClass.AppendFormat(" this.btnTaoMoi.Size = new System.Drawing.Size(75, 23); \r\n"); sbClass.AppendFormat(" this.btnTaoMoi.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.btnTaoMoi.TabIndex = 1; \r\n"); sbClass.AppendFormat(" this.btnTaoMoi.Text = \"&Tạo mới\"; \r\n"); sbClass.AppendFormat(" this.btnTaoMoi.Click += new System.EventHandler(this.btnTaoMoi_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // btnInAn \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.btnInAn.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; \r\n"); sbClass.AppendFormat(" this.btnInAn.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; \r\n"); sbClass.AppendFormat(" this.btnInAn.Location = new System.Drawing.Point(176, 5); \r\n"); sbClass.AppendFormat(" this.btnInAn.Name = \"btnInAn\"; \r\n"); sbClass.AppendFormat(" this.btnInAn.Size = new System.Drawing.Size(75, 23); \r\n"); sbClass.AppendFormat(" this.btnInAn.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.btnInAn.TabIndex = 2; \r\n"); sbClass.AppendFormat(" this.btnInAn.Text = \"&In ấn\"; \r\n"); sbClass.AppendFormat(" this.btnInAn.Click += new System.EventHandler(this.btnInAn_Click); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // btnXoa \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.btnXoa.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; \r\n"); sbClass.AppendFormat(" this.btnXoa.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; \r\n"); sbClass.AppendFormat(" this.btnXoa.Location = new System.Drawing.Point(301, 5); \r\n"); sbClass.AppendFormat(" this.btnXoa.Name = \"btnXoa\"; \r\n"); sbClass.AppendFormat(" this.btnXoa.Size = new System.Drawing.Size(75, 23); \r\n"); sbClass.AppendFormat(" this.btnXoa.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; \r\n"); sbClass.AppendFormat(" this.btnXoa.TabIndex = 3; \r\n"); sbClass.AppendFormat(" this.btnXoa.Text = \"&Xóa\"; \r\n"); sbClass.AppendFormat(" this.btnXoa.Click += new System.EventHandler(this.btnXoa_Click); \r\n"); int i2 = 0; int intCot = 0; int intHang = 0; foreach (DBField f in table.Fields) { if (f.IsKey == true) continue; sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // lbl{0}\r\n",f.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.lbl{0}.AutoSize = true;\r\n", f.Name); sbClass.AppendFormat(" this.lbl{0}.Location = new System.Drawing.Point({1}, {2});\r\n", f.Name, intCot*200, intHang * 20); sbClass.AppendFormat(" this.lbl{0}.Name = \"{0}\";\r\n", f.Name); sbClass.AppendFormat(" this.lbl{0}.Size = new System.Drawing.Size(35, 13);\r\n", f.Name); sbClass.AppendFormat(" this.lbl{0}.TabIndex = 0;\r\n", f.Name); sbClass.AppendFormat(" this.lbl{0}.Text = \"{1}\";\r\n", f.Name,f.Description); if (f.DBTypeName == "Date") { sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // {0}\r\n", f.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.{0}.AsciiOnly = true;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.BackgroundStyle.Class = \"TextBoxBorder\";\r\n", f.Name); sbClass.AppendFormat(" this.{0}.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.BắtBuộc = {1};\r\n", f.Name, f.IsNullAble ? "false" : "true"); sbClass.AppendFormat(" this.{0}.ButtonClear.Visible = true;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.DateValue = null;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.FocusHighlightEnabled = true;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Location = new System.Drawing.Point({1}, {2});\r\n", f.Name, intCot * 300 + 50, intHang * 20); sbClass.AppendFormat(" this.{0}.Size = new System.Drawing.Size(100, 20);\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.TabIndex = {1};\r\n", f.Name, ++i2); sbClass.AppendFormat(" this.{0}.Name = \"{0}\";\r\n", f.Name); } if (f.DBTypeName == "Numeric" || f.DBTypeName == "Single" || f.DBTypeName == "Double") { sbClass.AppendFormat(" this.{0}.BackgroundStyle.Class = \"DateTimeInputBackground\";\r\n", f.Name); sbClass.AppendFormat(" this.{0}.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.ButtonFreeText.Checked = true;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.ButtonFreeText.Shortcut = DevComponents.DotNetBar.eShortcut.F2;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.DisplayFormat = st.DecimalFormat;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.FreeTextEntryMode = false;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Increment = new decimal(new int[] {{\r\n", f.Name); sbClass.AppendFormat(" 1,\r\n"); sbClass.AppendFormat(" 0,\r\n"); sbClass.AppendFormat(" 0,\r\n"); sbClass.Append(" 0});\r\n"); sbClass.AppendFormat(" this.{0}.Location = new System.Drawing.Point({1}, {2});\r\n", f.Name, intCot * 300 + 50, intHang * 20); sbClass.AppendFormat(" this.{0}.Name = \"{0}\";\r\n", f.Name); sbClass.AppendFormat(" this.{0}.ShowUpDown = true;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Size = new System.Drawing.Size(100, 20);\r\n", f.Name); sbClass.AppendFormat(" this.{0}.TabIndex = 27;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Value = new decimal(new int[] {{\r\n", f.Name); sbClass.Append(" 0,\r\n"); sbClass.Append(" 0,\r\n"); sbClass.Append(" 0,\r\n"); sbClass.Append(" 0});\r\n"); //Chỉ hỗ trợ 20.8 (20 số trước dấu phẩy và 8 số lẻ sau dấu phẩy khi là decimal) if (f.DBTypeName == "Numeric") { sbClass.AppendFormat(" this.{0}.MaxValue = new decimal(new int[] {{\r\n", f.Name); sbClass.AppendFormat(" 268435455,\r\n"); sbClass.AppendFormat(" 1042612833,\r\n"); sbClass.AppendFormat(" 542101086,\r\n"); sbClass.Append(" 524288});\r\n"); sbClass.AppendFormat(" this.{0}.MinValue = new decimal(new int[] {{\r\n", f.Name); sbClass.AppendFormat(" 268435455,\r\n"); sbClass.AppendFormat(" 1042612833,\r\n"); sbClass.AppendFormat(" 542101086,\r\n"); sbClass.Append(" -2146959360});\r\n"); } } if (f.DBTypeName == "SmallInt" || f.DBTypeName == "Integer") { sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // {0}\r\n", f.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.{0}.BackgroundStyle.Class = \"DateTimeInputBackground\";\r\n", f.Name); sbClass.AppendFormat(" this.{0}.BackgroundStyle.CornerType = DevComponents.DotNetBar.eCornerType.Square;\r\n", f.Name); //sbClass.AppendFormat(" this.{0}.AutoSelectAll = true;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.ButtonFreeText.Shortcut = DevComponents.DotNetBar.eShortcut.F2;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.DisplayFormat = st.IntegerFormat;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.FocusHighlightEnabled = true;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Increment = 1;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Location = new System.Drawing.Point({1}, {2});\r\n", f.Name, intCot * 300 + 50, intHang * 20); sbClass.AppendFormat(" this.{0}.Name = \"{0}\";\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Size = new System.Drawing.Size(100, 20);\r\n", f.Name); sbClass.AppendFormat(" this.{0}.TabIndex = {1};\r\n", f.Name, ++i2); sbClass.AppendFormat(" this.{0}.BắtBuộc = {1};\r\n", f.Name, f.IsNullAble ? "false" : "true"); sbClass.AppendFormat(" this.{0}.ShowUpDown = true;\r\n", f.Name); if (f.DBTypeName == "SmallInt") { sbClass.AppendFormat(" this.{0}.MaxValue = 32767;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.MinValue = -32768;\r\n", f.Name); } if (f.DBTypeName == "Integer") { sbClass.AppendFormat(" this.{0}.MaxValue = 2147483647;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.MinValue = -2147483648;\r\n", f.Name); } } if (f.DBTypeName == "WChar")//string textbox { sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // {0}\r\n", f.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.{0}.AutoSelectAll = true;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.FocusHighlightEnabled = true;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.BắtBuộc = {1};\r\n", f.Name, f.IsNullAble ? "false" : "true"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.{0}.Border.Class = \"TextBoxBorder\";\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square;\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Location = new System.Drawing.Point({1}, {2});\r\n", f.Name, intCot * 300 + 50, intHang * 20); sbClass.AppendFormat(" this.{0}.Name = \"{0}\";\r\n", f.Name); sbClass.AppendFormat(" this.{0}.Size = new System.Drawing.Size(100, 20);\r\n", f.Name); sbClass.AppendFormat(" this.{0}.TabIndex = {1};\r\n", f.Name, ++i2); sbClass.AppendFormat(" this.{0}.MaxLength = {1};\r\n", f.Name, f.MaxLength); } ++intHang; if (intHang == 14) { intHang = 0; ++intCot; } } sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // bwLoadData \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.bwLoadData.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bwLoadData_DoWork); \r\n"); sbClass.AppendFormat(" this.bwLoadData.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.bwLoadData_RunWorkerCompleted); \r\n"); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" // frm{0}\r\n",table.Name); sbClass.AppendFormat(" // \r\n"); sbClass.AppendFormat(" this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); \r\n"); sbClass.AppendFormat(" this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; \r\n"); sbClass.AppendFormat(" this.ClientSize = new System.Drawing.Size(784, 565); \r\n"); sbClass.AppendFormat(" this.Controls.Add(this.menuPhimTat); \r\n"); sbClass.AppendFormat(" this.MainMenuStrip = this.menuPhimTat; \r\n"); sbClass.AppendFormat(" this.Name = \"frm{0}\";\r\n", table.Name); sbClass.AppendFormat(" this.Text = \"frm{0}\";\r\n", table.Name); sbClass.AppendFormat(" this.Load += new System.EventHandler(this.frm{0}_Load);\r\n", table.Name); sbClass.AppendFormat(" this.Controls.SetChildIndex(this.menuPhimTat, 0); \r\n"); sbClass.AppendFormat(" this.Controls.SetChildIndex(this.TITLE, 0); \r\n"); sbClass.AppendFormat(" this.Controls.SetChildIndex(this.pBOTTOM, 0); \r\n"); sbClass.AppendFormat(" this.Controls.SetChildIndex(this.CONTENT, 0); \r\n"); sbClass.AppendFormat(" this.CONTENT.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.CONTENT.PerformLayout(); \r\n"); sbClass.AppendFormat(" this.pBOTTOM.ResumeLayout(false); \r\n"); if (table1 != null) { sbClass.AppendFormat(" this.gLocDuLieu.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.mnuChuotPhai.ResumeLayout(false); \r\n"); } sbClass.AppendFormat(" ((System.ComponentModel.ISupportInitialize)(this.bsChungTu)).EndInit(); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.menuPhimTat.PerformLayout(); \r\n"); sbClass.AppendFormat(" this.pThongTinChung.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.pThongTinChung.PerformLayout(); \r\n"); sbClass.AppendFormat(" this.ResumeLayout(false); \r\n"); sbClass.AppendFormat(" this.PerformLayout(); \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.Append(" } \r\n"); sbClass.AppendFormat(" \r\n"); sbClass.AppendFormat(" #endregion \r\n"); sbClass.AppendFormat(" \r\n"); if (table1 != null) { sbClass.AppendFormat(" private GroupPanel gLocDuLieu; \r\n"); sbClass.AppendFormat(" private tGrid gList; \r\n"); sbClass.AppendFormat(" private LabelX lblPhimTat; \r\n"); sbClass.AppendFormat(" private ProgressBarX proLoad; \r\n"); foreach (DBField fi in table1.Fields) { if (fi.IsKey == true) continue; sbClass.AppendFormat(" private tTextBox txt{0};\r\n", fi.Name); } sbClass.AppendFormat(" private System.Windows.Forms.BindingSource bsList; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ContextMenuStrip mnuChuotPhai; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_GhiDuLieu; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_CopyDong; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_XoaDong; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_XoaHet; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem chuotPhai_XuatExcel; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_CopyDong; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_XoaDong; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_XoaHet; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_Excel; \r\n"); } sbClass.AppendFormat(" private DevComponents.DotNetBar.ButtonX btnGhi; \r\n"); sbClass.AppendFormat(" private DevComponents.DotNetBar.ButtonX btnXoa; \r\n"); sbClass.AppendFormat(" private DevComponents.DotNetBar.ButtonX btnInAn; \r\n"); sbClass.AppendFormat(" private DevComponents.DotNetBar.ButtonX btnTaoMoi; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.BindingSource bsChungTu; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.MenuStrip menuPhimTat; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat; \r\n"); sbClass.AppendFormat(" private System.Windows.Forms.ToolStripMenuItem phimTat_GhiDuLieu; \r\n"); foreach (DBField f in table.Fields) { if (f.IsKey == true) continue; sbClass.AppendFormat(" private System.Windows.Forms.Label lbl{0};\r\n",f.Name); if (f.DBTypeName == "Date") { sbClass.AppendFormat(" private tMaskedTextBox {0};\r\n", f.Name); continue; } if (f.DBTypeName == "WChar") { sbClass.AppendFormat(" private tTextBox {0};\r\n", f.Name); } if (f.DBTypeName == "Numeric" || f.DBTypeName == "Single" || f.DBTypeName == "Double") { sbClass.AppendFormat(" private tDecimalInput {0};\r\n", f.Name); } if (f.DBTypeName == "SmallInt" || f.DBTypeName == "Integer") { sbClass.AppendFormat(" private tIntegerInput {0};\r\n", f.Name); } } sbClass.AppendFormat(" private System.ComponentModel.BackgroundWorker bwLoadData; \r\n"); sbClass.AppendFormat(" private DevComponents.DotNetBar.Controls.GroupPanel pThongTinChung; \r\n"); sbClass.Append(" } \r\n"); sbClass.Append(" } \r\n"); return sbClass; }
public StringBuilder CreateClass(DBTable table) { StringBuilder sbClass = new StringBuilder(); StringBuilder sbSelect = new StringBuilder(); StringBuilder sbInsertFields = new StringBuilder(); StringBuilder sbInsertValues = new StringBuilder(); StringBuilder sbUpdateFields = new StringBuilder(); StringBuilder sbUpdateFullFields = new StringBuilder(); StringBuilder sbWhereClause = new StringBuilder(); StringBuilder sbInsertPramas = new StringBuilder(); StringBuilder sbWherePramas = new StringBuilder(); StringBuilder sbUpdatePramas = new StringBuilder(); int paramInsertCnt = 0; int paramWhereCnt = 0; int paramUpdateCnt = 0; string strOver; string strBase = "Table"; if (table.IsView) strBase = "View"; //Comment sbClass.Append("\t/// <summary>\r\n"); sbClass.AppendFormat("\t/// Generated Class for Table : {0}.\r\n", table.Name); sbClass.Append("\t/// </summary>\r\n"); //Class name if (table.IsFull) { sbClass.AppendFormat("\tpublic partial class {0} : {1}Base\r\n", table.Name, strBase); strOver = "override "; } else { sbClass.AppendFormat("\tpublic class {0}\r\n", table.Name); strOver = ""; } sbClass.Append("\t{\r\n"); //Constructor. if (table.IsFull) { sbClass.AppendFormat("\t\tpublic {0}()", table.Name); sbClass.Append(" : base(){}\r\n\r\n"); } else { sbClass.AppendFormat("\t\tpublic {0}()\r\n", table.Name); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t}\r\n\r\n"); } if (table.Fields != null && table.Fields.Count > 0) { //Overwrite IsView property. sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Là View hay là Table.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}bool IsView \r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\tget\r\n"); sbClass.Append("\t\t\t{\r\n"); sbClass.AppendFormat("\t\t\t\treturn {0};\r\n", table.IsView.ToString().ToLower()); sbClass.Append("\t\t\t}\r\n"); sbClass.Append("\t\t}\r\n"); for (int i = 0; i < table.Fields.Count; i++) { DBField Field = table.Fields[i]; string strType = Field.Type; if (chkStringOnly.Checked || (strType.ToLower().Contains("date") && chkDateString.Checked) || (strType.ToLower().Contains("bool") && chkBoolString.Checked) || (strType.ToLower().Contains("decimal") && chkNumString.Checked) || (strType.ToLower().Contains("double") && chkNumString.Checked) || (strType.ToLower().Contains("int") && chkIntString.Checked) || (strType.ToLower().Contains("long") && chkIntString.Checked)) strType = "string"; //Create properties. if (!table.IsFull) { sbClass.AppendFormat("\t\tpublic {0} {1}", strType, Field.Name); sbClass.Append(" { get; set; }\r\n\r\n"); } else { if (Field.HasDefault) { if (Field.Default.ToLower().Contains("date")) { if ("string".Equals(strType, StringComparison.CurrentCultureIgnoreCase)) sbClass.AppendFormat("\t\tprivate {0} m_{1} = System.DateTime.Now.ToString(\"dd/MM/yyyy HH:mm:ss\");\r\n", strType, Field.Name); else sbClass.AppendFormat("\t\tprivate {0} m_{1} = System.DateTime.Now;\r\n", strType, Field.Name); } else { if ("string".Equals(strType, StringComparison.CurrentCultureIgnoreCase)) sbClass.AppendFormat("\t\tprivate {0} m_{1} = \"{2}\";\r\n", strType, Field.Name, Field.Default.Replace("\"", string.Empty)); else { sbClass.AppendFormat("\t\tprivate {0} m_{1} = {2};\r\n", strType, Field.Name, Field.Default); } } } else { sbClass.AppendFormat("\t\tprivate {0} m_{1};\r\n", strType, Field.Name); } if (!Field.IsKey && !table.IsView) sbClass.AppendFormat("\t\tprivate bool m_{0}Updated = false;\r\n", Field.Name); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.AppendFormat("\t\t/// {0}.\r\n", string.IsNullOrEmpty(Field.Description) ? Field.Name : Field.Description); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0} {1}\r\n", strType, Field.Name); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\tget\r\n"); sbClass.Append("\t\t\t{\r\n"); sbClass.AppendFormat("\t\t\t\treturn m_{0};\r\n", Field.Name); sbClass.Append("\t\t\t}\r\n"); sbClass.Append("\t\t\tset\r\n"); sbClass.Append("\t\t\t{\r\n"); sbClass.AppendFormat("\t\t\t\tif ((this.m_{0} != value))\r\n", Field.Name); sbClass.Append("\t\t\t\t{\r\n"); sbClass.AppendFormat("\t\t\t\t\tthis.SendPropertyChanging(\"{0}\");\r\n", Field.Name); sbClass.AppendFormat("\t\t\t\t\tthis.m_{0} = value;\r\n", Field.Name); sbClass.AppendFormat("\t\t\t\t\tthis.SendPropertyChanged(\"{0}\");\r\n", Field.Name); if (!Field.IsKey && !table.IsView) { sbClass.AppendFormat("\t\t\t\t\tif ((this.DataStatus != DBStatus.Inserted))\r\n", Field.Name); sbClass.AppendFormat("\t\t\t\t\t\tthis.m_{0}Updated = true;\r\n", Field.Name); } sbClass.Append("\t\t\t\t}\r\n"); sbClass.Append("\t\t\t}\r\n"); sbClass.Append("\t\t}\r\n\r\n"); string fieldValue; string fieldSelect = string.Format("\"[{0}]\"", Field.Name);//ko nên dùng hàm clsDAL.SelectField vì chạy chậm, ko cần thiết switch (Field.Type) { case "string": if (!chkUsePARAM.Checked) { fieldValue = string.Format("clsDAL.IsDBNULL({0}, ProType.STRING, this.DataManagement)", Field.Name); } else { sbInsertPramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.STRING, this.DataManagement) , this.DataManagement));\r\n", paramInsertCnt++, Field.Name, Field.DBTypeName); fieldValue = string.Format("\"@{0}\"", Field.Name); if (Field.IsKey == true) { sbWherePramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.STRING, this.DataManagement) , this.DataManagement));\r\n", paramWhereCnt++, Field.Name, Field.DBTypeName); } else { sbUpdatePramas.AppendFormat("\t\t\tif(m_{1}Updated) paramList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.STRING, this.DataManagement) , this.DataManagement));\r\n", paramUpdateCnt++, Field.Name, Field.DBTypeName); } } break; case "DateTime": case "DateTime?": if (!chkUsePARAM.Checked) { if (chkStringOnly.Checked || chkDateString.Checked) { fieldValue = string.Format("clsDAL.IsDBNULL({0}, ProType.VNDATESTRING, this.DataManagement)", Field.Name); } else { fieldValue = string.Format("clsDAL.IsDBNULL({0}, ProType.DATETIME, this.DataManagement)", Field.Name); } } else { fieldValue = string.Format("\"@{0}\"", Field.Name); if (chkStringOnly.Checked || chkDateString.Checked) { sbInsertPramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.VNDATESTRING, this.DataManagement), this.DataManagement));\r\n", paramInsertCnt++, Field.Name, Field.DBTypeName); if (Field.IsKey == true) { sbWherePramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.VNDATESTRING, this.DataManagement), this.DataManagement));\r\n", paramWhereCnt++, Field.Name, Field.DBTypeName); } else { sbUpdatePramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.VNDATESTRING, this.DataManagement) , this.DataManagement));\r\n", paramUpdateCnt++, Field.Name, Field.DBTypeName); } } else { sbInsertPramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.DATETIME, this.DataManagement), this.DataManagement));\r\n", paramInsertCnt++, Field.Name, Field.DBTypeName); if (Field.IsKey == true) { sbWherePramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.DATETIME, this.DataManagement), this.DataManagement));\r\n", paramWhereCnt++, Field.Name, Field.DBTypeName); } else { sbUpdatePramas.AppendFormat("\t\t\tif(m_{1}Updated) paramList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.DATETIME, this.DataManagement) , this.DataManagement));\r\n", paramUpdateCnt++, Field.Name, Field.DBTypeName); } } } //không chơi kiểu string only nữa, cũ rồi, quê rồi //if (chkStringOnly.Checked || chkDateString.Checked) // fieldSelect = string.Format("clsDAL.SelectField(\"[{0}]\", ProType.VNDATESTRING, this.DataManagement)", Field.Name); //else // fieldSelect = string.Format("clsDAL.SelectField(\"[{0}]\", ProType.DATETIME, this.DataManagement)", Field.Name); break; case "object": fieldValue = string.Format("\"@{0}\"", Field.Name); sbInsertPramas.AppendFormat("\t\t\t paramList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.OTHER, this.DataManagement), this.DataManagement));\r\n", paramInsertCnt++, Field.Name, Field.DBTypeName); break; case "bool": case "bool?": if (!chkUsePARAM.Checked) { fieldValue = string.Format("clsDAL.IsDBNULL({0}, ProType.BOOL, this.DataManagement)", Field.Name); } else { sbInsertPramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.BOOL, this.DataManagement) , this.DataManagement));\r\n", paramInsertCnt++, Field.Name, Field.DBTypeName); fieldValue = string.Format("\"@{0}\"", Field.Name); if (Field.IsKey == true) { sbWherePramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.BOOL, this.DataManagement) , this.DataManagement));\r\n", paramWhereCnt++, Field.Name, Field.DBTypeName); } else { sbUpdatePramas.AppendFormat("\t\t\tif(m_{1}Updated) paramList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.BOOL, this.DataManagement) , this.DataManagement));\r\n", paramUpdateCnt++, Field.Name, Field.DBTypeName); } } break; case "int": default: if (!chkUsePARAM.Checked) { fieldValue = string.Format("clsDAL.IsDBNULL({0}, ProType.OTHER, this.DataManagement)", Field.Name); } else { sbInsertPramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.NUMBER, this.DataManagement) , this.DataManagement));\r\n", paramInsertCnt++, Field.Name, Field.DBTypeName); fieldValue = string.Format("\"@{0}\"", Field.Name); if (Field.IsKey == true) { sbWherePramas.AppendFormat("\t\t\tparamList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.NUMBER, this.DataManagement) , this.DataManagement));\r\n", paramWhereCnt++, Field.Name, Field.DBTypeName); } else { sbUpdatePramas.AppendFormat("\t\t\tif(m_{1}Updated) paramList.Add(clsDAL.CreateParameter(\"{1}\", \"{2}\", clsDAL.ToDBParam({1}, ProType.NUMBER, this.DataManagement) , this.DataManagement));\r\n", paramUpdateCnt++, Field.Name, Field.DBTypeName); } } break; } if (sbSelect.Length == 0) { sbSelect.AppendFormat(".Append({0})", fieldSelect); } else { sbSelect.AppendFormat(".Append(\",\").Append({0})", fieldSelect); } if (!Field.IsAuto) { if (sbInsertFields.Length == 0) { sbInsertFields.AppendFormat("[{0}]", Field.Name); sbInsertValues.AppendFormat(".Append({0})", fieldValue); } else { sbInsertFields.AppendFormat(", [{0}]", Field.Name); sbInsertValues.AppendFormat(".Append(\",\").Append({0})", fieldValue); } if (!Field.IsKey) { sbUpdateFields.AppendFormat(".Append(m_{0}Updated ? string.Format(\",[{0}] = {2}\", {1}) : string.Empty)", Field.Name, fieldValue, "{0}"); if (sbUpdateFullFields.Length == 0) { sbUpdateFullFields.AppendFormat(".AppendFormat(\"[{0}] = {2}\", {1})", Field.Name, fieldValue, "{0}"); } else { sbUpdateFullFields.AppendFormat(".AppendFormat(\",[{0}] = {2}\", {1})", Field.Name, fieldValue, "{0}"); } } } if (Field.IsKey) { if (sbWhereClause.Length == 0) { sbWhereClause.AppendFormat(".AppendFormat(\"[{0}] = {2}\", {1})", Field.Name, fieldValue, "{0}"); } else { sbWhereClause.AppendFormat(".AppendFormat(\" AND [{0}] = {2}\", {1})", Field.Name, fieldValue, "{0}"); } } } } if (table.IsFull) { //Select Statement. sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL lấy dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string SelectStatement(string Fields, string WhereClause, string OrderClause)\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\tswitch(this.DataManagement)\r\n"); sbClass.Append("\t\t\t{\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Access:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQL:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQLLite:\r\n"); sbClass.Append("\t\t\t\tdefault:\r\n"); sbClass.AppendFormat("\t\t\t\treturn \"SELECT \" + Fields + \" FROM {0} \" + (string.IsNullOrEmpty(WhereClause) ? string.Empty : \" WHERE \" + WhereClause) + (string.IsNullOrEmpty(OrderClause) ? string.Empty : \" ORDER BY \" + OrderClause);\r\n", table.Name); sbClass.Append("\t\t\t\tcase DBManagement.Oracle:\r\n"); sbClass.AppendFormat("\t\t\t\treturn \"SELECT \" + Fields + \" FROM \\\"{0}\\\" \" + (string.IsNullOrEmpty(WhereClause) ? string.Empty : \" WHERE \" + WhereClause) + (string.IsNullOrEmpty(OrderClause) ? string.Empty : \" ORDER BY \" + OrderClause);\r\n", table.Name); sbClass.Append("\t\t\t}\r\n"); sbClass.Append("\t\t}\r\n"); //Select Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL lấy dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string SelectStatement(string WhereClause, string OrderClause)\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\tStringBuilder sbSQL = new StringBuilder();\r\n"); sbClass.Append("\t\t\tswitch(this.DataManagement)\r\n"); sbClass.Append("\t\t\t{\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Access:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQL:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQLLite:\r\n"); sbClass.Append("\t\t\t\tdefault:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL{0};\r\n", sbSelect); sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t\t \r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Oracle:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL{0};\r\n", sbSelect.Replace("[", "\\\"").Replace("]", "\\\""));//oracle truong dữ liệu ko dùng 2 dấu ngoặc vuông, mà dùng nháy đôi sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t}\r\n"); sbClass.Append("\t\t\treturn SelectStatement(sbSQL.ToString(), WhereClause, OrderClause);\r\n"); sbClass.Append("\t\t}\r\n"); //Select Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL lấy dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string SelectStatement(string WhereClause)\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.AppendFormat("\t\t\treturn SelectStatement(WhereClause, string.Empty);\r\n"); sbClass.Append("\t\t}\r\n"); if (!table.IsView) { if (sbWhereClause.Length > 0) { //Select Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL lấy dữ liệu theo khóa chính.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string SelectStatement()\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\treturn SelectStatement(WhereById());\r\n"); sbClass.Append("\t\t}\r\n"); } //Insert Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL thêm dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string InsertStatement()\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\tStringBuilder sbSQL = new StringBuilder();\r\n"); sbClass.Append("\t\t\tswitch(this.DataManagement)\r\n"); sbClass.Append("\t\t\t{\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Access:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQL:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQLLite:\r\n"); sbClass.Append("\t\t\t\tdefault:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL.Append(\"INSERT INTO {0} ({1}) VALUES(\"){2}.Append(\")\");\r\n", table.Name, sbInsertFields, sbInsertValues); sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t\t \r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Oracle:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL.Append(\"INSERT INTO {0} ({1}) VALUES(\"){2}.Append(\")\");\r\n", table.Name, sbInsertFields.Replace("[", "").Replace("]", ""), sbInsertValues.Replace("@", ":")); sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t}\r\n"); sbClass.Append("\t\t\treturn sbSQL.ToString();"); sbClass.Append("\t\t}\r\n"); //Update Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL cập nhật dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string UpdateStatement(string Fields, string WhereClause)\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.AppendFormat("\t\t\treturn \"UPDATE {0} SET \" + Fields + (string.IsNullOrEmpty(WhereClause) ? string.Empty : \" WHERE \" + WhereClause);\r\n", table.Name); sbClass.Append("\t\t}\r\n"); if (sbUpdateFields.Length > 0) { //Update Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL cập nhật dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string UpdateStatement(string WhereClause)\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\tStringBuilder sbSQL = new StringBuilder();\r\n"); sbClass.Append("\t\t\tswitch(this.DataManagement)\r\n"); sbClass.Append("\t\t\t{\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Access:\r\n"); sbClass.Append("\t\t\t\t\t//return UpdateFullStatement(WhereClause);\r\n");//nếu lúc nào cũng update full sẽ bị giới hạn 127 param nên không chơi update full sbClass.Append("\t\t\t\tcase DBManagement.SQL:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQLLite:\r\n"); sbClass.Append("\t\t\t\tdefault:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL{0};\r\n", sbUpdateFields); sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t\t \r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Oracle:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL{0};\r\n", sbUpdateFields.Replace("[", "").Replace("]", "").Replace("@", ":")); sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t}\r\n"); sbClass.Append("\t\t\tif(sbSQL.Length > 0)\r\n"); sbClass.AppendFormat("\t\t\t\treturn UpdateStatement(sbSQL.ToString().Substring(1), WhereClause);\r\n"); sbClass.AppendFormat("\t\t\telse\r\n", sbUpdateFields); sbClass.Append("\t\t\t\treturn UpdateFullStatement(WhereClause);\r\n"); sbClass.Append("\t\t}\r\n"); //Update Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL cập nhật dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string UpdateFullStatement(string WhereClause)\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\tStringBuilder sbSQL = new StringBuilder();\r\n"); sbClass.Append("\t\t\tswitch(this.DataManagement)\r\n"); sbClass.Append("\t\t\t{\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Access:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQL:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQLLite:\r\n"); sbClass.Append("\t\t\t\tdefault:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL{0};\r\n", sbUpdateFullFields); sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t\t \r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Oracle:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL{0};\r\n", sbUpdateFullFields.Replace("[", "").Replace("]", "").Replace("@", ":")); sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t}\r\n"); sbClass.Append("\t\t\treturn UpdateStatement(sbSQL.ToString(), WhereClause);\r\n"); sbClass.Append("\t\t}\r\n"); if (sbWhereClause.Length > 0) { //Update Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL cập nhật liêu theo khóa chính.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string UpdateStatement()\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\treturn UpdateStatement(WhereById());\r\n"); sbClass.Append("\t\t}\r\n"); } } //Delete Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL xóa dữ liêu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string DeleteStatement(string WhereClause)\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.AppendFormat("\t\t\treturn clsDAL.DeleteString(\"{0}\", this.DataManagement)", table.Name); sbClass.Append(" + (string.IsNullOrEmpty(WhereClause) ? string.Empty : \" WHERE \" + WhereClause);\r\n"); sbClass.Append("\t\t}\r\n"); if (sbWhereClause.Length > 0) { //Delete Statement. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo câu SQL xóa dữ liệu theo khóa chính.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string DeleteStatement()\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\t return DeleteStatement(WhereById());\r\n"); sbClass.Append("\t\t}\r\n"); } if (sbWhereClause.Length > 0) { //Where Clause sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo điều kiện tìm kiếm theo khóa chính.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.AppendFormat("\t\tpublic {0}string WhereById()\r\n", strOver); sbClass.Append("\t\t{\r\n"); sbClass.Append("\t\t\tStringBuilder sbSQL = new StringBuilder();\r\n"); sbClass.Append("\t\t\tswitch(this.DataManagement)\r\n"); sbClass.Append("\t\t\t{\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Access:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQL:\r\n"); sbClass.Append("\t\t\t\tcase DBManagement.SQLLite:\r\n"); sbClass.Append("\t\t\t\tdefault:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL{0};\r\n", sbWhereClause); sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t\t \r\n"); sbClass.Append("\t\t\t\tcase DBManagement.Oracle:\r\n"); sbClass.AppendFormat("\t\t\t\tsbSQL{0};\r\n", sbWhereClause.Replace("[", "").Replace("]", "").Replace("@", ":")); sbClass.Append("\t\t\t\tbreak;\r\n"); sbClass.Append("\t\t\t}\r\n"); sbClass.Append("\t\t\treturn sbSQL.ToString();\r\n"); sbClass.Append("\t\t}\r\n"); } if (paramWhereCnt > 0) { //Create special parameters. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo parameter để Delete dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.Append("\t\tpublic override List<IDbDataParameter> DeleteParameters()\r\n"); sbClass.Append("\t\t{\r\n"); sbClass.AppendFormat("\t\t\tList<IDbDataParameter> paramList = new List<IDbDataParameter>();\r\n"); sbClass.Append(sbWherePramas); sbClass.Append("\t\t\treturn paramList;\r\n"); sbClass.Append("\t\t}\r\n"); } if (paramUpdateCnt > 0) { //Create special parameters. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo parameter để Insert dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.Append("\t\tpublic override List<IDbDataParameter> UpdateParameters()\r\n"); sbClass.Append("\t\t{\r\n"); sbClass.AppendFormat("\t\t\tList<IDbDataParameter> paramList = new List<IDbDataParameter>();\r\n"); sbClass.Append(sbUpdatePramas); sbClass.Append(sbWherePramas); sbClass.Append("\t\t\treturn paramList;\r\n"); sbClass.Append("\t\t}\r\n"); } if (paramInsertCnt > 0) { //Create special parameters. sbClass.Append("\r\n"); sbClass.Append("\t\t/// <summary>\r\n"); sbClass.Append("\t\t/// Tạo parameter để Insert dữ liệu.\r\n"); sbClass.Append("\t\t/// </summary>\r\n"); sbClass.Append("\t\tpublic override List<IDbDataParameter> InsertParameters()\r\n"); sbClass.Append("\t\t{\r\n"); sbClass.AppendFormat("\t\t\tList<IDbDataParameter> paramList = new List<IDbDataParameter>();\r\n"); sbClass.Append(sbInsertPramas); sbClass.Append("\t\t\treturn paramList;\r\n"); sbClass.Append("\t\t}\r\n"); } } } } //Kết thúc class sbClass.Append("\t" + "}" + "\r\n"); return sbClass; }