H1









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

Featured Snippets


File name: Report.cs Copy
19         private void Report_Load(object sender, EventArgs e)
21             {
22                 TS a = new TS();
23                 String strCon = "server=.\\SQLEXPRESS;database=QL_Thitracnghiem;integrated security=true";
24                 SqlConnection con = new SqlConnection(strCon);
25                 SqlCommand cmd = new SqlCommand("select * from THISINH", con);
26                 SqlDataAdapter adapter = new SqlDataAdapter(cmd);
27                 adapter.Fill(a, "THISINH");
28                 rptThisinh1.SetDataSource(a.Tables["THISINH"]);
29                 // Lấy dữ liệu từ dataset chèn vào rptThisinh
30
31             }
File name: ReorderableListResources.cs Copy
61         private static string[] s_DarkSkin = {
62             "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAYAAAABOs/SAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIBJREFUeNpiVFZW/u/i4sLw4sULBnoACQkJhj179jAwMQwQGHoWl5aWgvHI8TGlgIXU4MUn1t3dPcx8HB8fD2cvXLgQQ0xHR4c2FmMzmBTLhl5QYwt2cn1MtsXkWjg4gvrt27fgWoMeAGQXCDD+//+fQUVF5T89fXvnzh1GgAADAFmSI1Ed3FqgAAAAAElFTkSuQmCC",
63             "iVBORw0KGgoAAAANSUhEUgAAAB4AAAAQCAYAAAABOs/SAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHlJREFUeNpiFBER+f/jxw8GNjY2BnqAX79+MXBwcDAwMQwQGHoWv3nzBoxHjo8pBSykBi8+MWAOGWY+5uLigrO/ffuGIYbMppnF5Fg2tFM1yKfk+pbkoKZGEA+OVP3nzx+6WQizi/H///8MoqKi/+np2y9fvjACBBgAoTYjgvihfz0AAAAASUVORK5CYII=",
64             "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAECAYAAABGM/VAAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD1JREFUeNpi/P//P4OKisp/Bii4c+cOIwtIwMXFheHFixcMEhISYAVMINm3b9+CBUA0CDCiazc0NGQECDAAdH0YelA27kgAAAAASUVORK5CYII=",
65             "iVBORw0KGgoAAAANSUhEUgAAAAkAAAAFCAYAAACXU8ZrAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACRJREFUeNpizM3N/c9AADAqKysTVMTi5eXFSFAREFPHOoAAAwBCfwcAO8g48QAAAABJRU5ErkJggg==",
66             "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAECAYAAACzzX7wAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACJJREFUeNpi/P//PwM+wHL06FG8KpgYCABGZWVlvCYABBgA7/sHvGw+cz8AAAAASUVORK5CYII=",
67             "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAECAYAAACzzX7wAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAACBJREFUeNpi/P//PwM+wPKfgAomBgKAhYuLC68CgAADAAxjByOjCHIRAAAAAElFTkSuQmCC",
68             "iVBORw0KGgoAAAANSUhEUgAAAAUAAAAECAYAAABGM/VAAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADtJREFUeNpi/P//P4OKisp/Bii4c+cOIwtIQE9Pj+HLly9gQRCfBcQACbx69QqmmAEseO/ePQZkABBgAD04FXsmmijSAAAAAElFTkSuQmCC"
69         };
File name: ServerSettingsInspector.cs Copy
127     private int RpcListHashCode()
128     {
129         // this is a hashcode generated to (more) easily compare this Editor's RPC List with some other
130         int hashCode = PhotonEditor.Current.RpcList.Count + 1;
131         foreach (string s in PhotonEditor.Current.RpcList)
132         {
133             int h1 = s.GetHashCode();
134             hashCode = ((h1 << 5) + h1) ^ hashCode;
135         }
136
137         return hashCode;
138     }
File name: frmCustomerOrders.cs Copy
28         private void Button7_Click(object sender, EventArgs e)
29         {
30             if (DataGridView3.DataSource == null)
31             {
32                 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
33                 return;
34             }
35             int rowsTotal = 0;
36             int colsTotal = 0;
37             int I = 0;
38             int j = 0;
39             int iC = 0;
40             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
41             Excel.Application xlApp = new Excel.Application();
42
43             try
44             {
45                 Excel.Workbook excelBook = xlApp.Workbooks.Add();
46                 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
47                 xlApp.Visible = true;
48
49                 rowsTotal = DataGridView3.RowCount;
50                 colsTotal = DataGridView3.Columns.Count - 1;
51                 var _with1 = excelWorksheet;
52                 _with1.Cells.Select();
53                 _with1.Cells.Delete();
54                 for (iC = 0; iC <= colsTotal; iC++)
55                 {
56                     _with1.Cells[1, iC + 1].Value = DataGridView3.Columns[iC].HeaderText;
57                 }
58                 for (I = 0; I <= rowsTotal - 1; I++)
59                 {
60                     for (j = 0; j <= colsTotal; j++)
61                     {
62                         _with1.Cells[I + 2, j + 1].value = DataGridView3.Rows[I].Cells[j].Value;
63                     }
64                 }
65                 _with1.Rows["1:1"].Font.FontStyle = "Bold";
66                 _with1.Rows["1:1"].Font.Size = 12;
67
68                 _with1.Cells.Columns.AutoFit();
69                 _with1.Cells.Select();
70                 _with1.Cells.EntireColumn.AutoFit();
71                 _with1.Cells[1, 1].Select();
72             }
73             catch (Exception ex)
74             {
75                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
76             }
77             finally
78             {
79                 //RELEASE ALLOACTED RESOURCES
80                 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
81                 xlApp = null;
82             }
83         }
File name: frmCustomerOrders.cs Copy
223         private void Button3_Click(object sender, EventArgs e)
224         {
225             if (DataGridView1.DataSource == null)
226             {
227                 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
228                 return;
229             }
230             int rowsTotal = 0;
231             int colsTotal = 0;
232             int I = 0;
233             int j = 0;
234             int iC = 0;
235             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
236             Excel.Application xlApp = new Excel.Application();
237
238             try
239             {
240                 Excel.Workbook excelBook = xlApp.Workbooks.Add();
241                 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
242                 xlApp.Visible = true;
243
244                 rowsTotal = DataGridView1.RowCount;
245                 colsTotal = DataGridView1.Columns.Count - 1;
246                 var _with1 = excelWorksheet;
247                 _with1.Cells.Select();
248                 _with1.Cells.Delete();
249                 for (iC = 0; iC <= colsTotal; iC++)
250                 {
251                     _with1.Cells[1, iC + 1].Value = DataGridView1.Columns[iC].HeaderText;
252                 }
253                 for (I = 0; I <= rowsTotal - 1; I++)
254                 {
255                     for (j = 0; j <= colsTotal; j++)
256                     {
257                         _with1.Cells[I + 2, j + 1].value = DataGridView1.Rows[I].Cells[j].Value;
258                     }
259                 }
260                 _with1.Rows["1:1"].Font.FontStyle = "Bold";
261                 _with1.Rows["1:1"].Font.Size = 12;
262
263                 _with1.Cells.Columns.AutoFit();
264                 _with1.Cells.Select();
265                 _with1.Cells.EntireColumn.AutoFit();
266                 _with1.Cells[1, 1].Select();
267             }
268             catch (Exception ex)
269             {
270                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
271             }
272             finally
273             {
274                 //RELEASE ALLOACTED RESOURCES
275                 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
276                 xlApp = null;
277             }
278         }
File name: frmCustomersRecord.cs Copy
85         private void Button3_Click(object sender, EventArgs e)
86         {
87             if (dataGridView1.DataSource == null)
88             {
89                 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
90                 return;
91             }
92             int rowsTotal = 0;
93             int colsTotal = 0;
94             int I = 0;
95             int j = 0;
96             int iC = 0;
97             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
98             Excel.Application xlApp = new Excel.Application();
99
100             try
101             {
102                 Excel.Workbook excelBook = xlApp.Workbooks.Add();
103                 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
104                 xlApp.Visible = true;
105
106                 rowsTotal = dataGridView1.RowCount;
107                 colsTotal = dataGridView1.Columns.Count - 1;
108                 var _with1 = excelWorksheet;
109                 _with1.Cells.Select();
110                 _with1.Cells.Delete();
111                 for (iC = 0; iC <= colsTotal; iC++)
112                 {
113                     _with1.Cells[1, iC + 1].Value = dataGridView1.Columns[iC].HeaderText;
114                 }
115                 for (I = 0; I <= rowsTotal - 1; I++)
116                 {
117                     for (j = 0; j <= colsTotal; j++)
118                     {
119                         _with1.Cells[I + 2, j + 1].value = dataGridView1.Rows[I].Cells[j].Value;
120                     }
121                 }
122                 _with1.Rows["1:1"].Font.FontStyle = "Bold";
123                 _with1.Rows["1:1"].Font.Size = 12;
124
125                 _with1.Cells.Columns.AutoFit();
126                 _with1.Cells.Select();
127                 _with1.Cells.EntireColumn.AutoFit();
128                 _with1.Cells[1, 1].Select();
129             }
130             catch (Exception ex)
131             {
132                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
133             }
134             finally
135             {
136                 //RELEASE ALLOACTED RESOURCES
137                 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
138                 xlApp = null;
139             }
140         }
File name: frmCustomersRecord1.cs Copy
103         private void Button3_Click(object sender, EventArgs e)
104         {
105             if (dataGridView1.DataSource == null)
106             {
107                 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
108                 return;
109             }
110             int rowsTotal = 0;
111             int colsTotal = 0;
112             int I = 0;
113             int j = 0;
114             int iC = 0;
115             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
116             Excel.Application xlApp = new Excel.Application();
117
118             try
119             {
120                 Excel.Workbook excelBook = xlApp.Workbooks.Add();
121                 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
122                 xlApp.Visible = true;
123
124                 rowsTotal = dataGridView1.RowCount;
125                 colsTotal = dataGridView1.Columns.Count - 1;
126                 var _with1 = excelWorksheet;
127                 _with1.Cells.Select();
128                 _with1.Cells.Delete();
129                 for (iC = 0; iC <= colsTotal; iC++)
130                 {
131                     _with1.Cells[1, iC + 1].Value = dataGridView1.Columns[iC].HeaderText;
132                 }
133                 for (I = 0; I <= rowsTotal - 1; I++)
134                 {
135                     for (j = 0; j <= colsTotal; j++)
136                     {
137                         _with1.Cells[I + 2, j + 1].value = dataGridView1.Rows[I].Cells[j].Value;
138                     }
139                 }
140                 _with1.Rows["1:1"].Font.FontStyle = "Bold";
141                 _with1.Rows["1:1"].Font.Size = 12;
142
143                 _with1.Cells.Columns.AutoFit();
144                 _with1.Cells.Select();
145                 _with1.Cells.EntireColumn.AutoFit();
146                 _with1.Cells[1, 1].Select();
147             }
148             catch (Exception ex)
149             {
150                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
151             }
152             finally
153             {
154                 //RELEASE ALLOACTED RESOURCES
155                 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
156                 xlApp = null;
157             }
158         }
File name: frmCustomersRecord2.cs Copy
110         private void Button3_Click(object sender, EventArgs e)
111         {
112             if (dataGridView1.DataSource == null)
113             {
114                 MessageBox.Show("Sorry nothing to export into excel sheet..", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
115                 return;
116             }
117             int rowsTotal = 0;
118             int colsTotal = 0;
119             int I = 0;
120             int j = 0;
121             int iC = 0;
122             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
123             Excel.Application xlApp = new Excel.Application();
124
125             try
126             {
127                 Excel.Workbook excelBook = xlApp.Workbooks.Add();
128                 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
129                 xlApp.Visible = true;
130
131                 rowsTotal = dataGridView1.RowCount;
132                 colsTotal = dataGridView1.Columns.Count - 1;
133                 var _with1 = excelWorksheet;
134                 _with1.Cells.Select();
135                 _with1.Cells.Delete();
136                 for (iC = 0; iC <= colsTotal; iC++)
137                 {
138                     _with1.Cells[1, iC + 1].Value = dataGridView1.Columns[iC].HeaderText;
139                 }
140                 for (I = 0; I <= rowsTotal - 1; I++)
141                 {
142                     for (j = 0; j <= colsTotal; j++)
143                     {
144                         _with1.Cells[I + 2, j + 1].value = dataGridView1.Rows[I].Cells[j].Value;
145                     }
146                 }
147                 _with1.Rows["1:1"].Font.FontStyle = "Bold";
148                 _with1.Rows["1:1"].Font.Size = 12;
149
150                 _with1.Cells.Columns.AutoFit();
151                 _with1.Cells.Select();
152                 _with1.Cells.EntireColumn.AutoFit();
153                 _with1.Cells[1, 1].Select();
154             }
155             catch (Exception ex)
156             {
157                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
158             }
159             finally
160             {
161                 //RELEASE ALLOACTED RESOURCES
162                 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
163                 xlApp = null;
164             }
165         }
File name: frmMainMenu.cs Copy
393         private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
394         {
395             try
396             {
397                 var _with1 = openFileDialog1;
398                 _with1.Filter = ("DB Backup File|*.bak;");
399                 _with1.FilterIndex = 4;
400                 //Clear the file name
401                 openFileDialog1.FileName = "";
402
403                 if (openFileDialog1.ShowDialog() == DialogResult.OK)
404                 {
405                     Cursor = Cursors.WaitCursor;
406                     timer2.Enabled = true;
407                     SqlConnection.ClearAllPools();
408                     con = new SqlConnection(cs.DBConn);
409                     con.Open();
410                     string cb = "USE Master ALTER DATABASE [" + System.Windows.Forms.Application.StartupPath + "\\pos_db.mdf] SET Single_User WITH Rollback Immediate Restore database [" + System.Windows.Forms.Application.StartupPath + "\\pos_db.mdf] FROM disk='" + openFileDialog1.FileName + "' WITH REPLACE ALTER DATABASE [" + System.Windows.Forms.Application.StartupPath + "\\pos_db.mdf] SET Multi_User ";
411                     cmd = new SqlCommand(cb);
412                     cmd.Connection = con;
413                     cmd.ExecuteReader();
414                     MessageBox.Show("Successfully performed", "Database Restore", MessageBoxButtons.OK, MessageBoxIcon.Information);
415                     GetData();
416                 }
417             }
418             catch (Exception ex)
419             {
420                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
421             }
422         }
File name: frmMainMenu.cs Copy
430         private void btnGetData_Click(object sender, EventArgs e)
431         {
432
433             int rowsTotal = 0;
434             int colsTotal = 0;
435             int I = 0;
436             int j = 0;
437             int iC = 0;
438             System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
439             Excel.Application xlApp = new Excel.Application();
440
441             try
442             {
443                 Excel.Workbook excelBook = xlApp.Workbooks.Add();
444                 Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelBook.Worksheets[1];
445                 xlApp.Visible = true;
446
447                 rowsTotal = dataGridView1.RowCount;
448                 colsTotal = dataGridView1.Columns.Count - 1;
449                 var _with1 = excelWorksheet;
450                 _with1.Cells.Select();
451                 _with1.Cells.Delete();
452                 for (iC = 0; iC <= colsTotal; iC++)
453                 {
454                     _with1.Cells[1, iC + 1].Value = dataGridView1.Columns[iC].HeaderText;
455                 }
456                 for (I = 0; I <= rowsTotal - 1; I++)
457                 {
458                     for (j = 0; j <= colsTotal; j++)
459                     {
460                         _with1.Cells[I + 2, j + 1].value = dataGridView1.Rows[I].Cells[j].Value;
461                     }
462                 }
463                 _with1.Rows["1:1"].Font.FontStyle = "Bold";
464                 _with1.Rows["1:1"].Font.Size = 12;
465
466                 _with1.Cells.Columns.AutoFit();
467                 _with1.Cells.Select();
468                 _with1.Cells.EntireColumn.AutoFit();
469                 _with1.Cells[1, 1].Select();
470             }
471             catch (Exception ex)
472             {
473                 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
474             }
475             finally
476             {
477                 //RELEASE ALLOACTED RESOURCES
478                 System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
479                 xlApp = null;
480             }
481         }

Download file with original file name:H1

H1 94 lượt xem

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