Sunday, December 30, 2012

@Scripts.Render("~/bundles/jqueryval")


if you are using kendo UI web for asp.net MVC and you are getting the error when you are click on create new.






just hide/remove the code from create & Edit razor view of your controller


 @section Scripts {  
   @Scripts.Render("~/bundles/jqueryval")  
 }  


*Now This problem is resolve in VS 2013

Wednesday, December 26, 2012

silverlight hyperlink button image in datagrid column

In tool hyperlink image button in silverlight datagrid we can set property, command like other control.
the binding of the datagrid column is:


  <sdk:DataGridTemplateColumn Header="Buyer Comments" Width="2*">  
             <sdk:DataGridTemplateColumn.CellTemplate>  
               <DataTemplate>  
                 <StackPanel Orientation="Horizontal">  
                   <HyperlinkButton Content="" Width="30" Command="{Binding Source={StaticResource srConfirm}, Path=ShowComments}"   
                            CommandParameter="{Binding}" ToolTipService.ToolTip="{Binding Path=Comments}">  
                     <HyperlinkButton.Background>  
                       <ImageBrush ImageSource="/images/Icons/add.png" Stretch="Uniform" />  
                     </HyperlinkButton.Background>  
                   </HyperlinkButton>  
                 </StackPanel>  
               </DataTemplate>  
             </sdk:DataGridTemplateColumn.CellTemplate>  
           </sdk:DataGridTemplateColumn>  

here srConfirm is the Viewmodel of the window which i defined in cs.

     private VMEditReceiveBuyerComment _dataContext = null;  
     public EditBuyerCommentReceival()  
     {  
       _dataContext = new VMEditReceiveBuyerComment();  
                this.Resources.Add("srConfirm", _dataContext);  
       InitializeComponent();  
       this.DataContext = _dataContext;  
     }  

Sunday, December 23, 2012

SQL auto generate last column id without auto increment

If we want to get a table autogenerate column id, without auto increment column. we can do it easily.
we can also made it globally for all table. We can create a table name paramaterize store procedure that
will give us table last column ID without using auto increment column.

 CREATE PROCEDURE [dbo].[spSET_GetDB_TablePKID]  
      @tableName [varchar](100),  
      @locationId [int]  
 AS  
 BEGIN  
 declare @newID varchar(20)  
 declare @dbID varchar(20)  
 declare @generateID bigint  
 declare @ReturnValue varchar(100)  
  if exists(select * from DB_TablePKID where LocationID=@locationId and TableName=@tableName)  
   begin  
   --table name exists  
   set @ReturnValue= (select MaxID+1 from DB_TablePKID where LocationID=@locationId and TableName=@tableName)  
   end  
  else --table name is not exists.  
   begin  
   -- generate new first ID for the supplied table  
   select @dbID= DBid from DB where DBLocationID=@locationId  
   set @newID=@dbID+'00000000000001'  
   set @generateID=convert(bigint,@newID)  
   set @ReturnValue=@generateID  
   end   
   select @ReturnValue  
 end  

declar the store procedure in C#

 public long GetTablekeyID(string tableName, int locationId)  
     {  
       long id = 0;  
       // id = _db.spSET_GetDB_TablePKID(tableName, locationId);  
       System.Data.Objects.ObjectResult<string> sid = this.DataContext.spSET_GetDB_TablePKID(tableName, locationId);  
       foreach (string aa in sid)  
       {  
         id = long.Parse(aa.ToString());  
       }  
       return id;  
     }  

Now call from anywhere with your any table name. it will return last id of your table. here locationID is optional.

Tuesday, December 11, 2012

C# globally check List instance's item count

 We can check an instance of a list count() globally


 public class CheckListCount  
   {  
     public bool IsOneItemEntry(IEnumerable<dynamic> objEntity)  
     {  
             String ErrorMessage="";  
       bool IsValid = true;  
       if (objEntity.Count() == 0)  
       {  
         IsValid = false;  
         ErrorMessage = "At least one item must be available.";  
       }  
       return IsValid;  
     }  
   }  

Now create instance in any class &  check any list's instance Count();

  private CheckListCount _CheckList = new CheckListCount();  
       List<CommentReceipt> CommentReceiveItem = new List<CommentReceipt>();  
         foreach (LAB_LDCommentReceipt receipt in ViewData.LdCommentReceiveList)  
         {  
           if (receipt.AppStatusID>0)  
           {  
             CommentReceiveItem.Add(receipt);  
           }  
         }  
          if (_CheckList.IsOneItemEntry(CommentReceiveItem))  
          {  
           // do something  
          }  

Monday, December 10, 2012

Date range query in Entity framework



Entity Framework Date rang query is not same as like LINQ.
You can try like this


 var events = this.coreDomainContext.Events.Where(  
   e => EntityFunctions.TruncateTime(e.EventDate.Value) >= DateTime.Today  
    && EntityFunctions.TruncateTime(e.EventDate.Value) <= EntityFunctions.TruncateTime(endPeriod))  
   .OrderByDescending(e => e.EventDate)  
   .ToList();  

