-
Notifications
You must be signed in to change notification settings - Fork 0
/
Order.cs
89 lines (77 loc) · 2.57 KB
/
Order.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Web.UI.HtmlControls;
using System.Windows.Forms;
namespace ELO
{
public partial class Order : Form
{
public Order()
{
InitializeComponent();
Quantity.Text = "1";
}
private void btnSmall_Click(object sender, EventArgs e)
{
sizeLabel.Text = "S";
}
private void btnMedium_Click(object sender, EventArgs e)
{
sizeLabel.Text = "M";
}
private void btnLarge_Click(object sender, EventArgs e)
{
sizeLabel.Text = "L";
}
private void btnXL_Click(object sender, EventArgs e)
{
sizeLabel.Text = "XL";
}
private void btnDec_Click(object sender, EventArgs e)
{
if(Convert.ToInt64(Quantity.Text) >1)
Quantity.Text = (Convert.ToInt64(Quantity.Text)-1).ToString();
}
private void btnInc_Click(object sender, EventArgs e)
{
Quantity.Text = (Convert.ToInt64(Quantity.Text) + 1).ToString();
}
private void Order_Load(object sender, EventArgs e)
{
}
private void btnAddCart_Click(object sender, EventArgs e)
{
try {
String str = @"data source=Gareebooo; initial catalog=ELO; integrated security=true;";
SqlConnection con = new SqlConnection(str);
String query = "insert into cart values("+ int.Parse(productId.Text) + ",'" + productTitle.Text+ "','"+productPrice.Text+ "','"+ productImage.Tag.ToString() + "',"+int.Parse(Quantity.Text)+",'"+sizeLabel.Text+"')";
SqlCommand cmd = new SqlCommand(query, con);
con.Open();
int rows=cmd.ExecuteNonQuery();
con.Close();
if (rows > 0)
{
MessageBox.Show("Successfully Added to Cart", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
Home.Childform(new Cart(), sender);
}
else
MessageBox.Show("Some Error Occured!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
AddedLabel.Visible = true;
Thread.Sleep(3000);
AddedLabel.Visible = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}