0

Hello I have a inventory management system where I can print receipts.

  1. I cant add more items to list to print because sheet becomes 2 pages and the end part goes to next page
  2. my width is 3 inch and height can vary according to content .my printer name is XP-365b 3.yes I installed 80c driver for receipt print

ill attach some pictures below of my 1.rdlc report setting 2.code

 public partial class frmReceipt : Form
{
    SqlConnection cn = new SqlConnection();
    SqlCommand cm = new SqlCommand();
    DBConnection dbcon = new DBConnection();
    SqlDataReader dr;
    string store = "";
    string address = "";
    string mobile = "";
    frmPOS f;
    public frmReceipt(frmPOS frm)
    {
        InitializeComponent();
        cn = new SqlConnection(dbcon.MyConnection());
        f = frm;
        this.KeyPreview = true;

        // Fetch store and address values from the database
        FetchStoreAndAddress();

        // Now, you can use the 'store' and 'address' variables in your form.

    }

    private void frmReceipt_Load(object sender, EventArgs e)
    {

        this.reportViewer1.RefreshReport();
    }

    private void FetchStoreAndAddress()
    {
        cn.Open();
        cm = new SqlCommand("SELECT store, address, mobile FROM tblStore", cn);
        dr = cm.ExecuteReader();

        if (dr.Read())
        {
            store = dr["store"].ToString();
            address = dr["address"].ToString();
            mobile = dr["mobile"].ToString();
        }

        dr.Close();
        cn.Close();
    }

    public void LoadReport(string pcash, string pchange, string pdiscall, string ptype)
    {
        ReportDataSource rptDataSource;
        try
        {
            this.reportViewer1.LocalReport.ReportPath = Application.StartupPath + @"\Reports\Report1.rdlc";
            this.reportViewer1.LocalReport.DataSources.Clear();

            DataSet1 ds = new DataSet1();
            SqlDataAdapter da = new SqlDataAdapter();

            cn.Open();
            da.SelectCommand = new SqlCommand("Select c.id, c.transno, c.pcode, c.price, c.qty, c.disc, c.total, c.sdate, c.status, p.pdesc from tblCart as c inner join tblProduct as p on p.pcode = c.pcode where transno like '" + f.lblTransno.Text + "'", cn);
            da.Fill(ds.Tables["dtSold"]);
            cn.Close();

              

            ReportParameter pDiscount = new ReportParameter("pDiscount", f.lblDiscount.Text);
            ReportParameter pTotal = new ReportParameter("pTotal", f.lblTotal.Text);
            ReportParameter pCash = new ReportParameter("pCash", pcash);
            ReportParameter pChange = new ReportParameter("pChange", pchange);
            ReportParameter pStore = new ReportParameter("pStore", store);
            ReportParameter pAddress = new ReportParameter("pAddress", address);
            ReportParameter pMobile = new ReportParameter("pMobile", mobile);
            ReportParameter pTransaction = new ReportParameter("pTransaction", "Invoice #: " + f.lblTransno.Text);
            ReportParameter pCashier = new ReportParameter("pCashier", f.lblUser.Text);
            ReportParameter pShopcode = new ReportParameter("pShopcode", f.cboShopCode.Text);
            ReportParameter pDiscall = new ReportParameter("pDiscall", pdiscall);
            ReportParameter pType = new ReportParameter("pType", ptype);


            reportViewer1.LocalReport.SetParameters(pDiscount);
            reportViewer1.LocalReport.SetParameters(pTotal);
            reportViewer1.LocalReport.SetParameters(pCash);
            reportViewer1.LocalReport.SetParameters(pChange);
            reportViewer1.LocalReport.SetParameters(pStore);
            reportViewer1.LocalReport.SetParameters(pAddress);
            reportViewer1.LocalReport.SetParameters(pMobile);
            reportViewer1.LocalReport.SetParameters(pTransaction);
            reportViewer1.LocalReport.SetParameters(pCashier);
            reportViewer1.LocalReport.SetParameters(pShopcode);
            reportViewer1.LocalReport.SetParameters(pDiscall);
            reportViewer1.LocalReport.SetParameters(pType);


            rptDataSource = new ReportDataSource("DataSet1", ds.Tables["dtSold"]);
            reportViewer1.LocalReport.DataSources.Add(rptDataSource);
            reportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout);
            reportViewer1.ZoomMode = ZoomMode.Percent;
            reportViewer1.ZoomPercent = 100;

            // Print the report



        }
        catch (Exception ex)
        {
            cn.Close();
            MessageBox.Show(ex.Message);
        }


    }

above is my code.... i want to be able to print directly to printer and show print dialog and selection

Image of RDLC design & size setting Image of rdlc Page setup size

7
  • I don't know how..I am new to this..can you please give me ideas or codes to where should I change them I my provided code Commented Nov 13, 2023 at 13:57
  • Check Device Manager for the driver installed for the printer. Commented Nov 13, 2023 at 14:01
  • checked i installed the driver that came with the printer but print is coming i need to set the dimensions in the code correctly..thats what i need help with Commented Nov 13, 2023 at 15:57
  • What are the paper size options? Instead of custom is there a roll option? Try download latest printer driver. There may be a bug in older driver. Commented Nov 13, 2023 at 16:58
  • yes i am using 80mm thermal paper roll Commented Nov 13, 2023 at 20:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.