For details you can See

Tuesday, December 4, 2012

silverlight ria services association class relationship

If you have association relationship in your class. then normally you will not get the associated list data using Silverlight ria service. how to solve it..? please see this

MSDN Silverlight Ria Service Fourm

Thursday, November 29, 2012

Silverkight 5 datagrid image size

Normally our image can be different size when we upload the. if we want to fixed that all image size will be fixed in Silver light 5 Data grid.like this




XAML Binding for image:

  <sdk:DataGridTemplateColumn Header="Color image" Width="6*" IsReadOnly="True" >  
             <sdk:DataGridTemplateColumn.CellTemplate >   
               <DataTemplate>  
                 <Image Source="{Binding Path=ColorImageFile}" Stretch="Fill" Width="100" Height="60" Visibility="Visible"/>  
               </DataTemplate>  
             </sdk:DataGridTemplateColumn.CellTemplate>  
           </sdk:DataGridTemplateColumn>  

on datagrid onloading event. set the image column with your class image attribute. here it is ColorImageFile

  private void DgReceiveBuyerComment_OnLoadingRow(object sender, DataGridRowEventArgs e)  
     {  
       try  
       {  
         BO.LAB_LDCommentReceipt labLdCommentObj = e.Row.DataContext as BO.LAB_LDCommentReceipt;  
         if (labLdCommentObj != null)  
         {  
           FrameworkElement ele = dgReceiveBuyerComment.Columns[4].GetCellContent(e.Row);  
           (ele as Image).Source =  
             new BitmapImage(new Uri(GlobalVar.ImagePath + labLdCommentObj.ColorImageFile,  
                         UriKind.RelativeOrAbsolute));  
         }  
       }  
       catch (Exception ex)  
       {  
         throw ex;  
       }  
     }  

you also have to use this dll

 using System.Windows.Controls;  
 using System.Windows.Media.Imaging;  

Wednesday, November 28, 2012

Silverlight multiline textbox

For multiline text box you have to use just 2 property for text box AcceptsReturn="True" TextWrapping="Wrap". consider the datagrid.





the xaml code for the

  <sdk:DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False" Width="Auto" Header="Remarks" >  
             <sdk:DataGridTemplateColumn.CellTemplate>  
               <DataTemplate>  
                 <TextBox AcceptsReturn="True" TextWrapping="Wrap"></TextBox>  
               </DataTemplate>  
             </sdk:DataGridTemplateColumn.CellTemplate>  
           </sdk:DataGridTemplateColumn>  

thank you.

Tuesday, November 20, 2012

Silverlight application Life cycle



Quick review how a silverlight application work in browser

1. The user requests the HTML entry page in the browser.

2. The browser loads the Silverlight plug-in. It then downloads the XAP file that contains your application.

3. The Silverlight plug-in reads the AppManifest.xml file from the XAP to find out what assemblies your application uses. It creates the Silverlight runtime environment and then loads your application assembly (along with any dependent assemblies).

4. The Silverlight plug-in creates an instance of your custom application class (which is defined in the App.xaml and App.xaml.cs files).

5. The default constructor of the application class raises the Startup event.

6. Your application handles the Startup event and creates the root visual object for your application.

Monday, November 19, 2012

Silverlight 5 Datagrid xaml binding

Let see how to look our datagrid



it is very simple, as a data source  i just use a _listObj of my class. and bind the grid column with my class attribute.


  <sdk:DataGrid SelectedItem="{Binding Path=SelectedStudent,Mode=TwoWay}" ItemsSource="{Binding Path= StudentList,Source={StaticResource OutSouceItemList}, Mode=TwoWay}" CanUserResizeColumns="False" AutoGenerateColumns="False" ColumnWidth="*" Name="dgStudentList" VerticalScrollBarVisibility="Visible" MaxHeight="Infinity" >  
           <sdk:DataGrid.Columns>  
             <sdk:DataGridTextColumn Visibility="Collapsed" Binding="{Binding StudentId}" CanUserReorder="False" CanUserResize="False" CanUserSort="False" Width="*" />  
             <sdk:DataGridTextColumn Header="First name" Binding="{Binding FirstName}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTextColumn Header="Last Name" Binding="{Binding LastName}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTextColumn Header="Father name" Binding="{Binding FatherName}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTextColumn Header="Mother Name" Binding="{Binding MotherName}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTextColumn Header="Country" Binding="{Binding Country}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="*" />  
             <sdk:DataGridTemplateColumn x:Name="Edit" Width="*" Header="Edit" CanUserResize="False" CanUserReorder="False" CanUserSort="False">  
               <sdk:DataGridTemplateColumn.CellTemplate>  
                 <DataTemplate>  
                   <StackPanel>  
                     <HyperlinkButton Content=" " Command="{Binding SaveCommand}">  
                       <HyperlinkButton.Background>  
                         <ImageBrush ImageSource="/GoStudyBD_SLV;component/Assets/Images/edit_icon.png"></ImageBrush>  
                       </HyperlinkButton.Background>  
                     </HyperlinkButton>  
                   </StackPanel>  
                 </DataTemplate>  
               </sdk:DataGridTemplateColumn.CellTemplate>  
             </sdk:DataGridTemplateColumn>  
             <sdk:DataGridTemplateColumn x:Name="Delete" Width="*" Header="Delete" CanUserResize="False" CanUserReorder="False" CanUserSort="False">  
               <sdk:DataGridTemplateColumn.CellTemplate>  
                 <DataTemplate>  
                   <StackPanel>  
                     <HyperlinkButton Content=" " Command="{Binding Source={StaticResource OutSouceItemList}, Path=DeleteCommand}" CommandParameter="{Binding}" IsEnabled="{Binding Path=IsEnabled,Mode=TwoWay}" >  
                       <HyperlinkButton.Background>  
                         <ImageBrush ImageSource="/GoStudyBD_SLV;component/Assets/Images/delete_icon.png"></ImageBrush>  
                       </HyperlinkButton.Background>  
                     </HyperlinkButton>  
                   </StackPanel>  
                 </DataTemplate>  
               </sdk:DataGridTemplateColumn.CellTemplate>  
             </sdk:DataGridTemplateColumn>  
           </sdk:DataGrid.Columns>  
         </sdk:DataGrid>  


