This is my database.

I use ADO.NET Entities Framework 3.5 to get data in my project (it is a winform application), this is my Entities:

 

I want make a grid wich has two information, name of student and class name of student,for example:

To do that, I create a class to the project and name it ItemOfGrid to make struct object of grid.

And this is code in method Form_Load of my form:

And I get a error:


But when I add command: entities.Class.ToList();

Everything is ok,the form run correctly! I don't know why? Ip anyone know why or how to fix it,please help!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted in: ADO.NET Entity Framework  Tags:

Sử dụng CKEditor trong trang web MVC ASP.Net 

1. Cài đặt :

Để sử dụng bộ công cụ này, bạn phải download và giải nén tại thu mục gốc của trang web.

link download tại đây :

 http://download.cksource.com/CKEditor/CKEditor/CKEditor%203.0.1/ckeditor_3.0.1.zip 

2. Nhúng vào Web.

      Để nhúng nó vào trang web của mình , bạn phải khai báo nó trong thẻ <head> của trang html 

;

CKEditor hoạt động giống như một thẻ <textarea> trong html . 

   

Ta sẽ thay thế  <textarea> này bằng đoạn code sau: 

     

Bạn phải chèn đoạn code này sau <textarea> mà nó thay thế, hoặc có thể đưa nó vào trong sự kiện Window.onload để bảo đảm mọi thứ đã được load lên. 

     

Để lấy dữ liệu trong CKEditor ta dùng phương thức sau 

    

Code Ex: 


 

3. Cấu hình :

      Bạn có thể thay đổi cấu hình mặc định của bộ công cụ cho phù hợp tùy theo mục đích của bạn. 

Các bạn có thể  đọc kỹ hơn tại www.ckeditor.com

 

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted in: ASP.NET MVC  Tags:
ngocmanhnguyen posted on November 22, 2009 06:46

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted in: New Technology  Tags:
lequangthai posted on November 21, 2009 07:02

In this article,I will talk about how to use radio button in asp.net MVC.

To begin with open Visual Studio 2008 and choose File > New > Project > ASP.NET MVC.The first thing to do is to create a class that will be the structure of our data to fill radio button.Add new class to the project and name it RadioOption.Add the following code to the RadioOption class:

I will create a controller and name it RadioListController for this example. In the constructor of controller,following code to add data to List<RadioOption>

In method Get of action Create,following code to return a list of RadioOption to view for fill data to radio button.

In RadioListController,right click,choose Add View to genarate View of action,in the top of View,fill this code:

And following code to genarate radiobutton.

In method Post of action Create,fill this code:

"return RedirectToAction("Create", new { valueOfRadio = radio.ToString() });" to return value of radio button be selected to View of method Get of action Create to check value of radio be choose.

To do that,add this command to method Get of action Create.

ViewData["valueOfRadio"] = valueOfRadio;

This is full code of RadiolistController.cs

This is full code of View Create.aspx

Looking forward feedback from you!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted in: ASP.NET , ASP.NET MVC  Tags:
lehoangdung posted on November 21, 2009 00:07

I mapped a table to NHibernate (which's id is Indentity type), and write a repository method using NHibernate.LinQ as below:

 

And the code listing below is test unit:

 

And error when testing:

 

But when I use Expression:

 

Every thing is ok, test unit run correctly! I don't know why? If anyone know how to fix it, please help!

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

lehoangdung posted on November 20, 2009 19:08

Today I will introduce a tool for Visual Studio Build Version Increment Add-In Visual Studio

I want to have automatic build version increment for my apps and libraries to avoid setting it manually again and again. After 5 minutes searching on the internetnet, I found Build Version Increment add-in for Visual Studio 2005/2008. This add-in is very simple in use but do exactly what everyone developer needs. 

You can download it here: Build Version Increment Add-In Visual Studio

 

*Example of using this tool:

After you installed the addin, fire off Visual Studio and open your favorite solution. Your tools menu should contain an entry for the increment settings.


Clicking on this will display a dialog containing a mini solution explorer. Here you can select the solution or one of the available projects and change it's auto versioning properties:


The property grid contains the following values you can modify:

  • Versioning Style. Here you can configure per version attribute the increment scheme you wish to use. Options are:
    • None: Don't update this attribute.
    • Increment: Simple +1 increment per build.
    • TimeStamp: Set the attribute to the current time. (HHMM)
    • YearStamp: Set the attribute to the current year. (YYYY)
    • DeltaBaseDate: Use the Yogesh increment scheme for this attribute.
    • YearDayOfYear: Set the attribute to the current year followed by the day of the year. (YYDDD)
    • DeltaBaseYearDayOfYear: Set the attribute to the delta base year including day of year. (YYDDD)
    • DeltaBaseYear: Set the attribute to the delta base year.
  • Update file version. Setting this to true will update the AssemblyFileVersion attribute.
  • Update assembly version. Setting this to true will update the AssemblyVersion attribute.
  • Assembly info filename. If your project or solution isn't using the default AssemblyInfo.(cs|vb|cpp) file to set the assembly attributes, you can specify it here. Note that the path is stored relative so this also works for other project members.
  • Configuration name. Set this to the configuration name (Debug, Release, ...) which should be active.
  • Start date. Set this to a custom start date if you're using one of the delta versioning types.

 


Whenever one of the projects in the solution is beeing build, the addin kicks in and updates the required attributes. If the target file containing the attributes is under source control the addin will check it out.

*Result of the above setting:

 

 

I love this addin! :)

