Example #1
0
 /// <summary>
 /// 生成代码
 /// </summary>
 /// <param name="tableName"></param>
 private void CreateCode(string tableName)
 {
     if (tableName == null)
     {
         tbDAL.Text = tbModel.Text = "请选择要生成的表";
         return;
     }
     else
     {
         string           getfiled = sqltype == 2 ? "select * from `" + tableName + "` LIMIT 0" : "select top 0 * from [" + tableName + "]";
         DataTable        dt       = ExecuteDataTable(getfiled);
         CreateCodeHelper helper   = new CreateCodeHelper();
         string           strDAL   = "";
         this.Dispatcher.Invoke(delegate
         {
             strDAL = cbDAL.SelectedItem.ToString();
         });
         StringBuilder sb = new StringBuilder();
         if (!tbNamespace.Text.Equals("命名空间") && tbNamespace.Text.Trim().Length > 0)
         {
             modelstr = helper.CreateModelCode(tableName, dt, tbNamespace.Text);
             if (strDAL.Equals("All DAL"))
             {
                 dalstr     = helper.CreateDALCode(tableName, dt, tbNamespace.Text);
                 tbDAL.Text = dalstr.ToString();
             }
             else
             {
                 GetCode(tableName);
             }
         }
         else
         {
             modelstr = helper.CreateModelCode(tableName, dt);
             GetCode(tableName);
         }
         tbDAL.Text   = dalstr.ToString();
         tbModel.Text = modelstr.ToString();
     }
     btnExport.IsEnabled       = true;
     btnGenerateCode.IsDefault = false;
 }
        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;
        }
Example #3
0
        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;
            }
            }
        }
Example #4
0
 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;
             }
     }
 }
Example #5
0
 /// <summary>
 /// 生成代码
 /// </summary>
 /// <param name="tableName"></param>
 private void CreateCode(string tableName)
 {
     if (tableName == null)
     {
         tbDAL.Text = tbModel.Text = "请选择要生成的表";
         return;
     }
     else
     {
         string getfiled = sqltype == 2 ? "select * from `" + tableName + "` LIMIT 0" : "select top 0 * from [" + tableName + "]";
         DataTable dt = ExecuteDataTable(getfiled);
         CreateCodeHelper helper = new CreateCodeHelper();
         string strDAL = "";
         this.Dispatcher.Invoke(delegate
         {
             strDAL = cbDAL.SelectedItem.ToString();
         });
         StringBuilder sb = new StringBuilder();
         if (!tbNamespace.Text.Equals("命名空间") && tbNamespace.Text.Trim().Length > 0)
         {
             modelstr = helper.CreateModelCode(tableName, dt, tbNamespace.Text);
             if (strDAL.Equals("All DAL"))
             {
                 dalstr = helper.CreateDALCode(tableName, dt, tbNamespace.Text);
                 tbDAL.Text = dalstr.ToString();
             }
             else
             {
                 GetCode(tableName);
             }
         }
         else
         {
             modelstr = helper.CreateModelCode(tableName, dt);
             GetCode(tableName);
         }
         tbDAL.Text = dalstr.ToString();
         tbModel.Text = modelstr.ToString();
     }
     btnExport.IsEnabled = true;
     btnGenerateCode.IsDefault = false;
 }
        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;
        }