Wednesday, July 30, 2014

PIVOT Table in MS SQL

Table Structure


Now Pivot those  Tables like this

WITH AllowedAmount AS (
   SELECT
CAST(round(MAP.AllowedAmt,2) AS NUMERIC(36,2)) AllowedAmt
    ,c.CPT
    ,CAST(round(c.Charges,2) AS NUMERIC(36,2)) Charges
    , F.NAME
   FROM
      dbo.POSEVAllowedAmtMap MAP
      FULL JOIN POSEVAllowedAmtConfig c ON c.ID =MAP.AllowedAmtId
   LEFT OUTER JOIN dbo.finclass F
      ON MAP.FinClassId = F.FinClass_Id
   
)
SELECT *
FROM
   AllowedAmount
   PIVOT (Max(AllowedAmt) FOR NAME
    IN (Aetna,
Blue,
Cigna,
Humana,
Medicaid,
Medicare,
Tricare,
United,
Other,
CMS)) P    


Check Result of PIVOT Query Result



Find a checkbox in GridView on Textbox change in JQuery

Find the GridView checkbox or other control of same row in JQuery
Checkbox Id (chkChargesEntered): dgAllowedAmt__ctl2_chkChargesEntered

Textbox ID (txtTricare): dgAllowedAmt:_ctl2:txtTricare Now we are replacing txtTricare with checkbox id which is chkChargesEntered
after that selecting the checkbox.
  $(function () {        $(".jqKeyDown").each(function () {               $(this).val(($(this).val() * 1).toFixed(2));  });
 $(".jqKeyDown").change(function(){
        $(this).val(($(this).val() * 1).toFixed(2));
var idstr=this.id +'';
if($('#'+this.id).val()!='0.00')
   $('#'+ idstr.replace(idstr.split('_')[3],"chkChargesEntered")).attr('checked','checked');

});
 }); });



Now Use this JQ Class in GridView

<asp:TemplateColumn HeaderStyle-CssClass="HeaderStyle" HeaderText="Amount" HeaderStyle-ForeColor="White" HeaderStyle-HorizontalAlign="Center" ItemStyle-CssClass="ItemStyle" ItemStyle-HorizontalAlign="right" ItemStyle-Width="70px"><ItemTemplate> <asp:TextBox ID="txtAmount" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Amount") %>' style="text-align:right;width:50px" CssClass="jqKeyDown"> </asp:TextBox> </ItemTemplate></asp:TemplateColumn>






Find previous td in JQuery

 var total = parseFloat($(this).closest('td').prev().closest('td').prev().find('.jqHDHP').html());

Fix GridView Header on scrolling in ASP.NET

Wondering how to fix GridView header while scroll down.


Use This CSS class




  .HeaderStyleWithFixPos  { position:relative; top:expression(this.offsetParent.scrollTop);  }

Now use this class in header style 


<HeaderStyle HorizontalAlign="Center" ForeColor="White" CssClass="HeaderStyleWithFixPos"></HeaderStyle>