here i use MVVM you can also download the code.

https://skydrive.live.com/?cid=dbc6b335a854cc0e#cid=DBC6B335A854CC0E&id=DBC6B335A854CC0E%212389

Thursday, November 15, 2012

Silverlight 5 Development environment



Install the software step by step.

1. Install VS-2010

2. Install SQL Server 2008 R2 or other

3. Install VS Service Pack 1

Http://download.microsoft.com/download/E/B/A/EBA0A152-F426-47E6-9E3F-EFB686E3CA20/VS2010SP1dvd1.iso

4. Install Silverlight Toolkit

https://skydrive.live.com/?cid=dbc6b335a854cc0e#cid=DBC6B335A854CC0E&id=DBC6B335A854CC0E%212387

5. install Prism4.1_Source

http://www.microsoft.com/en-us/download/details.aspx?id=28950

6. Install Blend_UltimateTrial_en(silverlight-5)

http://www.microsoft.com/en-us/download/details.aspx?id=9503

Now your PC is ready for Silverlight 5 development Environment.


Saturday, October 20, 2012

C# LINQ Update using multiple where

We can use LINQ update using more than one where.

  // Upadate PR_RECIVEDINVOICEs status  
         var users = from u in dataContextObj.PR_RECIVEDINVOICEs  
               where u.RecivedInvoice_PublisherInvoice == receiveBook.InvoiceNo && u.Status=="Order"  
               select u;  
         users.ToList().ForEach(u => u.Status = "Book Receive");  
         dataContextObj.SubmitChanges();  

Tuesday, October 16, 2012

UML Getting Started For Software Development



                                                        FIG: Student Consultancy System  


To create and evolve a conceptual class diagram, you need to iteratively model:


  • Classes
  • Responsibilities
  • Associations
  • Inheritance relationships
  • Composition associations
  • Vocabularies


To create and evolve a design class diagram, you need to iteratively model:


  • Classes
  • Responsibilities
  • Associations
  • Inheritance relationships
  • Composition associations
  • Interfaces


I am not describe the details that how to you will design a UML Diagram for your Application...!! i just share a link which is really great for short time UML understanding.

                        http://www.agilemodeling.com/artifacts/classDiagram.htm

Thank you.

Monday, October 15, 2012

LINQ date range search

Here i just write down the direct code for LINQ date range search

1:  internal List<Book> GetStockInRecord(Book bookObj)  
2:      {  
3:        _dataContextObj = new KARIM_INT_SECURITY_DataClassesDataContext();  
4:        List<Book> bookLsit = new List<Book>();  
5:        foreach (var p in (from j in _dataContextObj.Stock_Ins  
6:                  where j.StockDate >= bookObj.StockFromDate && j.StockDate <= bookObj.StockToDate  
7:                  select j).Distinct())  
8:        {  
9:          Book aBook = new Book();  
10:          aBook.BookId = (int) p.BookId;  
11:          aBook.BookIsbnNo = p.AD_BOOK.Book_BookIsbnNo;  
12:          aBook.BookTitle = p.AD_BOOK.Book_BookTitle;  
13:          aBook.BookAuthorName = p.AD_BOOK.Book_BookAuthor;  
14:          aBook.BookBinding = p.AD_BOOK.Book_BookBinding;  
15:          aBook.BookCategoryName = p.AD_BOOK.Book_BookCategory;  
16:          aBook.BookCurrencyName = p.AD_BOOK.Book_Currency;  
17:          aBook.BookEdition = p.AD_BOOK.Book_BookEdition;  
18:          aBook.BookPrice = (decimal)p.AD_BOOK.Book_BookPrice;  
19:          aBook.BookPublisherName = p.AD_BOOK.Book_BookPublisher;  
20:          aBook.BookYearOfPublication = p.AD_BOOK.Book_BookYearOfPublication;  
21:          bookLsit.Add(aBook);  
22:        }  
23:        return bookLsit;  
24:      }  

