Skip to content

Commit 4878e54

Browse files
committed
Test 2
1 parent 1c7c9df commit 4878e54

8 files changed

Lines changed: 105 additions & 78 deletions

File tree

StudentProgramCsharp/Class/CDB.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ internal class CDB
1616

1717
public CDB()
1818
{
19-
20-
con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=""C:\Users\yosef\Documents\Visual Studio 2022\StudentProgramCsharp\StudentProgramCsharp\Database\Database1.mdf"";Integrated Security=True");
19+
//con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|Database\Database.mdf ;Integrated Security=True");
20+
con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=" + Application.StartupPath + @"\Database\Database2.mdf;Integrated Security=True");
21+
2122
}
2223

2324

@@ -104,8 +105,7 @@ public int count_Row (String nameOfTable ,String where = null)
104105
}
105106
public SqlConnection _con()
106107
{
107-
108-
return con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=""C:\Users\yosef\Documents\Visual Studio 2022\StudentProgramCsharp\StudentProgramCsharp\Database\Database1.mdf"";Integrated Security=True"); ;
108+
return con ;
109109
}
110110

111111
}

StudentProgramCsharp/Form1.Designer.cs

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

StudentProgramCsharp/Form1.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ private void popuDownloadItems()
9898
//Count the number of rows in the table
9999
int x = readData.count_Row("ProgramsData" , " where CONVERT(VARCHAR,Status) not in ('New')");
100100

101+
101102
SqlCommand cmd;
102103
SqlDataReader dataReader;
103104
String sql = "";
@@ -112,13 +113,19 @@ private void popuDownloadItems()
112113

113114
while (dataReader.Read())
114115
{
116+
117+
//this fix while bug!
118+
if (x == number)
119+
break;
120+
115121
listItems[number] = new DownloadList();
122+
116123
listItems[number].ProgramName = dataReader["Name"].ToString();
124+
listItems[number].Url = dataReader["Url"].ToString();
125+
117126
//listItems[number].Icone = dataReader["Image"].ToString();
127+
118128

119-
Properties.Settings.Default.SettingUrl = dataReader["Url"].ToString();
120-
Properties.Settings.Default.Save();
121-
listItems[number].Url = Properties.Settings.Default.SettingUrl.ToString();
122129

123130

124131
if (Downloads_flowLayoutPanel.Controls.Count < 0)
@@ -155,14 +162,8 @@ private void but_My_Library_Click(object sender, EventArgs e)
155162
private void but_Downloads_Click(object sender, EventArgs e)
156163
{
157164

158-
159-
Downloads_flowLayoutPanel.Refresh();
160165
Downloads_flowLayoutPanel.BringToFront();
161-
162-
163-
164-
165-
166166
}
167+
167168
}
168169
}

StudentProgramCsharp/Form1.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<data name="button1.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
122122
<value>
123123
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
124-
wAAADsABataJCQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAELWSURBVHhe7d0J
124+
vwAADr8BOAVTJAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAELWSURBVHhe7d0J
125125
/G7V3P//i2YNmidNmjUnUgqhQRrRRChFhVI3GnBT5FbdD+pOo1KRIWMhKiVpUCoaaFKaSTTPifx/73fX
126126
/zid0+d8z/d7Xddae+21X8/H4/V43I8bp87a+9rXsNdeqwcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
127127
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICavUgtodZWm6ltqZG2UOuo
@@ -413,7 +413,7 @@
413413
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
414414
<value>
415415
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAN
416-
0wAADdMBvdUcagAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAFk0SURBVHhe7d0L
416+
0gAADdIBb5L+jgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAFk0SURBVHhe7d0L
417417
uK5TvTf+ubAcsxyXs0KxtOxKJ4mIEr2l12k7vXYHW5LDuyOqP9HBqShqh9pK7NBJUsoupUTakaIopZCK
418418
DnopOSvZ/+93GXM11ljfOdc8PM843Pf3d12f62KsOefzG2P87vue83nue4yR//mf/zGzyiGWhXVhU3gp
419419
7AEHwtHwATgXLoZL4XL4DlwLN8DP4Da4A/4I98JD8FjA/2Yb/41fw6/l9/B7+TP4s/gz+bP5GnwtviZf

StudentProgramCsharp/StudentProgramCsharp.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@
122122
<None Include="App.config" />
123123
</ItemGroup>
124124
<ItemGroup>
125-
<Content Include="Database\Database1.mdf">
125+
<Content Include="Database\Database2.mdf">
126126
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
127127
</Content>
128-
<Content Include="Database\Database1_log.ldf">
128+
<Content Include="Database\Database2_log.ldf">
129129
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
130-
<DependentUpon>Database1.mdf</DependentUpon>
130+
<DependentUpon>Database2.mdf</DependentUpon>
131131
</Content>
132132
<Content Include="Image\search.png" />
133133
<Content Include="Image\settings.png" />

