Posts

Showing posts from 2012

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

Image
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

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

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' se…

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)) { …

Date range query in Entity framework

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

Silverkight 5 datagrid image size

Image
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…

Silverlight multiline textbox

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

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.

Silverlight 5 Datagrid xaml binding

Image
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" CanUserResi…

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.


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();

UML Getting Started For Software Development

Image
      FIG: Student Consultancy System  


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


ClassesResponsibilitiesAssociationsInheritance relationshipsComposition associationsVocabularies

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


ClassesResponsibilitiesAssociationsInheritance relationshipsComposition associationsInterfaces

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.

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: …

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.

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

LINQ to SQL connectionstring pickup from multiple DBML

Image
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





chan…

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 = CrystalDecis…

ASP.NET Gridview paging in List datasource

Image
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-Horizont…

ASP.NET Crystal report not showing after publish

Image
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…

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

Image
#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(&q…

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

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.

ASP.NET Jquery datepicker

Image
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="styleshee…

ASP.NET Gridview cell value alignment

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

how to remove time from datetime and display in a gridview

Image
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" H…

ASP.NET Dropdown item selected as my given value

Image
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="ser…

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

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



How to get ASP.NET Gridview selected row value

Image
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:B…

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"); }


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  .

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 }