1. References
using Fastreport; using Fastreport.barcode;
2. Code
Private voidToolstripbuttonprint_click (Objectsender, EventArgs e) { stringTextnewdate = DateTime.Now.ToString ("YYYY-MM-DD HH:mm:ss"); stringTextbarcode=string. Empty; Try { //Selecord = this.datagridview1.selectedrows[0]. CELLS[1]. Value.tostring ();//Select the value of the first cell of a row stringstrSQL ="SELECT PID, SN, Workno, Name, Sex_name, Idcard, age, Education_name, CONVERT (varchar (+), EntryDate, Max) as Entryda TE,"+"Usemanfrom_name, Post_name, Jobs_name,typework_name, idcardadress, Mobile,"+"Security_name, Contractterm_name,brithdate, Sex, Education, Usemanfrom, Post, Jobs, Typework, Security,"+"contractterm,workdate,nation,duty,worktelphone,hometelphone,email,workaddress, HomeAddress,"+"Memo, Photo, Idcardimage"+"From tbemployee where pid= '"+ IPid +"'"; Report Fsreport=NewReport ();//instantiating a printed reportSqlHelper Helper=NewSqlHelper (); DS= Sqlhelper.sqlgetdataset (strSQL,"V_tbemployee"); //SDA. Fill (DT, "Tbdevcard"); //string reportpath = appdomain.currentdomain.basedirectory+ "\otdevpgcard.frx"; //fsreport.load (@ "... \otdevpgcard.frx ");Fsreport.load (@"Fastreport\otempedit.frx"); Fsreport.registerdata (DS); DT= ds. tables[0]; Textobject Ptextprint= Fsreport.findobject ("textprintdate") asTextobject; //Textobject Ptextidcard = Fsreport.findobject ("Textidcard") as Textobject;Textbarcode = dt. rows[0]["Idcard"]. ToString (); //(Fsreport.findobject ("Barcode2") as Barcodeobject). Text = "21000002009"; //strarray[3];(Fsreport.findobject ("Barcode2") asBarcodeobject). Text =Textbarcode; //ptextidcard.text = Textbarcode;Ptextprint.text =textnewdate; Fsreport.show (); Fsreport.dispose (); } Catch(Exception err) {MessageBox.Show (err. Message); } }
C # winfrom Fastreport Print