Saturday, October 13, 2012

wcf ria domain services getting started

WCF ria domain service is one of most important technique for Silverlight application. When i start work on Domain service for Silverlight application here i found 2 thing:

1. what is wcf ria domain service...?
    http://stackoverflow.com/questions/3684421/what-is-wcf-ria-services
2. How to implement it...?
   http://www.silverlightshow.net/items/WCF-RIA-Services-Part-1-Getting-Started.aspx#addComment


Thank you.

Sunday, October 7, 2012

WPF role based window access

 Application security is one of the most important part for any application. In WPF application i just want to introduce that their will be many Dashboard for different module. Each dashboard will contain their menu.

The admin will assign group, user & password. Admin will also assign the access for each dashboard menu window for each Group. when a user will login he/she will see the all dashboard but can see those menu which was assign by the admin in his group.


To be continue based on feed back...

Tuesday, July 17, 2012

LINQ to SQL connectionstring pickup from multiple DBML

In Your application if you have more than one DBML file then each DBML file will contain app.config for each DBML file. consider the WPF application






it will be not possible for you to change the client app.config connection string on deployment.
when your application will be ready for deployment take a copy of your solution from your source control. bcoz now you are going to perform many change on your app.config.

1. if you have more than one project then you have change the all project output type as a class library except the start up project.
   right click on the project > properties > change the output as class library




2. Click on setting > right click on the connection string click remove string. if you have more than one then remove all as same.


3. if you have app.xaml . right click and exclude it from project.

4. open your DBML file > right click > properties > expand the connection > select application string as false.





5. Open the DBML cs file on the





change it with 

 public dbDataContext() : base(ConfigurationManager.ConnectionStrings["MyConnString"].ConnectionString, mappingSource)
and it will be look like and you will also get a error




6. To remove the error you have to add System.Configuration dll in your project.

 
 7. You have to remove or hide the connection string of this project





Now build the project if you have more than one projectdo it for all project.


9. In you start up project the app.config will be





 If you have any query please comment.
thank you

Monday, July 16, 2012

ASP.NET Crystal report Group Tree hide

It's really looking odd that when a crystal report load it also load the group tree. You can easily stop the group tree showing.

aspx :


 <CR:CrystalReportViewer ID="secondarySalesCrystalReportViewer" runat="server" EnableDatabaseLogonPrompt="False"  
             EnableParameterPrompt="False" AutoDataBind="true" EnableDrillDown="False"   
             GroupTreeStyle-ShowLines="False" HasCrystalLogo="False" Height="50px"   
             Width="350px" />  

and on the page loading  event you have to use:

 secondarySalesCrystalReportViewer.ToolPanelView =CrystalDecisions.Web.ToolPanelViewType.None;


for example



  protected void Page_Load(object sender, EventArgs e)  
     {  
       secondarySalesCrystalReportViewer.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;  
       if (!IsPostBack)  
       {  
         secondarySalesCrystalReportViewer.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;  
         LoadAllWingInformation();  
         LoadDivision();  
         LoadRegion();  
         LoadTeritory();  
       }  
     }  


thank you

Monday, July 9, 2012

ASP.NET Gridview paging in List datasource

In a grid view if the data-source is used a list and the grid view is bind with the class attribute then we can also use paging on the grid view.

consider the gridview image:

the aspx:


 <asp:GridView ID="productGridView" runat="server" Width="700px" CellPadding="3" CellSpacing="1"  
           AutoGenerateColumns="False" Height="125px" ForeColor="#333333" AllowPaging="True"  
           GridLines="None"   
           OnSelectedIndexChanged="productGridView_SelectedIndexChanged" onpageindexchanging="productGridView_PageIndexChanging"   
           >  
           <AlternatingRowStyle BackColor="#A99B17" />  
           <Columns>  
             <asp:BoundField DataField="ProductId" HeaderText="Id" />  
             <asp:BoundField DataField="ProductCode" HeaderText="Item Code" ItemStyle-HorizontalAlign="Center" />  
             <asp:BoundField DataField="ProductName" HeaderText=" Product Name" />  
             <asp:BoundField DataField="ProductDescription" HeaderText="Description" />  
             <asp:BoundField DataField="ProductPrice" HeaderText="Price" ItemStyle-HorizontalAlign="Right" />  
             <asp:BoundField DataField="ProductQty" HeaderText="Qty (in SKU)" ItemStyle-HorizontalAlign="Right" />  
             <asp:BoundField DataField="ProductUnit" HeaderText="SKU Name" />  
             <asp:BoundField DataField="ProductVersion" HeaderText="Version" ItemStyle-HorizontalAlign="Center" />  
              <asp:BoundField DataField="ProductLine" HeaderText="Product Line" ItemStyle-HorizontalAlign="Center" />  
             <asp:CommandField ShowSelectButton="True" />  
           </Columns>  
           <EditRowStyle BackColor="#7C6F57" />  
           <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />  
           <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />  
           <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />  
           <RowStyle BackColor="#E3EAEB" />  
           <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />  
           <SortedAscendingCellStyle BackColor="#F8FAFA" />  
           <SortedAscendingHeaderStyle BackColor="#246B61" />  
           <SortedDescendingCellStyle BackColor="#D4DFE1" />  
           <SortedDescendingHeaderStyle BackColor="#15524A" />  
         </asp:GridView>  


