Esempio n. 1
0
 /// <summary>
 /// 通过对象增加数据库记录
 /// </summary>
 /// <param name="mineral"></param>
 public static void Add(IMineral mineral)
 {
     if (mineral.mineralType == 1) //均质
     {
         HomogeneousMineralInfo homogeneousMineral = (HomogeneousMineralInfo)mineral;
         string sql = String.Empty;
         if (!string.IsNullOrEmpty(homogeneousMineral.Rr))
         {
             sql = String.Format(
                 "INSERT INTO HomogeneousMineral(ChineseName,EnglishName,ChemicalFormula,Syngony,NonUniformity,Reflectivity,Hardness,ReflectionColor,Rr,DRr,InternalReflection,Origin,IMK) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')",
                 homogeneousMineral.ChineseName, homogeneousMineral.EnglishName,
                 homogeneousMineral.ChemicalFormula, homogeneousMineral.Syngony,
                 homogeneousMineral.NonUniformity, homogeneousMineral.Reflectivity,
                 homogeneousMineral.Hardness, homogeneousMineral.ReflectionColor,
                 float.Parse(homogeneousMineral.Rr), homogeneousMineral.DRr,
                 homogeneousMineral.InternalReflection, homogeneousMineral.Origin,
                 homogeneousMineral.IMK);
         }
         else
         {
             sql = String.Format(
                 "INSERT INTO HomogeneousMineral(ChineseName,EnglishName,ChemicalFormula,Syngony,NonUniformity,Reflectivity,Hardness,ReflectionColor,DRr,InternalReflection,Origin,IMK) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}')",
                 homogeneousMineral.ChineseName, homogeneousMineral.EnglishName,
                 homogeneousMineral.ChemicalFormula, homogeneousMineral.Syngony,
                 homogeneousMineral.NonUniformity, homogeneousMineral.Reflectivity,
                 homogeneousMineral.Hardness, homogeneousMineral.ReflectionColor, homogeneousMineral.DRr,
                 homogeneousMineral.InternalReflection, homogeneousMineral.Origin,
                 homogeneousMineral.IMK);
         }
         SqlHelper.ExecuteNonQuery(sql);
     }
     else if (mineral.mineralType == 2) //非均质
     {
         HeterogeneousMineralInfo heterogeneousMineral = (HeterogeneousMineralInfo)mineral;
         string sql = String.Empty;
         if (!string.IsNullOrEmpty(heterogeneousMineral.Ar))
         {
             sql = String.Format(
                 "INSERT INTO HeterogeneousMineral(ChineseName,EnglishName,ChemicalFormula,Syngony,NonUniformity,Reflectivity,Hardness,ReflectionColor,Bireflection,Ar,DAr,Rs,Ps,DRr,ReflectionDAR,InternalReflection,Origin,IMK) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}')",
                 heterogeneousMineral.ChineseName, heterogeneousMineral.EnglishName,
                 heterogeneousMineral.ChemicalFormula, heterogeneousMineral.Syngony,
                 heterogeneousMineral.NonUniformity, heterogeneousMineral.Reflectivity,
                 heterogeneousMineral.Hardness, heterogeneousMineral.ReflectionColor,
                 heterogeneousMineral.Bireflection, heterogeneousMineral.Ar, heterogeneousMineral.DAr,
                 heterogeneousMineral.Rs, heterogeneousMineral.Ps, heterogeneousMineral.DRr,
                 heterogeneousMineral.ReflectionDAR, heterogeneousMineral.InternalReflection,
                 heterogeneousMineral.Origin, heterogeneousMineral.IMK);
         }
         else
         {
             sql = String.Format(
                 "INSERT INTO HeterogeneousMineral(ChineseName,EnglishName,ChemicalFormula,Syngony,NonUniformity,Reflectivity,Hardness,ReflectionColor,Bireflection,DAr,Rs,Ps,DRr,ReflectionDAR,InternalReflection,Origin,IMK) VALUES('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}')",
                 heterogeneousMineral.ChineseName, heterogeneousMineral.EnglishName,
                 heterogeneousMineral.ChemicalFormula, heterogeneousMineral.Syngony,
                 heterogeneousMineral.NonUniformity, heterogeneousMineral.Reflectivity,
                 heterogeneousMineral.Hardness, heterogeneousMineral.ReflectionColor,
                 heterogeneousMineral.Bireflection, heterogeneousMineral.DAr,
                 heterogeneousMineral.Rs, heterogeneousMineral.Ps, heterogeneousMineral.DRr,
                 heterogeneousMineral.ReflectionDAR, heterogeneousMineral.InternalReflection,
                 heterogeneousMineral.Origin, heterogeneousMineral.IMK);
         }
         SqlHelper.ExecuteNonQuery(sql);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 更新数据库
 /// </summary>
 /// <param name="mineral"></param>
 public static void Update(IMineral mineral)
 {
     if (mineral.mineralType == 1)
     {
         HomogeneousMineralInfo homogeneousMineral = (HomogeneousMineralInfo)mineral;
         string sql = String.Empty;
         if (!string.IsNullOrEmpty(homogeneousMineral.Rr))
         {
             sql = String.Format(
                 "UPDATE HomogeneousMineral SET ChineseName='{0}',EnglishName='{1}',ChemicalFormula='{2}',Syngony='{3}',NonUniformity='{4}',Reflectivity='{5}',Hardness='{6}',ReflectionColor='{7}',Rr='{8}',DRr='{9}',InternalReflection='{10}',Origin='{11}',IMK='{12}'  WHERE ID={13}",
                 homogeneousMineral.ChineseName, homogeneousMineral.EnglishName,
                 homogeneousMineral.ChemicalFormula, homogeneousMineral.Syngony,
                 homogeneousMineral.NonUniformity, homogeneousMineral.Reflectivity,
                 homogeneousMineral.Hardness, homogeneousMineral.ReflectionColor, homogeneousMineral.Rr,
                 homogeneousMineral.DRr, homogeneousMineral.InternalReflection,
                 homogeneousMineral.Origin, homogeneousMineral.IMK, homogeneousMineral.ID);
         }
         else
         {
             sql = String.Format(
                 "UPDATE HomogeneousMineral SET ChineseName='{0}',EnglishName='{1}',ChemicalFormula='{2}',Syngony='{3}',NonUniformity='{4}',Reflectivity='{5}',Hardness='{6}',ReflectionColor='{7}',DRr='{8}',InternalReflection='{9}',Origin='{10}',IMK='{11}'  WHERE ID={12}",
                 homogeneousMineral.ChineseName, homogeneousMineral.EnglishName,
                 homogeneousMineral.ChemicalFormula, homogeneousMineral.Syngony,
                 homogeneousMineral.NonUniformity, homogeneousMineral.Reflectivity,
                 homogeneousMineral.Hardness, homogeneousMineral.ReflectionColor,
                 homogeneousMineral.DRr, homogeneousMineral.InternalReflection,
                 homogeneousMineral.Origin, homogeneousMineral.IMK, homogeneousMineral.ID);
         }
         SqlHelper.ExecuteNonQuery(sql);
     }
     else if (mineral.mineralType == 2)
     {
         HeterogeneousMineralInfo heterogeneousMineral = (HeterogeneousMineralInfo)mineral;
         string sql = String.Empty;
         if (!string.IsNullOrEmpty(heterogeneousMineral.Ar))
         {
             sql = String.Format(
                 "UPDATE HeterogeneousMineral SET ChineseName='{0}',EnglishName='{1}',ChemicalFormula='{2}',Syngony='{3}',NonUniformity='{4}',Reflectivity='{5}',Hardness='{6}',ReflectionColor='{7}',Bireflection='{8}',Ar='{9}',DAr='{10}',Rs='{11}',Ps='{12}',DRr='{13}',ReflectionDAR='{14}',InternalReflection='{15}',Origin='{16}',IMK='{17}'  WHERE ID={18}",
                 heterogeneousMineral.ChineseName, heterogeneousMineral.EnglishName,
                 heterogeneousMineral.ChemicalFormula, heterogeneousMineral.Syngony,
                 heterogeneousMineral.NonUniformity, heterogeneousMineral.Reflectivity,
                 heterogeneousMineral.Hardness, heterogeneousMineral.ReflectionColor,
                 heterogeneousMineral.Bireflection, heterogeneousMineral.Ar, heterogeneousMineral.DAr,
                 heterogeneousMineral.Rs, heterogeneousMineral.Ps, heterogeneousMineral.DRr,
                 heterogeneousMineral.ReflectionDAR, heterogeneousMineral.InternalReflection,
                 heterogeneousMineral.Origin, heterogeneousMineral.IMK, heterogeneousMineral.ID);
         }
         else
         {
             sql = String.Format(
                 "UPDATE HeterogeneousMineral SET ChineseName='{0}',EnglishName='{1}',ChemicalFormula='{2}',Syngony='{3}',NonUniformity='{4}',Reflectivity='{5}',Hardness='{6}',ReflectionColor='{7}',Bireflection='{8}',DAr='{9}',Rs='{10}',Ps='{11}',DRr='{12}',ReflectionDAR='{13}',InternalReflection='{14}',Origin='{15}',IMK='{16}'  WHERE ID={17}",
                 heterogeneousMineral.ChineseName, heterogeneousMineral.EnglishName,
                 heterogeneousMineral.ChemicalFormula, heterogeneousMineral.Syngony,
                 heterogeneousMineral.NonUniformity, heterogeneousMineral.Reflectivity,
                 heterogeneousMineral.Hardness, heterogeneousMineral.ReflectionColor,
                 heterogeneousMineral.Bireflection, heterogeneousMineral.DAr,
                 heterogeneousMineral.Rs, heterogeneousMineral.Ps, heterogeneousMineral.DRr,
                 heterogeneousMineral.ReflectionDAR, heterogeneousMineral.InternalReflection,
                 heterogeneousMineral.Origin, heterogeneousMineral.IMK, heterogeneousMineral.ID);
         }
         SqlHelper.ExecuteNonQuery(sql);
     }
 }