Showing posts with label depending. Show all posts
Showing posts with label depending. Show all posts

Friday, February 17, 2012

Depending on the selection of the user of the asp.net web-form how can i do changes in the

Hi frdz,
  I have created the following stored procedure in sql server 2005.
 In my database i have one option for the payment mode which can be done thru cash or credit(cheque).  
 I have created my web-application in asp.net with C# 2005.
 There i have a dropdownlist box for the user to select the option whether wants to do the payment thru cash or cheque.
Depending on that selection if user selects cheque then all the reqt for cheque like it's no,dt,bankname etc...are visible.
but if user selects the option as cash then the cheque details become invisible.
Depending on the selection of the user of the asp.net web-form how can i do changes in the stored procedure...  
 
i can write the condition like
if paymentmode=cash
then ........
else
..........
but where and how can it be written ...pls tell me
thanxs in adv...u can go thru my below SP  
 
 
 
ALTER PROCEDURE MiscellaneousStoredProcedure @.miscidint output, @.storenamevarchar(20),--store name to storeid @.accountnamevarchar(20), @.groupnamevarchar(20), @.paymentdtdatetime,@.payeenamevarchar(30),@.paymodevarchar(20),@.banknamevarchar(50), @.chqdtdatetime, @.chqnovarchar(20), @.amtnumeric(10, 2),@.balnumeric(10, 2), @.remarksvarchar(50)asdeclare@.storeidint,@.accountidint,@.groupidintbeginset nocount onselect @.miscid =isnull(max(@.miscid),0) + 1from miscellaneourpayifexists (select *from storemasterwhere storename = @.storename)select @.storeid = storeidfrom storemasterwhere storename = @.storenameifexists (select *from accountmasterwhere accountname =@.accountname)select @.accountid = accountidfrom accountmasterwhere accountname =@.accountnameifexists (select *from accountgroupmasterwhere groupname=@.groupname)select @.groupid=groupidfrom accountgroupmasterwhere groupname=@.groupnamebegin transactioninsert into miscellaneourpay(miscid,storeid,accountid,groupid,paymentdt,paymode,payeename,bankname,chqdt,chqno,amt,bal, remarks)values( @.miscid,@.storeid,@.accountid,@.groupid,@.paymentdt,@.paymode,@.payeename,@.bankname,@.chqdt,@.chqno,@.amt,@.bal,@.remarks)commit transaction end
What about creating two different stored Proceedures for both cases?|||

Hi,

Try to use two different stroed procedure for cash and credit. The value from your DropDownList decides which one to use. In this way,you can make your stored procedure easier.

Thanks.

Depending on the due date, start date and end date calculate the number of entries

Hi!
I am using SQl server 8.0 and I have a web form on which I have below controls or I can say below column in the TABLE A

DueDate
Start date
End Date
Interval -- Monthly or Quarterly
Amount

Depending on the Interval(Monthly or Quarterly) I want to make an entry in the Table B which will be fall between start date and end date and on due date

EXample

DueDate = 11/15/2005
Start date =11/01/2005
End Date =11/30/2006
Interval = Monthly
Amount = 2500

In the table I should have an 12 entry as
PaymentDate Amount
=======================
11/15/2005 2500
12/15/2005 2500
01/15/2006 2500
02/15/2006 2500
03/15/2006 2500
04/15/2006 2500 ....

Please advice

Thanks
AshikaIf you keep a table of numbers then you can do this easily. Ex:

-- assume that you have table called Numbers with numbers from say 0...8000.
insert into tbl (PaymentDate, Amount)
select dateadd(month, N, @.DueDate), @.Amount
from Numbers
where N between 0 and datediff(month, @.DueDate, @.EndDate);

Alternatively, you should have a calendar table in the system that is prepoulated with all the dates. You can then use it to generate the data easily. The calendar table also solves other problems related to maintaining different calendar types in the database, accounting for holidays etc. This is a common approach in data warehousing.