Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

sql server - SQL custom unit conversion -


i looking solution custom unit conversion in sql, database company used microsoft sql server, need write sql return conversion factor based on "unit conversion table"

say:

item: chicken wings (itemid 1001) vendor: food wholesale ltd (vendorid 5000) unitid: gram (id=10) unitid: kilogram (id=500) unitid: boxes (id=305) quantity: 1000 grams = 1kgs = 5 boxs 

unit conversion table:

itemid | vendorid | unit1id | unit2id | quantity1 | quantity2  1001 5000 10 500 1000 1  1001 5000 500 305 1 5 

question: closing stock chicken wings in gram if have 10 boxes

how write sql return "conversion factor"?

thanks in advance

i think recursive table finds path desired unit , desired unit work best. (this assumes if there path a-->b-->c there path c-->b-->a in database. if not modified search both directions).

select  1001 itemid         ,5000 vendorid         ,10 fromunit         ,500 tounit         ,cast(1000 float) fromquantity         ,cast(1 float) toquantity #conversiontable union select  1001         ,5000         ,500         ,305         ,1         ,5 union select 1001         ,5000         ,305         ,500         ,5         ,1 union select  1001         ,5000         ,500         ,10         ,1         ,1000  declare @fromunit int         ,@tounit int         ,@input int set @fromunit = 305 --box set @tounit =  10 --gram set @input = 10  ;with recursivetable (     select  0 levelnum             ,ct.fromunit             ,ct.tounit             ,ct.toquantity / ct.fromquantity multiplicationfactor     #conversiontable ct       ct.fromunit = @fromunit      union      select  levelnum + 1             ,rt.fromunit             ,ct.tounit             ,rt.multiplicationfactor * (ct.toquantity / ct.fromquantity)     #conversiontable ct     inner join recursivetable rt on rt.tounit = ct.fromunit )  select @input * r.multiplicationfactor (     select top 1 * recursivetable      (fromunit = @fromunit     , tounit = @tounit) ) r 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -