public static void InsertVState(string state, double value)
        {
            BlackTD0DataContext blackTD0 = new BlackTD0DataContext();
            int sno = blackTD0.STATEs.Where(p => p.MSTATE == state).Single().SNO;

            if (!blackTD0.VSTATEs.Any(p => p.SNO == sno))
            {
                VSTATE tmps = new VSTATE();
                tmps.SNO = sno;
                tmps.VALUE = value;
                blackTD0.VSTATEs.InsertOnSubmit(tmps);
                blackTD0.SubmitChanges();
            }
            else
            {
                blackTD0.VSTATEs.Where(p => p.SNO == sno).Single().VALUE = value;
                blackTD0.SubmitChanges();
            }
        }
 public static double SelectVState(string state)
 {
     double value;
     BlackTD0DataContext blackTD0 = new BlackTD0DataContext();
     var tmp = from c in blackTD0.STATEs
               from o in blackTD0.VSTATEs
               where c.SNO == o.SNO && c.MSTATE == state
               select o.VALUE;
     if (tmp.Count() <= 0)
     {
         VSTATE tmps = new VSTATE();
         tmps.SNO = blackTD0.STATEs.Where(p => p.MSTATE == state).Single().SNO;
         tmps.VALUE = 1.0;
         blackTD0.VSTATEs.InsertOnSubmit(tmps);
         blackTD0.SubmitChanges();
         value = 1.0;
     }
     else value = tmp.Single();
     return value;
 }