函式範例

  • 1619
  • 0

函式範例

 

   1:   private string getPrescription(string code)
   2:      {
   3:          string prescription = " ";
   4:   
   5:          switch (code)
   6:          {
   7:              case "a":
   8:                  prescription = "方法1";
   9:                  break;
  10:              case "b":
  11:                  prescription = "方法2";
  12:                  break;
  13:              case "c":
  14:                  prescription = "方法3";
  15:                  break;
  16:              case "d":
  17:                  prescription = "方法4";
  18:                  break;
  19:              case "e":
  20:                  prescription = "方法5";
  21:                  break;
  22:              case "f":
  23:                  prescription = "方法6";
  24:                  break;
  25:              case "g":
  26:                  prescription = "方法7";
  27:                  break;
  28:               }
  29:   
  30:          return prescription;
  31:      }
  32:   
  33:   private static string GetBoolString(bool b)
  34:      {
  35:          if (b)
  36:              return "是";
  37:          else
  38:              return "否";
  39:      }
  40:   
  41:   protected void DataList4_ItemDataBound(object sender, DataListItemEventArgs e)
  42:      {
  43:   
  44:          MeasureP mpr = (MeasureP)e.Item.DataItem;
  45:   
  46:          ((Label)e.Item.FindControl("blooa")).Text = getPrescription(mpr.aaa);
  47:          ((Label)e.Item.FindControl("bloob")).Text = getPrescription(mpr.bbb);
  48:          ((Label)e.Item.FindControl("blooc")).Text = getPrescription(mpr.ccc);
  49:          ((Label)e.Item.FindControl("blood")).Text = getPrescription(mpr.ddd);
     
  55:          ((Label)e.Item.FindControl("blooaa")).Text = GetBoolString(mpr.Isaa);
  56:          ((Label)e.Item.FindControl("bloobb")).Text = GetBoolString(mpr.Isbb);
  57:          ((Label)e.Item.FindControl("blooc")).Text = GetBoolString(mpr.Iscc);
  58:      
  64:      }