FOYDALANILGAN ADABIYOTLAR
1. Ilmiy-texnologik kitoblar. Muallif: Sells C.
2. Основы систем баз данных: Учебник. / Е. Ж. Айтхожаева – Алматы: КазНИТУ имени К. И. Сатпаева, 2016. – 279 с. Ил. 38. Табл. 8. Библиогр. –53 назв.
3. Бейли Л. Изучаем SQL /Пер. с англ. – СПб.: Питер, 2012. – 573 с.
4.Object orentiring programming in C#. 2016
5. Пахомов Б. И. C# для начинающих. — СПб.БХВ-Петербург, 2014. — 432 с.
6. Справочник. Полное описание языка, 6-е изд.:Пер. с англ. – М.: ООО ―И. Д. Вильямс‖, 2016. –
1040.
7. Герберт Шилдт. C# 4.0: полное руководство.:Пер. с англ. М.: ООО ―И.Д. Вильямс‖,
2011. 1056 с.
INTERNET SAYTLARI
https://docs.dot-net.uz/c-.net/basic/starter/kirish
https://docs.dot-net.uz/c-.net/desktop/uwp-universal-
https://help.syncfusion.com/aspnet/progressbar/progress-control-by-using-the-length-of-the-password-field
https://help.syncfusion.com/aspnet/progressbar/enabling-progressbar
Ilovalar
Form1
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 WindowsFormsApplication30
{
public partial class SpalshForm : Form
{
public SpalshForm()
{
InitializeComponent();
}
private void Spalsh_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
LoginForm loginForm = new LoginForm();
this.Hide();
loginForm.Show();
}
}
}
Form2
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;
namespace WindowsFormsApplication30
{
public partial class LoginForm : Form
{
DBConnect dBCon = new DBConnect();
public static string sellerName;
public LoginForm()
{
InitializeComponent();
}
private void label2_Click(object sender, EventArgs e)
{
}
private void label_exit_MouseEnter(object sender, EventArgs e)
{
label_exit.ForeColor = Color.Red;
}
private void label_exit_MouseLeave(object sender, EventArgs e)
{
label_exit.ForeColor = Color.Goldenrod;
}
private void label_clear_MouseEnter(object sender, EventArgs e)
{
label_clear.ForeColor = Color.Red;
}
private void label_clear_MouseLeave(object sender, EventArgs e)
{
label_clear.ForeColor = Color.Goldenrod;
}
private void label_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void label_clear_Click(object sender, EventArgs e)
{
textBox_username.Clear();
textBox_password.Clear();
}
private void button_login_Click(object sender, EventArgs e)
{
if (textBox_username.Text == "" || textBox_password.Text == "")
{
MessageBox.Show("Iltimos Username va Passwordni kiriting", "Noto'liq malumot", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (comboBox_kim.SelectedIndex > -1)
{
if (comboBox_kim.SelectedItem.ToString() == "ADMIN")
{
if (textBox_username.Text == "Admin" && textBox_password.Text == "Admin123")
{
ProductForm1 product = new ProductForm1();
product.Show();
this.Hide();
}
else
{
MessageBox.Show("Agar siz Admin bo'lsangiz, Iltimos to'g'ri ID va Password kiriting", "Noto'liq malumot ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else
{
string selectQuery = "SELECT * FROM Sotuvchi WHERE Sotuvchiname='" + textBox_username.Text + "'AND Sotuvchipass='" + textBox_password.Text + "'";
SqlDataAdapter adapter = new SqlDataAdapter(selectQuery, dBCon.GetCon());
DataTable table = new DataTable();
adapter.Fill(table);
if (table.Rows.Count > 0)
{
sellerName = textBox_username.Text;
SellingForm1 selling = new SellingForm1();
selling.Show();
this.Hide();
}
else
{
MessageBox.Show("Noto'g'ri Username yoki Password", "Xato malumot", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
else
{
MessageBox.Show("Iltimos kimligingizni tanlang", "Noto'g'ri malumot", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
private void LoginForm_Load(object sender, EventArgs e)
{
}
}
}
Form3
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;
namespace WindowsFormsApplication30
{
public partial class ProductForm1 : Form
{
DBConnect dBCon = new DBConnect();
public ProductForm1()
{
InitializeComponent();
}
private void button_kategoriya_Click(object sender, EventArgs e)
{
CategoryForm1 category = new CategoryForm1();
category.Show();
this.Hide();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void ProductForm1_Load(object sender, EventArgs e)
{
getCategory();
getTable();
}
private void getCategory()
{
string selectQuerry = "SELECT * FROM Kategoriya ";
SqlCommand command = new SqlCommand(selectQuerry, dBCon.GetCon());
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
comboBox_kat.DataSource = table;
comboBox_kat.ValueMember = "KatName";
comboBox_search.DataSource = table;
comboBox_search.ValueMember = "KatName";
}
private void getTable()
{
string selectQuerry = "SELECT * FROM Tovar ";
SqlCommand command = new SqlCommand(selectQuerry, dBCon.GetCon());
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
dataGridView_product.DataSource = table;
}
private void clear()
{
textBox_id.Clear();
textBox_name.Clear();
textBox_price.Clear();
textBox_miq.Clear();
comboBox_kat.SelectedIndex = 0;
}
private void button_add_Click(object sender, EventArgs e)
{
try
{
string insertQuery = "INSERT INTO Tovar VALUES ("+textBox_id.Text+"," + textBox_id.Text + ",'" + textBox_name.Text + "'," + textBox_price.Text + "," + textBox_miq.Text + ",'" + comboBox_kat.Text + "') ";
SqlCommand command = new SqlCommand(insertQuery, dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Mahsulot muvofaqiyatli qo'shildi", "Malumot qoshish", MessageBoxButtons.OK, MessageBoxIcon.Information);
dBCon.CloseCon();
getTable();
clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button_update_Click(object sender, EventArgs e)
{
try
{
if (textBox_id.Text == "" || textBox_name.Text == "" || textBox_price.Text == "" || textBox_miq.Text == "")
{
MessageBox.Show("Malumotlaarni kiriting", "Malumotlar toliq emas", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
string updateQuery = "UPDATE Tovar SET Tovarname='" + textBox_name.Text + "',Tovarprice=" + textBox_price.Text + ",Tovarson=" + textBox_miq.Text + ",Tovarkat='" + comboBox_kat.Text + "'WHERE TovarId=" + textBox_id.Text + "";
SqlCommand command = new SqlCommand(updateQuery, dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Mahsulot muvofaqiyatli yangilandi", "Malumot yangilash", MessageBoxButtons.OK, MessageBoxIcon.Information);
dBCon.CloseCon();
getTable();
clear();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dataGridView_product_Click(object sender, EventArgs e)
{
textBox_id.Text=dataGridView_product.SelectedRows[0].Cells[0].Value.ToString();
textBox_name.Text=dataGridView_product.SelectedRows[0].Cells[1].Value.ToString();
textBox_price.Text=dataGridView_product.SelectedRows[0].Cells[2].Value.ToString();
textBox_miq.Text=dataGridView_product.SelectedRows[0].Cells[3].Value.ToString();
comboBox_kat.SelectedValue=dataGridView_product.SelectedRows[0].Cells[4].Value.ToString();
}
private void button_delete_Click(object sender, EventArgs e)
{
try
{
if (textBox_id.Text == "")
{
MessageBox.Show("Malumotlaarni kiriting", "Malumotlar toliq emas", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
string deleteQuery = "DELETE FROM Tovar WHERE TovarId=" + textBox_id + "";
SqlCommand command = new SqlCommand(deleteQuery, dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Mahsulot muvofaqiyatli o'chirildi", "Malumot O'chirish", MessageBoxButtons.OK, MessageBoxIcon.Information);
dBCon.CloseCon();
getTable();
clear();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button_refresh_Click(object sender, EventArgs e)
{
getTable();
}
private void comboBox_search_SelectionChangeCommitted(object sender, EventArgs e)
{
string selectQuerry = "SELECT * FROM Tovar WHERE Tovarkat='"+comboBox_search.SelectedValue.ToString()+"'";
SqlCommand command = new SqlCommand(selectQuerry, dBCon.GetCon());
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
dataGridView_product.DataSource = table;
}
private void label_exit_MouseEnter(object sender, EventArgs e)
{
label_exit.ForeColor = Color.Red;
}
private void label_exit_MouseLeave(object sender, EventArgs e)
{
label_exit.ForeColor = Color.Goldenrod;
}
private void label_logout_MouseEnter(object sender, EventArgs e)
{
label_logout.ForeColor = Color.Red;
}
private void label_logout_MouseLeave(object sender, EventArgs e)
{
label_logout.ForeColor = Color.Goldenrod;
}
private void label_logout_Click(object sender, EventArgs e)
{
LoginForm login = new LoginForm();
login.Show();
this.Hide();
}
private void label_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button_seller_Click(object sender, EventArgs e)
{
SellerForm1 sotuvchi = new SellerForm1();
sotuvchi.Show();
this.Hide();
}
private void comboBox_search_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
Form4
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 WindowsFormsApplication30
{
public partial class CategoryForm1 : Form
{
DBConnect dBCon = new DBConnect();
public CategoryForm1()
{
InitializeComponent();
}
private void getTable()
{
string selectQuerry = "SELECT * FROM Kategoriya ";
SqlCommand command = new SqlCommand(selectQuerry, dBCon.GetCon());
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table=new DataTable();
adapter.Fill(table);
dataGridView_kategoriya.DataSource = table;
}
private void button_delete_Click(object sender, EventArgs e)
{
try
{
string deleteQuery = "DELETE FROM Kategoriya WHERE KatId=" + textBox_id.Text + "";
SqlCommand command = new SqlCommand(deleteQuery, dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Kategoriya muvofaqiyatli o'chirildi", "O'chirish haqida malumot", MessageBoxButtons.OK, MessageBoxIcon.Information);
dBCon.CloseCon();
getTable();
clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button_add_Click_1(object sender, EventArgs e)
{
try
{
string insertQuery = "INSERT INTO Kategoriya VALUES(" + textBox_id.Text + ",'" + textBox_name.Text + "','" + textBox_tavsif.Text + "') ";
SqlCommand command = new SqlCommand(insertQuery,dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Kategoriya muvofaqiyatli qo'shildi","Malumot qoshish",MessageBoxButtons.OK,MessageBoxIcon.Information);
dBCon.CloseCon();
clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button_update_Click(object sender, EventArgs e)
{
try
{
if (textBox_id.Text == "" || textBox_name.Text == "" || textBox_tavsif.Text == "")
{
MessageBox.Show("Malumotlarni to'ldiring", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
string updateQuery = "UPDATE Kategoriya SET KatName='" + textBox_name.Text + "',Kattav='" + textBox_tavsif.Text + "'WHERE KatId=" + textBox_id.Text + " ";
SqlCommand command = new SqlCommand(updateQuery, dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Kategoriya muvofaqiyatli yangilandi", "Yangilanish haqida malumot", MessageBoxButtons.OK, MessageBoxIcon.Information);
dBCon.CloseCon();
getTable();
clear();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
private void CategoryForm1_Load(object sender, EventArgs e)
{
getTable();
}
private void dataGridView_kategoriya_Click(object sender, EventArgs e)
{
textBox_id.Text = dataGridView_kategoriya.SelectedRows[0].Cells[0].Value.ToString();
textBox_name.Text = dataGridView_kategoriya.SelectedRows[0].Cells[1].Value.ToString();
textBox_tavsif.Text = dataGridView_kategoriya.SelectedRows[0].Cells[2].Value.ToString();
}
private void clear()
{
textBox_id.Clear();
textBox_name.Clear();
textBox_tavsif.Clear();
}
private void label_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void label_exit_MouseEnter(object sender, EventArgs e)
{
label_exit.ForeColor = Color.Red;
}
private void label_exit_MouseLeave(object sender, EventArgs e)
{
label_exit.ForeColor = Color.Goldenrod;
}
private void label_logout_MouseEnter(object sender, EventArgs e)
{
label_logout.ForeColor = Color.Red;
}
private void label_logout_MouseLeave(object sender, EventArgs e)
{
label_logout.ForeColor = Color.Goldenrod;
}
private void label_logout_Click(object sender, EventArgs e)
{
LoginForm login = new LoginForm();
login.Show();
this.Hide();
}
private void button_mahsulot_Click(object sender, EventArgs e)
{
ProductForm1 product = new ProductForm1();
product.Show();
this.Hide();
}
private void button_seller_Click(object sender, EventArgs e)
{
SellerForm1 sotuvchi = new SellerForm1();
sotuvchi.Show();
this.Hide();
}
}
}
Form5
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;
namespace WindowsFormsApplication30
{
public partial class SellerForm1 : Form
{
DBConnect dBCon = new DBConnect();
public SellerForm1()
{
InitializeComponent();
}
private void getTable()
{
string selectQuerry = "SELECT * FROM Sotuvchi ";
SqlCommand command = new SqlCommand(selectQuerry, dBCon.GetCon());
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
dataGridView_seller.DataSource = table;
}
private void clear()
{
textBox_id.Clear();
textBox_name.Clear();
textBox_tel.Clear();
textBox_age.Clear();
textBox_pass.Clear();
}
private void button_add_Click(object sender, EventArgs e)
{
try
{
string insertQuery = "INSERT INTO Sotuvchi VALUES (" + textBox_id.Text + ",'" + textBox_name.Text + "','" + textBox_age.Text + "'," + textBox_tel.Text + ",'" + textBox_pass.Text + "') ";
SqlCommand command = new SqlCommand(insertQuery, dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Sotuvchi muvofaqiyatli qo'shildi", "Malumot qoshish", MessageBoxButtons.OK, MessageBoxIcon.Information);
dBCon.CloseCon();
getTable();
clear();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void SellerForm1_Load(object sender, EventArgs e)
{
getTable();
}
private void button_update_Click(object sender, EventArgs e)
{
try
{
if (textBox_id.Text == "" || textBox_name.Text == "" || textBox_age.Text == "" || textBox_tel.Text == ""||textBox_pass.Text=="")
{
MessageBox.Show("Malumotlaarni kiriting", "Malumotlar toliq emas", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
string updateQuery = "UPDATE Sotuvchi SET Sotuvchiname='" + textBox_name.Text + "',Sotuvchiyosh='" + textBox_age.Text + "',Sotuvchitel='" + textBox_tel.Text + "',Sotuvchipass='" + textBox_pass.Text + "'WHERE SotuvchiId=" + textBox_id.Text + "";
SqlCommand command = new SqlCommand(updateQuery, dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Sotuvchi muvofaqiyatli yangilandi", "Malumot yangilash", MessageBoxButtons.OK, MessageBoxIcon.Information);
dBCon.CloseCon();
getTable();
clear();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void dataGridView_seller_Click(object sender, EventArgs e)
{
textBox_id.Text = dataGridView_seller.SelectedRows[0].Cells[0].Value.ToString();
textBox_name.Text = dataGridView_seller.SelectedRows[0].Cells[1].Value.ToString();
textBox_age.Text = dataGridView_seller.SelectedRows[0].Cells[2].Value.ToString();
textBox_tel.Text = dataGridView_seller.SelectedRows[0].Cells[3].Value.ToString();
textBox_pass.Text = dataGridView_seller.SelectedRows[0].Cells[4].Value.ToString();
}
private void button_delete_Click(object sender, EventArgs e)
{
try
{
if (textBox_id.Text == "")
{
MessageBox.Show("Malumotlaarni kiriting", "Malumotlar toliq emas", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
if (MessageBox.Show("Siz rostdn ham buni o'chirishni istaysizmi?", "Delete Record", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
string deleteQuery = "DELETE FROM Sotuvchi WHERE SotuvchiId=" + textBox_id.Text + "";
SqlCommand command = new SqlCommand(deleteQuery, dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Sotuvchi muvofaqiyatli o'chirildi", "Malumot O'chirish", MessageBoxButtons.OK, MessageBoxIcon.Information);
dBCon.CloseCon();
getTable();
clear();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void label_logout_Click(object sender, EventArgs e)
{
LoginForm login = new LoginForm();
login.Show();
this.Hide();
}
private void label_logout_MouseEnter(object sender, EventArgs e)
{
label_logout.ForeColor = Color.Red;
}
private void label_logout_MouseLeave(object sender, EventArgs e)
{
label_logout.ForeColor = Color.Goldenrod;
}
private void label_exit_MouseEnter(object sender, EventArgs e)
{
label_exit.ForeColor = Color.Red;
}
private void label_exit_MouseLeave(object sender, EventArgs e)
{
label_exit.ForeColor = Color.Goldenrod;
}
private void label_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button_mahsulot_Click(object sender, EventArgs e)
{
ProductForm1 mahsulot = new ProductForm1();
mahsulot.Show();
this.Hide();
}
private void button_kategoriya_Click(object sender, EventArgs e)
{
CategoryForm1 kategoriya = new CategoryForm1();
kategoriya.Show();
this.Hide();
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
}
Form6
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 DGVPrinterHelper;
namespace WindowsFormsApplication30
{
public partial class SellingForm1 : Form
{
DBConnect dBCon = new DBConnect();
DGVPrinter printer = new DGVPrinter();
public SellingForm1()
{
InitializeComponent();
}
private void getCategory()
{
string selectQuerry = "SELECT * FROM Kategoriya ";
SqlCommand command = new SqlCommand(selectQuerry, dBCon.GetCon());
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
comboBox_kat.DataSource = table;
comboBox_kat.ValueMember = "KatName";
}
private void getTable()
{
string selectQuerry = "SELECT Tovarname ,Tovarprice FROM Tovar ";
SqlCommand command = new SqlCommand(selectQuerry, dBCon.GetCon());
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
dataGridView_mahsulot.DataSource = table;
}
private void getSellTable()
{
string selectQuerry = "SELECT * FROM Hisob ";
SqlCommand command = new SqlCommand(selectQuerry, dBCon.GetCon());
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
dataGridView_sotilgan.DataSource = table;
}
private void SellingForm1_Load(object sender, EventArgs e)
{
label_sana.Text = DateTime.Today.ToShortDateString();
label_seller.Text = LoginForm.sellerName;
getTable();
getCategory();
getSellTable();
}
private void dataGridView_mahsulot_Click(object sender, EventArgs e)
{
textBox_name.Text=dataGridView_mahsulot.SelectedRows[0].Cells[0].Value.ToString();
textBox_narx.Text = dataGridView_mahsulot.SelectedRows[0].Cells[1].Value.ToString();
}
int grandTotal = 0, n = 0;
private void button_addOrder_Click(object sender, EventArgs e)
{
if (textBox_name.Text == "" || textBox_miq.Text == "")
{
MessageBox.Show("Malumotni kiriting", "Malumotda xatolik", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
int Total = Convert.ToInt32(textBox_narx.Text) * Convert.ToInt32(textBox_miq.Text);
DataGridViewRow addRow = new DataGridViewRow();
addRow.CreateCells(dataGridView_buyurtma);
addRow.Cells[0].Value = ++n;
addRow.Cells[1].Value = textBox_name.Text;
addRow.Cells[2].Value = textBox_narx.Text;
addRow.Cells[3].Value = textBox_miq.Text;
addRow.Cells[4].Value = Total;
dataGridView_buyurtma.Rows.Add(addRow);
grandTotal += Total;
label_amount.Text = grandTotal + "Usd";
}
}
private void button_add_Click(object sender, EventArgs e)
{
try
{
string insertQuery = "INSERT INTO Hisob VALUES ("+textBox_id.Text+",'" +label_seller.Text + "','" + label_sana.Text + "'," + grandTotal.ToString() + ") ";
SqlCommand command = new SqlCommand(insertQuery, dBCon.GetCon());
dBCon.OpenCon();
command.ExecuteNonQuery();
MessageBox.Show("Buyurtma muvofaqiyatli qo'shildi", "Buyurtma qoshish", MessageBoxButtons.OK, MessageBoxIcon.Information);
dBCon.CloseCon();
getSellTable();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button_print_Click(object sender, EventArgs e)
{
printer.Title = "MiniMarket Sotuv Listlari";
printer.SubTitle = string.Format("Date: {0}", DateTime.Now.Date);
printer.SubTitleFormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoClip;
printer.PageNumbers = true;
printer.PageNumberInHeader = false;
printer.PorportionalColumns = true;
printer.HeaderCellAlignment = StringAlignment.Near;
printer.Footer = "foxlearn";
printer.FooterSpacing = 15;
printer.printDocument.DefaultPageSettings.Landscape = true;
printer.PrintDataGridView(dataGridView_sotilgan);
}
private void label_logout_Click(object sender, EventArgs e)
{
LoginForm login = new LoginForm();
login.Show();
this.Hide();
}
private void label_exit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void label_exit_MouseEnter(object sender, EventArgs e)
{
label_exit.ForeColor = Color.Red;
}
private void label_exit_MouseLeave(object sender, EventArgs e)
{
label_exit.ForeColor=Color.Goldenrod;
}
private void label_logout_MouseEnter(object sender, EventArgs e)
{
label_logout.ForeColor = Color.Red;
}
private void label_logout_MouseLeave(object sender, EventArgs e)
{
label_logout.ForeColor = Color.Goldenrod;
}
private void button_refresh_Click(object sender, EventArgs e)
{
getTable();
}
private void comboBox_kat_SelectionChangeCommitted(object sender, EventArgs e)
{
string selectQuerry = "SELECT Tovarname ,Tovarprice FROM Tovar WHERE Tovarkat='" + comboBox_kat.SelectedValue.ToString() + "'";
SqlCommand command = new SqlCommand(selectQuerry, dBCon.GetCon());
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable table = new DataTable();
adapter.Fill(table);
dataGridView_mahsulot.DataSource = table;
}
}
}
Do'stlaringiz bilan baham: |