If you feel happy with this post, please kick it! 

 

kick it on DotNetKicks.com

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

lehoangdung posted on November 20, 2009 00:05

I tried to install Adobe Illustrator CS4 and Photoshop CS4 on Windows 7 but the setups didn't work and give a error message and I found that these were verry common errors of installing CS4 Products on Windows 7 x64.

Before install you should do these steps:

  1. Click the Start button Click the image to open in full size., click All Programs, and then click Accessories.
  2. Right-click Command Prompt, and then click Run as administrator. Click the image to open in full size. In the User Account Control window, verify that Program name is Windows Command Processor, and then click Yes.
  3. In the Administrator: Command Prompt window, type or paste the following text at the prompt:
    reg delete HKLM\SOFTWARE\Microsoft\SQMClient\Windows\DisabledSessions /va /f
  4. Press Enter to install the solution.
  5. If The operation completed successfully displays, close the Administrator: Command Prompt window to complete this procedure. If "ERROR: Access is denied" displays, repeat this procedure from the top, making sure you clicked Run as administrator in step two."

This above solution I found on http://www.sevenforums.com/software/3183-why-cant-i-install-adobe-cs4-software.html

After done those steps, I can successfully install CS4 product on my Windows 7 Ultilimate x64.

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

phamtrungduc posted on November 17, 2009 23:55

 

Bài viết này mình xin hướng dẫn các bạn cách vẽ đường thẳng,dấu mũi tên,đường đứt nét,chữ đánh dấu điểm và trang trí màu trong việc vẽ hình đồ họa dựa trên ngôn ngữ C#

Mở Visual Studio,khởi tạo Winform Application,và thay đổi tên thành BeginGDI.cs 

Vào Toolbox chọn PictureBox như hình dưới:

Hệ tọa độ quy định trong Visual Studio khác với cách vẽ vốn dĩ của một hệ tọa độ thông thường

Có thể biểu diễn cách hình dung đơn giản của hệ tọa độ đó như hệ tọa độ bên dưới

 

Thay đổi hệ tọa độ trên về hệ tọa độ với cách hiểu thông thường sẻ giúp chúng ta dễ vẽ và dễ tính toán khi gặp những hình vẽ phức tạp

 

 Xây dựng lớp HeToaDoHelper.cs trong ứng dụng của bạn để thay đổi trục tọa độ trên

  1. public static void ThietLapHeToaDo(Graphics graphics, Point diemGoc)   
  2.   
  3.         {   
  4.   
  5.             var myMatrix = new Matrix(1, 0, 0, -1, 0, 0);   
  6.   
  7.             graphics.Transform = myMatrix;   
  8.   
  9.             graphics.TranslateTransform(diemGoc.X, diemGoc.Y, MatrixOrder.Append);   
  10.   
  11.         }   
  12.   
  13.     
  14.   
  15.         public static void ThietLapHeToaDo(Graphics graphics, int x, int y)   
  16.   
  17.         {   
  18.   
  19.             var p = new Point(x, y);   
  20.   
  21.             ThietLapHeToaDo(graphics, p);   
  22.   
  23.         } 

*Cách vẽ đường thẳng

