Kompyuter ilmlari va dasturlashtirish


FOYDALANILGAN ADABIYOTLAR


Download 1.1 Mb.
bet7/7
Sana28.12.2022
Hajmi1.1 Mb.
#1070620
1   2   3   4   5   6   7
Bog'liq
10 Hisobot

FOYDALANILGAN ADABIYOTLAR
1. Справочник. Полное описание языка, 6-е изд.:Пер. с англ. – М.: ООО ―И. Д. Вильямс‖, 2016. –
1040.
2. Герберт Шилдт. C# 4.0: полное руководство.:Пер. с англ. М.: ООО ―И.Д. Вильямс‖,
2011. 1056 с.
3. Фримен. ASP.NET Core MVC 2 с примерами на C# для профессионалов
INTERNET SAYTLAR
1.https://docs.microsoft.com/en-us/dotnet/csharp
2.https://youtu.be/bs_sgLY7lDo

ILOVALAR
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;

namespace ElectironDarslikAvtomatic


{
public partial class Form5 : Form
{
private SqlConnection sqlConnection = null;
public Form5()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\hp\source\repos\ElectironDarslikAvtomatic\ElectironDarslikAvtomatic\Darslik.mdf;Integrated Security=True");
private void button3_Click(object sender, EventArgs e)
{
this.Hide();
Form1 form1 = new Form1();
form1.Show();
}

private void button1_Click(object sender, EventArgs e)


{
SqlCommand cmd = con.CreateCommand();
DataTable table = new DataTable();
con.Open();

cmd.CommandText = $"select id,sinfNomeri,fanNomi,yili,tili from Fan where sinfNomeri={textBox1.Text}";


table.Load(cmd.ExecuteReader());
con.Close();
table.Columns.Add("Fayl");
for (int i = 0; i < table.Rows.Count; i++)
{
table.Rows[i][5] = "📁Faylni ochish";
}
dataGridView1.DataSource = table;

}


private void Form5_Load(object sender, EventArgs e)
{
SqlCommand cmd = con.CreateCommand();
DataTable table = new DataTable();
con.Open();

cmd.CommandText = "select id,sinfNomeri,fanNomi,yili,tili from Fan";


table.Load(cmd.ExecuteReader());
con.Close();
table.Columns.Add("Fayl");
for (int i = 0; i < table.Rows.Count; i++)
{
table.Rows[i][5] = "📁Faylni ochish";
}
dataGridView1.DataSource = table;

}


private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{

int index = e.RowIndex;


if (e.ColumnIndex == 5)
{
DataGridViewRow row = dataGridView1.Rows[index];
int d = int.Parse(row.Cells[0].Value.ToString());
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select FAYL,farmat from Fan where id=" + d;
DataTable table1 = new DataTable();
con.Open();
table1.Load(cmd.ExecuteReader());
con.Close();
var name = "Fan";
var fayl = (Byte[])(table1.Rows[0][0]);
var format = table1.Rows[0][1];
var newFileName = name + format;
File.WriteAllBytes(newFileName, fayl);
System.Diagnostics.Process.Start(newFileName);
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ElectironDarslikAvtomatic


{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
string login = textBox1.Text;
string parol = textBox2.Text;
if (login.Equals("sobir") && parol.Equals("admin")){
this.Hide();
Form3 form3 = new Form3();
form3.Show();
}
else
{
MessageBox.Show("Login yoki parol xato !");
}
}

private void Form2_Load(object sender, EventArgs e)


{

}


private void label_clear_MouseEnter(object sender, EventArgs e)
{
}

private void label_clear_Click(object sender, EventArgs e)


{

}
}
}


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;

namespace ElectironDarslikAvtomatic


{
public partial class Form3 : Form
{
string path2 = "";
private SqlConnection sqlConnection = null;
public Form3()
{
InitializeComponent();
}
string manzil;
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\hp\source\repos\ElectironDarslikAvtomatic\ElectironDarslikAvtomatic\Darslik.mdf;Integrated Security=True");

private void button3_Click(object sender, EventArgs e)


{
this.Close();
Form1 form1 = new Form1();
form1.Show();
}

private void button2_Click(object sender, EventArgs e)


{
if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "" && !path2.Equals(""))
{
int sinfNomeri = int.Parse(textBox1.Text);
string nomi = textBox2.Text;
string yili = textBox3.Text;
string tili = textBox4.Text;
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = $"insert into Fan (sinfNomeri,fanNomi,yili,tili,fayl,farmat) values ({sinfNomeri}, '{nomi}', '{yili}', '{tili}',@fayl,'{path2.Substring(path2.LastIndexOf('.'))}')";
FileStream fs = new FileStream(path2, FileMode.Open, FileAccess.Read);
Byte[] bytefile = new Byte[fs.Length];
fs.Read(bytefile, 0, bytefile.Length);
fs.Close();
cmd.Parameters.Add(new SqlParameter("@fayl", SqlDbType.VarBinary, bytefile.Length, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, bytefile));
DataTable table = new DataTable();
con.Open();
/* FileStream fs = new FileStream(manzil, FileMode.Open, FileAccess.Read);
Byte[] bytefile = new Byte[fs.Length];
fs.Read(bytefile, 0, bytefile.Length);
fs.Close();
cmd.Parameters.Add(new SqlParameter("@FILE", SqlDbType.VarBinary, bytefile.Length, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, bytefile));
*/
cmd.ExecuteNonQuery();
cmd.CommandText = "select id,sinfNomeri,fanNomi,yili,tili from Fan";
table.Load(cmd.ExecuteReader());
con.Close();
table.Columns.Add("Fayl");
for(int i=0; i{
table.Rows[i][5] = "📁Faylni ochish";
}
dataGridView1.DataSource = table;
MessageBox.Show("Yangi kitob qo'shildi (Malumotlar saqlandi).", "Muvaffaqiyatli !", MessageBoxButtons.OK);
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
textBox5.Clear();
path2 = "";
}

else
{


MessageBox.Show("Maydonlarni to'ldiring!");
}
}

private void Form3_Load(object sender, EventArgs e)


{
SqlCommand cmd = con.CreateCommand();
DataTable table = new DataTable();
con.Open();
cmd.CommandText = "select id,sinfNomeri,fanNomi,yili,tili from Fan";
table.Load(cmd.ExecuteReader());
con.Close();
table.Columns.Add("Fayl");
for (int i = 0; i < table.Rows.Count; i++)
{
table.Rows[i][5] = "📁Faylni ochish";
}
dataGridView1.DataSource = table;
}
private void button1_Click(object sender, EventArgs e)
{
int rowindex = dataGridView1.CurrentCell.RowIndex;
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = $"delete from Fan where id=" + dataGridView1.Rows[rowindex].Cells[0].Value.ToString();
DataTable table = new DataTable();
con.Open();
cmd.ExecuteNonQuery();
cmd.CommandText = "select * from Fan";
table.Load(cmd.ExecuteReader());
con.Close();
dataGridView1.DataSource = table;
MessageBox.Show("Fan o'chirib tashlandi.", "Muvaffaqiyatli !", MessageBoxButtons.OK);
}
private void textBox5_Click(object sender, EventArgs e)
{
if (openFileDialog2.ShowDialog() == DialogResult.OK)
{
path2 = openFileDialog2.FileName;
textBox5.Text = path2;
}
}

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)


{
int index = e.RowIndex;
if (e.ColumnIndex == 5)
{
DataGridViewRow row = dataGridView1.Rows[index];
int d = int.Parse(row.Cells[0].Value.ToString());
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select FAYL,farmat from Fan where id=" + d;
DataTable table1 = new DataTable();
con.Open();
table1.Load(cmd.ExecuteReader());
con.Close();
var name = "Fan";
var fayl = (Byte[])(table1.Rows[0][0]);
var format = table1.Rows[0][1];
var newFileName = name + format;
File.WriteAllBytes(newFileName, fayl);
System.Diagnostics.Process.Start(newFileName);
}
}

private void textBox5_TextChanged(object sender, EventArgs e)


{

}


private void textBox2_TextChanged(object sender, EventArgs e)
{

}
}
}


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Data.SqlClient;

namespace ElectironDarslikAvtomatic


{
public partial class Form5 : Form
{
private SqlConnection sqlConnection = null;
public Form5()
{
InitializeComponent();
}
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\hp\source\repos\ElectironDarslikAvtomatic\ElectironDarslikAvtomatic\Darslik.mdf;Integrated Security=True");
private void button3_Click(object sender, EventArgs e)
{
this.Hide();
Form1 form1 = new Form1();
form1.Show();
}

private void button1_Click(object sender, EventArgs e)


{
SqlCommand cmd = con.CreateCommand();
DataTable table = new DataTable();
con.Open();

cmd.CommandText = $"select id,sinfNomeri,fanNomi,yili,tili from Fan where sinfNomeri={textBox1.Text}";


table.Load(cmd.ExecuteReader());
con.Close();
table.Columns.Add("Fayl");
for (int i = 0; i < table.Rows.Count; i++)
{
table.Rows[i][5] = "📁Faylni ochish";
}
dataGridView1.DataSource = table;

}


private void Form5_Load(object sender, EventArgs e)
{
SqlCommand cmd = con.CreateCommand();
DataTable table = new DataTable();
con.Open();

cmd.CommandText = "select id,sinfNomeri,fanNomi,yili,tili from Fan";


table.Load(cmd.ExecuteReader());
con.Close();
table.Columns.Add("Fayl");
for (int i = 0; i < table.Rows.Count; i++)
{
table.Rows[i][5] = "📁Faylni ochish";
}
dataGridView1.DataSource = table;

}


private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{

int index = e.RowIndex;


if (e.ColumnIndex == 5)
{
DataGridViewRow row = dataGridView1.Rows[index];
int d = int.Parse(row.Cells[0].Value.ToString());
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "select FAYL,farmat from Fan where id=" + d;
DataTable table1 = new DataTable();
con.Open();
table1.Load(cmd.ExecuteReader());
con.Close();
var name = "Fan";
var fayl = (Byte[])(table1.Rows[0][0]);
var format = table1.Rows[0][1];
var newFileName = name + format;
File.WriteAllBytes(newFileName, fayl);
System.Diagnostics.Process.Start(newFileName);
}
}
}
}
Download 1.1 Mb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling