Thursday, January 26, 2017

WPF Devexpress Datagrid checkbox binding


We can easily bind the checkbox on devexpress datagrid


 <dxgcore:GridColumn Width="20"  
                     AllowEditing="True"  
                     Binding="{Binding Path=IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  
                     Header="R"  
                     Visible="{Binding CheckboxSelection}"  
                     VisibleIndex="6">  
             <dxgcore:GridColumn.CellTemplate>  
               <DataTemplate>  
                 <dxe:CheckEdit HorizontalAlignment="Center"  
                         VerticalAlignment="Center"  
                         Command="{Binding Path=View.DataContext.IsCheckedCommand}"  
                         CommandParameter="{Binding RowData.Row}"  
                         IsChecked="{Binding RowData.Row.IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  
                         IsEnabled="{Binding Path=View.DataContext.IsCheckBoxEnabled, UpdateSourceTrigger=PropertyChanged}" />  
               </DataTemplate>  
             </dxgcore:GridColumn.CellTemplate>  
           </dxgcore:GridColumn>  

Friday, January 20, 2017

Visual Studio copy dll from project folder to bin folder on build solution


If we want to copy from project folder DLL (3rd party or other type)  to Bin folder during build the solution we can easily map that option.

right click on you solution -> Properties -> Buld Events and follow the format for your folder


 C:\Windows\System32\xcopy /d /y "$(ProjectDir)PackagedDLL\FAX\*.*" "$(TargetDir)"  

In my case FAX is my folder name.



T-SQL update table from join table value



If you want to update your table from join table value you can try with this:


 UPDATE r  
  SET r.l_auto_refill = 1  
    ,r.d_start_date = p.dDispDate  
       ,r.n_frequency = p.nDispDaysSupply  
       ,r.d_next_fill  = DATEADD(DAY, p.ndispdayssupply, p.ddispdate)  
 FROM rx r  
 INNER join   
  profile AS p ON r.[rxno_PK] = p.rxno_FK  
 where r.rxno_PK = '000010578126'  


T-SQL get one records from multiple same record based on max value for join


Let's say you have same type 6 record, into this record when you will picked data you will pick only one record which has highest value.




 SELECT *   
 FROM rx r  
 INNER join   
  (SELECT distinct t1.*  
 FROM profile t1  
  LEFT OUTER JOIN profile t2  
   ON (t1.rxno_FK = t2.rxno_FK AND t1.nrefillno < t2.nrefillno )  
 WHERE t2.dispid_PK IS NULL) AS p ON r.[rxno_PK] = p.rxno_FK  






Thursday, January 12, 2017

sql get all table names with primary key columns

If you want to get all table name with table primary key coloumn you can use the sql query.


 SELECT i.name AS IndexName, OBJECT_NAME(ic.OBJECT_ID) AS TableName,   
     COL_NAME(ic.OBJECT_ID,ic.column_id) AS ColumnName  
 FROM sys.indexes AS i  
 INNER JOIN sys.index_columns AS ic  
 ON i.OBJECT_ID = ic.OBJECT_ID  
 AND i.index_id = ic.index_id  
 WHERE i.is_primary_key = 1  


SQL Get all Index create script from Database

To get all script from database as a create new index into another database you can use the following --Get all Index Script SELECT...