Esempio n. 1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            repReceive rpt = new repReceive();

            rpt.Site = this.Site;
            return(rpt);
        }
Esempio n. 2
0
        private void PrintReceive() //พิมพ์ใบรับสินค้า
        {
            DropTmpTable();         //ลบข้อมูลตารางชั่วคราว

            try
            {
                tr = Conn.BeginTransaction();
                sb = new StringBuilder();

                sb.Append(" SELECT G.CpID,G.CpName,G.CpAddress+ ' โทรศัพท์ : ' + G.CpTel AS CpAddress,");
                sb.Append(" G.CpContact + ' โทรศัพท์ : '+ G.CpContactTel AS CpContact,");
                sb.Append(" A.*,F.OrdDate,B.ProID,C.ProName,D.PtDetail,B.RectPrice,E.UnDetail,B.RectNum,B.RectTotal,");
                sb.Append(" I.TiDetail+H.UsFirstName+' '+ H.UsLastName AS UsFullName");
                sb.Append(" INTO _repReceive" + DBConnString.pUsID);//ใส่ในตารางที่สร้างขึ้นใหม่
                sb.Append(" FROM tblReceive");
                sb.Append(" A INNER JOIN tblRecTrn B ON A.RecID=B.RecID");
                sb.Append(" LEFT JOIN tblProduct C ON B.ProID=C.ProID");
                sb.Append(" LEFT JOIN tblSetProductType D ON D.PtID=C.PtID");
                sb.Append(" LEFT JOIN tblSetUnit E ON E.UnID=C.UnID");
                sb.Append(" LEFT JOIN tblOrder F ON F.OrdID=A.OrdID");
                sb.Append(" LEFT JOIN tblSetCompany G ON G.CpID=F.CpID");

                sb.Append(" LEFT JOIN tblSetUser H ON H.UsID=A.UsID");
                sb.Append(" LEFT JOIN tblSetTitle I ON I.TiID=H.TiID");

                sb.Append(" WHERE A.RecID=@RecID");

                SqlText         = sb.ToString();
                com             = new SqlCommand();
                com.CommandText = SqlText;
                com.CommandType = CommandType.Text;
                com.Connection  = Conn;
                com.Transaction = tr;
                com.Parameters.Clear();
                com.Parameters.Add("@RecID", SqlDbType.NVarChar).Value = txtRecID.Text.Trim();
                com.ExecuteNonQuery();
                tr.Commit();

                SqlConnection cnn;
                string        connectionString = null;
                string        sql = null;

                connectionString = DBConnString.strConn;
                cnn = new SqlConnection(connectionString);
                cnn.Open();
                sql = "SELECT * FROM " + "_repReceive" + DBConnString.pUsID;
                SqlDataAdapter  dscmd = new SqlDataAdapter(sql, cnn);
                repReceive_Data ds    = new repReceive_Data();
                dscmd.Fill(ds, "repReceive");
                cnn.Close();

                MoneyExt mne       = new MoneyExt();
                string   xThaiBath = "";
                xThaiBath = "(-" + mne.NumberToThaiWord(Convert.ToDouble(txtRecNet.Text)) + "-)";

                repReceive objRpt = new repReceive();
                objRpt.SetDataSource(ds.Tables[1]);
                objRpt.DataDefinition.FormulaFields["xSuName"].Text    = "'" + PublicVariable.pSuName + "'";
                objRpt.DataDefinition.FormulaFields["xSuAddress"].Text = "'" + PublicVariable.pSuAddress + "'";
                objRpt.DataDefinition.FormulaFields["xThaiBath"].Text  = "'" + xThaiBath + "'";

                crvRep.Visible = true;
                crvRep.Dock    = DockStyle.Fill;

                crvRep.ReportSource           = objRpt;
                objRpt.PrintOptions.PaperSize = CrystalDecisions.Shared.PaperSize.PaperA4;
                crvRep.Refresh();

                DropTmpTable();//ลบข้อมูลตารางชั่วคราว
            }
            catch (Exception Err)
            {
                MessageBox.Show("เกิดข้อผิดพลาด : " + Err.Message, DBConnString.xMessage, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                tr.Rollback();
                return;
            }
        }