Page index changing event :





     protected void productGridView_PageIndexChanging(object sender, System.Web.UI.WebControls.GridViewPageEventArgs e)  
     {  
       LoadProductDataGrid();  
       productGridView.PageIndex = e.NewPageIndex;  
       productGridView.DataBind();  
     }  
  private void LoadProductDataGrid()  
     {  
       productGridView.DataSource = _productManagerObj.GetAllProductInfo();  
       productGridView.DataBind();  
     }  
 // From Manager Class  
  internal List<Product> GetAllProductInfo()  
     {  
       return _productGatewayObj.GetAllProductInfo();  
     }  
 // In Gateway class  
 internal List<Product> GetAllProductInfo()  
     {  
      MeghnaGroupDataClassesDataContext  _meghnaGroupData = new MeghnaGroupDataClassesDataContext();  
       List<Product> products = new List<Product>();  
       foreach (var product in (from j in _meghnaGroupData.AD_PRODUCTs   
                    select j ).Distinct())  
       {  
         Product productObj = new Product();  
         productObj.ProductId = (int) product.ProductId;  
         productObj.ProductCode = product.Code;  
         productObj.ProductName = product.Name;  
         productObj.ProductDescription = product.Description;  
         productObj.ProductPrice = (decimal) product.Price;  
         productObj.ProductVersion = product.versionno;  
         productObj.ProductQty = (int) product.TotalQuantity;  
         productObj.ProductUnit = product.Unit;  
         productObj.ProductLine = product.TypeName;  
         products.Add(productObj);  
       }  
       return products;  
     }  

Tuesday, July 3, 2012

ASP.NET Crystal report not showing after publish


 1.Right click on your crystal report. go to properties



 2. Change build action properties Embedded Resource to-> Embedded Resource.
Now publish your application you will get your crystal report after publish.

you  can also try this:
Crystal report is not showing after publish, but it show on local PC. may be it the common issue in VS2010 for SAP crystal report. i am not sure about your crystal report error, but here is some possible solution link for your crystal report solution.

http://niitdeveloper.blogspot.com/2012/03/deploy-crystal-report-aspnet.html
http://social.msdn.microsoft.com/Forums/en-CA/vscrystalreports/thread/ef56f72b-7ede-47d8-ba9e-9e63b9ac0203
http://forums.asp.net/t/1764951.aspx/1

if all the link does not solve your problem you can follow this:

1. Put your crystal report in your UI folder.


2. Publish your application


Here you will see one interesting thing that their is no crystal report in your UI folder where you publish the application.

right click on your solution open in window explorer mode, copy the crystal report from UI folder and paste it to publisher folder UI. now upload the the solution.


Hope it will help you.




Monday, July 2, 2012

Failed to export using the options you specified. Please check your options and try again.

#Solution:1
 in post back just set report loading event as follows btnViewReport_Click(null, null);



  protected void Page_Load(object sender, EventArgs e)  
     {  
       if (!IsPostBack == true)  
       {  
         LoadFactoryName();  
       }  
       else  
       {  
         // Your report viewing button event name  
         btnViewReport_Click(null, null);  
       }  
     }  



#Solution:2
You are trying to export the crystal report in PDF or other format.  But it is not working in  VS2010 asp.net SAP crystal report. my this article is not solve the exception but you may can take a alternative way for the solution. you can export the the crystal report in pdf when the report load.

Consider the method it will just load the crystal report

  private void LoadDateRangeWiseAllItemDetails()  
     {  
       _secondarySales = new SecondarySales();  
       _secondarySaleses = new List<SecondarySales>();  
       _secondarySales.FromDate = Convert.ToDateTime(String.Format("{0}", Request.Form["startDate"]));  
       _secondarySales.ToDate = Convert.ToDateTime(String.Format("{0}", Request.Form["endDate"]));  
       _secondarySaleses = _secondarySalesObj.LoadDateRangeWiseAllItemDetails(_secondarySales);  
       ReportDocument details = new ReportDocument();  
       details.Load(Server.MapPath("../Report/secondarySalesItemDetailsCrystalReport.rpt"));  
       details.SetDataSource(_secondarySaleses);  
       secondarySalesCrystalReportViewer.ReportSource = details;  
     }  

it will look like this:



if i want to load the report in PDF....then..?? then we can take a  another button name Download Pdf . click on this button it will load a pdf file to download. In this button event method we will use the previous method code + add the code for pdf.then the crystal report to PDF method will be look like :


  private void LoadDateRangeWiseAllItemDetails()  
     {  
       _secondarySales = new SecondarySales();  
       _secondarySaleses = new List<SecondarySales>();  
       _secondarySales.FromDate = Convert.ToDateTime(String.Format("{0}", Request.Form["startDate"]));  
       _secondarySales.ToDate = Convert.ToDateTime(String.Format("{0}", Request.Form["endDate"]));  
       _secondarySaleses = _secondarySalesObj.LoadDateRangeWiseAllItemDetails(_secondarySales);  
       ReportDocument details = new ReportDocument();  
       details.Load(Server.MapPath("../Report/secondarySalesItemDetailsCrystalReport.rpt"));  
       details.SetDataSource(_secondarySaleses);  
       secondarySalesCrystalReportViewer.ReportSource = details;  
       // for pdf  
       BinaryReader stream = new BinaryReader(details.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));  
       Response.ClearContent();  
       Response.ClearHeaders();  
       Response.ContentType = "application/pdf";  
       Response.AddHeader("content-disposition", "attachment; filename=" + "pdfName");  
       Response.AddHeader("content-length", stream.BaseStream.Length.ToString());  
       Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));  
       Response.Flush();  
       Response.Close();   
     }  

Build and run the application you will get you report as pdf for download.



Enjoy...

SAP Crystal report Deployment Environment

In our application if we use SAP crystal report, then after deployment we fall such a problem that we need to install VS2010 and SAP crystal  report 13.0. But there need only a run time crystal report software. here is the link to download you appropriate run time software for deployment PC.

https://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=56787567

Thursday, June 28, 2012

ASP.NET HTML text input field get and set value

In our asp.net application if we use html text input field for jquery or like other as we need we can

Get the input field value :

  <input type="text" name="std" id="datepicker5" />  

in C#

  string startDatepicker = String.Format("{0}", Request.Form["std"]);  


Set the input Field :

  <input type="text"  id="datepicker5" value="<%= this.FromDate %>"/>  

in C#

    // declare a from attribute   
     protected string FromDate { get; set; }  
     protected void Page_Load(object sender, EventArgs e)  
     {  
       // setting value  
        this.FromDate = DateTime.Now.ToShortDateString();  
     }  


              Here it is important till now i not get any solution that set and get will work on same HTML text input field.

Tuesday, June 19, 2012

ASP.NET Jquery datepicker

In VS2010 the date time picker control is not available in toolbox. Their is only calender control. but if need to use date picker control in our form stylist j query date picker we can easily do it. let see some stylist datepicker from http://jqueryui.com/themeroller/ 




 You can also choose much more from http://jqueryui.com/themeroller/ . select which theme you want to use and download it. extract the zip file.  after extract you will see the file as like


we will use the css and the js folder data in our application.

Open visual studio 2010 select a new ASP.NET web application, after creating the project add the js and css from the downloaded file.


   In your master page head  show the reference of the js and css file and write the java script for .your datepicker.here i write 2 script named datepicker1 and datepicker2 for two datepicker control.


 <head runat="server">  
   <title></title>  
   <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />  
    <link href="~/Styles/jquery-ui-1.8.21.custom.css" rel="stylesheet" type="text/css" />  
     <script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>  
   <script src="Scripts/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>  
   <%--/* First script for first datepicker name datepicker1 */--%>  
   <script type="text/javascript" language="javascript">  
     $(document).ready(function () {  
       $("#datepicker1").datepicker();  
     });  
   </script>  
    <%--/* First script for first datepicker name datepicker2 */--%>  
    <script type="text/javascript" language="javascript">  
      $(document).ready(function () {  
        $("#datepicker2").datepicker();  
      });  
   </script>  
   <asp:ContentPlaceHolder ID="HeadContent" runat="server">  
   </asp:ContentPlaceHolder>  
 </head>  

Now in Default.aspx file i take a table with 2 row and 2 column .


 <table class="style1" align="center">  
     <tr>  
       <td class="style2">  
         <asp:Label ID="Label1" runat="server" Text="Start Date" Font-Bold="True"></asp:Label>  
       </td>  
       <td>  
          <div class="style3">  
        <input id="datepicker1" type="text" />  
       </div>   
         &nbsp;  
       </td>  
     </tr>  
     <tr>  
       <td class="style2">  
         <asp:Label ID="Label2" runat="server" Text="End Date" Font-Bold="True"></asp:Label>  
       </td>  
       <td>  
          <div class="style3">  
        <input id="datepicker2" type="text" />  
       </div>  
         &nbsp;  
       </td>  
     </tr>  
   </table>  

here i took 2 input control id name datepicker1 and datepicker1 and both's type is text. which is directly catch up our javascript. now run the application you will see both on click.







to Get data from the input field in C# you can write :


  string startDatepicker = String.Format("{0}", Request.Form["startDate"]);  
       string endDatepicker = String.Format("{0}", Request.Form["endDate"]);  


Enjoy...

ASP.NET Gridview cell value alignment

