Actually, I am trying to display the data into a crystal report table and on graph. so please tell me if I have created one xyz.rpt file and create one table and graph structure inside this report. How to use these structures multiple times in my report. Suppose I have a student table and this table contains data of multiple class for example I have two classes data class 8 and class 9. In this situation all the data of the both class are displaying in a single table and single graph. but I am trying to display the class 8 data into a table after that my table terminates here and display graph for class 8 after that in second loop class 8 display in another table which comes after the first graph with the help of same table structure and then display the graph for this class.
Here is my code, Which display all data into single table and single graph..
dtoverall = DbClass.getdata(CommandType.Text, "select vn.VelocityNormalX VNX,vn.VelocityNormalY VNY,vn.VelocityNormalZ VNZ,vn.Unit VNU, vn.SampleTimeVN VNT,an.AccelerationNormalX ANX,an.AccelerationNormalY ANY,an.AccelerationNormalZ ANZ,an.Unit ANU from vel_normal_overall vn left join acc_normal_overall an on vn.SampleTimeVN = an.SampleTimeAN where vn.SampleTimeVN between '" + SubTime + "' and '" + CurrTime + "' and vn.sensorid = '" + SensorNo + "'");
if (dtoverall.Rows.Count > 0)
{
foreach (DataRow drtime in dtoverall.Rows)
{
convertedtime = timechange.IndianTime(Convert.ToString(drtime["VNT"]));
string loc = FName + "/" + AName + "/" + TName + "/" + MName + "/" + PName;
Overallall.Rows.Add(convertedtime, Convert.ToString(Math.Round(Convert.ToDouble(drtime["VNX"]),3))+Convert.ToString(drtime["VNU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["VNY"]), 3)) + Convert.ToString(drtime["VNU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["VNZ"]), 3)) + Convert.ToString(drtime["VNU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["ANX"]), 3)) + Convert.ToString(drtime["ANU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["ANX"]), 3)) + Convert.ToString(drtime["ANU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["ANX"]), 3)) + Convert.ToString(drtime["ANU"]), loc);
}
}
crptall.Database.Tables["OverallForAll"].SetDataSource(Overallall);
CrysRptViewer.ReportSource = crptall;
CrysRptViewer.Refresh();
Group the report by {Class}. You do this by using the menu option of Insert, Group... or by using Report, Group Expert...
Then, place the chart in the Group Footer section.
Related
I have created a combobox with items.
Visually in my form the items texts will apear, and i want to change the values to numbers when i insert in the database.
example :
private void contact(){
TypeAdrCmBx.Items.Add("NPAI");
TypeAdrCmBx.Items.Add("Personnelle");
TypeAdrCmBx.Items.Add("Professionelle");
TypeAdrCmBx.Items.Add("Vacances"); }
this is my insert Query :
string Query2 = "INSERT INTO [dbo].[Adresses] ([Type] ,[Adresse0],[Adresse1],[Adresse2],[CPT],[Ville],[Pays]) VALUES ('" + this.TypeAdrCmBx.Text + "','" + this.AdrTxtBx0.Text + "','" + this.AdrTxtBx1.Text + "','" + this.AdrTxtBx2.Text + "','" + this.CptTxtBx.Text + "','" + this.VilleTxtBx.Text + "','" + this.PaysCmBx0.Text + "')";
in the database the combobox values are inserted as numbers :
"NPAI" = 1
"Personnelle" = 2
"Professionelle" = 3
"Vacances" = 4
On Database side solution,
You need to you 2 tables in database in order to do it. One table will hold strings and values like
X Table
ID Number Value
1 1 "NPAI"
2 2 "Personnelle"
3 3 "Professionelle"
4 4 "Vacances"
and other table you will only use the numbers.
When you want to read them, u will use left join.
On c# side solution.
You can basicly convert them with if,
string a="";
if (TypeAdrCmBx.Text.Equals("NPAI"))
a="1";
else if (TypeAdrCmBx.Text.Equals("Personnelle"))
a="2";
And then simply make the insertion with a.
Hope it helps.
I am using c# winform, When the users input something in State field I want to look up that value in another table and find that code. I have commented the line below on what I have tried but that has not worked
MySqlCommand cmdDatabase = new MySqlCommand(" update `STUDENT REGISTER` INNER JOIN `States` ON `STUDENT REGISTER`.`State` = `States`.`State Code` set " +
"`first Name`='" + cboStudentFirstName.Text.Trim() + "'," +
"`Surname`='" + cboStudentSurname.Text.Trim() + "'," +
//if the person selects inputs VIC on this table I want it to look up that value in a table called states and bring me back the code for that state
"STUDENT REGISTER.State= States.State Code," +
This is my code for the date:
DateTime datetry = DateTime.Now;
lebeldet.Text = string.Format("{0:MMM/dd/yyyy h:mm tt}", datetry);
In label, its displaying the result that i wanted
:
But when its inserted into the database and crystal report print it looked like this.
this is my code for insertion.
crud.AddRecord("Update SalesTransaction Set Date = '" + Convert.ToDateTime(lebeldet.Text) + "' , Cashier = '" + cashier.Text + "', TotalSales = '" + totaldue.Text + "' , SubTotal = '" + subtotal.Text + "' , Discount = '" + discount.Text + "' , DiscountableSales = '" + totaldiscountablesales.Text + "' , Vat = '" + totalvat.Text + "' , VatableSales = '" + totalvatablesales.Text + "' where TransactionID = '" + salestransaction.TransactionID+"' ");
How can i make the date to be inserted like "Aug/03/2017 12:30AM" ?
But when its inserted into the database and crystal report print it looked like...
A datetime value in a database, or a DateTime value in C#, do not have any format. They represent a value. You'll see a string in a particular format when you evaluate it, such as with the ToString method.
In a presentation tool, such as when you view the string in a table in SQL Management Studio, or in the Visual Studio debugger, there is an implicit call to ToString (or similar) occurring such that you can see the data. The format of that is specific to the tool being used. It is NOT part of the data itself.
For Crystal Reports and other reporting tools, you'll usually find a separate field or function to control the format displayed in the report. You do this on the field in the report design, not on the data in the database.
i want to display a set of report on my crystal report form in a app i develop using win form, c# and crystal report. i have 2 tables and wants to display a report from the two tables in one crystal report. here is the code
string sql = "select * from ISSUED, RECEIVED WHERE ISSUED.ITEMCODE=RECEIVED.ITEMCODE AND ISSUED.TRANSDATE,RECEIVED.TRANSDATE between'" + Convert.ToDateTime(date1) + "' and '" + Convert.ToDateTime(date2) + "' and ISSUED.ITEMCODE = '" + itemcode + "' and RECEIVED.ITEMCODE between '" + Convert.ToDateTime(date1) + "' and '" + Convert.ToDateTime(date2) + "'";
And this is the error i get
An expression of non-boolean type specified in a context where a condition is exprected, near '.'.
I'm new to programming, and trying to develop a database application with C# 2010 Express using MS Access DB 2010.
I've DataGridView and Detail view generated thru wizard on the form. I'm filtering the data with TextChanged event of a textbox.
When I navigate records, datagridview also scrolls according to current record on Detail view, and vice versa.
After filtering applied and removed this navigation behavior does not work at all (i.e. datagridview does not scroll according to current record in detail view anymore).
Any help would be appreciated.
Thanks.
Here is the code I use for filtering data (FilterField comes from Tag properties of radio buttons):
DataView dv = new DataView(personel_csDataSet.Tables["tblData"]);
dv.RowFilter = FilterField + " like '%' + '" + tbFilter.Text + "' + '%' ";
this.tblDataDataGridView.DataSource = dv;
tblDataBindingSource.Filter = FilterField + " like '%' + '" + tbFilter.Text + "' + '%' ";
That's because you set a different data source to the grid and the details view. If tblDataBindingSource is the data source of the detail view, assign it as a data source of the grid and don't create another view:
this.tblDataDataGridView.DataSource = tblDataBindingSource;
tblDataBindingSource.Filter = FilterField + " like '%' + '" + tbFilter.Text + "' + '%' ";
BTW, you don't have to assign the data source exactly there. You can do it in the beginning and you don't have to reassign it after applying a filter.