2.0 Process
5.4 Additional Toals
Successful resigtration of any custorners from the main panel entry is followed up here
n El
, Clrrt
Additional tools are
integrated additionally fotr user iaterface a-od b<tping aad make it friendly.they are Notepad.C alculaior-\{ S * ord- Task }{anager,Wordpad Shorcuts .
!
I
c?ryritunsaeatd*nentory
5-S
Bttirs
BilliE
3 &e 6nat panmel whse a trarsactioos are fulfilled ts go acdiutris
ae gwated -I!
ttb phase to go for product hansactim,from &e pm&rct pnelof Hiry
section, follow &is procedureto go for a Success&rl traasacaior-i*bk
35
r=- :*-.
Eb -
E1 r* ryr&
S&*dtu&
Could
pssible
to fiad out g@erated invoice&om get data bu*on of
billing
Select
product>Enter Quentity>Adl tB
transaction to the
cart{'lieL rrw !d
insert
tberequired VAT td lhc-
kkkre
rocording
to the customer.Save atrdor Invoice
Cntirua n :"r1- S a lis flnfu nventory 36
Source Codes
ConVutinzed SaEs gtndltrnlentory
using System;
usiag System.Collections.Generic;
using System.ComponentModel;
usiag Sysem.Data;
usi n g S1'stsm.Drawing;
using System.Lioq;
u5.ing Slstem.Text;
using Spem.Windows.Forms;
using System.Data.SqlClient;
om€space Sales_and lnventory_Systee
pblic partial class frrrCategory : Form SqlDaeReader rdr
:
null;DataTable dtable: new DataTable$;
SqlCo*nectioa con
:
null;SqlCommand cmd: null;
DaraTable
dt:
new DataTable$;CmnectioaString cs
:
new ConnectionString$;pblic frmCategory$
Initializdonponeat$;
prrrd€ toid frmCategory_Load(object serder, Eve*tArgs e) bnnSare "Enahled
:
false;-\mocmplete$:
I
?rnae toid bm5ave_Click{object sef,d€r. Erenl{rgs e}
f
t mrCategul'li*ms.]em:
..1VasageBor$bo*r-Pkase ecrer f"magrq
qr-.:' "k-r' \[asiagstxBuue. E
Uesua{EB.crlcu..Errort:
rcCeregrq Stme-Fo:rms',*
rEe-
rs
MessagrBoxlcm-Errsl
utcategoryNm.Text:
"i
fitCa&goryNaae-FocuS;
37
:a[. = 91 3!r-tm+lu,< -B] m1g
;cs- lqrem I
rl!.'rtf E = .SEI-^EL-T
:nlryiltmc fu Tj-qry 66 iqlTDrc-
*u{.tgrrylir"Text mi= s lqli:rrlrrrril.=:
,mrtf,*ry6=;a
yq-:.=tx Fur-Iqr 1
if
rr&Ld-m
1-
Itess*gsBffi
qh.,T('CftEq ik Akafi' Fr:it('.'Erru'"
HemgeBox.BctffiOI(
C,qtu ri riz;d- Sa lts fln/'lnvnrorlr
t-
rdr.Close0;
I l
return;
con
:
new SqlConnection(cs.DBConn);con.Open0;
srring
cb:
"INSERT INTO T_Category(CategoryName) VALUES ("'+ txtCategoryName T:.cmd
:
new SqlCommand(cb);cmd.Connection: con;
cmd.ExecuteReader0;
con.Close$;
MessageBox.Show("Successfully saved", "Record", MessageBoxButtons. OK.
)' 1
*
:ageB oxlcon.Information) ;Autocomplete$;
btnSave.Enabled
:
false;),]
catch (Exception ex) It
MessageBox.Show(ex.Message, "Error", MessageBoxBufions,OK, MessageBc r.l: :
-
:-
).
I
pnvate void btnDelete*Click(object sender, EventArgs e)
t t.
if (MessageBox.Show("Do you really want to delete this record?"' "Confirmai -':-'
\lessageBoxButtons.YesNo, MessageBoxlcon.Question)
::
System.Windo*'s.Ftn:rsl::
( t-
delete_recordsQ;
) J
I
J
private void delete_records0 {
int RowsAffected:0;
con = new SqlConnection(cs.DBConn il con.Open0;
string
cq:
"DELETE FROIVIT
Categ:l.
-::-: -:
cmd
:
new SqlCommandtcq t:cmd.Connection: con:
RowsAffected
:
cmd.Ere;i::l'-:
.-.-
if(RowsAffected>0'
t
MessageBor.Si-;';
">-::t.,'- -: -.- ; -.
--MessageBodcon. Inlbm rir : :, .
Resetl.
.{ut,r--'::.::=
e1;;
)'1.'..".5"::-
!:' t''"
::':-::
-\1->::-'3; t -- - -. -.-:'. -:- j* . -
I! -\' .
if ( con.Sute
:
[66asfl6nSue.Qoen ttry It
,ir
I
I
ety*irerlsa6s
Rndtnvenary
39i
catch (Exception ex)
t
MessageBox.Show(ex.Message, oError', MessageBoxButtons.Oli MessageBoxlcon.Error);
)
)
private void AutoccropleteQ
{ try {
con
:
new SqlConnection(cs.DBCona);con.OpenQ;
SqlCommand cmd: new SqlCommand("SELECT distinct Categoryname FROM T_Category", con);
DataSet ds: new DataSet$;
SqlDataAdapier da
:
new SqlDataAdapter(cmd);da-Fil(ds, "T_Category');
AutdompleteStringCollection col
:
new AutdompleteStringCollectionQ;int
i:
0;for (i
:0;
i<:
ds.Tables[0].Rows.Count - l; i++)t
col.Add(ds. Tables[0].Rows[i]["Categoryname"].Tostrirg$];
)
BtCategoryName.AutoCompleteSource
:
AutoCompleteSource.CustomSource;AtCategoryName.AutoCompleteCustomSource
:
col;EtCategoryName.AutoCompleteModo
:
AutoCompleteMode.Suggest;con.Close$;
cakh
l
@xception ex) {MessageBox.Show(ex.Message, 'Erroro, MessageBoxButtons.Ol( MessageBoxlcon.Error);
)
private void baUpdate_Click(object sender, EventArgs e)
t
try {
if (ktCategoryName.Text
-
"")t
MessageBox.Show("Please enter Category name", "Error", MessageBoxButtons.Oll MessageBoxlcon.Brror);
EdCafegoryName.Focus$;
retrn;
)
om
:
nsw SqlConnectioa(cs.DBConn);cm-OpenS;
striag cb = 'IIPDATE T_Category set CategoryName='n + txtCategoryName.Text + '' sfug1s ffEn 4
tdD.T€rl+*;
@d:nerSqtCmnd(cb);
sd.Cffiin:ccE
+
cmd-ExocmeReade{;coa.Cloee$;
MessageBox.Showfsuccessfrlly
qffi ,'Reodl,
MesageBoxButtons.OK,e
|\dessageBoxlcon.Iafsmatimb Autocomplete.Q;btnUpdate.Enabled
:
false;)
catch (Exception ex)
{
MessageBox.Show(exJvIessage, 'Errorn, MessageBoxButtons.Ol! MessageBoxlcon.Error);
)
Corrgwt{rizd Sa rts And lwentoty
btnSavE.Enabled
:
true;btnDelete.Enabled
:
false;btnUpdate.Enabled
:
false;htCategoryName.FocusQ;
l
private void b{nNes,_Clic(object sender, EventArgs e)
{
ReseCI;
)
private void btnGdllah_Click(object sender, EventArgs e) {
eis-Ilik0;
frEcategoryReeord
frm:
new frmcatE oryR@ordCI frm Show0;frm-&tDaraS;
l
)
l
uslng System;
using Systen . Collections . Generic;
using System. Componentfrodel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Wlndows. Forms;
using System. Data. SqlClient;
namespace 5a les_and_Inventory_System
{
public partial class
frmCategoryRecord:
Form{
SqlDataReaderrdr
=nulIj
SqlConnection con = nu1li
SqlCommand cmd
= null;
ConnectionString
cs
= neh, ConnectionStringO;public
f rmCategoryRecord ( )t
InitializeConponent ( ) ;)
private void
dataGridViexl_RuPostPaint(object sender,IHtridtl'i*nPostPaintEventArgs
e)t string strRd.*ep =
(e.Rorlndex+ 1).ToStringO;
SizeF
size
= e. Graphics. lbasureString(strRd.-er, lfiis.
Fcrt);
if (dat*idViF{ -ndlead€r{idt t
< Convert.Tolnt32((size-l6dth+
ZO))){ datfiili*r -IarlErdcr'flidlf
=Csrvert.Tolrrt32((size.Hidth +
20));
Brrrdr
l b
=Strstc*'uslEs-Ccrtrrlfext;
e-Gralrics-Htriry(sHcfnr, t ris.Ftrt, b,
e.Bo3ounds. Location.X +15, e.*&rds.Ltratim-Y + ((e.Mnds-lEiSht - size.lleiglrt) I
Z1'1;]
private void
dataGridllisl_IalleaderllouseClick( object
sender, DataGridl/ieyCellltouseEventArgs e){ DataGrid/idor dr
= data6ridVierl.SelectedRos[8] ;this-Hidef):
40
Cofigrat{* ed sa 6s Atnf, lnuentory
fnr.
txtcategoryrftame. Text = dr. Cells [ 1 J . Value. ToString( ] ; frm.btnDelete.Enabled =true;
frn.btnUpdate.Enabled =
true;
fnr . txtCategorytlae . Focus ( ) ; fr.tr.btnSave.Enabled =
false;
public ) void 6e{Ibtao {
c(rr
= ner
Sqlconnection(cs.DGConn) ; can.OpenO;String sql =
'SELECT*
FROI T_€ategoryorder
by CategoryName";cld
=o€r Sqlcmand(sql,
con);rdr =
crd. ExecuteReader(ComandBehavior. CloseConnection); dataGridl/isl.
Roxs . Clear ( ) ;*tile
(rdr.ReadO ==true)
{
data6ridVieul. Rows . Add (rdr[ 6], rdr [1 J ) ;)
con. Close(
);
]
catch (Exception ex){
HessageBox.Show(ex.Flessage,"Error",
MessageBoxButtons.0K, llessageBoxlcon - Error ) ;) )
ming System;
usiag System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Dmwing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.IO;
using System.Security.Cryptography;
4t
try {
private void
frmcategoryRecord_Formclosing(obJect sender, FormClosingEvertAr€F e){ this.
Hide();
frmCategory
frm
= new frmcategoryO;frm. Show(
);
)
private void
frmCategoryRecord_Load(object sender, EventArgs e) {GetData (
);
)
S.3Resistration Panel
I
I
I
l.
EFsDCca Sales and loveatorv Sysfim
ConTut{r{zef, Sabsfl nfu rreiltory SqlCoonection con
:
uull;SqlCommand cmd: null;
DataTable
dt:
new DataTableQ;ConnectionString cs
:
new ConnectionStringQ;public frrrRegistration$
{
InitializeComponent();
Il
private void Forrrl Load(object sender, EventArgs e)
{
btnRegister.Enabled
:
false;AutocompleteQ;
)
private void ResetQ {
fitUsemame,Text: n";
cmbUserTSrye.Selectedlndex
:
- 1 ; b<tPassword.Text: '";
brtContact_no.Text
:
"";fi.tName.Text: "";
txtEmail_Address.Text
:
n";btuRegister.Enabled
:
tme;btnDelete.Enabled
:
false;bhupdatc_resodEnabled
:
frlse;ktUsername -Focus0;
)
private void NewRecord_Click(object s€,nder, EventArgs e)
{
ReseQ;
)
private void Register_Click(object sender, EvmtArgs e) {
if (b<tUsername.Text
:
ntr){
MessageBox.Show("Please enterusemame", 'Error', MessageBoxButtons.OlL MessaSEBGIc[-Euor}
brtUseruame.Focus$;
retum;
if ) (cmbUserType.Text
:
nn;{
MessageBox.Show("Please select user t14le", nError", MessageBoxButtoos.OK" Mes$rlEEcIco-FrE);
cmbUserType.FocusQ;
retum;
if
l
(htPassword.Text-
"")( 1
MessageBox.Show("Please enterpassword', 'Errtrr',
MessagsBorfu.OL
ucstFBflIcm-Error);EtPassword.FocusQ;
refurn;
)
if (txtName.Text
-
"") {MessageBox.Show(?lease €[&[
rwrr', 'Erd, Lc*sl3eBorEtr: (X, [email protected]);
atName.FocusQ;
refirn;
)
if (kfContact-ro.Text
: *)
{
MessageBox.Sbos(-Pb.ce
adFolrEl rn.','E[d,
}{essege3oxMos-Oll MessageBofcon.Error);trilCmtact_aoJoflsQ[
42
I
cnyutirizd sa6s enf, n,ettory
brtEmail_Address.FocusQ;
return;
con
:
new SqlConnection(cs.DBCom);con.Open();
string
ct:
"SELECT usemame from T_REGISTRAfiON where username:@find";cmd
:
new SqlCommand(ct);cmd.Connection: con;
cmd.ParametersAdd(new SqlParameter("@frn{, Systerr.Data.SqlDbType.Nchar, 30, "username");
cmdParameters['@find'].Value
:
EtUsemame.Text;rdr
:
cmd.ExecuteReade{;if (rdr.Read0) {
MessageBox.Show('Usemame Already Exists", "Error", MessageBoxButtons.OK, MessageBoxlcon.Error) ;
brtUsername.Text:
"';
brtUsername .Focus$;
if (rdr
!:
null){
rdr.CloseQ;
) retun;
l
con
:
nsw SqlConnection(cs.DBConn);con.Open$;
sking ctl
:
"SELECT Email from T_REGISTRATION where Email:"'+ ktEmail_AddrcssTcril+-;
cmd
:
new SqlCorrmand(ct1);cmd.Connection: con;
rdr
:
cmd5xecuteReader$;if (rdr.Read0) {
MessageBox.Show("Email ID Already Exists", uError", MessageBoxButtoc.OX"
MessageBoxlcon,Error);
txtEmail_Address.Text
:
"";trtEmail Address.Focus$;
if
(r&
!:null)){
rdr.CloseQ;
)
rgfurn;
)
con = new SqlConnection(cs.DBCmn);
con.OpenQ;
string cb = "INSERT INTO
T_REGISTRATION(Usernane,UserT
VALI}ESf
+Etusemame.Text + "','"
*cmbUse,rTxE.Tcil*-,-*fuudTcec+ -,'*tffffi
no.Ttm+ "','' + EtEmail Address.Text*
-,'"*
EtNme.Tcrr* -,-
+$ilE I)-T'eJ{c
+T;
cmd: rew SqlConman(cb);
****;Ty
43
)
Ery
{
I
l.
Cottyrut{rizedl Sa frs Aaf, lnuentory
btnRegister.Enabled
:
false;)
cakh (Exception ex)
{
MessageBox.Show(ex.Messagen t'Error", MessageBoxButtons-Of! MessageBodcon.Error);
l
private void CheckAvailability-Click(object sender, EventArgs e) (
1
try {
if (trtUsemame.Text
:
nr){
MessageBox.Show("Please enter ussmame','EITol', MessageBoxButtons.Olq MessageBoxlcon.Error);
txtUsername.Focus0;
return;
)
coo
:
nsw SqlConnection(cs.DBCorn);con.OpenQ;
stoing
ct:
"SELECT us€nunrc from T_REGISTRATION where ussname:"'* txtUsetname-Text +-;
cmd
:
new SqlComman(ct);cmdCon@ion:coq
dr :
cmd-ExemteR€ad€rQ;if (rdr.ReadQ)
{
MeesageBox.Show("Usernanne not available", "', MessageBoxButtons.OK, MessageBodcon.Infonnation);
return;
)
if (lrdr.ReadQ) {
MessageBox.Show("Usernane available", "', MessageBoxButtons.O(
Lfe<s*SpBtrrcilfuirh
brtUsername.Focus$;
)
if ((rdr
!:
null)) {rdr.Closeo;
l
)catch @xception ex)
{
MessageBox.Show(ex.Message, t'Error", MessageBoxBufirc.OK"
Uersrgc8slcr.Euu}
l
)
private void Email_Address_Validating(oQiect
det, CrcdErtrAryl
e){
System.Text.RegularExpressimsleger
trffd : -r SyhT-t D@(@"^[a-zA-
Z]t\w\.-l{228lla-zA-Z0-91@la-zA-7*91[w\-ff+zA-Z)-9]t[tzA-Zfr-zA-AffrzA-!p];
if (trtEmail_Addrcss.TextlagiL > 0) {
if (!rEMail.IsMatc(BtEmail_AdfiEss.TcrtD {
MessageBorshoufiuvelid
trrril
rdfiEssf,'End, tltcssrgpBcM.OK,
MessageBoxlcon.Error);@
e-Cancel =Eue;
u
I
l'
l'
Corry"utiriz?trSabs
flnf,lwntory
45t
e.Handled = !(char.Islette(e.KeyChar) ll e.KeyChar
:
(char)Keys.Back ll e.KeyChar:
(char)Keys.Space);
)
private void Usernane_Validating(object sender, CancelEventArgs e) {
Sys0em-ToxrRegularExpre*sions.Regex rEMail: new System.Text.RegularExpressions.Regex(^fa-zA-20-
ell;
if (EtlJsemame.T€xt.l€ngth > 0)
t
if (lrf,MdJs}{*ch(txtllsernme.Text) {McssegeBox-Sffimly te*ers,nrrmtas md rmderscore is allowed', "Error", MessrgduBrdrm.OK, MessageBoxloonError);
trfl,Jsm.SelectAll$;
e.Cocel:true;
l l
)
fivae
void GetDetails_Click(object send€r, EventArgs e){
frmRqist*dUsersOetails frm
:
new &mRegis0erdUsersDetailsS;frndafaGdrlVievr l.DataSouree = &m.GetDaiao;
frm-ShowQ;
)
private void Usemame_TextChanged(object sender, EventArgs e)
t
bhDelete.Enabled
:
true;btnUpdate_record.Enabled
:
true;Ey {
brtUsername.Text = txtUsername.Text.TrimEndQ;
con
:
new SqlConnection(cs.DBConn);con.OpenS;
cmd
:
con.CreateCommand$;cmd-CorunandText: "SELECT Userfype,password,oame,cootactno,email FROM T_RBGETRATION WHERE useilHrrle:'" + atlJsemame.Text.Trim0 +
"-;
r&
:
cmd-ExecuteReade{;if(r&3ead$) {
cmbustrT!"e-Tcxt
:
(dr.Ce*Slring(0}Trimo}triksord-Teu :
(r&.GcrString(l)-Trir$tx0{ame-Tst = (rdr.GerSfring(2)-Trino}
trtCme_m-Terr
: (re-Gc6ringplTriEox ffiEE
{-Ad&Ess-Tcd: fdr.GaSuig(]Trinfl]
)
if (rdr
!: null)
{rdr.CloseQ;
l
if (con.State
:
ConnectionSab.Op€n) {con.Close$;
)
Cotyutflbe/ Sa6t nnd rwertory
MessageBox.Show(ex,Message, "Eilof , MessapBoxButtoas.Oll MessageBoxlcon Error);
1I )
private void AutocompleteQ
{ trv{
con
:
new SqlConnection(cs.DBConn) con.OpenQ;SqlCommand cmd: new SqlCommand("SELECT UserName FROM T_REGISTRATION", con);
DataSet ds: new DataSet$;
SqlDataAdapter da
:
new SqlDataAdapter(cmQ;da.Fil(ds, "T_REGISTRATION');
AutoCompleteStringCollection col
:
ne* AfioCmpleteStingCollection$;int
i:0;
for
(i:0;
i<:
ds.Tables[0].Rows.Cormt - 1;i+)
{
col.Add(ds. Tables[0].Rows[i] ['L]serNane"l.ToStdng$);
l
EtUsername.AutoCompleteSotrrce
:
Amocmplaesunce.CustomSource;EtUsername.AutoComplet{us*omSouoe
:
ool;EtUsername.AutoCompleteMode
:
AuoCoryle*efaode.Sugges{con.Close$;
It
catch (Exception ex)
{
MessageBox.Show(ex.Messags,'Eud, MessageBoxMms.Oll IUessageBoxlcoo-Enor);
) )
private void Update_record_Clic(object sepdEr, EveutArgs e) {
if (o<tUsername.Text
:'i)
{
MessageBox.Show('Please
eatsrUslDp,'Erd,
}{€ssageBorBem*.Of,[email protected]);
firtUsername.Focus$;
return;
)
if (cmbUserType.Text
:
"'1t
MessageBox.Show("Please selet Uscr T54r',
tr,
}Ics€E*oxB{iims.OK" MessageBoxlcm.Error);cmbUserType.Focus$;
return;
)
if (txtPassword-Text
:
nn)t
MessageBox.Show(?lease enter
Pssmuf, -Erd, }{qdox&*tons.OK,
MesageBoxlcon.Error);u$assword-Focu$;
lEturq
l if(trrNme.Ttxt:
""1{
McssageBorShow("Please eater
U*rl{ae','Euf,
MessageBoxButtons.Ol! MessageBoxlcon.Error);tdame.Fmo;
TI[E;
l if(ttrmg-no-Text:'i) t
MessageBoxShffi('Pl€ese effiomtact rc.",'Efior', MessageBoxButtons.OK, MessageBoxlcon.Eror);
trtConM_noJocr$t rEma;
46
Corrfutlrizedsa{es
con
:
new SqlConnection(cs.DBConn);con.OpenQ;
string
cb:
"UPDATE T_REGISTRATION SET UserTypr'" + cmbUserTlrye.Text + *', Password='* + brtPassword.Text*
"',ContactNo:"' + brtContact*no.Textf
'',Email:'" + firtEmail_Address.Text + "',Nam€="' + ktName.Text + ur WIIERE UserName:"'+ ArtUsername.Text*
"'";cmd
:
new SqlCommaad(cb);cmd.Connecfion: con;
cmd-ExecuteReader$;
con.Close$;
MessageBox.Show("Successfully updated", "IJser lofo", MessageBoxButtons.OK MessageBoxlcon.Information);
Autocomplete0;
btnUpdate_record.Enabled
:
false;l
catch (Exception ex)
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.Ol( MessageBoxlcon.Error);
)
private void Delete_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Do you
relly
want to &l€ilefiii recuf, 'Cffirtim',
MessageBoxButtons.YesNo, MessageBoxlcon-Qr#irn)
: Slaco-@Yce)
{
delete_recordsQ;
) )
private void delete_recudsQ
{ try {
if
(ffiLlseure-Td-'r--)
{
MeqsegFBq-SlorfAlh Aacil cr
rot beffied!,
'Etrrff', MessageBoxButtons.OK, Ma<srgFForlcor Fqrtr'tsFrq
iRo*sAft*d:Q l
o[:tsrSq|Cil.rrft<R rBCorr]
cc"Ogrfi
$ntg
t*:
TIELEIE FROlt T_REGISTRATION WHERE UserNam€='" + ktus$mam€.Text*
""';r:rrl:ar;g,Sq|QrmdCtX cmd-Cmin:coq
RowsAfrectod
:
cnrl FrccilcNrrQrtrrrG if(RowsAffcEd>0){
MessageBorshoutf Sooccstfrtly ddc*ed,'Rccmd, MessageBoxButtons.OK, MessageBoxlcon.Informatim);
AutocompleteQ;
Reset$;
) else
{
MessageBox.Show("No Record found", "Sorry", MessageBoxButtons.O$
MessageB oxf con. Information);
47
retum;
) try {
{ )
Conywtirizz/ SaEs glnd lnueatorlr
con.CIoseQ;
)
catch (Exce,ption ex) {
MessageBox.Shorr(ex.Message, "Erorn, MessageBoxBuftoos.OK, MessageBoxlcon.Error);
l
)
private void ktContact_no_KeyPress(object sender, KeyPressEventArgs e)
{
if ([email protected]) ll char.IsConko{e.Keychar) t
eJlaadled = false;
)
else {
e.Handled: true;
l
)