we can easily align our gridview cell value on load event like this

  for (int i = 0; i < damageDetailsGridView.Rows.Count; i++)  
         {  
           damageDetailsGridView.Rows[i].Cells[0].HorizontalAlign = HorizontalAlign.Center;  
           damageDetailsGridView.Rows[i].Cells[1].HorizontalAlign = HorizontalAlign.Left;  
           damageDetailsGridView.Rows[i].Cells[2].HorizontalAlign = HorizontalAlign.Center;  
         }  

the output of the grid look like


Enjoy..

Sunday, June 17, 2012

how to remove time from datetime and display in a gridview

When we  load a Gridview from database value. by default it shows time with date in gridview column.
look like






if we want to show only date without the time then we have to add 2 property in column binding. HtmlEncode="False" DataFormatString="{0:d}"

The gridview aspx bind will be

  <Columns>  
             <asp:BoundField DataField="DistributorId" HeaderText="Distributor Id" />  
             <asp:BoundField DataField="Status" HeaderText="Status" />  
             <asp:BoundField DataField="ProductLine" HeaderText="Product Line" />  
             <asp:BoundField DataField="OrderID" HeaderText="Order Id" />  
             <asp:BoundField DataField="OrderDate" HeaderText="Order Date" HtmlEncode="False"  
               DataFormatString="{0:d}" />  
             <asp:BoundField DataField="EmployeeId" HeaderText="Employee Id" />  
             <asp:BoundField DataField="MessageId" HeaderText="Message Id" />  
             <asp:BoundField DataField="SendDate" HeaderText="Send Date" HtmlEncode="False" DataFormatString="{0:d}" />  
           </Columns>  

the the gridview will llok like


Sunday, June 10, 2012

ASP.NET Dropdown item selected as my given value

if we want set the selected item of a drop down box from my given value we can use follow the code. here i am taking a gridview value and set it as selected item of the drop down. cosider the image



aspx :

Wing Dropdown :
 
 <asp:DropDownList ID="regionWingDropDownList" runat="server" Height="30px" Width="217px"  
           DataValueField="WingId" DataTextField="WingName" AutoPostBack="True" Style="margin-top: 0px"  
           OnSelectedIndexChanged="regionWingDropDownList_SelectedIndexChanged">  
         </asp:DropDownList>  

Division Dropdown


 <asp:DropDownList ID="regionDivisionDropDownList" runat="server" Height="30px" DataValueField="DivisionId"  
           DataTextField="DivisionName" Width="217px">  
         </asp:DropDownList>  


Region Gridview


 <asp:GridView ID="regionGridView" runat="server" Width="457px"   
           AutoGenerateColumns="False"   
           onselectedindexchanged="regionGridView_SelectedIndexChanged">  
           <Columns>  
              <asp:BoundField DataField="RegionId" HeaderText="ID" />  
             <asp:BoundField DataField="RegionCode" HeaderText="Region Code" />  
             <asp:BoundField DataField="RegionName" HeaderText="Region Name" />  
             <asp:BoundField DataField="WingId" />  
             <asp:BoundField DataField="Wingname" HeaderText="Wing Name" />  
             <asp:BoundField DataField="DivisionId" />  
             <asp:BoundField DataField="DivisionName" HeaderText="Division Name" />  
             <asp:CommandField ShowSelectButton="True" />  
           </Columns>  
         </asp:GridView>  

Code behind :

  protected void regionGridView_SelectedIndexChanged(object sender, EventArgs e)  
     {  
       if (regionGridView.SelectedIndex>-1)  
       {  
// setting value on dropdown
         for (int i = 0; i < regionWingDropDownList.Items.Count; i++)  
         {  
           ListItem wing = regionWingDropDownList.Items[i];  
           if (wing.Text == regionGridView.SelectedRow.Cells[4].Text)  
           {  
             regionWingDropDownList.SelectedIndex = i;  
           }  
         }  
       
         for (int i = 0; i < regionDivisionDropDownList.Items.Count; i++)  
         {  
           ListItem division = regionDivisionDropDownList.Items[i];  
           if (division.Text == regionGridView.SelectedRow.Cells[6].Text)  
           {  
             regionDivisionDropDownList.SelectedIndex = i;  
           }  
         }  
         regionCodeTextBox.Text = regionGridView.SelectedRow.Cells[1].Text;  
         regionNameTextBox.Text = regionGridView.SelectedRow.Cells[2].Text;  
         regionIdLabel.Text = regionGridView.SelectedRow.Cells[0].Text;  
         regionSaveButton.Text = "update";  
       }  
     }  

Thursday, June 7, 2012

ASP.NET Dropdown box event fire

Normally Dropdown box is not fire event. to fire any event of dropdown box you need to write the AutoPostBack="True" property in dropdown control.

ASPX File:

  <asp:DropDownList ID="regionWingDropDownList" runat="server" Height="30px" Width="217px"  
           DataValueField="WingId" DataTextField="WingName" AutoPostBack="True"  
           style="margin-top: 0px"   
           onselectedindexchanged="regionWingDropDownList_SelectedIndexChanged"   
          >  
         </asp:DropDownList>  

