public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport() { CRReciptPayment rpt = new CRReciptPayment(); rpt.Site = this.Site; return(rpt); }
private void pbSave_Click(object sender, EventArgs e) { if (txtIdTreatment.Text == "" || txtChange.Text == "") { MessageBox.Show("Please fill in the data"); } else { if (Convert.ToInt32(txtMoney.Text) < Convert.ToInt32(txtTotalPayment.Text)) { //uang kurang MessageBox.Show("less money"); } else { FileStream fs = new FileStream("Data\\payment.txt", FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); DialogResult result = MessageBox.Show("Are you sure want save the data?", "Save", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { sw.WriteLine(txtIdPayment.Text + "#" + txtIdTreatment.Text + "#" + txtPatientName.Text + "#" + txtDoctorName.Text + "#" + txtDiagnose.Text + "#" + txtDateTreatment.Text + "#" + txtPaymentDoctor.Text + "#" + txtPaymentDrug.Text + "#" + txtTotalPayment.Text + "#"); sw.Flush(); sw.Close(); fs.Close(); DialogResult dr = MessageBox.Show("Data has been saved, Print the data?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { /*ileStream fs2 = new FileStream("Data\\recipedetail.txt", FileMode.Open, FileAccess.Read); StreamReader sr2 = new StreamReader(fs2); while((str = sr2.ReadLine()) != null) { if (str.Contains(recipe)) { string[] isi = str.Split('#'); //idrecipe = isi[1]; dosis = isi[3]; drugqty = isi[4]; subdrug = isi[5]; } } sr2.Close(); fs2.Close();*/ //MessageBox.Show("Printernya belum jadi:p"); FCashierReciptPayment fcrp = new FCashierReciptPayment(); CRReciptPayment crrp = new CRReciptPayment(); TextObject to = (TextObject)crrp.ReportDefinition.Sections["Section2"].ReportObjects["IdPayment"]; to.Text = txtIdPayment.Text; TextObject totreatment = (TextObject)crrp.ReportDefinition.Sections["Section2"].ReportObjects["IdTreatment"]; totreatment.Text = txtIdTreatment.Text; TextObject topatientname = (TextObject)crrp.ReportDefinition.Sections["Section2"].ReportObjects["PatientName"]; topatientname.Text = txtPatientName.Text; TextObject todoctorname = (TextObject)crrp.ReportDefinition.Sections["Section2"].ReportObjects["DoctorName"]; todoctorname.Text = txtDoctorName.Text; TextObject toidrecipe = (TextObject)crrp.ReportDefinition.Sections["Section2"].ReportObjects["IdRecipe"]; toidrecipe.Text = recipe; TextObject todiagnose = (TextObject)crrp.ReportDefinition.Sections["Section2"].ReportObjects["Diagnose"]; todiagnose.Text = txtDiagnose.Text; //details drug TextObject topaydrug = (TextObject)crrp.ReportDefinition.Sections["Section4"].ReportObjects["PaymentDrug"]; topaydrug.Text = txtPaymentDrug.Text; TextObject topaydoc = (TextObject)crrp.ReportDefinition.Sections["Section4"].ReportObjects["PaymentDoctor"]; topaydoc.Text = txtPaymentDoctor.Text; TextObject totalpay = (TextObject)crrp.ReportDefinition.Sections["Section4"].ReportObjects["TotalPayment"]; totalpay.Text = txtTotalPayment.Text; TextObject tomoney = (TextObject)crrp.ReportDefinition.Sections["Section4"].ReportObjects["Moneyy"]; tomoney.Text = txtMoney.Text; TextObject tochange = (TextObject)crrp.ReportDefinition.Sections["Section4"].ReportObjects["Changee"]; tochange.Text = txtChange.Text; /* FileStream fs1 = new FileStream("Data\\drug.txt", FileMode.Open, FileAccess.Read); StreamReader sr1 = new StreamReader(fs1); while ((str = sr1.ReadLine()) != null) { if (str.Contains(iddrug)) { string[] isi = str.Split('#'); //namaobat = isi[1]; //crrp.SetParameterValue("?DrugName", new string[] { isi[1] }); } } sr1.Close(); fs1.Close(); */ //crrp.SetParameterValue("?DrugName", new string[] {"test1" , "test2"}); //crrp.SetParameterValue("pDose1", dosis); //crrp.SetParameterValue("pQty1", drugqty); //crrp.SetParameterValue("pSub1", subdrug); fcrp.crystalReportViewer1.ReportSource = crrp; fcrp.crystalReportViewer1.Refresh(); fcrp.Show(); this.Hide(); } txtTotalPayment.Clear(); txtPaymentDrug.Clear(); txtPaymentDoctor.Clear(); txtIdTreatment.Clear(); txtIdPayment.Clear(); txtPatientName.Clear(); txtDoctorName.Clear(); txtDiagnose.Clear(); txtDateTreatment.Clear(); txtMoney.Focus(); txtIdPayment.Text = payment(); } } } }