Shopping Cart, How Do I Subtract The Quantity Purchased From The Stock In Database?
Dec 11, 2007
Im making a shopping cart website for a school project in ASP.net with VB. I need help subtracting the quantity purchased (its saved in a session) from the stock number saved in a database.
I know this:UPDATE inventory SET stock = stock - <quantity_purchased> WHERE id = <inventory_id>
But I dont understand how to get the quantity purchased from the session to <quantity_purchased>. I tried putting the name of the session there and I got an error, i tried saving the session into a dim didnt work either.
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [stock] FROM [product]" InsertCommand="INSERT INTO [product] ([stock]) VALUES (@stock)" UpdateCommand="UPDATE product SET stock = (stock - @Quantity) WHERE (productID = @productID)">
<InsertParameters>
<asp:Parameter Name="stock" Type="Int16" />
</InsertParameters>
<UpdateParameters>
<asp:SessionParameter Name="Quantity" SessionField="Quantity" Type="Int32" />
<asp:SessionParameter Name="productID" SessionField="productID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
and I have than in my VB code on submit : SqlDataSource1.Update()
View 1 Replies
ADVERTISEMENT
Feb 5, 2008
protected void Buy_Click(object sender, EventArgs e)
{SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
try
{String connStr = ConfigurationManager.ConnectionStrings["project_DataFile"].ConnectionString;
conn.ConnectionString = connStr;
conn.Open();
cmd.Connection = conn;ArrayList cart = (ArrayList)Session["Cart"];
{String oldSel = "SELECT Qty_warehouse FROM Producttable";
Int32 sel = 0;Int32.TryParse(oldSel, out sel);
string num = cart.Count.ToString();Int32 numQty = 0;
Int32.TryParse(num, out numQty);int nQty_warehouse = 0;
nQty_warehouse = sel - numQty;String sql = "UPDATE Producttable" + " SET Qty_warehouse =" + "'"+ nQty_warehouse +"'";
cmd.CommandText = sql;}
}catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{if (conn.State.Equals(ConnectionState.Open))
{
conn.Close();
Response.Write("end.aspx");
}
}
from this code, i want to reduce product's quantity in database.
when I click buy button,it reduce old quantity and new quantity (quantity from cart when I want to buy it) in auto.
please advise me.
View 3 Replies
View Related
Jun 23, 2004
After a user adds items to the cart he doesn't checkout but leaves the site.
The next user on the same computer then opens another browser and sees the same items in the cart.
How do I Empty temp shopping cart database after leaving the site just like if I were using cookies.
Thx.
View 1 Replies
View Related
Sep 30, 2005
hi! I'm still fairly wet behind the ears when it comes to databases, especially sql server 2000. But I just got a copy from my University and I really want to spend some time messing with it. The first thing I want to try is making a shopping cart that stores the items in the database rather than in the session. I'm using asp.net (VB) and I had previously made a simple shopping cart for a SMALL site that stored all the information in a dataset stored in the session... but I've been told that isn't a good idea and reccomended I store the data in the sql database. so that's what I want to do!
I'm looking for resources that can help me get this started. These are the first questions I have about this approach, and any advice from you experts would be most appreciated!
1) do I store the data in a temporary table or do I use the regular table and make temporary rows? if the former how do I transfer the rows from the temp table to the order table? if the latter how do I change it from temporary to peromanent? in either case, how do I eliminate rows if the user abandons their cart?
2) how do I first initialize an order and keep track of the orderID for each user and ensure that no one is assigned a duplicate orderID?
those are my biggest confusions about this approach. I've looked for books on this but most are either too much about sql syntax and big-time server management, or they are too general and not specific to sql server. I've tried looking online, but I can't find much information on doing this using asp.net 2.0. thanks again for your help!
-SelArom
View 6 Replies
View Related
Dec 29, 2005
Hello,
I'm in the progress of developing a shopping cart system that operates with an SQL database in Visual Web Developer 2005. I've managed to successfully add items to the cart and display them, but I'm having trouble providing the user with the option of removing items from the cart.
My understanding so far is that I've got to adjust the DELETE SQL statement of the data source. At first I was thinking along the lines of a simple statement:
DELETE * FROM ShoppingCart WHERE CartID=@CartID AND CategoryID=@CategoryID AND ProductID=@ProductID
However, I've realised that the parameters I need for this SQL query aren't automatically passed in when a user clicks the "Delete" text of the Delete field (at least I think this is the problem).
The error message which I'm getting when I try to remove an item from the cart is as follows:
Incorrect syntax near '*'.
If anyone could let me know where I'm going wrong and point me in the right direction I'd be really grateful.
Thank you,
Luke
View 2 Replies
View Related
Jan 2, 2007
I'm trying to figure out how to associate users in my ASPNETDB.MDF to create a shopping cart.IE: I have 3 tables, for a list of existing orders, list of products, and list of specific orders.The idea is for users who've signed up with the built-in user creation control, can then place orders from the shopping cart, and view their existing previous orders. This would normally be done with a unique UserID # to associate orders with specific users, however I don't BELIEVE there's anything like UserID's associated with each user in the ASPNETDB.MDF, it just uses usernames as the unique identifiers right?Anyway I'm not sure I'm explaining what I'm trying to do perfectly and I apologize, but I don't think it's an un-common problem I'm having. Basically I'm trying to avoid having to have existing ASPNETDB users create a sort of SECOND user that would associate them into a seperate Customers table, it seems like extra user steps that shouldn't be necessary.
View 1 Replies
View Related
Mar 16, 2008
Hi all,
There is nothing happen when I finished my checkout process, I expect the data will be saved to order and orderitem table in my SQL database, but no data found on order and orderitem table and no error messages display during operation!!!
Below is my checkout.aspx.vb code, the whole code line number around 138, I captured the part from 1~ 64 line number, I suspect line 35 - 48 have a problem, can somebody help me, many thanks.
1 Imports System
2 Imports System.Data.SqlClient
3 Imports SW.Commerce
4 Partial Class CheckOut
5 Inherits System.Web.UI.Page
6 Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
7 If Not Page.IsPostBack Then
8 If Profile.Cart Is Nothing Then
9 NoCartlabel.Visible = True
10 Wizard1.Visible = False
11 End If
12 If User.Identity.IsAuthenticated Then
13 Wizard1.ActiveStepIndex = 1
14 Else
15 Wizard1.ActiveStepIndex = 0
16 End If
17 End If
18 End Sub
19 Sub chkUseProfileAddress_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs)
20
21 ' fill the delivery address from the profile, but only if it’s empty
22 ' we don’t want to overwrite the values
23
24 If chkUseProfileAddress.Checked AndAlso txtName.Text.Trim() = "" Then
25 txtName.Text = Profile.Name
26 txtAddress.Text = Profile.Address
27 txtcity.Text = Profile.City
28 txtCountry.Text = Profile.Country
29 End If
30 End Sub
31 Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs)
32
33 ' Insert the order and order lines into the database
34
35 Dim conn As SqlConnection = Nothing
36 Dim trans As SqlTransaction = Nothing
37 Dim cmd As SqlCommand
38 Try
39 conn = New SqlConnection(ConfigurationManager.ConnectionStrings("swshop").connectionstring)
40 conn.Open()
41 trans = conn.BeginTransaction
42 cmd = New SqlCommand()
43 cmd.Connection = conn
44 cmd.Transaction = trans
45
46 ' set the order details
47
48 cmd.CommandText = "INSERT INTO Order(MemberName, OrderDate, Name, Address1, Address2, Country, Total) VALUES (@MemberName, @OrderDate, @Name, @Address, @city, @Country, @Total)"
49 cmd.Parameters.Add("@MemberName", Data.SqlDbType.VarChar, 50)
50 cmd.Parameters.Add("@OrderDate", Data.SqlDbType.DateTime)
51 cmd.Parameters.Add("@Name", Data.SqlDbType.VarChar, 50)
52 cmd.Parameters.Add("@Address", Data.SqlDbType.VarChar, 255)
53 cmd.Parameters.Add("@City", Data.SqlDbType.VarChar, 15)
54 cmd.Parameters.Add("@Country", Data.SqlDbType.VarChar, 50)
55 cmd.Parameters.Add("@Total", Data.SqlDbType.Money)
56 cmd.Parameters("@MemberName").Value = User.Identity.Name
57 cmd.Parameters("@OrderDate").Value = DateTime.Now()
58 cmd.Parameters("@Name").Value = CType(Wizard1.FindControl("txtName"), TextBox).Text
59 cmd.Parameters("@Address").Value = CType(Wizard1.FindControl("txtAddress"), TextBox).Text
60 cmd.Parameters("@City").Value = CType(Wizard1.FindControl("txtCity"), TextBox).Text
61 cmd.Parameters("@Country").Value = CType(Wizard1.FindControl("txtCountry"), TextBox).Text
62 cmd.Parameters("@Total").Value = Profile.Cart.Total
63 Dim OrderID As Integer
64 OrderID = Convert.ToInt32(cmd.ExecuteScalar())
Below is checkout.aspx1 <%@ Import Namespace ="System.Data.SqlClient"%>
2 <%@ Import Namespace ="SW.Commerce"%>
3 <%@ Page Language="VB" MasterPageFile="~/SWSHOP.master" AutoEventWireup="false" CodeFile="CheckOut.aspx.vb" Inherits="CheckOut" title="Untitled Page" %>
4
5 <%@ Register Src="SWShoppingCart.ascx" TagName="SWShoppingCart" TagPrefix="uc1" %>
6 <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
7
8 <asp:Label id="NoCartlabel" runat="server" visible="false">
9 There are no items in your cart. Visit the shop to buy items.
10 </asp:Label>
11
12 <div style="float:right">
13 </div>
14
15
16 <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="1" Width="274px">
17 <WizardSteps>
18 <asp:WizardStep runat="server" Title="Login">
19 <asp:Login ID="Login1" runat="server">
20 </asp:Login>
21 </asp:WizardStep>
22 <asp:WizardStep runat="server" Title="Delievery Address">
23 <asp:checkbox id="chkUseProfileAddress" runat="server" autopostback="True"
24 text="Use membership address"
25 OnCheckedChanged="chkUseProfileAddress_CheckedChanged"></asp:checkbox><br />
26 <table border=�0�>
27 <tr><td>Name</td><td><asp:textbox id="txtName" runat="server" /></td></tr>
28 <tr><td>Address</td><td><asp:textbox id="txtAddress" runat="server" /></td></tr>
29 <tr><td>City</td><td><asp:textbox id="txtcity" runat="server" /></td></tr>
30 <tr><td>
31 Country</td><td><asp:textbox id="txtCountry" runat="server" /></td></tr>
32 </table>
33 </asp:WizardStep>
34 <asp:WizardStep runat="server" Title="Payment">
35 <asp:DropDownList id="lstCardType" runat="server">
36 <asp:ListItem>MasterCard</asp:ListItem>
37 <asp:ListItem>Visa</asp:ListItem>
38 </asp:DropDownList>
39 <br />
40 Card Number: <asp:Textbox id="txtNumber" runat="server" Text="0123456789" ReadOnly="True"/>
41 <br />
42 Expires: <asp:textbox id="txtExpiresMonth" runat="server" columns="2" />
43 /
44 <asp:textbox id="txtExpiresYear" runat="server" columns="4" />
45 </asp:WizardStep>
46 <asp:WizardStep runat="server" Title="confirmation">
47 <uc1:SWShoppingCart ID="SWShoppingCart1" runat="server" />
48 <br />
49 <br />
50 Please confirm amount you wish to have deduct from your credit card.
51 </asp:WizardStep>
52 <asp:WizardStep runat="server" Title="Complete">
53 Thank you for your order.</asp:WizardStep>
54 </WizardSteps>
55 </asp:Wizard>
56 </asp:Content>
57 <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
58 <asp:LoginView ID="LoginView1" Runat="server">
59 <AnonymousTemplate>
60 <asp:passwordrecovery id="PasswordRecovery1" runat="server" />
61 </AnonymousTemplate>
62 </asp:LoginView>
63 </asp:Content>
View 2 Replies
View Related
Sep 3, 2007
helo alll...,this is my data:my table is item(productid,stock) ,order(customerid,no_order), and orderdetail (no_order,productid,quantity) example: order and orderdetail displayed in gridview....order is displayed like this: customerid no_orderdetail A 1detail B 2 when i click detail in row 2, it's display orderdetail:no_order productid quantity 2 c1 2 2 p1 3 i have make all this is ok. but i want to decrease stok in item with quantity in orderdetail.my code in procedure like:CREATE PROCEDURE [dbo].[order_item](@productid AS varchar,@quantity AS INT)ASBEGINBEGIN TRANSACTIONDECLARE @no_order AS INTDECLARE @stock AS INTINSERT INTO [Orderdetail]([ProductId],[Quantity])VALUES(@productId,@quantity)SET @no_order = SCOPE_IDENTITY()SET @Stock = (SELECT [Stock] FROM [item] WHERE [ProductId] = @productId)UPDATE [item]SET[Stock] = @Stock - @quantityWHERE[ProductId] = @productIdCOMMIT TRANSACTIONENDreturn it can't work..how about his true code in store procedure?ok..., thx..
View 8 Replies
View Related
Dec 11, 2014
I have been asked to report on missing Stock in my works Warehouses. My work uses SAP Business One for ERP, and Accellos for Warehouse Management. Both SAP / Accellos maintain stock levels, and whilst they do talk to each other (in real time), nothing is perfect and stock counts (within each system) sometimes develop discrepancies.
Here is the code that I developed to show stock discrepancies -
Code:
SELECT
Tx.[Item Code]
, ISNULL(Ty.Qty, 0) AS 'A1 Qty'
[Code]....
View 1 Replies
View Related
Sep 10, 2014
I need to create query for last stock quantity.
I have 3 tables. Stores, Dates and Transactions. I want to combine all Stores with all Dates in one table and then calculate Last Stock Quantity.
Stores
London
Paris
Prague
Dates
1.1.2014
2.1.2014
3.1.2014
Transactions
1.1.2014 London 1000
1.1.2014 Paris 1300
1.1.2014 Prague 1500
2.1.2014 London 800
3.1.2014 Prague 1200
And result should look like this Last_Quantity should be Quantity for last date in Transactions table.
1.1.2014 London 1000
1.1.2014 Paris 1300
1.1.2014 Prague 1500
2.1.2014 London 800
2.1.2014 Paris 1300
2.1.2014 Prague 1500
3.1.2014 London 800
3.1.2014 Paris 1300
3.1.2014 Prague 1200
View 8 Replies
View Related
Jan 18, 2015
I want to calculate stock aging (qty, cost) based on the on hand quantity.
Currently I am recording only in/out transaction only.
For ex: Item A i have 115 pieces (Balance stock) as on to day.
Transaction History
---------------------
Lot 1 - 01/01/2015 - 50
Lot 2 - 10/02/2015 - 50
Lot 3 - 11/03/2015 - 50
Lot 4 - 15/04/2014 - 50
I want to calculate cost of balance qty as shown below.
Jan -
Feb - 15 @ 1.1
Mar - 50 @ 0.90
Apr - 50 @ 1.2
Database schema
--------------------
CREATE TABLE [dbo].[StockManagement](
[Uniid] [int] IDENTITY(1,1) NOT NULL,
[StockCode] [int] NULL,
[TransactionDate] [datetime] NULL,
[TransactionTime] [time](0) NULL,
[Code] .....
View 0 Replies
View Related
May 8, 2015
I need sql query to select max date shipment where sum of quantity required > sum of quantity shipped from sales line table but i dont know how to make my sales line table as following
shipment date  quantity required quantity shipped
07/05/2015Â Â Â Â Â Â Â Â Â 200Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 100
07/05/2015Â Â Â Â Â Â Â Â Â 300Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 300
07/05/2015Â Â Â Â Â Â Â Â Â 100Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 50
06/05/2015Â Â Â Â Â Â Â Â Â 200Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 100
06/05/2015Â Â Â Â Â Â Â Â Â 200Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 200
Here the result of query i need is  max shipment date is 07/05/2015 and quantity required is 600 and quantity shipped is 450 so tat i must select this date because quantity Required is big from quantity shippedmy question How i write the query get result above in sql server 2005.
View 9 Replies
View Related
Sep 11, 2007
helo all...,i want to make procedure like:examplei have table: item (itemid,itemname,stock)orderdetail(no_order,itemid,quantity)itemmoment(itemid,itemname,stock)item table itemid itemname stock c1 coconut 2 p1 peanut 2orderdetail tableno_order itemid quantity 1 c1 5itemmoment tableitemid itemname stock c1 coconut 0 p1 peanut 0 when customer paid, his quantity in orderdetail decrease stock in item table..so stock in item table became:itemid itemname stock c1 coconut -3 p1 peanut 2it's not good, because stock may not minus...so i want to move -3 to itemmoment table..so stock in item table became:itemid itemname stock c1 coconut 0 p1 peanut 2and in itemmoment table became:itemid itemname stock c1 coconut 3 p1 peanut 0my store procedure like:ALTER PROCEDURE [dbo].[orders]( @no_order as integer, @itemid AS varchar(50), @quantity AS INT)ASBEGIN BEGIN TRANSACTION DECLARE @currentStock AS INT SET @currentStock = (SELECT [Stok] FROM [item] WHERE [itemid] = @itemid) UPDATE [item] SET [Stock] = @currentStock - @quantity WHERE [itemid] = @itemid COMMIT TRANSACTIONENDit's only decrease stock with quantity. i want move stock minus from item to itemmoment..can anyone add code to my store procedure?plss.. helpp.thxx....
View 2 Replies
View Related
Jan 3, 2013
currently we have some shipping software that has a mqsql database locally.There are filters on the program and when an item is shipped from our warehouse it goes into a filter "Shipped".We have a SKU and also quantity for the product.
Now we have an inventory program that also has a mqsql database,this has the same SKU as the shipping software database.what we hope to do is when an SKU is shipped in our software program(ie it Goes into the "Shipped" folder),it will deduct the quantity from the adjacent SKU in the inventory program database.
Note that the 2 databases are independent from each other but would like them to be in effect linked to each other.
View 1 Replies
View Related
May 17, 2006
We started out with the trial version of sql2005 and we later purchased the full standard version I belive, I just realized our trial is going to expire which we have data we are using on it. Is it possible to enter our liscense number in the trial to continue using or do I have to detach all of the databases and install the new sql version and then reattach all of the databases and setup any maintence plans again.
View 5 Replies
View Related
Jul 2, 2007
How to find out number of SQL Server seats purchased?
View 2 Replies
View Related
Nov 12, 2014
I've the table like
create table test
(
product varchar(50),
QTY int,
rate float,
Bill_date datetime,
total_val float
)
insert into test values ('Milk','50','500','2014-04-20', '25000')
values ('Milk','20','560','2014-05-20','12000')
values ('Milk','30','450','2014-06-18','13500')
values ('Milk','30','700','2014-06-18','21000')
My expecting output:
Month product Qty Rate T_val
April Milk 50 700 25000
MAY MILK 20 700 12000
Like I've to show the price of latest price in all of months product billed. How to make Query?
View 9 Replies
View Related
Dec 15, 2005
I'm looking for any help/tricks on creating an item numbering system in a MSSQL database. The object is to number the items in a cart from 1 to whatever and have the ability for the user to change that sequence. The client wants the ability to order the items any way they choose by changing the sequence number. This process would require.
1. Starting at one (1) for the first item in the cart and incrementing from there.2. If I have 10 items and I change item 3 to 5, items 4 and 5 have to increment down by one and 6-10 would stay the same. (and vise versa moving item 3 to item 1)3. If I have 10 items and I delete item 4, 5-10 must incremet down by one.
On 1 my first though in adding items is doing a select count to see if any items exist in the cart. If they don't assign the number one. if it does do a max on the sequence column and increment by one.
on 3 I would simply delete the item and do an update on all items with seq# > then the deleted Seq#
on 2 I'm not sure yet.
Am I on the right track and are there any tricks to doing this? Any help would be appreciated. This would all be done in stored procedures.
View 3 Replies
View Related
Nov 10, 2013
1. I need to find the names of the customers who have purchased academic books. (Coding required as Subquery NOT as Join)
2. Here, I need to show a list of authors who have written books and list the books they have written.
Sort the list by last name
(Coding required as Subquery)
View 4 Replies
View Related
Oct 29, 2007
Ok, we need to purchase a license enterprise license. However, I got confused on what to pick. We have one machine with a single processor. Does anyone have any idea on what to get? This is apparently my first time and there are a vast number of different options.
thanks in advance
View 9 Replies
View Related
Jun 3, 2014
I am looking for a way to show how I can have a result set that shows a record with one item and the number of records where it was purchased or sold. Below is my sample data.
Use tempdb
go
create table #ItemLedgerEntry
(
ENTRYNO INT NOT NULL
, ITEMNO VARCHAR (50) NOT NULL
, POSTINGDATE DATETIME NOT NULL
, ENTRYTYPE INT NOT NULL
[code]....
I know something like this will give me results but I'd like to run one query.
select itemno, count(*) from #ItemLedgerEntry where entrytype = 0
group by itemno
order by count(*) desc
View 5 Replies
View Related
Mar 3, 2004
Good Afternoon
First time shopper on this board...hopefully you can help me.
I am trying to figure out how to schedule a DTS package located on a Server to run at a certain time. The DTS package will contain the path to a V/B 6 executable file residing on the same server.
So to test my methodology, I made a package on a server with code to run the V/B 6 executable off of my local machine. When executing the
package manually it works fine. However, when I schedule it the job does not start. I could not find a way to edit the job I had previously scheduled so I made another one in case I "fat fingered" something.
The same thing happens...no job starts.
Any ideas?
Thanks,
Ed
View 3 Replies
View Related
Jul 23, 2005
How should I set up a database to be able to efficiently maintainassociations between related items?Example: Users shopping for Lord Of The Rings trilogy were alsointerested in The Hobbit.There will be many (20000+) items for sale and I need to do thisefficiently, but I don't have an idea how could I do it.TIA
View 4 Replies
View Related
Oct 17, 2006
After a customer decides to buy a shopping list, there is generally aneed to store/insert one master record and a variable number of childdetail records, preferably all wrapped in a transaction. There are lotsof ways to do this and I am wondering if anyone knows which is mostefficient.One approach is to use ADO.NET's transaction capabilities, definesingle-record insert procs for the master and detail tables, and callthe detail insert in a loop from the web page. This has N+1 trips tothe server, which is not too attractive.Another approach is to concatenate all the data into a bigstring/varchar variable and pass it to a decoder proc that would thencall the single record insert procs via a loop inside the decoder proc.This second approach would use T-SQL's transaction capability and haveonly one trip to the server, but it is more effort to code on the webpage and in the decoder proc.Surely this is a common problem. Are there any more elegant/efficientmethods that anyone can suggest? Can one pass an array to a proc? Isthis a place for a user defined data type?Any advice is much appreciated.
View 2 Replies
View Related
Nov 19, 2007
Dear all,
I am trying to create a recipe database and one of the funtions is to generate shopping list based on the selected recipes.
at the moment, I have a table --recipe, a table--ingredient, and a cross
over table between these two, reIng.
Does anyone know how can I write a procedure with cursor that no matter how
many recipes the user selected, a list of ingredients will be created based
on that? Another things I can't solve is if an ingredient appears twice, how can I make them sum together..
I can write a simple procedure with one parameter so that I can get the ingredients for a certain recipe.( the parameter is the recipeID ). But I get struck when the possibility is that user will select more than one recipe and
wish to get a list of the ingredients. should I use a cursor to do that? Or I should create a temporary table to store the selected recipe?
THanks for your help!
View 1 Replies
View Related
Feb 5, 2007
Hi guys
I have a column with datas as
"0.0"
"123.0"
"45.0"
i have a query were i have to match the value only. i don't want the decimal and followed by the any thing.
or
how do i extract just the value not the decimal part so that i can compare it with other value.
how do i do that.
thanks
View 10 Replies
View Related
Dec 10, 2007
I have a View in SQL,
SELECT dbo.ATTTblAttendance.LogIn, dbo.ATTTblAttendance.LogOut,
ISNULL(DATEDIFF(Hour, dbo.ATTTblAttendance.LogIn, dbo.ATTTblAttendance.LogOut),0) AS TimeWorked
FROM dbo.ATTTblAttendance
Currently, when Login = 1:00 PM and LogOut = 4:30 PM, TimeWorked = 3.
What I need is for TimeWorked to = 3.5
My ASP.NET page has the following:
<asp:TemplateField HeaderText ="Total Hours" >
<ItemTemplate >
<asp:Label ID="TimeWorked" runat="server" Text='<%# Eval("TimeWorked") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
The goal is to take a person's dailt time in and time out, and subtract their AM and PM break time to yield their TimeWorked.
Ex. time in > 8:00 AM,
lunch > :30 minutes
time out > 4:30 PM
Total Time Worked today = 8.0 or 7.45, or 7.5, if the time warrant it.
How I get this to subtract correctly?
Ayomide
View 3 Replies
View Related
Jun 24, 2004
Hello everyone. I have a query where I pull all item_codes that start with a 7. I need all the item_codes that start with 7, but I need to subtract the last 3 characters from only the item_codes that are not 71860kit or 71851nggun. How would I be able to accomplish this. What I have below subtracts the last 3 characters from all item_codes including 71860kit and 71851nggun. I want these two to stay in tact when I select them in the query.
This is the Query that I have now!
select datepart(year, date_cust_invoice)as INV_YEAR,
datepart(month, date_cust_invoice)as INV_MONTH,
item_code=left(item_code, len(item_code)-3)
, sum(QTY_SALES)as QTY_SALES_TOTALS, sum(SALES_VAL)as SALES_VAL_TOTALS
from opcsahf
where datepart(year, date_cust_invoice) >= '2003'
and substring(item_code, 1, 1) = '7'
group by datepart(year, date_cust_invoice), datepart(month, date_cust_invoice),
item_code
order by inv_year, inv_month, item_code
All help is appreciated!
View 1 Replies
View Related
Nov 5, 2007
Hi,I am trying to solve the following issue, can anybody throw some lights...Here is some sample data from the tableTIME STAMP PROJECTID FUNCTION2007-10-31-01.10.05.00 3333311111 First2007-10-31-01.10.06.00 3333311111 Second2007-10-31-01.10.08.00 3333311111 Third2007-10-31-01.10.10.00 3333311111 Complete2007-10-31-01.10.11.00 2222244444 First2007-10-31-01.10.12.00 2222244444 Second2007-10-31-01.10.14.00 2222244444 Third2007-10-31-01.10.15.00 2222244444 Complete... and result I am looking something like below PROJECT ID FUNCTION DURATION3333311111 First 0:00:01 (2007-10-31-01.10.06.00 - 2007-10-31-01.10.05.00) 3333311111 Second 0:00:06 (2007-10-31-01.10.08.00 - 2007-10-31-01.10.06.00)3333311111 Third 0:00:02 (2007-10-31-01.10.10.00 - 2007-10-31-01.10.08.00)2222244444 First 0:00:01 (2007-10-31-01.10.12.00 - 2007-10-31-01.10.11.00)2222244444 Second 0:00:02 (2007-10-31-01.10.14.00 - 2007-10-31-01.10.12.00)2222244444 Third 0:00:01 (2007-10-31-01.10.15.00 - 2007-10-31-01.10.14.00)hope the question is clear!thanks for your time, Murali
View 11 Replies
View Related
Mar 4, 2007
Hi all, i don't know where to post these, and so i posted in here about sql stuff... I want to do a stock inventory for my restaurant, and i don't know how to start building the database, so, I want to ask if anyone knows if they have a database diagram for stock inventory... any kind of database diagram will helps, so I get and Idea how to start... thanks...
View 2 Replies
View Related
Jun 17, 2008
Well probably not that complex for some of you out there!
I need to work out the amount of stock which was sold between @datefrom and @dateto and how much we currently have on hand (to work out if we are over ordering etc). That's the pretty easy part but I also need to include a column which works out how many items have been sold 3 months prior to @datefrom (from invoiceline). The proc I have so far works out the items sold between 2 dates so basically what I need is another column which is the amount sold (QtySold) in the 3 months prior to datefrom
This is the basic part I have so far:
ALTER PROCEDURE [dbo].[rptstockholdinglevel]
-- Add the parameters for the stored procedure here
@datefrom datetime,
@dateto datetime,
@periodname varchar(50),
@percentage int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT
products.productname,
@periodname AS periodname,
isnull(SUM(invoiceline.qty),0) AS QtySold,
products.qtyonhand AS OnHand,
nominals.nominalname,
productcategories.categoryname,
productmanufacturers.manufacturername
FROM
productmanufacturers RIGHT OUTER JOIN
invoices INNER JOIN
invoiceline ON invoices.invoiceid = invoiceline.invoiceid RIGHT OUTER JOIN
products ON invoiceline.productid = products.productid ON productmanufacturers.manufacturerid = products.manufacturerid LEFT OUTER JOIN
nominals INNER JOIN
productcategories ON nominals.nominalid = productcategories.salesnominal ON products.categoryid = productcategories.productcategoryid
WHERE
(invoices.invoicedate BETWEEN @datefrom AND @dateto)
OR
(invoices.invoicedate is null)
GROUP BY
products.productname,
products.qtyonhand,
productcategories.categoryname,
nominals.nominalname,
productmanufacturers.manufacturername
HAVING (SUM(isnull(invoiceline.qty,0)) < products.qtyonhand)
ORDER BY
nominals.nominalname,
productcategories.categoryname,
productmanufacturers.manufacturername
END
I'd be really grateful for any pointers as I'm just going round in circles on this one.
Thanks in advance as usual all :)
Stephen.
View 6 Replies
View Related
May 7, 2007
hello,I have a table like this:thing, size, color, type_mov, vary1, s, red, sell, 11, s, red, buy, 21, m, green, return, 10....and the question is how I can see the total number of products by sizeand color having in mind that some type of movement are + and otherare -.in other words, like stock control.how I can control this in sql server?code, procedures?thanks!
View 2 Replies
View Related
Oct 18, 2007
I want to fetch all the records which are 2 minutes older
How can I do it?
View 2 Replies
View Related