StudentProgramCsharp/user control/DownloadList.Designer.cs

Lines changed: 6 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

StudentProgramCsharp/user control/DownloadList.cs

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using AltoHttp;
2+
using StudentProgramCsharp.Class;
23
using System;
34
using System.Collections.Generic;
45
using System.ComponentModel;
@@ -19,28 +20,40 @@ public partial class DownloadList : UserControl
1920
public DownloadList()
2021
{
2122
InitializeComponent();
22-
start_Download();
2323

2424
}
2525

26+
27+
private void DownloadList_Load(object sender, EventArgs e)
28+
{
29+
30+
start_Download();
31+
}
32+
33+
//Fun when Progress is Changed
2634
private void HttpDownloader_ProgressChanged(object sender, AltoHttp.ProgressChangedEventArgs e)
2735
{
2836
progressBar1.Value = (int)e.Progress;
2937
lbspeed.Text = String.Format("{0} MB/s", (e.SpeedInBytes / 1024d / 1024d).ToString("0.00"));
3038

3139
}
3240

41+
42+
//Fun for if Download is Completed
3343
private void HttpDownloader_DownloadCompleted(object sender, EventArgs e)
3444
{
3545
this.Invoke((MethodInvoker)delegate
3646
{
3747
lab_processing.Text = "Download Completed";
3848
but_stop.Enabled = false;
49+
but_Install.Enabled = true;
50+
lbspeed.Text = "0.00 MB/s";
3951

4052
});
4153
}
4254

4355

56+
//get set
4457
#region Properties
4558
private Image _icone;
4659
private string _name;
@@ -89,44 +102,52 @@ public string Procssing
89102
public string Url
90103
{
91104
get { return _url; }
92-
set { _url = value;
93-
lbUrl.Text = _url;
94-
}
105+
set { _url = value;}
95106
}
96107

97108

98109
#endregion
110+
111+
112+
//Fun for download fill from URL
99113
private void start_Download()
100114
{
115+
try
116+
{
117+
httpDownloader = new HttpDownloader(Url, $"{"C:\\Download"}\\{Path.GetFileName(Url)}");
118+
httpDownloader.DownloadCompleted += HttpDownloader_DownloadCompleted;
119+
httpDownloader.ProgressChanged += HttpDownloader_ProgressChanged;
120+
httpDownloader.Start();
121+
lab_processing.Text = "Downloading....";
122+
}
123+
catch
124+
{
125+
lab_processing.Text = "Try Later....";
101126

102-
String url_2 = Properties.Settings.Default.SettingUrl.ToString();
103-
String url_3 = "https://download-cdn.jetbrains.com/python/pycharm-community-2022.2.3.exe";
104-
httpDownloader = new HttpDownloader(url_2, $"{"C:\\Download"}\\{Path.GetFileName(url_2)}");
105-
httpDownloader.DownloadCompleted += HttpDownloader_DownloadCompleted;
106-
httpDownloader.ProgressChanged += HttpDownloader_ProgressChanged;
107-
httpDownloader.Start();
108-
lab_processing.Text = "Downloading....";
109-
127+
}
110128

111129
}
112-
113130

114131

115-
116132

133+
134+
//Button for Pause or Resume the Download
117135
private void but_stop_Click(object sender, EventArgs e)
118136
{
137+
//if Paused Resume
119138
if (httpDownloader.State == AltoHttp.Status.Paused)
120139
{
121-
but_stop.Text = "&Pause";
140+
but_stop.Text = "Pause";
122141
lab_processing.Text = "Downloading....";
123142
httpDownloader.Resume();
124143

125144
}
126-
if (httpDownloader.State != AltoHttp.Status.Paused)
145+
146+
//if Resume Paused
147+
else if (httpDownloader.State != AltoHttp.Status.Paused)
127148
{
128149
lbspeed.Text = "0.00 MB/s";
129-
but_stop.Text = "&Start";
150+
but_stop.Text = "Resume";
130151
lab_processing.Text = "Paused...";
131152
httpDownloader.Pause();
132153

@@ -137,5 +158,14 @@ private void but_stop_Click(object sender, EventArgs e)
137158

138159
}
139160

161+
//Button for installing the application
162+
private void but_Install_Click(object sender, EventArgs e)
163+
{
164+
165+
RunCMD install = new RunCMD();
166+
install.cmd(@"C:\Download\" + Path.GetFileName(Url));
167+
168+
169+
}
140170
}
141171
}

0 commit comments

Comments
 (0)