Codebehind:
 protected void regionWingDropDownList_SelectedIndexChanged(object sender, EventArgs e)  
     {  
       Wing wing = new Wing();  
       wing.WingId = Convert.ToInt32(regionWingDropDownList.SelectedItem.Value);  
       regionDivisionDropDownList.DataSource = _regionManagerObj.GetSelectedWingAllDiviSionName(wing);  
       regionDivisionDropDownList.DataBind();  
     }  

ASP.NET Gridview Column Hide

If you want to hide any column Of a grid you have hide it after load the grid.






Now i want to hide the id Column which contain 1,2,3,4.....

then the code will be on load event of the grid :


 private void LoadDivisionGridData()  
     {  
       _divisionslist = new List<Division>();  
       _divisionslist = _divisionManagerObj.GetAllDivisionInfo();  
       divisionGridView.DataSource = _divisionslist;  
       divisionGridView.DataBind();  
       ResetAllField();  
       divisionGridView.Columns[0].Visible = false;  
     }  


after hide the Id column it will be look life



 Thank you.



Wednesday, June 6, 2012

How to get ASP.NET Gridview selected row value


Gridview binding is one of the important to get selected row value from a asp.net Grid view. consider the following ASP.NET form i want to insert data that will save in SQL database and the Gridview will be load. Now i want when i will click on Select in Gridview button , selected row value will be load on Text field for update.









  Class File:

 public class Wing  
   {  
     public int WingId { get; set; }  
     public string WingName { get; set; }  
     public string WingCode { get; set; }  
   }  



Datagrid binding in aspx

 <asp:GridView ID="wingsGridView" runat="server" Width="500px" AutoGenerateColumns="False"  
           OnSelectedIndexChanged="wingsGridView_SelectedIndexChanged">  
           <Columns>  
             <asp:BoundField DataField="WingId" HeaderText="Id" />  
             <asp:BoundField DataField="WingCode" HeaderText="Code" />  
             <asp:BoundField DataField="WingName" HeaderText="Name" />  
             <asp:CommandField ShowSelectButton="True" />  
           </Columns>  
         </asp:GridView>  



code behind code :


 protected void Page_Load(object sender, EventArgs e)  
     {  
       if (!IsPostBack)  
       {  
         LoadWingDataGrid();  
         wingIdLabel.Visible = false;  
       }  
     }  
     private void LoadWingDataGrid()  
     {  
       wings = new List<Wing>();  
       wings = wingManagerObj.GetAllWingsName();  
       if (wings.Count > 0)  
       {  
         wingsGridView.DataSource = wings;  
         wingsGridView.DataBind();  
         wingsGridView.Visible = true;  
         ResetAllField();  
       }  
     }  
  protected void wingsGridView_SelectedIndexChanged(object sender, EventArgs e)  
     {  
       try  
       {  
        Wing  _wingObj = new Wing();  
         _wingObj.WingId = Convert.ToInt32(wingsGridView.SelectedRow.Cells[0].Text);  
         _wingObj.WingCode = wingsGridView.SelectedRow.Cells[1].Text;  
         _wingObj.WingName = wingsGridView.SelectedRow.Cells[2].Text;  
         wingCodeTextBox.Text = _wingObj.WingCode;  
         wingNameTextBox.Text = _wingObj.WingName;  
         wingIdLabel.Text = _wingObj.WingId.ToString();  
         wingInSaveButton.Text = "Update";  
       }  
       catch (Exception exception)  
       {  
         messageLabel.Text = exception.Message;  
       }  
     }  

If you have any query please replay.


Tuesday, May 29, 2012

How to get WPF datagrid cell value

We can easily get the value of a WPF datagrid cell value using cast with the class. in which class the data grid is   bind. consider the code




 private void GetTotalGBP()  
     {  
       decimal dr = 0, cr = 0;  
      for (int i = 0; i < receiveInvoiceDataGrid.Items.Count; i++)  
        {  
          ReceiveInvoice obj = receiveInvoiceDataGrid.Items[i] as ReceiveInvoice;  
          TGBP += Convert.ToDecimal(obj.NetValue); // getting cell value  
          TQTY += Convert.ToDecimal(obj.ConfirmOrderQty); // getting cell value  
        }  
       totalGBPTextbox.Text = TGBP .ToString("F");  
       totalQtyTextBox.Text = TQTY .ToString("F");  
     }  



Friday, May 4, 2012

How to delete duplicate row from table sql

If we want to delete the duplicate row from a table we can perform it by sq l. Consider the following SQ L query


 delete from PATIENT_INFO   
 where MrNo in (select MrNo  
         from PATIENT_INFO group by MrNo  
         having (count(PatientId))>1) and   
         PatientId not in (select min(PatientId)  
              from PATIENT_INFO   
              group by MrNo  
              having (count(PatientId))>1)  

Here PATIENT_INFO    is Table Name. and PatientId  is the primary key of the table. and we want to delete the duplicate MrNo  .

Wednesday, April 25, 2012

C# message box confirmation formate

When we need use Yes/No confirmation from a Meassage Box  we can use the formate.


 if (MessageBox.Show("Are you sure want to Remove the Record?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)  
           {  
            // Do something  
           }  

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...