Beispiel #1
0
        public virtual CrystalDecisions.CrystalReports.Engine.ReportDocument CreateReport()
        {
            repOrder rpt = new repOrder();

            rpt.Site = this.Site;
            return(rpt);
        }
Beispiel #2
0
        private void PrintOrder()
        {
            DropTmpTable();//ลบข้อมูลตารางชั่วคราว

            try
            {
                tr = Conn.BeginTransaction();
                sb = new StringBuilder();
                sb.Append(" SELECT A.OrdID,A.OrdDate,E.CpID,E.CpName,E.CpAddress,E.CpTel,E.CpContact,E.CpContactTel,A.UsID,");
                sb.Append(" G.TiDetail,F.UsFirstName,F.UsLastName,B.ProID,C.ProName,D.UnDetail,B.OrtPrice,B.OrtNum,B.OrtTotal,");
                sb.Append(" A.OrdStatus,A.OrdTotal,A.OrdDisc,A.OrdNet");
                sb.Append(" INTO _repOrder" + DBConnString.pUsID);//ใส่ในตารางที่สร้างขึ้นใหม่
                sb.Append(" FROM tblOrder A INNER JOIN tblOrderTrn B ON A.OrdID=B.OrdID");
                sb.Append(" LEFT JOIN tblProduct C ON B.ProID=C.ProID");
                sb.Append(" LEFT JOIN tblSetUnit D ON C.UnID=D.UnID");
                sb.Append(" LEFT JOIN tblSetCompany E ON E.CpID=A.CpID");
                sb.Append(" LEFT JOIN tblSetUser F ON F.UsID=A.UsID");
                sb.Append(" LEFT JOIN tblSetTitle G ON G.TiID=F.TiID");
                sb.Append(" WHERE A.OrdID=@OrdID");

                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("@OrdID", SqlDbType.NVarChar).Value = txtOrdID.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 " + "_repOrder" + DBConnString.pUsID;
                SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn);
                repOrder_DATA  ds    = new repOrder_DATA();
                dscmd.Fill(ds, "repOrder");
                cnn.Close();

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

                repOrder objRpt = new repOrder();
                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;
            }
        }