-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOSMO_Print_Bill.cs
442 lines (384 loc) · 27.1 KB
/
OSMO_Print_Bill.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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
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 Furniture_System
{
public partial class OSMO_Print_Bill : MetroFramework.Forms.MetroForm
{
public OSMO_Print_Bill(string sm,string nm)
{
InitializeComponent();
SM = sm;
NM = nm;
}
FurnitureDB FurDB = new FurnitureDB();
double NewQan;
string SM,NM;
private void OSMO_Print_Bill_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
if (metroGrid_Rec_Itms.Rows.Count != 0)
{
for (int i = 0; i < metroGrid_Rec_Itms.RowCount - 1; i++)
{
string ST_LD = metroGrid_Rec_Itms.Rows[i].Cells["Load_or_Store"].Value.ToString();
string Itm = metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString();
string Qua = metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString();
if (FurDB.Insert_Update_Delete("update Store_Items set Quantity=Quantity+'" + Convert.ToInt32(Qua) + "' where Stor_ID='" + ST_LD + "' and Item_CD='" + Itm + "'") == 1)
{ }
}
}
}
catch (Exception)
{
//MessageBox.Show(ex.Message);
MetroFramework.MetroMessageBox.Show(this, "Please check again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
FurDB.CloseCon();
}
OSMO_Dashboard obj = new OSMO_Dashboard(SM,NM);
obj.Show();
}
private void btn_Back_Click(object sender, EventArgs e)
{
try
{
if (metroGrid_Rec_Itms.Rows.Count != 0)
{
for (int i = 0; i < metroGrid_Rec_Itms.RowCount - 1; i++)
{
string ST_LD = metroGrid_Rec_Itms.Rows[i].Cells["Load_or_Store"].Value.ToString();
string Itm = metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString();
string Qua = metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString();
if (FurDB.Insert_Update_Delete("update Store_Items set Quantity=Quantity+'" + Convert.ToInt32(Qua) + "' where Stor_ID='" + ST_LD + "' and Item_CD='" + Itm + "'") == 1)
{ }
}
}
}
catch (Exception)
{
//MessageBox.Show(ex.Message);
MetroFramework.MetroMessageBox.Show(this, "Please check again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
FurDB.CloseCon();
}
this.Hide();
OSMO_Dashboard obj = new OSMO_Dashboard(SM,NM);
obj.Show();
}
private void OSMO_Print_Bill_Load(object sender, EventArgs e)
{
try
{
cmb_Str_Ldr_Name.DataSource = FurDB.getValue("select Stor_ID from Store_Items where Item_CD='" + cmb_Item_Name.Text + "'").Tables[0];
cmb_Str_Ldr_Name.ValueMember = "Stor_ID";
cmb_Str_Ldr_Name.Enabled = true;
cmb_Str_Ldr_Name.SelectedIndex = -1;
cmb_Item_Name.DataSource = FurDB.getValue("select Item_Code from Item").Tables[0];
cmb_Item_Name.ValueMember = "Item_Code";
cmb_Item_Name.Enabled = true;
cmb_Item_Name.SelectedIndex = -1;
lbl_uPrice.Text = "";
for (int i = 0; i < 8; i++)
{
metroGrid_Rec_Itms.Columns[i].Width = 100;
}
}
catch (Exception)
{
//MessageBox.Show(ex.Message);
MetroFramework.MetroMessageBox.Show(this, "Please check again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
FurDB.CloseCon();
}
}
DateTime date = DateTime.Now;
int dis;
private void btn_Print_Click(object sender, EventArgs e)
{
try
{
if ((txt_Receipt_No.Text.Length != 0) && (txt_NIC.Text.Length != 0) && (metroGrid_Rec_Itms.Rows.Count != 0))
{
if (FurDB.readData("select * from Full_Receipt where Receipt_No='" + txt_Receipt_No.Text + "'") == true && FurDB.readData("select * from Installment_Receipt where Receipt_No='" + txt_Receipt_No.Text + "'") == true && FurDB.readData("select * from Installment_Date where Rec_No='" + txt_Receipt_No.Text + "'") == true)
MetroFramework.MetroMessageBox.Show(this, "Receipt already Issued!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
{
if (FurDB.readData("select * from Customer where NIC='" + txt_NIC.Text + "'") == true)
{
if (txt_Discount_Pcnt.Text.Length == 0)
dis = 0;
else
{
dis = Convert.ToInt32(txt_Discount_Pcnt.Text);
Totfull = Totfull - (Totfull * Convert.ToInt32(txt_Discount_Pcnt.Text) * 0.01);
}
for (int i = 0; i < metroGrid_Rec_Itms.RowCount - 1; i++)
{
if (metroGrid_Rec_Itms.Rows[i].Cells["Payment_Type"].Value.ToString() == "Full Payment")
{
if (FurDB.readData("select * from Full_Receipt where Receipt_No='" + txt_Receipt_No.Text + "'") == false)
{
FurDB.Insert_Update_Delete("insert into Full_Receipt (Receipt_No,Total_Amount,Payment_Type,Discount,Cus_ID,Full_SM) values ('" + txt_Receipt_No.Text + "','" + Totfull + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Payment_Type"].Value.ToString() + "','" + dis + "','" + txt_NIC.Text + "','" + SM + "')");
FurDB.Insert_Update_Delete("insert into Item_Bought_Full values('" + txt_Receipt_No.Text + "','" + txt_NIC.Text + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString() + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString() + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Unit_Price"].Value.ToString() + "')");
}
else
FurDB.Insert_Update_Delete("insert into Item_Bought_Full values('" + txt_Receipt_No.Text + "','" + txt_NIC.Text + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString() + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString() + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Unit_Price"].Value.ToString() + "')");
}
else if (metroGrid_Rec_Itms.Rows[i].Cells["Payment_Type"].Value.ToString() == "Installment Payment")
{
double InsAmount;
if (FurDB.readData("select * from Installment_Receipt where Receipt_No='" + txt_Receipt_No.Text + "'") == false)
{
FurDB.Insert_Update_Delete("insert into Installment_Receipt (Receipt_No,Total_Amount,Payment_Type,Cust_ID,Ins_SM) values('" + txt_Receipt_No.Text + "','" + TotIns + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Payment_Type"].Value.ToString() + "','" + txt_NIC.Text + "','" + SM + "')");
FurDB.Insert_Update_Delete("insert into Item_Bought_Ins values('" + txt_Receipt_No.Text + "','" + txt_NIC.Text + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString() + "','" + Convert.ToDouble(metroGrid_Rec_Itms.Rows[i].Cells["Downpayment"].Value.ToString()) + "','" + Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["No_of_Installments"].Value.ToString()) + "','" + Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString()) + "','" + Convert.ToDouble(metroGrid_Rec_Itms.Rows[i].Cells["Unit_Price"].Value.ToString()) + "')");
//InsAmount = (TotIns - Totdown) / Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["No_of_Installments"].Value.ToString());
InsAmount = ((Convert.ToDouble(metroGrid_Rec_Itms.Rows[i].Cells["Unit_Price"].Value.ToString()) * Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString())) - Convert.ToDouble(metroGrid_Rec_Itms.Rows[i].Cells["Downpayment"].Value.ToString())) / Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["No_of_Installments"].Value.ToString());
for (int j = 1; j <= (Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["No_of_Installments"].Value.ToString())); j++)
{
FurDB.Insert_Update_Delete("insert into Installment_Date (Rec_No,InItm_Code,Installment_Date,Installment_Amount,Status,SM_ID) values('" + txt_Receipt_No.Text + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString() + "','" + date.AddMonths(j) + "','" + InsAmount + "','Not Paid','" + SM + "')");
}
}
else
{
FurDB.Insert_Update_Delete("insert into Item_Bought_Ins values('" + txt_Receipt_No.Text + "','" + txt_NIC.Text + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString() + "','" + Convert.ToDouble(metroGrid_Rec_Itms.Rows[i].Cells["Downpayment"].Value.ToString()) + "','" + Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["No_of_Installments"].Value.ToString()) + "','" + Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString()) + "','" + Convert.ToDouble(metroGrid_Rec_Itms.Rows[i].Cells["Unit_Price"].Value.ToString()) + "')");
//InsAmount = (TotIns - Totdown) / Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["No_of_Installments"].Value.ToString());
InsAmount = ((Convert.ToDouble(metroGrid_Rec_Itms.Rows[i].Cells["Unit_Price"].Value.ToString()) * Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString())) - Convert.ToDouble(metroGrid_Rec_Itms.Rows[i].Cells["Downpayment"].Value.ToString())) / Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["No_of_Installments"].Value.ToString());
for (int j = 1; j <= (Convert.ToInt32(metroGrid_Rec_Itms.Rows[i].Cells["No_of_Installments"].Value.ToString())); j++)
{
FurDB.Insert_Update_Delete("insert into Installment_Date (Rec_No,InItm_Code,Installment_Date,Installment_Amount,Status,SM_ID) values('" + txt_Receipt_No.Text + "','" + metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString() + "','" + date.AddMonths(j) + "','" + InsAmount + "','Not Paid','" + SM + "')");
}
}
}
}
MetroFramework.MetroMessageBox.Show(this, "Successfull!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
Receipt obj = new Receipt(txt_Receipt_No.Text, txt_NIC.Text);
obj.Show();
cmb_Payment_Type.SelectedIndex = -1; cmb_Item_Name.SelectedIndex = -1; cmb_Str_Ldr_Name.SelectedIndex = -1; cmb_Quantity.SelectedIndex = -1;
lbl_Item_Name.Text = ""; lbl_Str_Ld_Name.Text = ""; lbl_uPrice.Text = "";
txt_Downpayment.Clear(); txt_No_of_Ins.Clear(); txt_Discount_Pcnt.Clear(); txt_Discount_Pcnt.Enabled = true; txt_Downpayment.Enabled = true;
txt_No_of_Ins.Enabled = true; txt_NIC.Clear(); txt_Receipt_No.Clear(); metroGrid_Rec_Itms.Rows.Clear();
lbl_Sub_Tot.Text = ""; lbl_Tot_Down.Text = ""; lbl_Tot_Full.Text = ""; Totdown = 0; Totfull = 0; Totsub = 0; TotIns = 0;
}
else
MetroFramework.MetroMessageBox.Show(this, "Customer not Found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
MetroFramework.MetroMessageBox.Show(this, "Please enter all fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception)
{
//MessageBox.Show(ex.Message);
MetroFramework.MetroMessageBox.Show(this, "Please check again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
FurDB.CloseCon();
}
}
double Totdown, Totfull, Totsub, TotIns;
private void btn_clear_all_Click(object sender, EventArgs e)
{
try
{
if (metroGrid_Rec_Itms.Rows.Count != 0)
{
for (int i = 0; i < metroGrid_Rec_Itms.RowCount - 1; i++)
{
string ST_LD = metroGrid_Rec_Itms.Rows[i].Cells["Load_or_Store"].Value.ToString();
string Itm = metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString();
string Qua = metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString();
if (FurDB.Insert_Update_Delete("update Store_Items set Quantity=Quantity+'" + Convert.ToInt32(Qua) + "' where Stor_ID='" + ST_LD + "' and Item_CD='" + Itm + "'") == 1)
{ }
}
}
}
catch (Exception)
{
//MessageBox.Show(ex.Message);
MetroFramework.MetroMessageBox.Show(this, "Please check again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
FurDB.CloseCon();
}
cmb_Payment_Type.SelectedIndex = -1; cmb_Item_Name.SelectedIndex = -1; cmb_Str_Ldr_Name.SelectedIndex = -1; cmb_Quantity.SelectedIndex = -1;
lbl_Item_Name.Text = ""; lbl_Str_Ld_Name.Text = ""; lbl_uPrice.Text = "";
txt_Downpayment.Clear(); txt_No_of_Ins.Clear(); txt_Discount_Pcnt.Clear(); txt_Discount_Pcnt.Enabled = true; txt_Downpayment.Enabled = true;
txt_No_of_Ins.Enabled = true; txt_NIC.Clear(); txt_Receipt_No.Clear(); metroGrid_Rec_Itms.Rows.Clear();
lbl_Sub_Tot.Text = ""; lbl_Tot_Down.Text = ""; lbl_Tot_Full.Text = ""; Totdown = 0; Totfull = 0; Totsub = 0; TotIns = 0;
}
private void cmb_Item_Name_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
lbl_Item_Name.Text = FurDB.readData("select Item_Name from Item where Item_Code='" + cmb_Item_Name.Text + "'", "Item_Name", "");
lbl_Str_Ld_Name.Text = "";
lbl_uPrice.Text = "Rs." + FurDB.readData("select Price from Item where Item_Code='" + cmb_Item_Name.Text + "'", "Price", "");
cmb_Str_Ldr_Name.DataSource = FurDB.getValue("select Stor_ID from Store_Items where Item_CD='" + cmb_Item_Name.Text + "'").Tables[0];
cmb_Str_Ldr_Name.ValueMember = "Stor_ID";
cmb_Str_Ldr_Name.Enabled = true;
cmb_Str_Ldr_Name.SelectedIndex = -1;
}
catch (Exception)
{
//MessageBox.Show(ex.Message);
MetroFramework.MetroMessageBox.Show(this, "Please check again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
FurDB.CloseCon();
}
}
private void btn_clear_Load_Click(object sender, EventArgs e)
{
//try
//{
// if (metroGrid_Rec_Itms.Rows.Count != 0)
// {
// for (int i = 0; i < metroGrid_Rec_Itms.RowCount - 1; i++)
// {
// string ST_LD = metroGrid_Rec_Itms.Rows[i].Cells["Load_or_Store"].Value.ToString();
// string Itm = metroGrid_Rec_Itms.Rows[i].Cells["Item_Code"].Value.ToString();
// string Qua = metroGrid_Rec_Itms.Rows[i].Cells["Quantity"].Value.ToString();
// if (FurDB.Insert_Update_Delete("update Store_Items set Quantity=Quantity+'" + Convert.ToInt32(Qua) + "' where Stor_ID='" + ST_LD + "' and Item_CD='" + Itm + "'") == 1)
// { }
// }
// }
//}
//catch (Exception)
//{
// //MessageBox.Show(ex.Message);
// MetroFramework.MetroMessageBox.Show(this, "Please check again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
// FurDB.CloseCon();
//}
cmb_Payment_Type.SelectedIndex = -1; cmb_Item_Name.SelectedIndex = -1; cmb_Str_Ldr_Name.SelectedIndex = -1; cmb_Quantity.SelectedIndex = -1;
lbl_Item_Name.Text = ""; lbl_Str_Ld_Name.Text = ""; lbl_uPrice.Text = "";
txt_Downpayment.Clear(); txt_No_of_Ins.Clear(); txt_Discount_Pcnt.Clear(); txt_Discount_Pcnt.Enabled = true; txt_Downpayment.Enabled = true;
txt_No_of_Ins.Enabled = true;
}
private void btn_Add_Item_Click(object sender, EventArgs e)
{
try
{
if ((cmb_Payment_Type.SelectedIndex != -1) && (cmb_Item_Name.SelectedIndex != -1) && (cmb_Str_Ldr_Name.SelectedIndex != -1) && (cmb_Quantity.SelectedIndex != -1) && !(txt_Discount_Pcnt.Text.StartsWith("-")) && !(txt_Downpayment.Text.StartsWith("-")) && !(txt_No_of_Ins.Text.StartsWith("-")))
{
if (cmb_Payment_Type.Text == "Full Payment")
{
if (0 <= Convert.ToDouble(FurDB.readData("select Quantity from Store_Items where Stor_ID='" + cmb_Str_Ldr_Name.Text + "' and Item_CD='" + cmb_Item_Name.Text + "'", "Quantity")) - Convert.ToDouble(cmb_Quantity.Text))
{
NewQan = Convert.ToDouble(FurDB.readData("select Quantity from Store_Items where Stor_ID='" + cmb_Str_Ldr_Name.Text + "' and Item_CD='" + cmb_Item_Name.Text + "'", "Quantity")) - Convert.ToDouble(cmb_Quantity.Text);
DataGridViewRow row = (DataGridViewRow)metroGrid_Rec_Itms.Rows[0].Clone();
row.Cells[0].Value = cmb_Str_Ldr_Name.Text;
row.Cells[1].Value = cmb_Payment_Type.Text;
row.Cells[2].Value = cmb_Item_Name.Text;
row.Cells[3].Value = lbl_Item_Name.Text;
row.Cells[4].Value = cmb_Quantity.Text;
row.Cells[5].Value = FurDB.readData("select Price from Item where Item_Code='" + cmb_Item_Name.Text + "'", "Price", "").ToString();
metroGrid_Rec_Itms.Rows.Add(row);
FurDB.Insert_Update_Delete("update Store_Items set Quantity='" + NewQan + "' where Stor_ID='" + cmb_Str_Ldr_Name.Text + "' and Item_CD='" + cmb_Item_Name.Text + "'");
Totfull += Convert.ToDouble(FurDB.readData("select Price from Item where Item_Code='" + cmb_Item_Name.Text + "'", "Price", "")) * Convert.ToDouble(cmb_Quantity.Text);
Totsub = Totfull + Totdown;
lbl_Tot_Full.Text = "Rs." + Totfull.ToString();
lbl_Sub_Tot.Text = "Rs." + Totsub.ToString();
}
else
MetroFramework.MetroMessageBox.Show(this, "No Balance in the Store!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if ((cmb_Payment_Type.Text == "Installment Payment") && (txt_Downpayment.Text.Length != 0) && (txt_Downpayment.Text.Any(char.IsDigit) && (txt_No_of_Ins.Text.Length != 0) && (txt_No_of_Ins.Text.Any(char.IsDigit))))
{
if (0 <= Convert.ToDouble(FurDB.readData("select Quantity from Store_Items where Stor_ID='" + cmb_Str_Ldr_Name.Text + "' and Item_CD='" + cmb_Item_Name.Text + "'", "Quantity")) - Convert.ToDouble(cmb_Quantity.Text))
{
if (Convert.ToDouble(txt_Downpayment.Text) < Convert.ToDouble(FurDB.readData("select Price from Item where Item_Code='" + cmb_Item_Name.Text + "'", "Price", "")) * Convert.ToDouble(cmb_Quantity.Text))
{
NewQan = Convert.ToDouble(FurDB.readData("select Quantity from Store_Items where Stor_ID='" + cmb_Str_Ldr_Name.Text + "' and Item_CD='" + cmb_Item_Name.Text + "'", "Quantity")) - Convert.ToDouble(cmb_Quantity.Text);
DataGridViewRow row = (DataGridViewRow)metroGrid_Rec_Itms.Rows[0].Clone();
row.Cells[0].Value = cmb_Str_Ldr_Name.Text;
row.Cells[1].Value = cmb_Payment_Type.Text;
row.Cells[2].Value = cmb_Item_Name.Text;
row.Cells[3].Value = lbl_Item_Name.Text;
row.Cells[4].Value = cmb_Quantity.Text;
row.Cells[5].Value = FurDB.readData("select Price from Item where Item_Code='" + cmb_Item_Name.Text + "'", "Price", "").ToString();
row.Cells[6].Value = txt_Downpayment.Text;
row.Cells[7].Value = txt_No_of_Ins.Text;
metroGrid_Rec_Itms.Rows.Add(row);
FurDB.Insert_Update_Delete("update Store_Items set Quantity='" + NewQan + "' where Stor_ID='" + cmb_Str_Ldr_Name.Text + "' and Item_CD='" + cmb_Item_Name.Text + "'");
Totdown += Convert.ToDouble(txt_Downpayment.Text);
TotIns += Convert.ToDouble(cmb_Quantity.Text) * Convert.ToDouble(FurDB.readData("select Price from Item where Item_Code='" + cmb_Item_Name.Text + "'", "Price", ""));
Totsub = Totfull + Totdown;
lbl_Tot_Down.Text = "Rs." + Totdown.ToString();
lbl_Sub_Tot.Text = "Rs." + Totsub.ToString();
}
else
MetroFramework.MetroMessageBox.Show(this, "Enter a valid Downpayment!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MetroFramework.MetroMessageBox.Show(this, "No Balance in the Store!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MetroFramework.MetroMessageBox.Show(this, "Please enter all fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
MetroFramework.MetroMessageBox.Show(this, "Please enter all fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception)
{
//MessageBox.Show(ex.Message);
MetroFramework.MetroMessageBox.Show(this, "Please check again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
FurDB.CloseCon();
}
}
private void cmb_Str_Ldr_Name_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
lbl_Str_Ld_Name.Text = FurDB.readData("select Store_Name from Store where Store_No='" + cmb_Str_Ldr_Name.Text + "'", "Store_Name", "");
}
catch (Exception)
{
//MessageBox.Show(ex.Message);
MetroFramework.MetroMessageBox.Show(this, "Please check again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
FurDB.CloseCon();
}
}
private void btn_search2_Click(object sender, EventArgs e)
{
try
{
if (txt_View_Receipt_No.Text.Length != 0)
{
this.DataTable_InsTableAdapter.Fill(this.DataSet3.DataTable_Ins, txt_View_Receipt_No.Text, FurDB.readData("select f.FCus_ID as [NIC] from Item_Bought_Full f where f.Rcpt_No = '" + txt_View_Receipt_No.Text + "' union select i.ICus_ID as [NIC] from Item_Bought_Ins i where i.Rcipt_No = '" + txt_View_Receipt_No.Text + "'", "NIC", ""));
// TODO: This line of code loads data into the 'DataSet2.DataTable_Full' table. You can move, or remove it, as needed.
this.DataTable_FullTableAdapter.Fill(this.DataSet2.DataTable_Full, txt_View_Receipt_No.Text, FurDB.readData("select f.FCus_ID as [NIC] from Item_Bought_Full f where f.Rcpt_No = '" + txt_View_Receipt_No.Text + "' union select i.ICus_ID as [NIC] from Item_Bought_Ins i where i.Rcipt_No = '" + txt_View_Receipt_No.Text + "'", "NIC", ""));
// TODO: This line of code loads data into the 'DataSet1.Customer_Detail' table. You can move, or remove it, as needed.
this.Customer_DetailTableAdapter.Fill(this.DataSet1.Customer_Detail, FurDB.readData("select f.FCus_ID as [NIC] from Item_Bought_Full f where f.Rcpt_No = '" + txt_View_Receipt_No.Text + "' union select i.ICus_ID as [NIC] from Item_Bought_Ins i where i.Rcipt_No = '" + txt_View_Receipt_No.Text + "'", "NIC", ""));
this.reportViewer_View_Receipts.RefreshReport();
}
else
MetroFramework.MetroMessageBox.Show(this, "Please enter all fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
catch (Exception)
{
//MessageBox.Show(ex.Message);
MetroFramework.MetroMessageBox.Show(this, "No Records Found!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
FurDB.CloseCon();
}
}
private void btn_search_Click(object sender, EventArgs e)
{
Add_Customer Addcus = new Add_Customer();
Addcus.ShowDialog();
}
private void cmb_Payment_Type_SelectedIndexChanged(object sender, EventArgs e)
{
if (cmb_Payment_Type.Text == "Full Payment")
{
txt_Discount_Pcnt.Enabled = true;
txt_Downpayment.Enabled = false;
txt_No_of_Ins.Enabled = false; txt_Downpayment.Clear(); txt_No_of_Ins.Clear();
}
else if (cmb_Payment_Type.Text == "Installment Payment")
{
txt_Downpayment.Enabled = true;
txt_No_of_Ins.Enabled = true;
txt_Discount_Pcnt.Enabled = false; txt_Discount_Pcnt.Clear();
}
}
}
}