Click here to Skip to main content
15,897,891 members
Home / Discussions / C#
   

C#

 
GeneralRe: XML as DataBase Pin
E_Gold13-Oct-08 22:15
E_Gold13-Oct-08 22:15 
AnswerRe: XML as DataBase Pin
Guffa13-Oct-08 22:45
Guffa13-Oct-08 22:45 
AnswerRe: XML as DataBase Pin
N a v a n e e t h13-Oct-08 20:41
N a v a n e e t h13-Oct-08 20:41 
QuestionShow Control out of the Window Pin
softwarejaeger13-Oct-08 19:44
softwarejaeger13-Oct-08 19:44 
AnswerRe: Show Control out of the Window Pin
leppie13-Oct-08 22:17
leppie13-Oct-08 22:17 
GeneralRe: Show Control out of the Window [modified] Pin
softwarejaeger14-Oct-08 2:32
softwarejaeger14-Oct-08 2:32 
QuestionHow to add Plugin in IE ? Pin
bishwajeet13-Oct-08 19:42
bishwajeet13-Oct-08 19:42 
QuestionGridview by using TemplateField? Pin
my_amrizal13-Oct-08 16:44
my_amrizal13-Oct-08 16:44 
I have a problem when I want call funtion in gridview by using templatefield.

The scenario is like this :

I want to call function : % of Compliance = getComplaince(field1,field2) in gridview. For your information field1 and field2 to in this gridview was set visible=false.

For example field1 = 1, field2 =1

The code is like below :


Field 1 Field 2 Application Definition % of Compliance
1 1 SMP Sistem Maklumbalas getCompliance(1,1)
2 1 E-App E-Application getComplaince(2,1)


getCompliance Function

1 public string getCompliance(int applicationID, int serviceID)
2 {
3 serviceCalculation c = new serviceCalculation();
4 string itemAB = c.getItemAB(serviceID, applicationID, lblError);
5 string[] splitItem = itemAB.Split(',');
6 string comply = c.countCompliant(splitItem[0].ToString(), splitItem[1].ToString());
7 return comply + "%";
8 }



getItemAB Function

1 public string getItemAB(int service, int applicationID, Label lblError)
2 {
3 database d = new database("S15TeRS");
4 int valueA = 0;
5 int valueB = 0;
6 double percentage = 0.0;
7 int counter = 0;
8 string query = "SELECT ss.ValueA,ss.ValueB,ss.Percentage FROM StateService ss" +
9 " INNER JOIN papv2.dbo.tblState s ON s.stateID = ss.stateID" +
10 " WHERE" +
11 " ss.ApplicationID='" + applicationID + "' AND ss.Service ='" + service + "'" +
12 " UNION" +
13 " SELECT ks.ValueA, ks.ValueB, ks.Percentage FROM KawasanService ks" +
14 " INNER JOIN papv2.dbo.tblKawasan k ON k.kawasanID = ks.kawasanID" +
15 " WHERE ks.ApplicationID='"+ applicationID +"' AND ks.Service='"+ service +"'" +
16 " UNION" +
17 " SELECT cs.ValueA, cs.ValueB, cs.Percentage FROM CawanganService cs" +
18 " INNER JOIN papv2.dbo.tblCawangan c ON c.cawanganID = cs.cawanganID" +
19 " INNER JOIN papv2.dbo.tblKawasan k ON k.kawasanID = c.cawanganID" +
20 " WHERE cs.ApplicationID='"+ applicationID +"' AND cs.Service='"+ service +"'";
21
22 try
23 {
24 d.Query = query;
25 d.InitDataReader();
26 while (d.findMoreRows())
27 {
28 counter++;
29 valueA += Int32.Parse(d.returnRow("ValueA"));
30 valueB += Int32.Parse(d.returnRow("ValueB"));
31 percentage += double.Parse(d.returnRow("Percentage"));
32 }
33 return valueA + "," + valueB;
34 }
35 catch (Exception ex)
36 {
37 lblError.Text = ex.Message.ToString();
38 return "";
39 }
40 }
41



countComplaint Function

1 public string countCompliant(string x, string y)
2 {
3 if (!(x.Trim().Equals("")) && !(y.Trim().Equals("")))
4 {
5 double a = double.Parse(x);
6 double b = double.Parse(y);
7 double compliant = b / a * 100;
8 double roundComplaint = Math.Round(compliant, 2);
9 return roundComplaint.ToString();
10 }
11 else
12 return "";
13 }










<img src="http://img72.imageshack.us/img72/7031/takafulbanner2ga0.jpg">
Koleksi Busana Muslimah Moden (sila klik)


QuestionSet Seperate Background Images of Dual Monitors Pin
aj.esler13-Oct-08 14:13
aj.esler13-Oct-08 14:13 
AnswerRe: Set Seperate Background Images of Dual Monitors Pin
Jakob Olsen14-Oct-08 1:00
Jakob Olsen14-Oct-08 1:00 
GeneralRe: Set Seperate Background Images of Dual Monitors Pin
aj.esler14-Oct-08 11:12
aj.esler14-Oct-08 11:12 
GeneralRe: Set Seperate Background Images of Dual Monitors Pin
Jakob Olsen14-Oct-08 21:10
Jakob Olsen14-Oct-08 21:10 
QuestionExternal sorting Pin
Diamonddrake13-Oct-08 13:37
Diamonddrake13-Oct-08 13:37 
AnswerRe: External sorting Pin
Simon P Stevens13-Oct-08 22:51
Simon P Stevens13-Oct-08 22:51 
GeneralRe: External sorting Pin
Diamonddrake14-Oct-08 10:08
Diamonddrake14-Oct-08 10:08 
GeneralRe: External sorting Pin
Simon P Stevens14-Oct-08 11:15
Simon P Stevens14-Oct-08 11:15 
GeneralRe: External sorting Pin
Diamonddrake14-Oct-08 14:37
Diamonddrake14-Oct-08 14:37 
GeneralRe: External sorting Pin
Simon P Stevens14-Oct-08 21:32
Simon P Stevens14-Oct-08 21:32 
Questioncrystal report viewer - treelist Pin
nelsonpaixao13-Oct-08 12:32
nelsonpaixao13-Oct-08 12:32 
QuestionCRYSTAL REPORTS - load image Pin
nelsonpaixao13-Oct-08 12:12
nelsonpaixao13-Oct-08 12:12 
AnswerRe: CRYSTAL REPORTS - load image Pin
teddddddddddd13-Oct-08 19:20
teddddddddddd13-Oct-08 19:20 
GeneralRe: CRYSTAL REPORTS - load image Pin
nelsonpaixao14-Oct-08 12:31
nelsonpaixao14-Oct-08 12:31 
GeneralRe: CRYSTAL REPORTS - load image Pin
nelsonpaixao15-Oct-08 13:21
nelsonpaixao15-Oct-08 13:21 
GeneralRe: CRYSTAL REPORTS - load image Pin
teddddddddddd15-Oct-08 19:41
teddddddddddd15-Oct-08 19:41 
QuestionWrite to Ms word document ??? Pin
TALHAKOSEN13-Oct-08 10:01
TALHAKOSEN13-Oct-08 10:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.