private void CreateCode(string tableName)
        {
            if (tableName == null)
            {
                tbDAL.Text = tbModel.Text = "请选择要生成的表";
                return;
            }

            else
            {
                DataTable dt = ExecuteDataTable("select top 0 * from " + tableName);
                CreateCodeHelper helper = new CreateCodeHelper();
                string strDAL = cbDAL.SelectedItem.ToString();
                StringBuilder sb = new StringBuilder();

                if (!tbNamespace.Text.Equals("命名空间") && tbNamespace.Text.Trim().Length > 0)
                {
                    modelstr = helper.CreateModelCode(tableName, dt, tbNamespace.Text).ToString();

                    if (strDAL.Equals("All DAL"))
                    {
                        dalstr = helper.CreateDALCode(tableName, dt, tbNamespace.Text).ToString();
                        tbDAL.Text = dalstr;
                    }
                    else
                    {
                        switch (strDAL)
                        {
                            case "All DAL":
                                {
                                    dalstr = helper.CreateDALCode(tableName, dt).ToString();
                                    break;
                                }
                            case "ListAll()":
                                {
                                    helper.CreateListAll(tableName, dt, sb, "");
                                    dalstr = sb.ToString();
                                    break;
                                }
                            case "DeleteById()":
                                {
                                    helper.CreateDeleteById(tableName, dt, sb, "");
                                    dalstr = sb.ToString();
                                    break;
                                }
                            case "GetById()":
                                {
                                    helper.CreateGetById(tableName, dt, sb, "");
                                    dalstr = sb.ToString();
                                    break;
                                }
                            case "Insert()":
                                {
                                    helper.CreateInsert(tableName, dt, sb, "");
                                    dalstr = sb.ToString();
                                    break;
                                }
                            case "Update()":
                                {
                                    helper.CreateUpdate(tableName, dt, sb, "");
                                    dalstr = sb.ToString();
                                    break;
                                }
                            case "ListByWhere()":
                                {
                                    helper.CreateListByWhere(tableName, sb, "");
                                    dalstr = sb.ToString();
                                    break;
                                }
                            default:
                                {
                                    dalstr = sb.ToString();
                                    break;
                                }
                        }
                    }
                }
                else
                {
                    modelstr = helper.CreateModelCode(tableName, dt).ToString();

                    switch (strDAL)
                    {
                        case "All DAL":
                            {
                                dalstr = helper.CreateDALCode(tableName, dt).ToString();
                                break;
                            }
                        case "ListAll()":
                            {
                                helper.CreateListAll(tableName, dt, sb, "");
                                dalstr = sb.ToString();
                                break;
                            }
                        case "DeleteById()":
                            {
                                helper.CreateDeleteById(tableName, dt, sb, "");
                                dalstr = sb.ToString();
                                break;
                            }
                        case "GetById()":
                            {
                                helper.CreateGetById(tableName, dt, sb, "");
                                dalstr = sb.ToString();
                                break;
                            }
                        case "Insert()":
                            {
                                helper.CreateInsert(tableName, dt, sb, "");
                                dalstr = sb.ToString();
                                break;
                            }
                        case "Update()":
                            {
                                helper.CreateUpdate(tableName, dt, sb, "");
                                dalstr = sb.ToString();
                                break;
                            }
                        case "ListByWhere()":
                            {
                                helper.CreateListByWhere(tableName, sb, "");
                                dalstr = sb.ToString();
                                break;
                            }
                        default:
                            {
                                dalstr = sb.ToString();
                                break;
                            }
                    }
                    tbDAL.Text = dalstr;
                    tbModel.Text = modelstr;
                }
                tbDAL.Text = dalstr;
                tbModel.Text = modelstr;
            }
            btnExport.IsEnabled = true;
            btnGenerateCode.IsDefault = false;
        }
 private void GetCode(string tableName)
 {
     string getfiled = sqltype == 2 ? "select * from `" + tableName + "` LIMIT 0" : "select top 0 * from [" + tableName + "]";
     DataTable dt = ExecuteDataTable(getfiled);
     CreateCodeHelper helper = new CreateCodeHelper();
     string strDAL = cbDAL.SelectedItem.ToString();
     StringBuilder sb = new StringBuilder();
     switch (strDAL)
     {
         case "All DAL":
             {
                 dalstr = helper.CreateDALCode(tableName, dt);
                 break;
             }
         case "ListAll()":
             {
                 helper.CreateListAll(tableName, dt, sb, "");
                 dalstr = sb;
                 break;
             }
         case "DeleteById()":
             {
                 helper.CreateDeleteById(tableName, dt, sb, "");
                 dalstr = sb;
                 break;
             }
         case "GetById()":
             {
                 helper.CreateGetById(tableName, dt, sb, "");
                 dalstr = sb;
                 break;
             }
         case "Insert()":
             {
                 helper.CreateInsert(tableName, dt, sb, "");
                 dalstr = sb;
                 break;
             }
         case "Update()":
             {
                 helper.CreateUpdate(tableName, dt, sb, "");
                 dalstr = sb;
                 break;
             }
         case "ListByWhere()":
             {
                 helper.CreateListByWhere(tableName, sb, "");
                 dalstr = sb;
                 break;
             }
         case "ListByPage()":
             {
                 helper.CreateListByPage(tableName, dt, sb, "");
                 dalstr = sb;
                 break;
             }
         default:
             {
                 dalstr = sb;
                 break;
             }
     }
 }
        private void GetCode(string tableName)
        {
            string           getfiled = sqltype == 2 ? "select * from `" + tableName + "` LIMIT 0" : "select top 0 * from [" + tableName + "]";
            DataTable        dt       = ExecuteDataTable(getfiled);
            CreateCodeHelper helper   = new CreateCodeHelper();
            string           strDAL   = cbDAL.SelectedItem.ToString();
            StringBuilder    sb       = new StringBuilder();

            switch (strDAL)
            {
            case "All DAL":
            {
                dalstr = helper.CreateDALCode(tableName, dt);
                break;
            }

            case "ListAll()":
            {
                helper.CreateListAll(tableName, dt, sb, "");
                dalstr = sb;
                break;
            }

            case "DeleteById()":
            {
                helper.CreateDeleteById(tableName, dt, sb, "");
                dalstr = sb;
                break;
            }

            case "GetById()":
            {
                helper.CreateGetById(tableName, dt, sb, "");
                dalstr = sb;
                break;
            }

            case "Insert()":
            {
                helper.CreateInsert(tableName, dt, sb, "");
                dalstr = sb;
                break;
            }

            case "Update()":
            {
                helper.CreateUpdate(tableName, dt, sb, "");
                dalstr = sb;
                break;
            }

            case "ListByWhere()":
            {
                helper.CreateListByWhere(tableName, sb, "");
                dalstr = sb;
                break;
            }

            case "ListByPage()":
            {
                helper.CreateListByPage(tableName, dt, sb, "");
                dalstr = sb;
                break;
            }

            default:
            {
                dalstr = sb;
                break;
            }
            }
        }
        private void CreateCode(string tableName)
        {
            if (tableName == null)
            {
                tbDAL.Text = tbModel.Text = "请选择要生成的表";
                return;
            }

            else
            {
                DataTable        dt     = ExecuteDataTable("select top 0 * from " + tableName);
                CreateCodeHelper helper = new CreateCodeHelper();
                string           strDAL = cbDAL.SelectedItem.ToString();
                StringBuilder    sb     = new StringBuilder();

                if (!tbNamespace.Text.Equals("命名空间") && tbNamespace.Text.Trim().Length > 0)
                {
                    modelstr = helper.CreateModelCode(tableName, dt, tbNamespace.Text).ToString();

                    if (strDAL.Equals("All DAL"))
                    {
                        dalstr     = helper.CreateDALCode(tableName, dt, tbNamespace.Text).ToString();
                        tbDAL.Text = dalstr;
                    }
                    else
                    {
                        switch (strDAL)
                        {
                        case "All DAL":
                        {
                            dalstr = helper.CreateDALCode(tableName, dt).ToString();
                            break;
                        }

                        case "ListAll()":
                        {
                            helper.CreateListAll(tableName, dt, sb, "");
                            dalstr = sb.ToString();
                            break;
                        }

                        case "DeleteById()":
                        {
                            helper.CreateDeleteById(tableName, dt, sb, "");
                            dalstr = sb.ToString();
                            break;
                        }

                        case "GetById()":
                        {
                            helper.CreateGetById(tableName, dt, sb, "");
                            dalstr = sb.ToString();
                            break;
                        }

                        case "Insert()":
                        {
                            helper.CreateInsert(tableName, dt, sb, "");
                            dalstr = sb.ToString();
                            break;
                        }

                        case "Update()":
                        {
                            helper.CreateUpdate(tableName, dt, sb, "");
                            dalstr = sb.ToString();
                            break;
                        }

                        case "ListByWhere()":
                        {
                            helper.CreateListByWhere(tableName, sb, "");
                            dalstr = sb.ToString();
                            break;
                        }

                        default:
                        {
                            dalstr = sb.ToString();
                            break;
                        }
                        }
                    }
                }
                else
                {
                    modelstr = helper.CreateModelCode(tableName, dt).ToString();

                    switch (strDAL)
                    {
                    case "All DAL":
                    {
                        dalstr = helper.CreateDALCode(tableName, dt).ToString();
                        break;
                    }

                    case "ListAll()":
                    {
                        helper.CreateListAll(tableName, dt, sb, "");
                        dalstr = sb.ToString();
                        break;
                    }

                    case "DeleteById()":
                    {
                        helper.CreateDeleteById(tableName, dt, sb, "");
                        dalstr = sb.ToString();
                        break;
                    }

                    case "GetById()":
                    {
                        helper.CreateGetById(tableName, dt, sb, "");
                        dalstr = sb.ToString();
                        break;
                    }

                    case "Insert()":
                    {
                        helper.CreateInsert(tableName, dt, sb, "");
                        dalstr = sb.ToString();
                        break;
                    }

                    case "Update()":
                    {
                        helper.CreateUpdate(tableName, dt, sb, "");
                        dalstr = sb.ToString();
                        break;
                    }

                    case "ListByWhere()":
                    {
                        helper.CreateListByWhere(tableName, sb, "");
                        dalstr = sb.ToString();
                        break;
                    }

                    default:
                    {
                        dalstr = sb.ToString();
                        break;
                    }
                    }
                    tbDAL.Text   = dalstr;
                    tbModel.Text = modelstr;
                }
                tbDAL.Text   = dalstr;
                tbModel.Text = modelstr;
            }
            btnExport.IsEnabled       = true;
            btnGenerateCode.IsDefault = false;
        }