Ejemplo n.º 1
0
    def InsertProduct(self, form):
        self.PName = form.cleaned_data.get('PName')
        self.Design = form.cleaned_data.get('Design')
        self.NPieces = form.cleaned_data.get('NPieces')
        self.Qstock = form.cleaned_data.get('Qstock')
        self.Price = form.cleaned_data.get('Price')
        self.color = form.cleaned_data.get('color')
        self.KFabric = form.cleaned_data.get('KFabric')
        self.SFabric = form.cleaned_data.get('SFabric')
        self.DFabric = form.cleaned_data.get('DFabric')
        self.IsKameezFront = form.cleaned_data.get('IsKameezFront')
        self.IsKameezBack = form.cleaned_data.get('IsKameezBack')
        self.IsDupatta = form.cleaned_data.get('IsDupatta')
        self.IsShalwar = form.cleaned_data.get('IsShalwar')
        self.Image = form.cleaned_data.get('Image')
        ImageByte = self.Image.read()
        t1 = database()
        querry = '''set nocount on; insert into Images (Image) values (%s);
     select SCOPE_IDENTITY() as id'''
        data = (ImageByte, )
        id = t1.Insert_ReadId(querry, data)
        data = (self.PName, self.Design, self.NPieces, self.Qstock, self.Price,
                self.color, self.KFabric, self.SFabric, self.DFabric,
                self.IsKameezFront, self.IsKameezBack, self.IsDupatta,
                self.IsShalwar, id)
        querry = '''insert into Product([Product Name],[Design Code],[Number Of Pieces]
,[Quantity in Stock],[Product Price],Color,[Kameez Fabric],[Shalwar Fabric],
[Dupatta Fabric],IsKameezFrontEmbroided,IsKameezBackEmbroided
,IsDupattaEmbroided,IsShalwarEmbroided,Image
) values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)'''
        t1.Insert(querry, data)
Ejemplo n.º 2
0
 def GetCart(self, userid):
     querry = '''
     select Product.[Product ID],Product.[Product Name],Cart.Qunatity,Image from cart inner join Product on Product.[Product ID]=Cart.ProductId where UserId={}
  '''.format(userid)
     d1 = database()
     x = d1.read(querry)
     return x
Ejemplo n.º 3
0
    def GetProductList(self):
        d1 = database()

        Querry2 = "select [Product ID],[Product Name],Image from product"
        data = d1.read(Querry2)
        data = self.GenerateProductView(data)
        return data
Ejemplo n.º 4
0
 def RemoveFromCart(self, userid, ProductId):
     querry = "delete from Cart where UserId='{}' and ProductId='{}'".format(
         userid, ProductId)
     ProductId = int(ProductId)
     d1 = database()
     d1.Delete(querry)
     return None
Ejemplo n.º 5
0
    def LoadDetails(self, id):
        d1 = database()
        Querry = '''select Product.[Product Name],Designs.DesignName,Color.color ,Product.[Number Of Pieces]
       ,Product.[Quantity in Stock],Product.[Product Price]
       ,x.Fabric,y.Fabric,Fabric.Fabric,Product.IsKameezFrontEmbroided,Product.IsKameezBackEmbroided
       ,Product.IsDupattaEmbroided,Product.IsShalwarEmbroided from Product inner join color on Color.id=Product.Color 
       inner join Designs on Product.[Design Code]=Designs.DesignCode
inner join 
Fabric  on Fabric.id=Product.[Dupatta Fabric]inner join 
Fabric as x on x.id=Product.[Kameez Fabric]inner join 
Fabric as y on y.id=Product.[Shalwar Fabric] where [Product ID]=''' + id
        print(Querry)
        x = d1.read(Querry)
        self.PName = x[0][0]
        self.Design = x[0][1]
        self.color = x[0][2]
        self.NPieces = x[0][3]
        self.Qstock = x[0][4]
        self.Price = x[0][5]
        self.KFabric = x[0][6]
        self.SFabric = x[0][7]
        self.DFabric = x[0][8]
        self.IsKameezFront = x[0][9]
        self.IsKameezBack = x[0][10]
        self.IsDupatta = x[0][11]
        self.IsShalwar = x[0][12]
Ejemplo n.º 6
0
 def IsInStock(self, ProductId, Qty):
     querry = "select [Quantity in Stock] from Product where [Product ID]=" + ProductId
     d1 = database()
     x = d1.read(querry)
     x = int(x[0][0])
     if x < int(Qty):
         return False
     else:
         return True
