-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRequestItem.cs
157 lines (139 loc) · 4.56 KB
/
RequestItem.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using BusinessLogic;
using Model;
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 SupplierBranching
{
public partial class RequestItem : Form
{
RequestItemLogic req = new RequestItemLogic();
int reqid;
int itemno;
public RequestItem()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void RequestItem_Load(object sender, EventArgs e)
{
AutoComplete();
}
private void btn_add_Click(object sender, EventArgs e)
{
AddReqItem();
ShowGrid();
ClearFields();
}
private void txt_category_TextChanged(object sender, EventArgs e)
{
}
public void AddReqItem()
{
try
{
string cname = txt_category.Text;
int cid = req.getCategoryid(cname);
reqid = req.GetReqId();
RequestItemDTO obj = new RequestItemDTO();
obj.reqcid = cid;
obj.reqid = reqid;
obj.itemdes = txt_itemdes.Text;
obj.itemphoto = txt_itemphoto.Text;
obj.itemspeci = txt_itemspeci.Text;
obj.quantity = Convert.ToDecimal(txt_qty.Text);
obj.estimateprice = Convert.ToDecimal(txt_estimateprice.Text);
req.AddRequestItem(obj);
}
catch (Exception)
{
throw;
}
}
public void ShowGrid()
{
dgv_reqitem.DataSource = req.ShowGrid(reqid);
}
public void AutoComplete()
{
try
{
List<string> listnew = req.GetSource();
var listn = new AutoCompleteStringCollection();
listn.AddRange(listnew.ToArray());
txt_category.AutoCompleteCustomSource = listn;
}
catch (Exception)
{
throw;
}
}
private void btn_clear_Click(object sender, EventArgs e)
{
ClearFields();
}
public void ClearFields()
{
txt_category.Text = "";
txt_estimateprice.Text = "";
txt_itemdes.Text = "";
txt_itemphoto.Text = "";
txt_itemspeci.Text = "";
txt_qty.Text = "";
}
private void dgv_reqitem_CellClick(object sender, DataGridViewCellEventArgs e)
{
int rindex = e.RowIndex;
if (rindex >= 0)
{
txt_category.Text = dgv_reqitem.Rows[rindex].Cells["requestcategory"].Value.ToString();
txt_itemdes.Text = dgv_reqitem.Rows[rindex].Cells["itemdes"].Value.ToString();
txt_itemphoto.Text = dgv_reqitem.Rows[rindex].Cells["itemphoto"].Value.ToString();
txt_itemspeci.Text = dgv_reqitem.Rows[rindex].Cells["itemspeci"].Value.ToString();
txt_qty.Text = dgv_reqitem.Rows[rindex].Cells["quantity"].Value.ToString();
txt_estimateprice.Text = dgv_reqitem.Rows[rindex].Cells["estimateprice"].Value.ToString();
itemno = Convert.ToInt32(dgv_reqitem.Rows[rindex].Cells["itemid"].Value.ToString());
}
}
public void EditItem()
{
RequestItemDTO obj = new RequestItemDTO();
obj.itemid = itemno;
obj.itemdes = txt_itemdes.Text;
obj.itemphoto = txt_itemphoto.Text;
obj.quantity = Convert.ToDecimal(txt_qty.Text);
obj.itemspeci = txt_itemspeci.Text;
obj.estimateprice = Convert.ToDecimal(txt_estimateprice.Text);
obj.reqcid = req.getCategoryid(txt_category.Text);
obj.reqid = reqid;
req.EditItem(obj);
}
private void btn_edit_Click(object sender, EventArgs e)
{
EditItem();
ShowGrid();
ClearFields();
}
private void btn_delete_Click(object sender, EventArgs e)
{
DeleteItem();
}
public void DeleteItem()
{
req.DeleteItem(itemno);
ShowGrid();
ClearFields();
}
private void lbl_itemphoto_Click(object sender, EventArgs e)
{
}
}
}