virtual shop - technical presentation
TRANSCRIPT
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 1/37
1/8/2012 » Traing – Virtual Shop
TrainingVirtual ShopRevision: Version 1.0
Update Date: Sunday, January 08, 2012 15:36:00 a1/p1
Prepared For: Fasma
Prepared By: Cristi Salcescu Project Manager
Versions of the document:
Version Date Author Description
1.0 08/09/2008 Cristi Salcescu Creation
Draft confidential Page 1 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 2/37
1/8/2012 » Traing – Virtual Shop
1. Fisiere Componente
VirtualShop - Solution.zip The .sln with all the projects
VirtualShop.bak The database backup
Virtual Shop - Technical Presentation.doc
2. Organizarea aplicatiei pe N-Nivele
Draft confidential Page 2 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 3/37
1/8/2012 » Traing – Virtual Shop
Solutia aplicatiei :
Draft confidential Page 3 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 4/37
1/8/2012 » Traing – Virtual Shop
3. Nivelul de Date (Data Tier)
3.1. Diagrame
Utilizatori
Adrese
Draft confidential Page 4 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 5/37
1/8/2012 » Traing – Virtual Shop
Produse
Draft confidential Page 5 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 6/37
1/8/2012 » Traing – Virtual Shop
Comenzi
3.2. Vederi
Utilizatori
Draft confidential Page 6 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 7/37
1/8/2012 » Traing – Virtual Shop
Adrese
Produse
Comenzi
Draft confidential Page 7 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 8/37
1/8/2012 » Traing – Virtual Shop
Linii comenzi
Detalii utilizatori
3.3. Proceduri stocate
spAddress_AddAddress – Adauga o adresaset ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[spAddress_AddAddress]
@County nvarchar(30),
@Town nvarchar(30),
@Address nvarchar(200)
Draft confidential Page 8 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 9/37
1/8/2012 » Traing – Virtual Shop
AS
DECLARE @CountyID int
DECLARE @TownID int
BEGIN TRAN
--ADD COUNTY
SELECT @CountyID = CountyIDFROM Counties
WHERE (County = @County)
IF (@CountyID IS NULL)
BEGIN
INSERT INTO [dbo].[Counties] (County) VALUES (@County)
IF @@ERROR <>0
BEGIN
RAISERROR ('spAddress_AddAddrees insert Counties error [County =
%s]', 16, 1, @County)
ROLLBACK TRAN
ENDSET @CountyID = @@IDENTITY
END
-- ADD TOWN
SELECT @TownID = [TownID]
FROM Towns
WHERE (Town = @Town) AND (CountyID = @CountyID)
IF (@TownID IS NULL)
BEGIN
INSERT INTO [dbo].[Towns] (Town, CountyID) VALUES (@Town, @CountyID)
IF @@ERROR <>0BEGIN
RAISERROR ('spAddress_AddAddrees insert Towns error [CountyID =
%d;Town = %s]', 16, 1, @CountyID, @Town)
ROLLBACK TRAN
END
SET @TownID = @@IDENTITY
END
--ADD ADDRESS
INSERT INTO [dbo].[Addresses] (Address, TownID) VALUES (@Address, @TownID)
IF @@ERROR <>0
BEGIN
RAISERROR ('spAddress_AddAddrees insert Towns error [TownID = %d;Address= %s]', 16, 1, @TownID, @Address)
ROLLBACK TRAN
END
COMMIT TRAN
spOrders_AddOrder – Adauga o comanda. Liniile de comanda sunt primite ca Xmlset ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[spOrders_AddOrder]
@ShippingLastName nvarchar(50),
@ShippingFirstName nvarchar(50),
@County nvarchar(30),
Draft confidential Page 9 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 10/37
1/8/2012 » Traing – Virtual Shop
@Town nvarchar(30),
@Address nvarchar(200),
@ShippingPhone char(10),
@IP char(12),
@ItemsXml nvarchar(2000)
AS
DECLARE @AddressID intDECLARE @OrderID int
DECLARE @XML xml
Set @XML = @ItemsXml
BEGIN TRAN
exec [dbo].[spAddress_AddAddress] @County, @Town, @Address
IF @@ERROR <>0 ROLLBACK TRAN
SET @AddressID = @@IDENTITY
INSERT INTO [VirtualShop].[dbo].[Orders]
([StatusID],[CustomerUserID]
,[CreationDate]
,[LastUpdate]
,[ShippingLastName]
,[ShippingFirstName]
,[ShippingAddressID]
,[ShippingPhone]
,[IP])
VALUES
(1 --CREATED
,null
,GETDATE()
,GETDATE(),@ShippingLastName
,@ShippingFirstName
,@AddressID
,@ShippingPhone
,@IP)
SET @OrderID = @@IDENTITY
INSERT INTO [OrderItems] (OrderID, ProductID, Quantity)
select @OrderID,
R.i.value('productID[1]', 'int') [ProductID],
R.i.value('quantity[1]', 'int') [Quantity]
from @XML.nodes('/order/item') R(i)
SELECT @OrderID
COMMIT TRAN
spProducts_GetProducts – Returneaza produsele. Daca parametrii @CategoryID sau @Product nu sunt
NULL se tine cont de ei la filtrare.ALTER PROCEDURE [dbo].[spProducts_GetProducts]
@CategoryID int,
@Product nvarchar(50)
AS
SELECT *FROM vwProducts
WHERE (@CategoryID IS NULL OR CategoryID = @CategoryID) AND
(@Product IS NULL OR Product LIKE '%' + @Product + '%' OR Description LIKE '%' +
@Product + '%')
Draft confidential Page 10 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 11/37
1/8/2012 » Traing – Virtual Shop
ORDER BY Product
spProducts_SetProduct – Adauga/Editeaza un produsset ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [dbo].[spProducts_SetProduct]
@ProductID int,
@Product nvarchar(50),
@Code varchar(50),
@ProducerID smallint,
@Description nvarchar(max),
@CategoryID smallint,
@Quantity int,
@Price float,
@PriceCurrencyID tinyint
AS
IF (@ProductID IS NULL)
BEGIN
INSERT INTO [dbo].[Products]
([Product]
,[Code]
,[ProducerID]
,[Description]
,[CategoryID]
,[Enabled]
,[Quantity]
,[Price]
,[PriceCurrencyID],[LastUpdate])
VALUES
(@Product
,@Code
,@ProducerID
,@Description
,@CategoryID
,1
,@Quantity
,@Price
,@PriceCurrencyID
,GETDATE())
SELECT @@IDENTITYEND
ELSE
BEGIN
UPDATE [dbo].[Products]
SET [Product] = @Product
,[Code] = @Code
,[ProducerID] = @ProducerID
,[Description] = @Description
,[CategoryID] = @CategoryID
,[Enabled] = 1
,[Quantity] = @Quantity
,[Price] = @Price
,[PriceCurrencyID] = @PriceCurrencyID,[LastUpdate] = GETDATE()
WHERE ProductID = @ProductID
SELECT @ProductID
END
Draft confidential Page 11 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 12/37
1/8/2012 » Traing – Virtual Shop
spUsers_GetUsers – Returneaza utilizatorii. Daca parametrii
@Username sau @GroupID nu sunt NULL se tine cont de ei la filtrare.ALTER PROCEDURE [dbo].[spUsers_GetUsers]@Username nvarchar(50),@GroupID intAS
SELECT *FROM vwUsersWHERE (@Username IS NULL OR Username LIKE '%' + @Username + '%') AND
(@GroupID IS NULL OR GroupID = @GroupID)ORDER BY CreationDate
4. Nivelul de accesare date (Data Access Tier)
Rolul acestui nivel este de a incapsula toate cererile la baza de date. Un prim avantaj este incapsulareaacestor cereri intr-un singur loc si deci o mai mare usurinta in mentenanta.
Un alt avantaj apare in momentul schimbarii bazei de date folosite, de exemplu trecerea pe Oracle nu va
necesita decat rescrierea metodelor din DAL restul codului ramanand perfect functional.
Cod sursa reprezentativ
Path = DAL/Products.cs – Metode prin care se pot selecta, edita, adauga produse.namespace DAL
{
public static class Products
{
public static ProductsDataSet.vwProductsDataTable GetProducts(string categoryID, string product)
{
string spName = "spProducts_GetProducts";
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetStoredProcCommand(spName);
db.AddInParameter(dbCommand, "CategoryID", DbType.Int32,
Empty2NullConvert.ToInt32(categoryID));
db.AddInParameter(dbCommand, "Product", DbType.String,
Empty2NullConvert.ToString(product));
ProductsDataSet dataSet = new ProductsDataSet();
db.LoadDataSet(dbCommand, dataSet, dataSet.vwProducts.TableName);
return dataSet.vwProducts;
}
Draft confidential Page 12 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 13/37
1/8/2012 » Traing – Virtual Shop
public static ProductsDataSet.vwProductsDataTable GetProduct(int productID)
{
string sqlCommand = "SELECT * FROM vwProducts Where ProductID = @ProductID";
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);
db.AddInParameter(dbCommand, "ProductID", DbType.Int32, productID);
ProductsDataSet dataSet = new ProductsDataSet();
db.LoadDataSet(dbCommand, dataSet, dataSet.vwProducts.TableName);
return dataSet.vwProducts;
}
public static void SetImage(string productID, byte[] imageContent)
{
string sqlCommand = "UPDATE [dbo].[Products] SET [Image] = @Image WHERE ProductID =
@ProductID";
Database db = DatabaseFactory.CreateDatabase();DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);
db.AddInParameter(dbCommand, "Image", DbType.Binary, imageContent);
db.AddInParameter(dbCommand, "ProductID", DbType.Int32, productID);
db.ExecuteNonQuery(dbCommand);
}
public static byte[] GetImage(string productID)
{
string sqlCommand = "SELECT [Image] FROM [dbo].[Products] WHERE [ProductID] =
@ProductID";
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand);
db.AddInParameter(dbCommand, "ProductID", DbType.Int32, productID);
object imageContent = db.ExecuteScalar(dbCommand);
return imageContent != DBNull.Value ? (byte[])imageContent : null;
}
public static int AddSetProduct(string productID, string product, string code, string producerID, string
description, string categoryID, string quantity, string price, string priceCurrencyID)
{
string spName = "spProducts_SetProduct";
Database db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetStoredProcCommand(spName);
db.AddInParameter(dbCommand, "ProductID", DbType.Int32,
Empty2NullConvert.ToInt32(productID));
db.AddInParameter(dbCommand, "Product", DbType.String,
Empty2NullConvert.ToString(product));
db.AddInParameter(dbCommand, "Code", DbType.String, Empty2NullConvert.ToString(code));
db.AddInParameter(dbCommand, "ProducerID", DbType.Int16,
Empty2NullConvert.ToInt32(producerID));
db.AddInParameter(dbCommand, "Description", DbType.String,
Empty2NullConvert.ToString(description));
db.AddInParameter(dbCommand, "CategoryID", DbType.Int16,
Empty2NullConvert.ToInt32(categoryID));
db.AddInParameter(dbCommand, "Quantity", DbType.Int32,
Draft confidential Page 13 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 14/37
1/8/2012 » Traing – Virtual Shop
Empty2NullConvert.ToInt32(quantity));
db.AddInParameter(dbCommand, "Price", DbType.Double, Empty2NullConvert.ToDouble(price));
db.AddInParameter(dbCommand, "PriceCurrencyID", DbType.Int16,
Empty2NullConvert.ToInt32(priceCurrencyID));
return (int)db.ExecuteScalar(dbCommand);
}
}}
5. Nivelul de logica (Business Tier)Un alt pas foarte important in arhitectura pe n-nivele este de a separa logica aplicatiei de logica interfetei.
Ideea este de a porta aceesi logica cat mai usor in diferite, de exemplu de a porta aceleshi clase de BLL de
la o aplicatie web la una client cu efort cat mai mic.
5.1 Proiectul BLL
BLL – Business Logic Layer In general toate entitatile din db sunt mapate prin clase din BLL. Deasemnea tot in BLL intalnim si clasa
ShoppingCart ce acopera functionalitatea cosului de cumparaturi.
In CurrentUser se stocheaza toate informatiile referitoare la utilizatorul logat.
Cod sursa reprezentativ Path = BLL/ShoppingCart.cs
namespace BLL
{
public class ShoppingCart
{
public static Hashtable CartTable
{
get
{
if (HttpContext.Current.Session["CartTable"] == null)
HttpContext.Current.Session["CartTable"] = new Hashtable();
return (Hashtable)HttpContext.Current.Session["CartTable"];}
set
{
HttpContext.Current.Session["CartTable"] = value;
Draft confidential Page 14 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 15/37
1/8/2012 » Traing – Virtual Shop
}
}
public static DataTable ComputedTable
{
get
{
DataTable myDataTable = new DataTable();DataColumn myColumn;
DataRow myRow;
myColumn = new DataColumn();
myColumn.DataType = System.Type.GetType("System.Int32");
myColumn.ColumnName = "ProductID";
myDataTable.Columns.Add(myColumn);
myColumn = new DataColumn();
myColumn.DataType = Type.GetType("System.String");
myColumn.ColumnName = "Product";
myDataTable.Columns.Add(myColumn);
myColumn = new DataColumn ( );
myColumn.DataType = System.Type.GetType ( "System.Int32" );
myColumn.ColumnName = "Quantity";
myDataTable.Columns.Add ( myColumn );
myColumn = new DataColumn();
myColumn.DataType = System.Type.GetType("System.Double");
myColumn.ColumnName = "Price";
myDataTable.Columns.Add(myColumn);
myColumn = new DataColumn();
myColumn.DataType = Type.GetType("System.String");
myColumn.ColumnName = "PriceCurrency";myDataTable.Columns.Add(myColumn);
CartItem item;
foreach (int key in ShoppingCart.CartTable.Keys)
{
item = (CartItem)ShoppingCart.CartTable[key];
myRow = myDataTable.NewRow();
myRow["ProductID"] = key;
myRow["Product"] = item.Product;
myRow["Quantity"] = item.Quantity;
myRow["Price"] = item.Quantity * item.Price;
myRow["PriceCurrency"] = item.PriceCurrency;myDataTable.Rows.Add(myRow);
}
return myDataTable;
}
}
public static double Total
{
get
{
double total = 0;
foreach (CartItem item in ShoppingCart.CartTable.Values)
total += item.Quantity * item.Price;
return total;
Draft confidential Page 15 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 16/37
1/8/2012 » Traing – Virtual Shop
}
}
public static void AddProduct(int productID, string product, double price, string priceCurrency)
{
if (CartTable.ContainsKey(productID))
{
((CartItem)CartTable[productID]).Quantity += 1;}
else
CartTable[productID] = new CartItem(product, 1, price, priceCurrency);
}
public static void RemoveProduct(int productID)
{
if (CartTable.ContainsKey(productID))
CartTable.Remove(productID);
}
public static string GetOrderItemsXml()
{XmlDocument xmlDoc = new XmlDocument();
XmlElement rootElement = xmlDoc.CreateElement("order");
xmlDoc.AppendChild(rootElement);
XmlElement itemElement;
XmlElement productIDElement;
XmlElement quantityElement;
string xml = string.Empty;
foreach (int productID in CartTable.Keys)
{
itemElement = xmlDoc.CreateElement("item");
productIDElement = xmlDoc.CreateElement("productID");quantityElement = xmlDoc.CreateElement("quantity");
productIDElement.InnerText = productID.ToString();
quantityElement.InnerText = ((CartItem)CartTable[productID]).Quantity.ToString();
itemElement.AppendChild(productIDElement);
itemElement.AppendChild(quantityElement);
rootElement.AppendChild(itemElement);
}
return xmlDoc.OuterXml;
}
}
}
Path = BLL/CurrentUser.csnamespace BLL
{
public class CurrentUser
{
private CurrentUser() { }
public static bool IsAuthenticated
{
get { return (HttpContext.Current.Session["SiteUserID"] != null); }
}
public static int ID
{
get
Draft confidential Page 16 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 17/37
1/8/2012 » Traing – Virtual Shop
{
if (HttpContext.Current.Session["SiteUserID"] != null)
return Convert.ToInt32(HttpContext.Current.Session["SiteUserID"]);
else
return 0;
}
set
{HttpContext.Current.Session["SiteUserID"] = value;
}
}
public static string Name
{
get
{
if (HttpContext.Current.Session["SiteUserName"] != null)
return HttpContext.Current.Session["SiteUserName"].ToString();
else
return string.Empty;
}set
{
HttpContext.Current.Session["SiteUserName"] = value;
}
}
public static string Role
{
get
{
if (HttpContext.Current.Session["SiteUserRole"] != null)
return HttpContext.Current.Session["SiteUserRole"].ToString();
elsereturn string.Empty;
}
set
{
HttpContext.Current.Session["SiteUserRole"] = value;
}
}
public static bool IsAdmin
{
get
{
return ((CurrentUser.IsAuthenticated) && (CurrentUser.Role.Equals("Administrators")));}
}
}
}
5.2 Proiectul Info
Proiectul Info contine clase ce au numai proprietati fara metode. Fisierele .xsd sunt dataseturi care
mapeaza coloanele tabelelor sau vederilor din baza de date.
Draft confidential Page 17 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 18/37
1/8/2012 » Traing – Virtual Shop
Path = BLL/ProductFilter.cs[Serializable()]
public class ProductFilter
{
public string CategoryID;public string Product;
}
Path = BLL/CartItem.cspublic class CartItem
{
public string Product;
public int Quantity;
public double Price;
public string PriceCurrency;
public CartItem(string product, int quantity, double price, string priceCurrency){
this.Product = product;
this.Quantity = quantity;
this.Price = price;
Draft confidential Page 18 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 19/37
1/8/2012 » Traing – Virtual Shop
this.PriceCurrency = priceCurrency;
}
}
5.3 Proiect Library
Proiectul Library contine acele clase ce pot fi reutilizate in diferite alte proiecte, clase ce nu sunt strans
legate de logica aplicatie curente : delegate-uri, interfete. Clasa Empty2NullConvert are rolul de a converti
string-uri in alte tipuri de date cu conditia ca empty devine null, este foarte utila in trimitea datelor catre
db.
Path = Library/CommonTypes/EventHandlers.csnamespace Library.CommonTypes
{
public class IdEventArgs : EventArgs
{public int ID;
public IdEventArgs(int id)
{
this.ID = id;
}
}
public delegate void IdEventHandler(object sender, IdEventArgs e);
}
Path = Library/ CommonTypes/Interfaces.csnamespace Library.CommonTypes
{
public interface IDataBind
{
void DataBind();
}
public interface IDetailsView : IDataBind
{
string DataSourceID { get; set; }
}
public interface IInitEvents
{
Draft confidential Page 19 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 20/37
1/8/2012 » Traing – Virtual Shop
void InitEvents();
}
public interface IItemCommand
{
event IdEventHandler ItemCommand;
}
public interface IListControl : IDataBind
{
int PageIndex { get; set; }
int PageSize { get; set; }
}
}
Path = Library/Convertion/Empty2NullConvert.csnamespace Library.Convertion
{
public class Empty2NullConvert
{
private Empty2NullConvert() {}
public static object ToDateTime(object objectValue)
{
if (objectValue == null)
return null;
else
{
if (IsEmptyString(objectValue)) return null;
try
{
return Convert.ToDateTime(objectValue);
}catch(Exception)
{
return null;
}
}
}
public static object ToInt32(object objectValue)
{
if (objectValue == null)
return null;
else
{if (IsEmptyString(objectValue)) return null;
try
{
return Convert.ToInt32(objectValue);
}
catch(Exception)
{
return null;
}
}
}
6 Nivelul de Prezentare (Presentation GUI & Presentation Logic)
Draft confidential Page 20 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 21/37
1/8/2012 » Traing – Virtual Shop
Utilizatorii sistemului sunt de 3 tipuri cumparatori, operatori si administratori.
Operatorii lucreaza pe backoffice sunt cei care aproba cumparaturile si trimiterea lor catre destinatie.
Administratori sunt cei care pot edita/stege/ produse produse,categorii etc.
6.1 Cazuri de utilizare Cumparator
6.1.1 Login
DescriereSistemul poate fi folosit si de utilizatori neautentificati. Dar pentru o mai mare usurinta la cumparaturi, in
sensul ca datele de trimitere cosului vor fi completate automat, cumparatori se pot autentifica la sistem.
Autentificare duce si la o mai buna evidenta a cumparaturilor aceleashi persoane.
Imagine din aplicatie
Cod sursa reprezentativ Path = /Front/Login.aspx
<asp:Login ID="lgnLogin" runat="server" DestinationPageUrl="~/Default.aspx" FailureText="Invalid
credentials" >
</asp:Login>
void lgnLogin_Authenticate(object sender, AuthenticateEventArgs e)
{
UsersDataSet.vwUsersRow userRow = Users.GetUser(lgnLogin.UserName, lgnLogin.Password);
if (userRow != null)
{
e.Authenticated = true;
CurrentUser.ID = userRow.UserID;
CurrentUser.Name = userRow.Username;
CurrentUser.Role = userRow.Group;
}
elsee.Authenticated = false;
}
6.1.2 Inregistrare
DescriereInregistrarea se face completand un formular cu datele personale.
Imagine din aplicatie
Draft confidential Page 21 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 22/37
1/8/2012 » Traing – Virtual Shop
Cod sursa reprezentativ Path = /Front/UC/Register.ascx
void btnRegister_Click(object sender, EventArgs e){
int userID = Users.AddCustomerUser(txtUsername.Text,txtPassword.Text,txtLastName.Text,txtFirstName.Text,txtCounty.Text,txtTown.Text,txtAddress.Text,txtPhone.Text,txtEmail.Text);
if (userID != 0)
{CurrentUser.ID = userID;CurrentUser.Name = txtPassword.Text;CurrentUser.Role = "Customers";Response.Redirect("~/default.aspx");
}}
Draft confidential Page 22 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 23/37
1/8/2012 » Traing – Virtual Shop
6.1.3 Cautare produse
DescriereCautarea produselor se poate face in doua moduri : dupa categoriile din care acestea fac parte sau dupa
nume produs sau un termen folosit in descrierea acestuia.
Imagini din aplicatieCautare dupa categorie
Draft confidential Page 23 of 37
Cuvant cautatId cate orie
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 24/37
1/8/2012 » Traing – Virtual Shop
Cautare dupa cuvant cheie
Cod sursa reprezentativPath = /Front/default.aspxprotected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (!IsProductSearchByName && !IsProductSearchByCategory)
FillAllProducts();
else
{
if (IsProductSearchByName)
OnProductSearchByName(Request.QueryString["Product"]);
if (IsProductSearchByCategory)
OnProductSearchByCategory(Request.QueryString["CategoryID"]);
}
}
}
void OnProductSearchByName(string product)
{
ucProductsList.DataFilter.CategoryID = null;
ucProductsList.DataFilter.Product = product;
ucProductsList.PageIndex = 0;
ucProductsList.DataBind();}
void OnProductSearchByCategory(string categoryID)
Draft confidential Page 24 of 37
Cuvant cautat
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 25/37
1/8/2012 » Traing – Virtual Shop
{
ucProductsList.DataFilter.CategoryID = categoryID;
ucProductsList.DataFilter.Product = null;
ucProductsList.PageIndex = 0;
ucProductsList.DataBind();
}
6.1.4 Adaugare produs in cos
DescriereOdata gasite produsele dorite acestea se pot adauga in cos in vederea cumparari lor.
Un produs poate fi vizualizat in detaliu dand click pe imaginea acestuia.
Produsul se poate aduga in cos apasand pe inconita Comand.
In dreapta pagii se poate vedea cosul de cumparaturii cu toate produsele adaugate.
Cosul de cumparaturi si poate edita astfel se poate renunta la anumite produse selectate.
Draft confidential Page 25 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 26/37
1/8/2012 » Traing – Virtual Shop
Imagine din aplicatie
Vizualizarea in detaliu a produsului
Cosul de cumparaturi
Cod sursa reprezentativ
Draft confidential Page 26 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 27/37
1/8/2012 » Traing – Virtual Shop
Path = /Front/UC/Products/ProductDetailView.ascx – adaugare produs in cosvoid dvProduct_ItemCommand(object sender, DetailsViewCommandEventArgs e)
{
switch (e.CommandName)
{
case "Add" :
ShoppingCart.AddProduct(ProductID, Product, Price, Currency);
break;}
}
Path = /Front/Product/ProductFormView.aspx – vizualizare/editare produs<asp:FormView ID="fvProduct" runat="server" DataKeyNames="ProductID" DefaultMode="Edit">
<ItemTemplate>
<table>
<tr>
<td>Product</td>
<td><%# Eval("Product") %></td>
</tr><tr>
<td>Code:</td>
<td><%# Eval("Code") %></td>
</tr>
<tr>
<td colspan="2"><img src='../Products/ProductImage.aspx?id=<%# Eval("ProductID") %>' /></td>
</tr>
<tr>
<td>Quantity:</td>
<td><%# Eval("Quantity") %></td>
</tr>
<tr>
<td>Price:</td><td>
<%# Eval("Price") %>
<%# Eval("Currency") %>
</td>
</tr>
<tr>
<td>Producer:</td>
<td>
<%# Eval("Producer") %>
</td>
</tr>
<tr>
<td valign="top">Description:</td><td>
<textarea class="border" rows="20" cols="50" readonly="readonly">
<%# Eval("Description") %>
</textarea>
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table>
<tr>
<td>Product:</td>
<td><asp:TextBox ID="txtProduct" runat="server" Text='<%# Bind("Product")%>'></asp:TextBox></td>
</tr>
<tr>
Draft confidential Page 27 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 28/37
1/8/2012 » Traing – Virtual Shop
<td>Code:</td>
<td><asp:TextBox ID="txtCode" runat="server" Text='<%# Bind("Code") %>'></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<img src='../Products/ProductImage.aspx?id=<%# Eval("ProductID") %>' />
<br />
<input type="file" id="fileUpload" runat="server" /><asp:Button ID="btnUpload" runat="server" Text="Upload" CommandName="Upload" />
</td>
</tr>
<tr>
<td>Quantity:</td>
<td><asp:TextBox ID="txtQuantity" runat="server" Text='<%# Bind("Quantity")
%>'></asp:TextBox></td>
</tr>
<tr>
<td>Price:</td>
<td><asp:TextBox ID="txtPrice" runat="server" Text='<%# Bind("Price") %>'></asp:TextBox></td>
</tr>
<tr><td>Currency:</td>
<td>
<asp:DropDownList ID="ddlCurrencies" runat="server" DataSourceID="odsGetCurrencies"
DataTextField="Currency" DataValueField="CurrencyID" >
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Category:</td>
<td><asp:DropDownList ID="ddlCategories" runat="server" DataSourceID="odsGetChildCategories"
DataTextField="Category" DataValueField="CategoryID"></asp:DropDownList></td>
</tr>
<tr><td>Description:</td>
<td><asp:TextBox ID="txtDescription" runat="server" Text='<%# Bind("Description") %>'
TextMode="MultiLine" Rows="5" Columns="40"></asp:TextBox></td>
</tr>
<tr>
<td>LastUpdate:</td>
<td><%# Eval("LastUpdate") %></td>
</tr>
<tr>
<td>Producer:</td>
<td><asp:DropDownList ID="ddlProducers" runat="server" DataSourceID="odsGetProducers"
DataTextField="Producer" DataValueField="ProducerID"></asp:DropDownList></td>
</tr></table>
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Update" CssClass="button"></asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel" CssClass="button"></asp:LinkButton>
</EditItemTemplate>
<InsertItemTemplate>
<table>
<tr>
<td>Product:</td>
<td><asp:TextBox ID="txtProduct" runat="server" Text='<%# Bind("Product")
%>'></asp:TextBox></td>
</tr>
<tr>
<td>Code:</td>
Draft confidential Page 28 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 29/37
1/8/2012 » Traing – Virtual Shop
<td><asp:TextBox ID="txtCode" runat="server" Text='<%# Bind("Code") %>'></asp:TextBox></td>
</tr>
<tr>
<td colspan="2">
<asp:Image ID="imgProduct" runat="server" ImageUrl='~/Products/ProductImage.aspx?id={<%#
Bind("ProductID") %>}' />
<br />
<input type="file" id="fileUpload" runat="server" /><asp:Button ID="btnUpload" runat="server" Text="Upload" />
</td>
</tr>
<tr>
<td>Quantity:</td>
<td><asp:TextBox ID="txtQuantity" runat="server" Text='<%# Bind("Quantity")
%>'></asp:TextBox></td>
</tr>
<tr>
<td>Price:</td>
<td><asp:TextBox ID="txtPrice" runat="server" Text='<%# Bind("Price") %>'></asp:TextBox></td>
</tr>
<tr><td>Currency:</td>
<td>
<asp:DropDownList ID="ddlCurrencies" runat="server" DataSourceID="odsGetCurrencies"
DataTextField="Currency" DataValueField="CurrencyID" >
</asp:DropDownList>
</td>
</tr>
<tr>
<td>Category:</td>
<td><asp:DropDownList ID="ddlCategories" runat="server" DataSourceID="odsGetChildCategories"
DataTextField="Category" DataValueField="CategoryID"></asp:DropDownList></td>
</tr>
<tr><td>Description:</td>
<td><asp:TextBox ID="txtDescription" runat="server" Text='<%# Bind("Description") %>'
TextMode="MultiLine" Rows="5" Columns="40"></asp:TextBox></td>
</tr>
<tr>
<td>LastUpdate:</td>
<td><%# Eval("LastUpdate") %></td>
</tr>
<tr>
<td>Producer:</td>
<td><asp:DropDownList ID="ddlProducers" runat="server" DataSourceID="odsGetProducers"
DataTextField="Producer" DataValueField="ProducerID"></asp:DropDownList></td>
</tr></table>
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
Text="Insert">
</asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False"
CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</InsertItemTemplate>
</asp:FormView>
<asp:ObjectDataSource ID="odsGetCurrencies" runat="server" SelectMethod="GetCurrencies"
TypeName="BLL.Currencies"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsGetProducers" runat="server" SelectMethod="GetProducers"
TypeName="BLL.Producers"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsGetChildCategories" runat="server" SelectMethod="GetChildCategories"
Draft confidential Page 29 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 30/37
1/8/2012 » Traing – Virtual Shop
TypeName="BLL.Categories"></asp:ObjectDataSource>
Path = /Front/UC/ShoppingCart.ascx – controlul reprezentant cosul de cumparaturi<asp:GridView ID="gvCartItems" runat="server" DataKeyNames="ProductID">
<Columns>
<asp:ButtonField CommandName="DELETE" CausesValidation="false" ButtonType="Link"
Text="DELETE" />
</Columns>
</asp:GridView>
Total : <asp:Label ID="lblTotal" Text="Total" runat="server"></asp:Label> RON
<br /><br />
void gvCartItems_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int productID = Convert.ToInt32(gvCartItems.DataKeys[e.RowIndex].Value);
ShoppingCart.RemoveProduct(productID);
}
public override void DataBind()
{
gvCartItems.DataSource = ShoppingCart.ComputedTable;
gvCartItems.DataBind();
lblTotal.Text = ShoppingCart.Total.ToString();
}
6.1.5 Cumparare produs
DescrierePentru a putea cumpara produsele adaugate in cos se solicita completarea unui formular cu toate datele
necesare pentru a putea fi contact si pentru a vi se putea trimite produsele.
Draft confidential Page 30 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 31/37
1/8/2012 » Traing – Virtual Shop
Imagine din aplicatie
Cod sursa reprezentativ Path = /Front/UC/Shipping.ascx – Adaugare comanda
void btnSubmit_Click(object sender, EventArgs e)
{
Orders.AddOrder(txtLastName.Text, txtFirstName.Text, txtCounty.Text, txtTown.Text,
txtAddress.Text, txtPhone.Text);
Response.Write("Comanda a fost trimisa!");
Session.Clear();}
Draft confidential Page 31 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 32/37
1/8/2012 » Traing – Virtual Shop
6.2 Cazuri de utilizare Operator
6.2.1 Aprobare comenzi
Operatorii au rolul de a aproba sau respinge comenzile primite. Comenzile pot fi sortate dupa adresa, data,
statusul comenzi. Comenzile ale caror date nu sunt reale vor fi respinse. Odata vizualizata comanda,
comparatorul este sunat pentru confirmarea comenzii si pentru a fi informat de data sosirii comenzi.Comenzile ce trebuiesc analizate apar cu starea Created. Comenzile trimise catre client apar cu starea
Shipped. Comenzile trimise si platite apar la starea Payed. Comenzile primite si respinse de client apar la
starea Returned.
Imagine din aplicatie
Cod sursa reprezentativ
Path = /Back/Orders/OrdersList.ascx – Lista de comenzi<asp:GridView ID="gvOrders" AutoGenerateColumns="false" runat="server" GridLines="Horizontal"
BorderColor="#636FA6" BorderWidth="1" AllowPaging="true" PageSize="5" Width="100%">
<AlternatingRowStyle BackColor="GhostWhite" />
<RowStyle height="21px" backcolor="White"/>
<headerstyle font-bold="True" height="22px" forecolor="White" backcolor="#636FA6">
</headerstyle>
<PagerStyle HorizontalAlign="Right"/>
<Columns>
<asp:BoundField datafield="Status" sortexpression="Status" headertext="Status"></asp:BoundField>
<asp:BoundField datafield="OrderID" sortexpression="OrderID" headertext="#" ItemStyle-
Width="30"></asp:BoundField>
<asp:BoundField datafield="CreationDate" sortexpression="CreationDate" headertext="Data
crearii"></asp:BoundField>
<asp:BoundField datafield="LastUpdate" sortexpression="LastUpdate" headertext="Ultima modificare"
></asp:BoundField>
<asp:BoundField datafield="ShippingLastName" sortexpression="ShippingLastName"
headertext="Nume" ></asp:BoundField>
<asp:BoundField datafield="ShippingFirstName" sortexpression="ShippingFirstName"
headertext="Prenume" ></asp:BoundField>
<asp:BoundField datafield="ShippingPhone" sortexpression="ShippingPhone" headertext="Telefon"
></asp:BoundField>
<asp:BoundField datafield="IP" sortexpression="IP" headertext="IP" ></asp:BoundField>
<asp:BoundField datafield="County" sortexpression="County" headertext="Judet" ></asp:BoundField>
<asp:BoundField datafield="Town" sortexpression="Town" headertext="Oras"></asp:BoundField>
<asp:BoundField datafield="Address" sortexpression="Address" headertext="Adresa"></asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<img alt="select application" src="Images/detail.gif" style = "cursor:
Draft confidential Page 32 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 33/37
1/8/2012 » Traing – Virtual Shop
hand;">
</ItemTemplate>
</asp:TemplateField>
</Columns>
public int PageIndex{
get { return gvOrders.PageIndex; }
set { gvOrders.PageIndex = value; }
}
public int PageSize
{
get { return gvOrders.PageSize; }
set { gvOrders.PageSize = value; }
}
public override void DataBind()
{gvOrders.DataSource = BLL.Orders.GetOrders();
gvOrders.DataBind();
}
void gvOrders_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvOrders.PageIndex = e.NewPageIndex;
this.DataBind();
}
Draft confidential Page 33 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 34/37
1/8/2012 » Traing – Virtual Shop
6.3 Cazuri de utilizare Administrator
6.3.1 Gestionare produse
DescriereAdministratorul poate adauga, edita, sterge produsele existente
Imagine din aplicatie
Cod sursa reprezentativ Path = /Front/Products/ProductFormView.ascx – Editare produs
void fvProduct_ItemCommand(object sender, FormViewCommandEventArgs e)
{
switch(e.CommandName)
{
case "Upload" :
SetImage();break;
}
}
void SetImage()
{
HtmlInputFile fileUpload = (HtmlInputFile)fvProduct.Row.FindControl("fileUpload");
Products.SetImage(DataSourceID, fileUpload);
}
void fvProduct_ItemUpdating(object sender, FormViewUpdateEventArgs e)
{
TextBox txtProduct = (TextBox)fvProduct.Row.FindControl("txtProduct");
TextBox txtCode = (TextBox)fvProduct.Row.FindControl("txtCode");
HtmlInputFile fileUpload = (HtmlInputFile)fvProduct.Row.FindControl("fileUpload");
TextBox txtQuantity = (TextBox)fvProduct.Row.FindControl("txtQuantity");
Draft confidential Page 34 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 35/37
1/8/2012 » Traing – Virtual Shop
TextBox txtPrice = (TextBox)fvProduct.Row.FindControl("txtPrice");
DropDownList ddlCurrencies = (DropDownList)fvProduct.Row.FindControl("ddlCurrencies");
DropDownList ddlCategories = (DropDownList)fvProduct.Row.FindControl("ddlCategories");
TextBox txtDescription = (TextBox)fvProduct.Row.FindControl("txtDescription");
DropDownList ddlProducers = (DropDownList)fvProduct.Row.FindControl("ddlProducers");
Products.SetProduct(
DataSourceID,txtProduct.Text,
txtCode.Text,
ddlProducers.SelectedValue,
txtDescription.Text,
fileUpload,
ddlCategories.SelectedValue,
txtQuantity.Text,
txtPrice.Text,
ddlCurrencies.SelectedValue);
}
6.3.2 Gestionare conturi
DescriereAdministratorul poate vizualiza detaliile conturile, crea conturi noi atat de Customer cat si de
Administrator sau Operator, poate activa, dezactiva sau sterge conturile existente.
Imagine din aplicatie
Cod sursa reprezentativ Path = /Back/Users/UsersList.ascx – Lista cu utilizatoripublic partial class UC_Users_UsersList : System.Web.UI.UserControl,IInitEvents, IListControl{
public event IdEventHandler SelectedIndexChanged;
public UsersFilter DataFilter
{get{
if (ViewState["DataFilter"] == null) ViewState["DataFilter"]= new UsersFilter();
Draft confidential Page 35 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 36/37
1/8/2012 » Traing – Virtual Shop
return (UsersFilter)ViewState["DataFilter"];}set { ViewState["DataFilter"] = value; }
}
public int PageIndex{
get { return gvUsers.PageIndex; }set { gvUsers.PageIndex = value; }}
public int PageSize{
get { return gvUsers.PageSize; }set { gvUsers.PageSize = value; }
}
void gvUsers_PageIndexChanging(object sender, GridViewPageEventArgse){
gvUsers.PageIndex = e.NewPageIndex;DataBind();
}
void gvUsers_SelectedIndexChanged(object sender, EventArgs e){
int userID =Convert.ToInt32(gvUsers.DataKeys[gvUsers.SelectedIndex].Value);if (SelectedIndexChanged != null)
SelectedIndexChanged(this, new IdEventArgs(userID));DataBind();
}
public override void DataBind(){
gvUsers.DataSource = Users.GetUsers(DataFilter);gvUsers.DataBind();
}}
Path = /Back/Users/UsersFilter.ascx–Controlul de unde se pot seta filtre de cautare utilizatoripublic event UsersFilterEventHandler SearchClick;
void btnSearch_Click(object sender, EventArgs e){
if (SearchClick != null)
SearchClick(this, new UsersFilterEventArgs(txtName.Text,ddlGroups.SelectedValue));
}
Path = /Back/Users/UserFormView.ascx – Editare utilizator public string DataSourceID{
get{
if (ViewState["DataSourceID"] == null)return string.Empty;
elsereturn ViewState["DataSourceID"].ToString();
}set{
ViewState["DataSourceID"] = value;
Draft confidential Page 36 of 37
5/12/2018 Virtual Shop - Technical Presentation - slidepdf.com
http://slidepdf.com/reader/full/virtual-shop-technical-presentation 37/37
1/8/2012 » Traing – Virtual Shop
}}
public override void DataBind(){
if (!DataSourceID.Equals(string.Empty)){
UsersDetailsDataSet.vwUsersDetailsDataTable dataTable =Users.GetUserDetails(DataSourceID);fvUser.DataSource = dataTable;fvUser.DataBind();
DropDownList ddlGroups =(DropDownList)fvUser.Row.FindControl("ddlGroups");ddlGroups.DataSource = Users.GetGroups();ddlGroups.DataBind();
UsersDetailsDataSet.vwUsersDetailsRow row =(UsersDetailsDataSet.vwUsersDetailsRow)dataTable.Rows[0];ddlGroups.Items.FindByValue(row.GroupID.ToString()).Selected= true;
}}
Path = /Back/Users.aspx – Pagina de administrare utilizatoriprotected void Page_Load(object sender, EventArgs e){
if (!Page.IsPostBack)ucUsersList.DataBind();
}
void ucUsersList_SelectedIndexChanged(object sender,Library.CommonTypes.IdEventArgs e)
{ucUserFormView.DataSourceID = e.ID.ToString();ucUserFormView.DataBind();
}
void ucUsersFilter_SearchClick(object sender,BLL.UsersFilterEventArgs e){
ucUsersList.DataFilter = e.UsersFilter;ucUsersList.DataBind();
}
Draft confidential Page 37 of 37