Question









How do I use Question
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: frmMain.cs Copy
41         private void button1_Click(object sender, EventArgs e)
42         {
43             if (MessageBox.Show("Bạn có chắc chắn muốn thoát ?","Thông báo",MessageBoxButtons.OKCancel,MessageBoxIcon.Question)==DialogResult.OK)
44
45             {
46                 Application.Exit();
47
48             }
49         }
File name: frmMain.cs Copy
51         private void thoátToolStripMenuItem1_Click(object sender, EventArgs e)
52         {
53             if (MessageBox.Show("Bạn có chắc chắn muốn thoát ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
54             {
55                 Application.Exit();
56
57             }
58         }
File name: frmMain.cs Copy
113         private void thoátToolStripMenuItem2_Click_1(object sender, EventArgs e)
114         {
115             if (MessageBox.Show("Bạn có chắc chắn muốn thoát ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
116             {
117                 Application.Exit();
118
119             }
120         }
File name: frmThiThat.cs Copy
34         void Load_DeThiThat()
35         {
36             try
37             {
38                 SqlConnection cnn = new SqlConnection("server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security =true");
39                 SqlDataAdapter da = new SqlDataAdapter("select cauhoi.mach,cauhoi,a,b,c,d ,dapan from cauhoi,DAPAN where cauhoi.mach=DAPAN.mach", cnn);
40                 DataTable BangQuestion = new DataTable();
41                 da.Fill(BangQuestion);
42                 TaoBangRandomCauHoi(BangQuestion);
43             }
44             catch (Exception ex)
45             { MessageBox.Show(ex.Message); }
46             p = 60;//nhap thoi gian thi
47             s = 60;
48             h = 0;
49         }
File name: frmThiThat.cs Copy
50         void TaoBangRandomCauHoi(DataTable BangQuestion)
51         {
52
53             try
54             {
55                 Random Rnd = new Random();
56                 ArrayList ArrQuestion = new ArrayList();
57
58                 ArrQuestion.Clear();
59                 int x, dem = 0;
60                 int SoCauTrongBangGoc = BangQuestion.Rows.Count;
61                 while (dem < SoCauNgauNhien)
62                 {
63                     x = Rnd.Next(0, SoCauTrongBangGoc);
64                     if (!ArrQuestion.Contains(x))
65                     {
66                         ArrQuestion.Add(x);
67                         dem++;
68                     }
69                 }
70                 for (int j = SoCauTrongBangGoc - 1; j >= 0; j--)
71                     if (!ArrQuestion.Contains(j))
72                         BangQuestion.Rows.RemoveAt(j);
73
74                 BangDeThi = BangQuestion;
75                 BangDeThi.Columns.Add("cauhoi,DAPAN");
76
77             }
78             catch (Exception ex)
79             { MessageBox.Show(ex.Message); }
80
81         }
File name: PhotonEditor.cs Copy
630     protected virtual void OnGuiCompareAndHelpOptions()
631     {
632         GUILayout.FlexibleSpace();
633
634         GUILayout.Label(CurrentLang.QuestionsLabel);
635         if (GUILayout.Button(CurrentLang.SeeForumButton))
636         {
637             Application.OpenURL(UrlForum);
638         }
639
640         if (photonSetupState != PhotonSetupStates.SetupSelfHosted)
641         {
642             if (GUILayout.Button(CurrentLang.OpenDashboardButton))
643             {
644                 EditorUtility.OpenWithDefaultApp(UrlCloudDashboard + Uri.EscapeUriString(this.emailAddress));
645             }
646         }
647     }
File name: Form1.cs Copy
236   public void Button4_Click(System.Object sender, System.EventArgs e)
237   {
238
239    string strmessage = default(string);
240    DialogResult dgrResult;
241
242    strmessage = "Are you sure you want to save data?";
243    dgrResult = MessageBox.Show(strmessage, "Save data", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
244
245
246    if (dgrResult == System.Windows.Forms.DialogResult.Yes)
247    {
248
249     newgrade = gradeclass.DataModule.SaveItem();
250    }
251
252   }
File name: Form1.cs Copy
373   public void Button11_Click(System.Object sender, System.EventArgs e)
374   {
375    string strmessage = default(string);
376    DialogResult dgrResult;
377
378    strmessage = "Are you sure you want to Delete this record?";
379    dgrResult = MessageBox.Show(strmessage, "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
380
381
382    if (dgrResult == System.Windows.Forms.DialogResult.Yes)
383    {
384
385     dsgrade = gradeclass.DataModule.deldata();
386
387    }
388
389
390
391   }
File name: frmQLThe.cs Copy
138         private void btnSave_Click(object sender, EventArgs e)
139         {
140             if (btnupdate.Enabled==false)
141             {
142                 try
143                 {
144                     tbThe test = (db.tbThes.Where(t => t.MaThe == txtMaThe.Text).SingleOrDefault());
145                     if (test!=null)
146                     {
147                         MessageBox.Show("Mã Thẻ Đã Tòn Tại","Thông Báo",MessageBoxButtons.OK,MessageBoxIcon.Warning);
148                         return;
149                     }
150                     else
151                     {
152                         if (db.CRUDThe('t', txtMaThe.Text, cbxMaDG.Text, mklNgayCap.Text, mktHan.Text) == 1)
153                         {
154                            db.SubmitChanges();
155                            MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
156                         }
157                         else
158                             MessageBox.Show("Thêm Thất Bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
159                     }
160
161                 }
162                 catch (Exception ex)
163                 {
164                     MessageBox.Show(ex.Message, "Quản Lý Thư Viện");
165                 }
166                 finally
167                 {
168                     tbTHE.LoadGridView(dataGridViewX1);
169                     btninsert.Image = Resources.add1_;
170                     BtnThem(true);
171                     txtMaThe.ReadOnly = true;
172                     btnSave.Enabled = false;
173                 }
174             }
175             if (btninsert.Enabled==false)
176             {
177                 try
178                 {
179                     if (MessageBox.Show("Bạn Có Muốn Sửa Không","Thông Báo",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
180                     {
181                         tbThe test = (db.tbThes.Where(t => t.MaThe == txtMaThe.Text).SingleOrDefault());
182                         if (test != null)
183                         {
184                             if (db.CRUDThe('t',txtMaThe.Text,cbxMaDG.Text,mklNgayCap.Text,mktHan.Text)==1)
185                             {
186                                 db.SubmitChanges();
187                                 MessageBox.Show("Sửa Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
188                             }
189                             else
190                             {
191                                 MessageBox.Show("Sửa Thất Bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
192                             }
193                         }
194                         else
195                             MessageBox.Show("Mã Thẻ Không Tòn Tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
196
197                     }
198
199                 }
200                 catch (Exception ex)
201                 {
202                     MessageBox.Show(ex.Message, "Quản Lý Thư Viện");
203                 }
204                 finally
205                 {
206
207                     //var query = (from tbTHE in db.tbThes
208                     // join tbDOCGIA in db.tbDGs
209                     // on tbTHE.MaDG equals tbDOCGIA.MaDG
210                     // select new
211                     // {
212                     // tbDOCGIA.MaDG,
213                     // tbDOCGIA.TenDG,
214                     // tbDOCGIA.ChucVu,
215                     // tbTHE.MaThe,
216                     // tbTHE.NgayCap,
217                     // tbTHE.Han
218                     // });
219                     //dataGridViewX1.DataSource = query;
220                     tbThe tbthenew = new tbThe();
221                     tbthenew.LoadGridView(dataGridViewX1);
222                     BtnThem(true);
223                     txtMaThe.ReadOnly = true;
224                     mklNgayCap.ReadOnly = true;
225                     mktHan.ReadOnly = false;
226                     btnupdate.Image = Resources.edit;
227                     btnSave.Enabled = false;
228                 }
229             }
230         }
File name: frmQLThe.cs Copy
244         private void btndel_Click(object sender, EventArgs e)
245         {
246             try
247             {
248                 if (MessageBox.Show("Bạn Có Muốn Xóa Không", "Thông Báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
249                 {
250
251                     if (db.CRUDThe('x', txtMaThe.Text, String.Empty, String.Empty, String.Empty) == 1)
252                     {
253
254                         db.SubmitChanges();
255                         MessageBox.Show("Xóa Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
256                     }
257                     else
258                     {
259                         MessageBox.Show("Xóa Thất Bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
260                     }
261                 }
262             }
263             catch (Exception ex)
264             {
265                 MessageBox.Show(ex.Message, "Quản Lý Thư Viện");
266             }
267             finally
268             {
269                 tbTHE.LoadGridView(dataGridViewX1);
270
271             }
272         }

Download file with original file name:Question

Question 144 lượt xem

Gõ tìm kiếm nhanh...