Studio
How do I use Studio
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: VSCode.cs
Copy
403 static string AutodetectCodePath()
404 {
405 string[] possiblePaths =
406#if UNITY_EDITOR_OSX
407 {
408 "/Applications/Visual Studio Code.app",
409 "/Applications/Visual Studio Code - Insiders.app"
410 };
411#elif UNITY_EDITOR_WIN
412 {
413 ProgramFilesx86() + Path.DirectorySeparatorChar + "Microsoft VS Code"
414 + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar + "code.cmd",
415 ProgramFilesx86() + Path.DirectorySeparatorChar + "Microsoft VS Code Insiders"
416 + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar + "code-insiders.cmd"
417 };
418#else
419 {
420 "/usr/bin/code",
421 "/bin/code",
422 "/usr/local/bin/code"
423 };
424#endif
425 for(int i = 0; i < possiblePaths.Length; i++)
426 {
427 if(VSCodeExists(possiblePaths[i]))
428 {
429 return possiblePaths[i];
430 }
431 }
432 PrintNotFound(possiblePaths[0]);
433 return possiblePaths[0]; //returns the default one, printing a warning message 'executable not found'
434 }
File name: MilkDairy.cs
Copy
21 private void button1_Click(object sender, EventArgs e)
22 {
23 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True");
24 con.Open();
25 string gen = string.Empty;
26
27 try
28 {
29 string str = "INSERT INTO dairy(acnt_no,name,addr,d_no,liter,fate,pperl,total) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "','" + textBox6.Text + "','" + textBox7.Text + "','" + textBox8.Text + "'); ";
30
31 SqlCommand cmd = new SqlCommand(str, con);
32 cmd.ExecuteNonQuery();
33
34 string str1 = "select max(Id) from dairy;";
35
36 SqlCommand cmd1 = new SqlCommand(str1, con);
37 SqlDataReader dr = cmd1.ExecuteReader();
38 if (dr.Read())
39 {
40 MessageBox.Show("Inserted Dairy Details Information Successfully..");
41 textBox1.Text = "";
42 textBox2.Text = "";
43 textBox4.Text = "";
44 textBox3.Text = "";
45 textBox5.Text = "";
46 textBox6.Text = "";
47 textBox7.Text = "";
48 textBox8.Text = "";
49
50 }
51 }
52 catch (SqlException excep)
53 {
54 MessageBox.Show(excep.Message);
55 }
56 con.Close();
57 }
File name: NewAccount.cs
Copy
21 private void button1_Click(object sender, EventArgs e)
22 {
23 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True");
24 con.Open();
25 string gen = string.Empty;
26
27 try
28 {
29 string str = "INSERT INTO acnt(name,addr,mobile,center) VALUES('" + textBox2.Text + "','" + textBox3.Text + "','" + textBox4.Text + "','" + textBox5.Text + "'); ";
30
31 SqlCommand cmd = new SqlCommand(str, con);
32 cmd.ExecuteNonQuery();
33
34 string str1 = "select max(Id) from acnt;";
35
36 SqlCommand cmd1 = new SqlCommand(str1, con);
37 SqlDataReader dr = cmd1.ExecuteReader();
38 if (dr.Read())
39 {
40 MessageBox.Show("Inserted FliAccountght Details Information Successfully..");
41 textBox1.Text = "";
42 textBox2.Text = "";
43 textBox4.Text = "";
44 textBox3.Text = "";
45 textBox5.Text = "";
46
47 using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True"))
48 {
49 string str2 = "SELECT * FROM acnt";
50 SqlCommand cmd2 = new SqlCommand(str2, con1);
51 SqlDataAdapter da = new SqlDataAdapter(cmd2);
52 DataTable dt = new DataTable();
53 da.Fill(dt);
54 dataGridView1.DataSource = new BindingSource(dt, null);
55 }
56 }
57 }
58 catch (SqlException excep)
59 {
60 MessageBox.Show(excep.Message);
61 }
62 con.Close();
63 }
File name: NewAccount.cs
Copy
65 private void NewAccount_Load(object sender, EventArgs e)
66 {
67 // TODO: This line of code loads data into the 'milkdairyDataSet1.acnt' table. You can move, or remove it, as needed.
68 this.acntTableAdapter.Fill(this.milkdairyDataSet1.acnt);
69 using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True"))
70 {
71
72 string str2 = "SELECT * FROM acnt";
73 SqlCommand cmd2 = new SqlCommand(str2, con1);
74 SqlDataAdapter da = new SqlDataAdapter(cmd2);
75 DataTable dt = new DataTable();
76 da.Fill(dt);
77
78 dataGridView1.DataSource = new BindingSource(dt, null);
79 }
80 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True");
81 con.Open();
82 string str1 = "select max(id) from acnt;";
83
84 SqlCommand cmd1 = new SqlCommand(str1, con);
85 SqlDataReader dr = cmd1.ExecuteReader();
86 if (dr.Read())
87 {
88 string val = dr[0].ToString();
89 if (val == "")
90 {
91 textBox1.Text = "1";
92 }
93 else
94 {
95 int a;
96 a = Convert.ToInt32(dr[0].ToString());
97 a = a + 1;
98 textBox1.Text = a.ToString();
99 }
100 }
101 con.Close();
102 }
File name: NewAccount.cs
Copy
104 private void button2_Click(object sender, EventArgs e)
105 {
106 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True");
107 con.Open();
108 if (textBox1.Text != "")
109 {
110 try
111 {
112 string getCust = "select name,addr,mobile,center from acnt where id=" + Convert.ToInt32(textBox1.Text) + " ;";
113
114 SqlCommand cmd = new SqlCommand(getCust, con);
115 SqlDataReader dr;
116 dr = cmd.ExecuteReader();
117 if (dr.Read())
118 {
119 textBox2.Text = dr.GetValue(0).ToString();
120 textBox3.Text = dr.GetValue(1).ToString();
121 textBox4.Text = dr.GetValue(2).ToString();
122 textBox5.Text = dr.GetValue(3).ToString();
123
124
125 }
126 else
127 {
128 MessageBox.Show(" Sorry, This ID, " + textBox1.Text + " Account Details Record is not Available. ");
129 textBox1.Text = "";
130 }
131 }
132 catch (SqlException excep)
133 {
134 MessageBox.Show(excep.Message);
135 }
136 con.Close();
137 }
138 }
File name: NewAccount.cs
Copy
140 private void button4_Click(object sender, EventArgs e)
141 {
142 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True");
143 con.Open();
144 try
145 {
146 string str = " Update acnt set name='" + textBox2.Text + "',addr='" + textBox3.Text + "',mobile='" + textBox4.Text + "',center='" + textBox5.Text + "' where id='" + textBox1.Text + "'";
147
148 SqlCommand cmd = new SqlCommand(str, con);
149 cmd.ExecuteNonQuery();
150
151 string str1 = "select max(id) from acnt;";
152
153 SqlCommand cmd1 = new SqlCommand(str1, con);
154 SqlDataReader dr = cmd1.ExecuteReader();
155 if (dr.Read())
156 {
157 MessageBox.Show("" + textBox2.Text + "'s Details is Updated Successfully.. ", "Important Message");
158 textBox2.Text = "";
159 textBox4.Text = "";
160 textBox3.Text = "";
161 textBox5.Text = "";
162 textBox1.Text = "";
163
164 using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True"))
165 {
166 string str2 = "SELECT * FROM acnt";
167 SqlCommand cmd2 = new SqlCommand(str2, con1);
168 SqlDataAdapter da = new SqlDataAdapter(cmd2);
169 DataTable dt = new DataTable();
170 da.Fill(dt);
171 dataGridView1.DataSource = new BindingSource(dt, null);
172 }
173 }
174 }
175 catch (SqlException excep)
176 {
177 MessageBox.Show(excep.Message);
178 }
179 con.Close();
180 }
File name: SearchAccount.cs
Copy
21 private void SearchAccount_Load(object sender, EventArgs e)
22 {
23 // TODO: This line of code loads data into the 'milkdairyDataSet2.acnt' table. You can move, or remove it, as needed.
24 this.acntTableAdapter.Fill(this.milkdairyDataSet2.acnt);
25 using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True"))
26 {
27
28 string str2 = "SELECT * FROM acnt";
29 SqlCommand cmd2 = new SqlCommand(str2, con1);
30 SqlDataAdapter da = new SqlDataAdapter(cmd2);
31 DataTable dt = new DataTable();
32 da.Fill(dt);
33
34 dataGridView1.DataSource = new BindingSource(dt, null);
35 }
36 }
File name: SearchAccount.cs
Copy
38 private void button1_Click(object sender, EventArgs e)
39 {
40 using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True"))
41 {
42
43 string str2 = "SELECT * FROM acnt where id='" + textBox1.Text + "'";
44 SqlCommand cmd2 = new SqlCommand(str2, con1);
45 SqlDataAdapter da = new SqlDataAdapter(cmd2);
46 DataTable dt = new DataTable();
47 da.Fill(dt);
48
49 dataGridView1.DataSource = new BindingSource(dt, null);
50 }
51 }
File name: SearchDairyMilkRecord.cs
Copy
21 private void SearchDairyMilkRecord_Load(object sender, EventArgs e)
22 {
23 // TODO: This line of code loads data into the 'milkdairyDataSet.dairy' table. You can move, or remove it, as needed.
24 this.dairyTableAdapter.Fill(this.milkdairyDataSet.dairy);
25 using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True"))
26 {
27
28 string str2 = "SELECT * FROM dairy";
29 SqlCommand cmd2 = new SqlCommand(str2, con1);
30 SqlDataAdapter da = new SqlDataAdapter(cmd2);
31 DataTable dt = new DataTable();
32 da.Fill(dt);
33
34 dataGridView1.DataSource = new BindingSource(dt, null);
35 }
36 }
File name: SetFatePrice.cs
Copy
21 private void SetFatePrice_Load(object sender, EventArgs e)
22 {
23 // TODO: This line of code loads data into the 'milkdairyDataSet3.rate' table. You can move, or remove it, as needed.
24 this.rateTableAdapter.Fill(this.milkdairyDataSet3.rate);
25 using (SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True"))
26 {
27
28 string str2 = "SELECT * FROM rate";
29 SqlCommand cmd2 = new SqlCommand(str2, con1);
30 SqlDataAdapter da = new SqlDataAdapter(cmd2);
31 DataTable dt = new DataTable();
32 da.Fill(dt);
33
34 dataGridView1.DataSource = new BindingSource(dt, null);
35 }
36 SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\dell\Documents\Visual Studio 2015\Projects\MilkDairyManagementSystemCSharp\MilkDairyManagementSystemCSharp\milkdairy.mdf;Integrated Security=True");
37 con.Open();
38 string str1 = "select max(id) from rate;";
39
40 SqlCommand cmd1 = new SqlCommand(str1, con);
41 SqlDataReader dr = cmd1.ExecuteReader();
42 if (dr.Read())
43 {
44 string val = dr[0].ToString();
45 if (val == "")
46 {
47 textBox1.Text = "1";
48 }
49 else
50 {
51 int a;
52 a = Convert.ToInt32(dr[0].ToString());
53 a = a + 1;
54 textBox1.Text = a.ToString();
55 }
56 }
57 con.Close();
58 }
Studio 99 lượt xem
Gõ tìm kiếm nhanh...