问题描述
Dobrýden,chtělbychpoprositsjménemvšechmaturantům,zda by jste tuto diskusi nemazali,protožesevnínanicneptám。 Jednáseo tožedokoncekvětnamaturujemeamůžemepoužívatmicrosoft.com,tak sisemdáváme"tahák"。 Byli bychom moc $ b $brádizaoshovívavost一个pochopení。 Předemjěkujeme。
CONSOLE
静态无效Main(string [] args)
      {
          Console.ForegroundColor = ConsoleColor.Yellow;
          Console.WriteLine(QUOT; -------------------------------------------- - ");
          Console.WriteLine( Počítačovéhry - ");
            Console.WriteLine(QUOT; -------------------------------------------- - ");
          Console.WriteLine();
          Console.WriteLine(" ProvstupstiskněteENTER。);
          Console.ForegroundColor = ConsoleColor.Gray;
          Console.ReadLine();
$
          string constr =" server = lsd.spsejecna.net; database = slabyo; user id = slabyo; pwd = maxik1597" ;;
          conn = new SqlConnection(constr);
          conn.Open();
          char key ='0';
         你是
          {
              Console.Clear();
              WriteTable("THra");
              Console.Write("Možnéakce:\ nn - novýzáznam\\\
v - vymazatzáznam\\\
u - upravitzáznam\\\
q - ukončitaplikaci\\\
Vášvýběr:");
                Console.ForegroundColor = ConsoleColor.Gray;
              key = Console.ReadKey()。KeyChar;
             行动(关键);
          } while(key!='q');
$
          conn.Close();
          //Console.Read();
      }
static void WriteTable(string tablename)
      {
          Console.ForegroundColor = ConsoleColor.DarkYellow;
          Console.WriteLine(" --------------- Tabulka" + tablename +" --------------- \\\
");
          Console.ForegroundColor = ConsoleColor.Gray;
          string select =" SELECT * FROM" + tablename +" ;;" ;;
          comm = new SqlCommand(select,conn);
          reader = comm.ExecuteReader();
$
          if(reader.HasRows)
          {
              while(reader.Read())
              {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< reader.FieldCount; i ++)// FieldCount - > početsloupečků
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.White;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write(ColumnNameToLabel(reader.GetName(i))+":");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.DarkGray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(reader.GetValue(i).ToString()+" \t");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; reader.Close();
$
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.DarkYellow;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(" ------------ Konec Tabulky" + tablename +" -------------");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Green;
&NBSP; &NBSP; &NBSP; }
static void ModifyRow()
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Cyan;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write(" Zadejte ID hrykúpravě:");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string id = Console.ReadLine();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Clear();
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string cmd =" SELECT * FROM THra WHERE id_hra =" + id +" ;;" ;;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; comm = new SqlCommand(cmd,conn);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; reader = comm.ExecuteReader();
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; reader.Read();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< reader.FieldCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.White;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write(ColumnNameToLabel(reader.GetName(i))+":");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.DarkGray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(reader.GetValue(i).ToString()+" \t");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Cyan;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; object [] vals = new object [reader.FieldCount]; //Připraví杆proprovenujícihodnoty
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; reader.GetValues(vals);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; reader.Close();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine();
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine("Všechnynevyplněnéhodnotyzůstanounemměněny。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Cyan;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write("Zadejtenázevhry:");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string nazev = GetInput< string>(true,(x)=> x.Length< = 25);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; nazev = nazev =="" ? vals [1] .ToString():nazev;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Cyan;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write(" Zadejte popis hry:");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string popis = GetInput< string>(true,(x)=> true);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; popis = popis =="" ? vals [2] .ToString():popis;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Cyan;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write(" Zadejtedatumvydáníhry(formátmm-dd-rrrr)hry:");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string dat_vyd = GetInput< string>(true,(x)=> x.Length == 10);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dat_vyd = dat_vyd =="" ? vals [3] .ToString():dat_vyd;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Cyan;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write("Zadejtedoboručenývěkhry:");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string doporuc_vek = GetInput< int>(true,(x)=> x< = 18&& x> 0);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; doporuc_vek = doporuc_vek =="" ? vals [4] .ToString():doporuc_vek;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; WriteTable("TVyvojar");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Cyan;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write(" ZadejteIDvývojářoery:");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string id_vyvoj = GetInput< int>(true,(x)=> x> 0);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; id_vyvoj = id_vyvoj =="" ? vals [5] .ToString():id_vyvoj;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Cyan;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write("Zadejtewebovéstránkyhry:");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string web = GetInput< string>(true,(x)=> x.Length< = 20);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; web = web =="" ? vals [6] .ToString():web;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; WriteTable("TEngine");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Cyan;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write(" Zadejte ID enginu hry:");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string id_eng = GetInput< int>(true,(x)=> x> 0);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; id_eng = id_eng =="" ? vals [7] .ToString():id_eng;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; cmd = String.Format(" UPDATE THra SET nazev ='{0}',popis ='{1}',dat_vyd ='{2}',id_eng = {3},id_vyvoj = {4},web =' {5}',doporuc_vek = {6} WHERE id_hra = {7};",nazev,popis,dat_vyd,id_eng,id_vyvoj,web,doporuc_vek,
id);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; comm = new SqlCommand(cmd,conn);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; comm.ExecuteNonQuery();
&NBSP; &NBSP; &NBSP; }
静态字符串GetInput< T>(bool allowempty,Func< T,bool> func)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MethodInfo parseMethod = null;
&NBSP; &NBSP; &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(typeof(T)!= typeof(string))//Kdyžtonenístring
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; parseMethod = typeof(T)。GetMethod(" Parse",new Type [] {typeof(string)});
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool first = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string output ="" ;;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; T测试; //例如
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;你是
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(!first)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Red;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.Write("Neplatnáhodnota!Zadejte znovu:");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.ForegroundColor = ConsoleColor.Gray;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; first = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; output = Console.ReadLine();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(output ==""&& allowempty)break;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则if(output ==""&&!allowempty)继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(typeof(T)!= typeof(string))
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; testing =(T)parseMethod.Invoke(null,new object [] {output}); // ostani
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; testing =(T)(object)output; // string
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(func(testing))break;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; } while(true);
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回输出;
&NBSP; &NBSP; &NBSP; }
FORM-METODY
使用System;
使用System。 Collections.Generic;
使用System.Linq;
使用System.Text;
使用System.Threading.Tasks;
使用System.Data;
使用System.Windows.Forms;
使用System.Text.RegularExpressions; // Onlzstring
/ / using System.Data.SqlClient;
命名空间WindowsFormsApplication1
{
&NBSP; classMaskMetody
&NBSP; {
&NBSP; &NBSP; &NBSP; public static bool OnlyInt(string text)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int x;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; return int.TryParse(text,out x);
&NBSP; &NBSP; &NBSP; &NBSP; / * bool pass = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< text.Length; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; pass = pass&& text [i]> ='0'&& text [i]< ='9';
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回通行证; * /
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static bool OnlyString(string text)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回新的正则表达式(" ^([A-ZĚŠČŘŽÝÁÍÉÚŮÓŤĎ] {1})([a-zěščřžýáíéůúťďó] *)")。匹配(文本).Value == text;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; / * bool pass = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< text.Length; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(i == 0)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; pass = pass&& ((text [i]> ='A'&& text [i]< ='Z')|| text [i] =='Ř'|| text [i] =='Š'| | text [i] =='Č'|| text [i] =='Ž'|| text [i] =='Á'|| text [i] =='Í'|| text [i]
=='É'|| text [i] =='Ď'|| text [i] =='Ť'|| text [i] =='Ň'|| text [i] ==' Ú');
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; pass = pass&& (text [i]> ='a'&& text [i]< ='z'|| text [i]> ='á'&& text [i]< ='ž ');
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回通行证; * /
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static bool OnlyStringCheck(string text)//Velkápísmena
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回新的正则表达式("([A-ZĚŠČŘŽÝÁÍÉÚŮÓŤĎ] *)")。匹配(文本).Value == text;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; / * bool pass = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< text.Length; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(i == 0)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; pass = pass&& ((text [i]> ='A'&& text [i]< ='Z')|| text [i] =='Ř'|| text [i] =='Š'| | text [i] =='Č'|| text [i] =='Ž'|| text [i] =='Á'|| text [i] =='Í'|| text [i]
=='É'|| text [i] =='Ď'|| text [i] =='Ť'|| text [i] =='Ň'|| text [i] ==' Ú');
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; pass = pass&& (text [i]> ='a'&& text [i]< ='z'|| text [i]> ='á'&& text [i]< ='ž ');
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回通行证; * /
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static bool OnlyMesta(string text)
&NBSP; &NBSP; &NBSP; {
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回新的正则表达式("^([A-ZĚŠČŘŽÝÁÍÉÚŮÓŤĎ] {1})([a-zěščřžýáíéůúťďó0-9] *)")。匹配(文本).Value == text;
  ; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; / * bool pass = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< text.Length; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(i == 0)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; pass = pass&& ((text [i]> ='A'&& text [i]< ='Z')|| text [i] =='Ř'|| text [i] =='Š'| | text [i] =='Č'|| text [i] =='Ž'|| text [i] =='Á'|| text [i] =='Í'|| text [i]
=='É'|| text [i] =='Ď'|| text [i] =='Ť'|| text [i] =='Ň'|| text [i] ==' Ú');
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; pass = pass&& (text [i]> ='a'&& text [i]< ='z'|| text [i]> ='á'&& text [i]< ='ž '|| text [i]> ='0'&& text [i]< ='9');
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回通行证; * /
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static string zk(string text)//Peníze
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int pos = text.Length;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< text.Length; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(text [i] ==',')
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; pos = i;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string str ="" ;; $
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< pos; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; str + = text [i];
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; return str;
&NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; public static bool existencVaz(DataGridView grid1,DataGridView grid2,DataGridView grid3)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int a =(int)grid2.SelectedRows [0] .Cells [0] .Value;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int b =(int)grid3.SelectedRows [0] .Cells [0] .Value;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< grid1.RowCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if((int)grid1.Rows [i] .Cells [3] .Value == a)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if((int)grid1.Rows [i] .Cells [2] .Value == b)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show("Vazbaužmevenujev tabulce。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回zk;
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static bool existencRod(string text,DataGridView grid1)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string c;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; //(c.CompareTo(a)== 0?true:false)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; // int aa = Convert.ToInt32(a); MessageBox.Show("Záznam(Pacinet /Lékař)užmevenujev tabulce。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< grid1.RowCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; c = grid1.Rows [i] .Cells [4] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(c.CompareTo(text)== 0?true:false / * text == c * /)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show("Rodnéčíslorevenujev tabulce。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; // MessageBox.Show("Rodnéčíslorevenujev tabulce。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回zk;
&NBSP; &NBSP; &NBSP; } &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; public static bool existCisla(string a,DataGridView grid1)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int b = Convert.ToInt32(a);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< grid1.RowCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(b ==(int)grid1.Rows [i] .Cells [1] .Value)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show("Číslooužpresentuje。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回zk;
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static bool UpdateexistenceCisla(string a,string text,string text2,DataGridView grid1)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int b = Convert.ToInt32(a);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< grid1.RowCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(b ==(int)grid1.Rows [i] .Cells [1] .Value&&(text!= grid1.Rows [i] .Cells [2] .Value.ToString()|| text2! = grid1.Rows [i] .Cells [3] .Value.ToString())))
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show("Číslooužpresentuje。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回zk;
&NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; public static bool UpdateLekarCislo(string text,string text2,string text3,string text4,DataGridView grid1)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< grid1.RowCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(text == grid1.Rows [i] .Cells [1] .Value.ToString()&& text2 == grid1.Rows [i] .Cells [2] .Value.ToString()&& text3 == grid1.Rows [i] .Cells [3] .Value.ToString()/ *&& text4 == grid1.Rows [i] .Cells [4] .Value.ToString()* /)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(text == grid1.Rows [i] .Cells [1] .Value.ToString()&& text2!= grid1.Rows [i] .Cells [2] .Value.ToString()&& text3!= grid1.Rows [i] .Cells [3] .Value.ToString()/ * text4!= grid1.Rows [i] .Cells [4] .Value.ToString()* /)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show("Číslolekařejížmexusuje。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; } // zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回zk;
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static bool UpdateLekarRod(string text,string text2,string text3,string text4,DataGridView grid1)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< grid1.RowCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(/ * text == grid1.Rows [i] .Cells [1] .Value.ToString()&& * / text2 == grid1.Rows [i] .Cells [2] .Value.ToString() && text3 == grid1.Rows [i] .Cells [3] .Value.ToString()&& text4 == grid1.Rows [i] .Cells [4] .Value.ToString())
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(/ * text!= grid1.Rows [i] .Cells [1] .Value.ToString()* / text2!= grid1.Rows [i] .Cells [2] .Value.ToString()&& text3!= grid1.Rows [i] .Cells [3] .Value.ToString()&& text4 == grid1.Rows [i] .Cells [4] .Value.ToString())
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show("Rodnéčíslojížmexusuje。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回zk;
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; public static bool existAtes(string a,DataGridView grid1)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;字符串b;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< grid1.RowCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; b = grid1.Rows [i] .Cells [1] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(b.CompareTo(a)== 0?true:false)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show("Atestacejížmexusujev tabulce。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; } return zk;
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static bool UpdateexistenceAtes(string a,string c,DataGridView grid1)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;字符串b;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< grid1.RowCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; b = grid1.Rows [i] .Cells [1] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(a == b&& c == grid1.Rows [i] .Cells [1] .Value.ToString())
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show("Atestacejížmexusujev tabulce。");
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; } return zk;
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static bool existencAtestaceDel(DataGridView grid1,DataGridView grid2)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; bool zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; int a =(int)grid1.SelectedRows [0] .Cells [0] .Value;
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< grid2.RowCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if((int)grid2.Rows [i] .Cells [2] .Value == a)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; MessageBox.Show(" Atestace,kterou chcete smazat jevevazbě。);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;休息;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;否则
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; zk = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;继续;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回zk;
&NBSP; &NBSP; &NBSP; }
&NBSP; }
}
FORM - SQL
public static void LekarPridat(字符串a,字符串b,字符串c ,string d,string e,string f,string g,string h,string i,string j,string k,string l,SqlConnection s)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string com = String.Format(" INSERT INTO TLekar(cislo_lek,jmeno_lek,prijmeni_lek,datum_nar_lek,tel_cislo_lek,mob_cislo_lek,email_lek,mesto_lek,ulice_lek,psc_lek,plat_lek,souk_sluzby_lek)值('{0}','{1}' , '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}'," {10}','{11}');"
,a,b,c,d,e,f ,g,h,i,j,k,l);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlCommand con = new SqlCommand(com,s);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; con.ExecuteNonQuery();
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static void LekarUpdate(string a,string b,string c,string d,string e,string f,string g,string h,string i,string j,string k,string l,string m,SqlConnection s)// NAUCIT
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; string com = String.Format(" UPDATE TLekar SET cislo_lek = {0},jmeno_lek ='{1}',prijmeni_lek ='{2}',datum_nar_lek ='{3}',tel_cislo_lek ='{4}', mob_cislo_lek ='{5}',email_lek ='{6}',mesto_lek ='{7}',
ulice_lek ='{8}',psc_lek ='{9}',plat_lek = {10}, souk_sluzby_lek ='{11}'WHERE id_lek = {12}",a,b,c,d,e,f,g,h,i,j,k,/*numericUpDown1.Value.ToString()* / l ,m);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlCommand con = new SqlCommand(com,s);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; con.ExecuteNonQuery();
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static void LekarDelete(string a,SqlConnection s)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; &NBSP; // SqlCommand vaz = new SqlCommand(" DELETE FROM TLekarVazAtestace,其中lek_id =" + a +" ;;",s);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; // SqlCommand pac = new SqlCommand(" UPDATA TPacient set lek_id = null where lek_id =" + a +" ;;",s);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlCommand con = new SqlCommand(" DELETE FROM TLekar WHERE id_lek =" + a +" ;;",s);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; //vaz.ExecuteNonQuery();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; //pac.ExecuteNonQuery();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; con.ExecuteNonQuery();
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static void LekarLoad(DataGridView dataGridView1,SqlConnection s)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView1.Columns.Clear();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView1.Rows.Clear();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlCommand conn = new SqlCommand(" SELECT * from TLekar",s);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlDataReader rdn = conn.ExecuteReader();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< rdn.FieldCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView1.Columns.Add(rdn.GetName(i),ColumnNameToLabel(rdn.GetName(i)));
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; object [] vals = new object [rdn.FieldCount];
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; while(rdn.Read())
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; rdn.GetValues(vals);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView1.Rows.Add(vals);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; rdn.Close();
&NBSP; &NBSP; &NBSP; }
public static string tran(SqlConnection s)//Nepřímátransakce
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlCommand com = new SqlCommand(" exec mp_ates @vysledek = @vysledek output",s);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlParameter par = com.Parameters.Add(" @ vysledek",SqlDbType.NVarChar,50);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; par.Direction = ParameterDirection.Output;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; com.ExecuteNonQuery();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; return(string)par.Value;
&NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; public static bool transaction_command(string command,SqlConnection s)//Přímatranskace
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlTransaction tran = s.BeginTransaction();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlCommand cmd = new SqlCommand(command,s);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; cmd.Transaction = tran;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;试试
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; cmd.ExecuteNonQuery();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; tran.Commit();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; catch(例外e)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(" //////////////////" + command +" //////////////////" ;);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(e.ToString());
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;试试
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; tran.Rollback();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; catch(例外f)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; Console.WriteLine(f.ToString());
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回false;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; }
public static void Zkouska(DataGridView dataGridView1,SqlConnection s,int a)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView1.Columns.Clear();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView1.Rows.Clear();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlCommand com = new SqlCommand(在TLekar.id_lek上的SELECT * FROM TLekar内部连接TLekarVazAtestace = TLekarVazAtestace.lek_id TAtestace.id_ates上的内部连接TAtestace = TLekarVazAtestace.ates_id WHERE TLekar.id_lek
=" + a,s) ;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; SqlDataReader rdn = com.ExecuteReader();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; for(int i = 0; i< rdn.FieldCount; i ++)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView1.Columns.Add(rdn.GetName(i),ColumnNameToLabel(rdn.GetName(i)));
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; object [] vals = new object [rdn.FieldCount];
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; while(rdn.Read())
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; rdn.GetValues(vals);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView1.Rows.Add(vals);
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; rdn.Close();
&NBSP; &NBSP; &NBSP; }
静态字符串ColumnNameToLabel(字符串名称)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP;开关(名称)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; case"id_lek":
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回"ID lekare";
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; case"cislo_lek":
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回"Cislolékaře";
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;默认值:
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP;返回姓名;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; }
声明@gynekologu int;
开始交易
set @ gynekologu =(SELECT count(*)FROM TAtestace WHERE nazev_ates ='Gynekologie');
set @gynekologu + = @@ ERROR;
INSERT INTO TAtestace(nazev_ates)VALUES ('Gynekologie');如果是@gynekologu<>,则为
0
开始
设置@vysledek ='Transakce se nepovedla';
回滚;
结束
else
begin
set @vysledek ='Transakce se povedla';
commit
结束
private void dataGridView1_SelectionChanged(object sender,EventArgs e)
&NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if(dataGridView1.SelectedRows.Count == 0)返回;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox2.Text = dataGridView1.SelectedRows [0] .Cells [1] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox3.Text = dataGridView1.SelectedRows [0] .Cells [2] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox4.Text = dataGridView1.SelectedRows [0] .Cells [3] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox5.Text = dataGridView1.SelectedRows [0] .Cells [4] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox8.Text = dataGridView1.SelectedRows [0] .Cells [5] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox9.Text = dataGridView1.SelectedRows [0] .Cells [6] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox10.Text = dataGridView1.SelectedRows [0] .Cells [7] .Value.ToString();
$
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; richTextBox1.Text = dataGridView1.SelectedRows [0] .Cells [9] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; richTextBox2.Text = dataGridView1.SelectedRows [0] .Cells [10] .Value.ToString();
&NBSP; &NBSP; &NBSP; &NBSP;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox2.BackColor = Color.White;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox3.BackColor = Color.White;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox4.BackColor = Color.White;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox5.BackColor = Color.White;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox8.BackColor = Color.White;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox9.BackColor = Color.White;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; textBox10.BackColor = Color.White;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView2.ClearSelection();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; foreach(dataGridView2.Rows中的DataGridViewRow行)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if((int)row.Cells [0] .Value ==(int)dataGridView1.SelectedRows [0] .Cells [8] .Value)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; row.Selected = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; dataGridView3.ClearSelection();
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; foreach(dataGridView3.Rows中的DataGridViewRow行)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; {
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; if((int)row.Cells [0] .Value ==(int)dataGridView1.SelectedRows [0] .Cells [11] .Value)
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; &NBSP; row.Selected = true;
&NBSP; &NBSP; &NBSP; &NBSP; &NBSP; }¥b $ b &NBSP; &NBSP; &NBSP; }
$
Dobrý den, chtěl bych poprosit s jménem všech maturantům, zda by jste tuto diskusi nemazali, protože se v ní na nic neptám. Jedná se o to že do konce května maturujeme a můžeme používat microsoft.com, tak si sem dáváme "tahák". Byli bychom moc rádi za shovívavost a pochopení. Předem děkujeme.
CONSOLE
static void Main(string[] args)
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("---------------------------------------------");
Console.WriteLine("- Počítačové hry -");
Console.WriteLine("---------------------------------------------");
Console.WriteLine();
Console.WriteLine("Pro vstup stiskněte ENTER.");
Console.ForegroundColor = ConsoleColor.Gray;
Console.ReadLine();
string constr = "server=lsd.spsejecna.net;database=slabyo;user id=slabyo;pwd=maxik1597";
conn = new SqlConnection(constr);
conn.Open();
char key = '0';
do
{
Console.Clear();
WriteTable("THra");
Console.Write("Možné akce:\nn - nový záznam\nv - vymazat záznam\nu - upravit záznam\nq - ukončit aplikaci\nVáš výběr: ");
Console.ForegroundColor = ConsoleColor.Gray;
key = Console.ReadKey().KeyChar;
Action(key);
} while (key != 'q');
conn.Close();
//Console.Read();
}
static void WriteTable(string tablename)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("---------------Tabulka "+tablename+"---------------\n");
Console.ForegroundColor = ConsoleColor.Gray;
string select = "SELECT * FROM " + tablename + ";";
comm = new SqlCommand(select, conn);
reader = comm.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)//FieldCount -> počet sloupečků
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write(ColumnNameToLabel(reader.GetName(i)) + ": ");
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine(reader.GetValue(i).ToString() + "\t");
Console.ForegroundColor = ConsoleColor.Gray;
}
Console.WriteLine();
}
}
reader.Close();
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("------------Konec Tabulky " + tablename + "-------------");
Console.ForegroundColor = ConsoleColor.Green;
}
static void ModifyRow()
{
Console.WriteLine();
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Zadejte ID hry k úpravě: ");
Console.ForegroundColor = ConsoleColor.Gray;
string id = Console.ReadLine();
Console.Clear();
string cmd = "SELECT * FROM THra WHERE id_hra = " + id + ";";
comm = new SqlCommand(cmd, conn);
reader = comm.ExecuteReader();
reader.Read();
for (int i = 0; i < reader.FieldCount; i++)
{
Console.ForegroundColor = ConsoleColor.White;
Console.Write(ColumnNameToLabel(reader.GetName(i)) + ": ");
Console.ForegroundColor = ConsoleColor.DarkGray;
Console.WriteLine(reader.GetValue(i).ToString() + "\t");
Console.ForegroundColor = ConsoleColor.Cyan;
}
object[] vals = new object[reader.FieldCount];//Připraví pole pro existujíci hodnoty
reader.GetValues(vals);
reader.Close();
Console.WriteLine();
Console.WriteLine("Všechny nevyplněné hodnoty zůstanou nezměněny.");
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Zadejte název hry: ");
Console.ForegroundColor = ConsoleColor.Gray;
string nazev = GetInput<string>(true, (x) => x.Length <= 25);
nazev = nazev == "" ? vals[1].ToString() : nazev;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Zadejte popis hry: ");
Console.ForegroundColor = ConsoleColor.Gray;
string popis = GetInput<string>(true, (x) => true);
popis = popis == "" ? vals[2].ToString() : popis;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Zadejte datum vydání hry (formát mm-dd-rrrr) hry: ");
Console.ForegroundColor = ConsoleColor.Gray;
string dat_vyd = GetInput<string>(true, (x) => x.Length == 10);
dat_vyd = dat_vyd == "" ? vals[3].ToString() : dat_vyd;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Zadejte doporučený věk hry: ");
Console.ForegroundColor = ConsoleColor.Gray;
string doporuc_vek = GetInput<int>(true, (x) => x <= 18 && x > 0);
doporuc_vek = doporuc_vek == "" ? vals[4].ToString() : doporuc_vek;
WriteTable("TVyvojar");
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Zadejte ID vývojáře hry: ");
Console.ForegroundColor = ConsoleColor.Gray;
string id_vyvoj = GetInput<int>(true, (x) => x > 0);
id_vyvoj = id_vyvoj == "" ? vals[5].ToString() : id_vyvoj;
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Zadejte webové stránky hry: ");
Console.ForegroundColor = ConsoleColor.Gray;
string web = GetInput<string>(true, (x) => x.Length <= 20);
web = web == "" ? vals[6].ToString() : web;
WriteTable("TEngine");
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("Zadejte ID enginu hry: ");
Console.ForegroundColor = ConsoleColor.Gray;
string id_eng = GetInput<int>(true, (x) => x > 0);
id_eng = id_eng == "" ? vals[7].ToString() : id_eng;
cmd = String.Format("UPDATE THra SET nazev='{0}', popis='{1}', dat_vyd='{2}', id_eng={3}, id_vyvoj={4}, web='{5}', doporuc_vek={6} WHERE id_hra={7};", nazev, popis, dat_vyd, id_eng, id_vyvoj, web, doporuc_vek, id);
comm = new SqlCommand(cmd, conn);
comm.ExecuteNonQuery();
}
static string GetInput<T>(bool allowempty, Func<T, bool> func)
{
MethodInfo parseMethod = null;
if (typeof(T) != typeof(string))//Když to není string
{
parseMethod = typeof(T).GetMethod("Parse", new Type[] {typeof(string)});
}
bool first = true;
string output = "";
T testing;//typ
do
{
if(!first)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("Neplatná hodnota! Zadejte znovu: ");
Console.ForegroundColor = ConsoleColor.Gray;
}
first = false;
output = Console.ReadLine();
if (output == "" && allowempty) break;
else if (output == "" && !allowempty) continue;
if (typeof(T) != typeof(string))
{
testing = (T)parseMethod.Invoke(null, new object[] { output });//ostani
}
else
{
testing = (T)(object)output;//string
}
if (func(testing)) break;
} while(true);
return output;
}
FORM-METODY
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Windows.Forms;
using System.Text.RegularExpressions;//Onlzstring
//using System.Data.SqlClient;
namespace WindowsFormsApplication1
{
class MaskMetody
{
public static bool OnlyInt(string text)
{
int x;
return int.TryParse(text, out x);
/* bool pass = true;
for (int i = 0; i < text.Length; i++)
{
pass = pass && text[i] >= '0' && text[i] <= '9';
}
return pass;*/
}
public static bool OnlyString(string text)
{
return new Regex("^([A-ZĚŠČŘŽÝÁÍÉÚŮÓŤĎ]{1})([a-zěščřžýáíéůúťďó]*)").Match(text).Value == text;
/*bool pass = true;
for (int i = 0; i < text.Length; i++)
{
if (i == 0)
{
pass = pass && ((text[i] >= 'A' && text[i] <= 'Z') || text[i] == 'Ř' || text[i] == 'Š' || text[i] == 'Č' || text[i] == 'Ž' || text[i] == 'Á' || text[i] == 'Í' || text[i] == 'É' || text[i] == 'Ď' || text[i] == 'Ť' || text[i] == 'Ň' || text[i] == 'Ú');
}
else
{
pass = pass && (text[i] >= 'a' && text[i] <= 'z' || text[i] >= 'á' && text[i] <= 'ž');
}
}
return pass;*/
}
public static bool OnlyStringCheck(string text) //Velká písmena
{
return new Regex("([A-ZĚŠČŘŽÝÁÍÉÚŮÓŤĎ]*)").Match(text).Value == text;
/*bool pass = true;
for (int i = 0; i < text.Length; i++)
{
if (i == 0)
{
pass = pass && ((text[i] >= 'A' && text[i] <= 'Z') || text[i] == 'Ř' || text[i] == 'Š' || text[i] == 'Č' || text[i] == 'Ž' || text[i] == 'Á' || text[i] == 'Í' || text[i] == 'É' || text[i] == 'Ď' || text[i] == 'Ť' || text[i] == 'Ň' || text[i] == 'Ú');
}
else
{
pass = pass && (text[i] >= 'a' && text[i] <= 'z' || text[i] >= 'á' && text[i] <= 'ž');
}
}
return pass;*/
}
public static bool OnlyMesta(string text)
{
return new Regex("^([A-ZĚŠČŘŽÝÁÍÉÚŮÓŤĎ]{1})([a-zěščřžýáíéůúťďó0-9]*)").Match(text).Value == text;
/*bool pass = true;
for (int i = 0; i < text.Length; i++)
{
if (i == 0)
{
pass = pass && ((text[i] >= 'A' && text[i] <= 'Z') || text[i] == 'Ř' || text[i] == 'Š' || text[i] == 'Č' || text[i] == 'Ž' || text[i] == 'Á' || text[i] == 'Í' || text[i] == 'É' || text[i] == 'Ď' || text[i] == 'Ť' || text[i] == 'Ň' || text[i] == 'Ú');
}
else
{
pass = pass && (text[i] >= 'a' && text[i] <= 'z' || text[i] >= 'á' && text[i] <= 'ž' || text[i] >= '0' && text[i] <= '9');
}
}
return pass;*/
}
public static string zk(string text) //Peníze
{
int pos = text.Length;
for (int i = 0; i < text.Length; i++)
{
if (text[i] == ',')
{
pos = i;
break;
}
}
string str = "";
for (int i = 0; i < pos; i++)
{
str += text[i];
}
return str;
}
public static bool existencVaz(DataGridView grid1, DataGridView grid2, DataGridView grid3)
{
bool zk = false;
int a = (int)grid2.SelectedRows[0].Cells[0].Value;
int b = (int)grid3.SelectedRows[0].Cells[0].Value;
for (int i = 0; i < grid1.RowCount; i++)
{
if ((int)grid1.Rows[i].Cells[3].Value == a)
{
if ((int)grid1.Rows[i].Cells[2].Value == b)
{
MessageBox.Show("Vazba už existuje v tabulce.");
zk = false;
break;
}
else
{
zk = true;
continue;
}
}
else
{
zk = true;
continue;
}
}
return zk;
}
public static bool existencRod(string text, DataGridView grid1)
{
bool zk = false;
string c;
//(c.CompareTo(a) == 0 ? true : false)
//int aa = Convert.ToInt32(a);MessageBox.Show("Záznam(Pacinet/Lékař) už existuje v tabulce.");
for (int i = 0; i < grid1.RowCount; i++)
{
c = grid1.Rows[i].Cells[4].Value.ToString();
if (c.CompareTo(text) == 0 ? true : false/*text == c*/)
{
MessageBox.Show("Rodné číslo existuje v tabulce.");
zk = false;
break;
}
else
{
// MessageBox.Show("Rodné číslo existuje v tabulce.");
zk = true;
continue;
}
}
return zk;
}
public static bool existenceCisla(string a, DataGridView grid1)
{
bool zk = false;
int b = Convert.ToInt32(a);
for (int i = 0; i < grid1.RowCount; i++)
{
if (b == (int)grid1.Rows[i].Cells[1].Value)
{
MessageBox.Show("Číslo už existuje.");
zk = false;
break;
}
else
{
zk = true;
continue;
}
}
return zk;
}
public static bool UpdateexistenceCisla(string a,string text, string text2, DataGridView grid1)
{
bool zk = false;
int b = Convert.ToInt32(a);
for (int i = 0; i < grid1.RowCount; i++)
{
if (b == (int)grid1.Rows[i].Cells[1].Value && (text != grid1.Rows[i].Cells[2].Value.ToString() || text2 != grid1.Rows[i].Cells[3].Value.ToString()))
{
MessageBox.Show("Číslo už existuje.");
zk = false;
break;
}
else
{
zk = true;
continue;
}
}
return zk;
}
public static bool UpdateLekarCislo(string text, string text2,string text3, string text4,DataGridView grid1)
{
bool zk = false;
for (int i = 0; i < grid1.RowCount; i++)
{
if (text == grid1.Rows[i].Cells[1].Value.ToString() && text2 == grid1.Rows[i].Cells[2].Value.ToString() && text3 == grid1.Rows[i].Cells[3].Value.ToString() /*&& text4 == grid1.Rows[i].Cells[4].Value.ToString()*/)
{
zk = true;
break;
}
else
{
if (text == grid1.Rows[i].Cells[1].Value.ToString() && text2 != grid1.Rows[i].Cells[2].Value.ToString() && text3 != grid1.Rows[i].Cells[3].Value.ToString() /*text4 != grid1.Rows[i].Cells[4].Value.ToString()*/)
{
MessageBox.Show("Číslo lekaře jíž existuje.");
zk = false;
continue;
}
}//zk = true;
}
return zk;
}
public static bool UpdateLekarRod(string text, string text2, string text3, string text4, DataGridView grid1)
{
bool zk = false;
for (int i = 0; i < grid1.RowCount; i++)
{
if (/*text == grid1.Rows[i].Cells[1].Value.ToString() &&*/ text2 == grid1.Rows[i].Cells[2].Value.ToString() && text3 == grid1.Rows[i].Cells[3].Value.ToString() && text4 == grid1.Rows[i].Cells[4].Value.ToString())
{
zk = true;
break;
}
else
{
if (/*text != grid1.Rows[i].Cells[1].Value.ToString()*/text2 != grid1.Rows[i].Cells[2].Value.ToString() && text3 != grid1.Rows[i].Cells[3].Value.ToString() && text4 == grid1.Rows[i].Cells[4].Value.ToString())
{
MessageBox.Show("Rodné číslo jíž existuje.");
zk = false;
continue;
}
}
}
return zk;
}
public static bool existenceAtes(string a, DataGridView grid1)
{
bool zk = false;
string b;
for (int i = 0; i < grid1.RowCount; i++)
{
b = grid1.Rows[i].Cells[1].Value.ToString();
if (b.CompareTo(a) == 0 ? true : false)
{
MessageBox.Show("Atestace jíž existuje v tabulce.");
zk = false;
break;
}
else
{
zk = true;
continue;
}
}return zk;
}
public static bool UpdateexistenceAtes(string a,string c, DataGridView grid1)
{
bool zk = false;
string b;
for (int i = 0; i < grid1.RowCount; i++)
{
b = grid1.Rows[i].Cells[1].Value.ToString();
if (a == b && c == grid1.Rows[i].Cells[1].Value.ToString())
{
MessageBox.Show("Atestace jíž existuje v tabulce.");
zk = false;
break;
}
else
{
zk = true;
continue;
}
} return zk;
}
public static bool existencAtestaceDel(DataGridView grid1, DataGridView grid2)
{
bool zk = false;
int a = (int)grid1.SelectedRows[0].Cells[0].Value;
for (int i = 0; i < grid2.RowCount; i++)
{
if ((int)grid2.Rows[i].Cells[2].Value == a)
{
MessageBox.Show("Atestace, kterou chcete smazat je ve vazbě.");
zk = false;
break;
}
else
{
zk = true;
continue;
}
}
return zk;
}
}
}
FORM - SQL
public static void LekarPridat(string a, string b, string c, string d, string e, string f, string g, string h, string i, string j, string k, string l, SqlConnection s)
{
string com = String.Format("INSERT INTO TLekar(cislo_lek,jmeno_lek,prijmeni_lek,datum_nar_lek,tel_cislo_lek,mob_cislo_lek,email_lek,mesto_lek,ulice_lek,psc_lek,plat_lek,souk_sluzby_lek) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}');"
,a,b,c,d,e,f,g,h,i,j,k,l);
SqlCommand con = new SqlCommand(com, s);
con.ExecuteNonQuery();
}
public static void LekarUpdate(string a,string b, string c, string d, string e,string f, string g, string h, string i, string j, string k, string l,string m, SqlConnection s)//NAUCIT
{
string com = String.Format("UPDATE TLekar SET cislo_lek = {0}, jmeno_lek = '{1}', prijmeni_lek = '{2}', datum_nar_lek = '{3}', tel_cislo_lek = '{4}', mob_cislo_lek = '{5}', email_lek = '{6}',mesto_lek='{7}', ulice_lek='{8}', psc_lek = '{9}', plat_lek={10}, souk_sluzby_lek = '{11}' WHERE id_lek = {12}", a, b, c, d, e, f,g, h, i, j,k, /*numericUpDown1.Value.ToString()*/l,m);
SqlCommand con = new SqlCommand(com, s);
con.ExecuteNonQuery();
}
public static void LekarDelete(string a, SqlConnection s)
{
// SqlCommand vaz = new SqlCommand("DELETE FROM TLekarVazAtestace where lek_id = "+a+ ";",s);
//SqlCommand pac = new SqlCommand("UPDATA TPacient set lek_id=null where lek_id = " + a + ";", s);
SqlCommand con = new SqlCommand("DELETE FROM TLekar WHERE id_lek = " + a + ";", s);
//vaz.ExecuteNonQuery();
//pac.ExecuteNonQuery();
con.ExecuteNonQuery();
}
public static void LekarLoad(DataGridView dataGridView1, SqlConnection s)
{
dataGridView1.Columns.Clear();
dataGridView1.Rows.Clear();
SqlCommand conn = new SqlCommand("SELECT * from TLekar", s);
SqlDataReader rdn = conn.ExecuteReader();
for (int i = 0; i < rdn.FieldCount; i++)
dataGridView1.Columns.Add(rdn.GetName(i), ColumnNameToLabel(rdn.GetName(i)));
object[] vals = new object[rdn.FieldCount];
while (rdn.Read())
{
rdn.GetValues(vals);
dataGridView1.Rows.Add(vals);
}
rdn.Close();
}
public static string tran(SqlConnection s) //Nepřímá transakce
{
SqlCommand com = new SqlCommand("exec mp_ates @vysledek = @vysledek output", s);
SqlParameter par = com.Parameters.Add("@vysledek", SqlDbType.NVarChar,50);
par.Direction = ParameterDirection.Output;
com.ExecuteNonQuery();
return(string)par.Value;
}
public static bool transaction_command(string command, SqlConnection s) //Příma transkace
{
SqlTransaction tran = s.BeginTransaction();
SqlCommand cmd = new SqlCommand(command, s);
cmd.Transaction = tran;
try
{
cmd.ExecuteNonQuery();
tran.Commit();
return true;
}
catch (Exception e)
{
Console.WriteLine("//////////////////" + command + "//////////////////");
Console.WriteLine(e.ToString());
try
{
tran.Rollback();
}
catch (Exception f)
{
Console.WriteLine(f.ToString());
return false;
}
return false;
}
}
public static void Zkouska(DataGridView dataGridView1, SqlConnection s, int a)
{
dataGridView1.Columns.Clear();
dataGridView1.Rows.Clear();
SqlCommand com = new SqlCommand("SELECT * FROM TLekar inner join TLekarVazAtestace on TLekar.id_lek = TLekarVazAtestace.lek_id Inner join TAtestace on TAtestace.id_ates = TLekarVazAtestace.ates_id WHERE TLekar.id_lek = "+a, s);
SqlDataReader rdn = com.ExecuteReader();
for (int i = 0; i < rdn.FieldCount; i++)
{
dataGridView1.Columns.Add(rdn.GetName(i), ColumnNameToLabel(rdn.GetName(i)));
}
object[] vals = new object[rdn.FieldCount];
while (rdn.Read())
{
rdn.GetValues(vals);
dataGridView1.Rows.Add(vals);
}
rdn.Close();
}
static string ColumnNameToLabel(string name)
{
switch (name)
{
case "id_lek":
return "ID lekare";
case "cislo_lek":
return "Cislo lékaře";
default:
return name;
}
}
declare @gynekologu int;
begin transaction
set @gynekologu = (SELECT count(*) FROM TAtestace WHERE nazev_ates = 'Gynekologie');
set @gynekologu += @@ERROR;
INSERT INTO TAtestace(nazev_ates) VALUES('Gynekologie');
if @gynekologu <> 0
begin
set @vysledek = 'Transakce se nepovedla';
rollback;
end
else
begin
set @vysledek = 'Transakce se povedla';
commit
end
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 0) return;
textBox2.Text = dataGridView1.SelectedRows[0].Cells[1].Value.ToString();
textBox3.Text = dataGridView1.SelectedRows[0].Cells[2].Value.ToString();
textBox4.Text = dataGridView1.SelectedRows[0].Cells[3].Value.ToString();
textBox5.Text = dataGridView1.SelectedRows[0].Cells[4].Value.ToString();
textBox8.Text = dataGridView1.SelectedRows[0].Cells[5].Value.ToString();
textBox9.Text = dataGridView1.SelectedRows[0].Cells[6].Value.ToString();
textBox10.Text = dataGridView1.SelectedRows[0].Cells[7].Value.ToString();
richTextBox1.Text = dataGridView1.SelectedRows[0].Cells[9].Value.ToString();
richTextBox2.Text = dataGridView1.SelectedRows[0].Cells[10].Value.ToString();
textBox2.BackColor = Color.White;
textBox3.BackColor = Color.White;
textBox4.BackColor = Color.White;
textBox5.BackColor = Color.White;
textBox8.BackColor = Color.White;
textBox9.BackColor = Color.White;
textBox10.BackColor = Color.White;
dataGridView2.ClearSelection();
foreach (DataGridViewRow row in dataGridView2.Rows)
{
if ((int)row.Cells[0].Value == (int)dataGridView1.SelectedRows[0].Cells[8].Value)
row.Selected = true;
}
dataGridView3.ClearSelection();
foreach (DataGridViewRow row in dataGridView3.Rows)
{
if ((int)row.Cells[0].Value == (int)dataGridView1.SelectedRows[0].Cells[11].Value)
row.Selected = true;
}
}
推荐答案
此论坛专门针对Project Server应用程序相关的自定义项,如果它与项目服务器无关,建议将其发布到其他论坛喜欢 视觉工作室论坛
This forum is specifically for Project Server application related customizations, if it is not related to project server would suggest posting it to other forums like visual studio forums or so
这篇关于Programováníve表格/控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!