Nhấn vào picturebox trong form,ở phần Properties,chuyển qua phần Events.Chọn sự kiện Paint đặt tên là duongThang và nhấn đôi vào sự kiện đó

 

  1. private void duongThang(object sender, PaintEventArgs e)   
  2.   
  3.       {   
  4.   
  5.     
  6.   
  7.         HeToaDoHelper.ThietLapHeToaDo(e.Graphics, 200, 150);   
  8.   
  9.     
  10.   
  11.             //Ve truc hoanh   
  12.   
  13.         e.Graphics.DrawLine(new Pen(Brushes.Black, 1.5f), -200, 0, 200, 0);   
  14.   
  15.     
  16.   
  17.             //Ve truc tung   
  18.   
  19.         e.Graphics.DrawLine(blackPen, new Point(0, 300), new Point(0, -300));   
  20.   
  21.      } 

 

Việc tạo đường thẳng được xem như là đã hoàn tất và qua đó thiết lập lên nên hệ tọa độ dựa vào lớp HetoadoHelper.cs được xây dựng ở trước đó

*Vẽ dấu mũi tên

Trong lớp HeToaDoHelper.cs xây dựng đoạn code sau:

  1. public static void MuiTen(Graphics graphics, Pen p, PointF diemDau, PointF diemCuoi)   
  2.   
  3.         {   
  4.   
  5.             Pen myPen = new Pen(Color.Yellow);   
  6.   
  7.             myPen.Width = 5;   
  8.   
  9.             myPen.EndCap = LineCap.ArrowAnchor;   
  10.   
  11.             PointF endPoint = new PointF((diemDau.X + diemCuoi.X) / 2, (diemDau.Y + diemCuoi.Y) / 2);   
  12.   
  13.             graphics.DrawLine(myPen, diemDau, endPoint);   
  14.   
  15.             graphics.DrawLine(new Pen(Brushes.Yellow, 5f), endPoint, diemCuoi);   
  16.   
  17.     
  18.   
  19.         } 

Xác thực tọa độ điểm đầu và điểm cuối của mũi tên ví dụ:

  1. var diemDau = new PointF(100,100);   
  2.   
  3. var diemCuoi = new PointF(0, 0); 

Ta vẽ được mũi tên sau đoạn code dưới đây:

HeToaDoHelper.MuiTen(e.Graphics, pen, diemDau, diemCuoi);

*Đường đứt nét

Chèn 1 đường đứt nét bất kỳ với tạo độ ở bên dưới:

  1. float[] dashValues = { 5, 2, 15, 4 };   
  2.   
  3. Pen blackPen = new Pen(Color.Black, 0.5f);   
  4.   
  5. blackPen.DashPattern = dashValues;   
  6.   
  7. e.Graphics.DrawLine(blackPen, new Point(0, 300), new Point(0, -300)); 


 *Chữ ghi tên điểm:

Chữ ghi tên điểm được chèn code cùng trong sự kiện paint của picturebox.Ví dụ sau đây là cách chèn chữ S vào hình ở tạo độ quy định sẵn

//VE DIEM S

e.Graphics.DrawString("S", new Font("Times New Roman", 12), Brushes.Black, 600, 60);

Brush myBrush3 = new SolidBrush(Color.Yellow);

Rectangle myRect3 = new Rectangle(600, 60, 5, 5);

*Trang trí màu cho hình vẽ

Khi vẽ đường thẳng hay bất cứ đường gì,trong Graphics có thuộc tính Brushes quy định màu trang trí cho hình vẽ.Cách hình dung:

e.Graphics.DrawLine(new Pen(Brushes.Black, 1.5f), O, U);

e.Graphics.DrawLine(new Pen(Brushes.Blue, 5f), A, B);

e.Graphics.DrawLine(new Pen(Brushes.Blue, 5f), A, X);

e.Graphics.DrawLine(new Pen(Brushes.Blue, 5f), B, Y);

e.Graphics.DrawLine(new Pen(Brushes.Yellow, 3f), O, C2);

e.Graphics.DrawLine(new Pen(Brushes.Yellow, 3f), O, C3);

Bài viết này mình cung cấp cho các bạn những kĩ năng tuy nhỏ nhưng từ đó các bạn có thể phát triển lên thành các chương trình lớn hơn,mà hình ảnh của nó chắc chắn sẻ khiến các bạn không tiếc công mình đã tìm hiểu

 

 

 

 

 

 

 

                                                                              Thân!

           Tài liệu tham khảo:Lập trình Manage GDI+ với C#-Thầy Lê Hoàng Dũng

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Posted in:   Tags:

Page List

    Calendar

    «  September 2010  »
    MoTuWeThFrSaSu
    303112345
    6789101112
    13141516171819
    20212223242526
    27282930123
    45678910
    View posts in large calendar

    Recent Comments

    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010 SFI.VN Team