-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmSearchCustomer.cs
170 lines (149 loc) · 5.35 KB
/
frmSearchCustomer.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace SalesPurchase
{
public partial class frmSearchCustomer : Form
{
public frmSearchCustomer()
{
InitializeComponent();
}
string sFlag, sSearchedCriteria;
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
public delegate void UpdateCustomerDetails(object sender, CustomerDetUpdateArgs e);
public event UpdateCustomerDetails CustomerDetUpdated;
private void textBox4_TextChanged(object sender, EventArgs e)
{
sFlag = "CUSTPHONE";
sSearchedCriteria = txtSearchCustMob.Text;
SearchCustomer(sFlag, sSearchedCriteria);
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
private void txtSearchCustCode_TextChanged(object sender, EventArgs e)
{
sFlag = "CUSTCODE";
sSearchedCriteria = txtSearchCustCode.Text;
SearchCustomer(sFlag, sSearchedCriteria);
}
public void SearchCustomer(string sFlag, string sSearchedCrit)
{
try
{
cmd = new SqlCommand();
ds = new DataSet();
cmd.Connection = GlobalClass.gCon;
cmd.CommandText = "SP_SearchCustomer";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Flag", SqlDbType.VarChar, sFlag.Length).Value = sFlag.Trim();
cmd.Parameters.Add("@SearchedCrit", SqlDbType.VarChar, sSearchedCrit.Length).Value = sSearchedCrit.Trim();
ds.Load(cmd.ExecuteReader(), LoadOption.OverwriteChanges, "Result");
dgSearchCustomer.DataSource = ds.Tables["Result"];
}
catch (Exception ex)
{
}
}
private void txtSearchCustName_TextChanged(object sender, EventArgs e)
{
sFlag = "CUSTNAME";
sSearchedCriteria = txtSearchCustName.Text;
SearchCustomer(sFlag, sSearchedCriteria);
}
private void txtsearchCustAddress_TextChanged(object sender, EventArgs e)
{
sFlag = "CUSTADDRESS";
sSearchedCriteria = txtsearchCustAddress.Text;
SearchCustomer(sFlag, sSearchedCriteria);
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
private void dgSearchCustomer_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
private void dgSearchCustomer_Click(object sender, EventArgs e)
{
try
{
int i;
i = dgSearchCustomer.CurrentCell.RowIndex;
GlobalClass.gsCustomerName = dgSearchCustomer.Rows[i].Cells["CustomerFirstName"].Value.ToString();
GlobalClass.gsCustomerAddress = dgSearchCustomer.Rows[i].Cells["AddressLine1"].Value.ToString() + " , " + dgSearchCustomer.Rows[i].Cells["AddressLine2"].Value.ToString();
GlobalClass.gsPhoneNo = dgSearchCustomer.Rows[i].Cells["MobilePhone"].Value.ToString();
CustomerDetUpdateArgs args = new CustomerDetUpdateArgs(GlobalClass.gsCustomerName, GlobalClass.gsCustomerAddress,GlobalClass.gsPhoneNo);
CustomerDetUpdated(this, args);
//frmOrders fr = new frmOrders();
//fr.txtCustAddress.Text = GlobalClass.gsCustomerAddress;
// this.Close();
}
catch (Exception Ex)
{
}
}
private void button3_Click(object sender, EventArgs e)
{
try
{
ClearForm();
}
catch (Exception ex)
{
}
}
public void ClearForm()
{
txtSearchCustCode.Text = "";
txtSearchCustName.Text = "";
txtsearchCustAddress.Text = "";
txtSearchCustMob.Text = "";
dgSearchCustomer.DataSource = null;
}
private void dgSearchCustomer_MouseDoubleClick(object sender, MouseEventArgs e)
{
this.Close();
}
}
public class CustomerDetUpdateArgs : System.EventArgs
{
private string sCustName,sCustAddress,sCustPhone;
public CustomerDetUpdateArgs(string sCustomerName, string sCustomerAddress, string sCustomerPhone)
{
this.sCustName = sCustomerName;
this.sCustAddress = sCustomerAddress;
this.sCustPhone = sCustomerPhone;
}
public string CustomerName
{
get
{
return sCustName;
}
}
public string CustomerAddress
{
get
{
return sCustAddress;
}
}
public string CustomerPhone
{
get
{
return sCustPhone;
}
}
}
}