Ejemplo n.º 7
0
 def Authenticate(self, username, password):
     Querry = "select * from Users where UserName='******' and Password='******' ".format(
         username, password)
     d1 = database()
     x = d1.read(Querry)
     if len(x) == 1:
         self.ReadUser(x)
         return True
     else:
         return False
Ejemplo n.º 8
0
 def UpdateCart(self, userid, ProductId, Qty):
     querry = '''update Cart set Qunatity=%s where UserId=%s and ProductId=%s'''
     ProductId = int(ProductId)
     Qty = int(Qty)
     data = (
         Qty,
         userid,
         ProductId,
     )
     d1 = database()
     d1.Update(querry, data)
     return None
Ejemplo n.º 9
0
    def CheckQty(self, uid):
        list = []

        querry = '''Select Cart.ProductId,Cart.Qunatity,Product.[Product ID],Product.[Quantity in Stock],Product.[Product Name] from Cart inner join Product on Product.[Product ID]=Cart.ProductId where UserId={}'''.format(
            uid)
        d1 = database()
        x = d1.read(querry)
        for i in x:
            if i[1] > i[3]:
                list2 = []
                list2.append(i[4])
                list2.append("Only {} pieces available in stock".format(i[3]))
                list.append(list2)
        return list
Ejemplo n.º 10
0
    def AddToCart(self, userid, ProductId, Qty):
        check = self.IsInStock(ProductId, Qty)
        if check:
            querry = '''exec cartupdate %s,%s,%s'''
            ProductId = int(ProductId)
            Qty = int(Qty)
            data = (
                userid,
                ProductId,
                Qty,
            )
            d1 = database()
            d1.Insert(querry, data)
        else:
            raise OverflowError("Quantity out of range")

        return None
Ejemplo n.º 11
0
 def RegisterNewUser(self, form):
     self.Name = form.cleaned_data.get('Name')
     self.Contact = form.cleaned_data.get('Contact')
     self.UserName = form.cleaned_data.get('UserName')
     self.Password = form.cleaned_data.get('Password')
     self.Image = form.cleaned_data.get('Image')
     imgbytes = self.Image.read()
     data = (
         self.Name,
         self.UserName,
         self.Password,
         self.Contact,
         imgbytes,
     )
     Querry = "exec RegisterUser %s,%s,%s,%s,%s"
     d1 = database()
     id = d1.Insert(Querry, data)
     self.Authenticate(self.UserName, self.Password)
     return None
Ejemplo n.º 12
0
 def GetOrder(self, uid):
     Querry = "select * from CustomerOrder where CustomerId=" + str(uid)
     d1 = database()
     x = d1.read(Querry)
     return x
Ejemplo n.º 13
0
 def OrderDetail(self, uid, billno):
     d1 = database()
     Querry = '''SET NOCOUNT ON; exec OrderDetail {},{} '''.format(
         uid, billno)
     x = d1.read(Querry)
     return x
Ejemplo n.º 14
0
 def RemoveCart(self, userid):
     querry = "delete from Cart where UserId='{}'".format(userid)
     d1 = database()
     d1.Delete(querry)
     return None
Ejemplo n.º 15
0
 def GetAccountTypes(self):
     d1=database()
     querry="select * from AccountType"
     x=d1.read(querry)
     return x
Ejemplo n.º 16
0
 def GetDealers(self):
     d1=database()
     querry="select * from DealerTypes"
     x=d1.read(querry)
     return x
Ejemplo n.º 17
0
 def GetUserId(self, username):
     Querry = "select UserId from Users where UserName='******'".format(
         username)
     d1 = database()
     x = d1.read(Querry)
     return x[0][0]
Ejemplo n.º 18
0
 def calculatebill(self, uid):
     querry = "select FORMAT(sum(Product.[Product Price]*Cart.Qunatity), 'c', 'en-pk')as TotalBill from Cart inner join  Product on Cart.ProductId=Product.[Product ID] where Cart.UserId=" + str(
         uid)
     d1 = database()
     x = d1.read(querry)
     return x[0][0]
Ejemplo n.º 19
0
 def checkoutcart(self, userid):
     querry = '''exec checkoutcart %s'''
     data = (userid, )
     d1 = database()
     x = d1.Insert(querry, data)
     return None
Ejemplo n.º 20
0
 def GetProductImage(self, id):
     querry = "select * from Images where id=%s"
     data = (id, )
     t1 = database()
     img = t1.read_p(querry, data)
     return img[0]