1 namespace PV 2 { 3 public enum SaddleType 4 { 5 Draw1 = 1, 6 Draw2, 7 Draw3, 8 Draw4, 9 Draw5, 10 Draw6, 11 Draw7, 12 Draw8, 13 } 14 }
先构建一个枚举变量
枚举出一些数据
1 public void Draw() 2 { 3 pcenter = zPInsertMain.dPolar(90, zDi / 2 +ztn+zdelta4+ zh); 4 zMainEntIds = new ObjectIdCollection(); 5 DrawZ1(PInsertMain); 6 switch (zSaddleType) 7 { 8 case SaddleType.Draw1: 9 case SaddleType.Draw2: 10 case SaddleType.Draw3: 11 DrawA(); 12 break; 13 case SaddleType.Draw4: 14 break; 15 case SaddleType.Draw5: 16 break; 17 case SaddleType.Draw6: 18 break; 19 case SaddleType.Draw7: 20 break; 21 case SaddleType.Draw8: 22 break; 23 default: 24 break; 25 } 26 } 27 public void DrawA() 28 { 29 switch (zViewType) 30 { 31 case ViewType.Main: 32 33 break; 34 case ViewType.Top: 35 break; 36 case ViewType.Side: 37 break; 38 default: 39 break; 40 } 41 }
在saddle中定义枚举使用方法
1 string draw = tbBiao.Rows[0]["Drawing"].ToString(); 2 saddle.SaddleType = (SaddleType)Enum.Parse(typeof(SaddleType), draw); 3 saddle.ViewType = (ViewType)Enum.Parse(typeof(ViewType), rbViewNow.Name.Replace("rb", "")); 4 using (Transaction trans = db.TransactionManager.StartTransaction())//添加事物 5 { 6 saddle.Draw(); 7 }
在窗体代码中获取数据库中数据然后赋值给saddle中的参数
原文:http://www.cnblogs.com/xzh1993/p/4141368.html