|
|
|
สอบถามการออก รายงานแสดงผลรูปภาพหน่อยครับ Crystal Report |
|
|
|
|
|
|
|
ต้องการให้ภาพออกมาในลักษณะนี้ครับ
แต่ภาพที่ออกมาเป็นแบบนี้ ครับ ถ้าเรียงเหมือนภาพข้างบนข้อมูลจะซ้ำกันครับ
code ส่งไป Report ตามนี้ครับ
Code (C#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using CrystalDecisions.CrystalReports.Engine;
namespace ProgramDemoHR
{
public partial class Reportcard : DevExpress.XtraEditors.XtraForm
{
DataTable dt = new DataTable();
public Reportcard()
{
InitializeComponent();
this.btnadd.Click += new EventHandler(btnadd_Click);
ShowreportCard1();
}
private void btnadd_Click(object sender, EventArgs e)
{
string str = "";
for (int i = 0; i < gridView1.RowCount; i++)
{
//Console.WriteLine(gridView1.GetRowCellValue(i, "chk"));
if (Convert.ToBoolean(gridView1.GetRowCellValue(i, "chk")) == true)
{
str += gridView1.GetRowCellValue(i, "employee_ID") + ",";
}
}
if (str != "")
{
str = str.Substring(0, str.Length - 1);
ShowReportCard(str);
}
}
private void ShowreportCard1()
{
DataTable dt = new DataTable();
string sql = "SELECT cast(0 as bit) As chk,employee.Emp_ID, employee.employee_ID, employee.nameth, employee.startday,dept.dept_name, position.pos_nameth, position.pos_nameeng, party.party_name, employee.pic FROM tbl_Employee AS employee INNER JOIN tbl_Position AS position ON employee.position_ID = position.position_ID INNER JOIN tbl_Party AS party ON employee.party_ID = party.party_ID INNER JOIN tbl_Department AS dept ON employee.dept_ID = dept.dept_ID WHERE employee.statusemp_ID = '1' AND employee.employee_ID LIKE '1%'";
dt = connect_db.SelectData(sql);
dgvmaincardcode1.DataSource = dt;
}
private void ShowReportCard(string id)
{
DataTable dt = new DataTable();
string sql = "SELECT employee.Emp_ID, employee.employee_ID, employee.nameth, employee.startday, position.pos_nameth, dept.dept_name, position.pos_nameeng, party.party_name, employee.pic FROM tbl_Employee AS employee INNER JOIN tbl_Position AS position ON employee.position_ID = position.position_ID INNER JOIN tbl_Party AS party ON employee.party_ID = party.party_ID INNER JOIN tbl_Department AS dept ON employee.dept_ID = dept.dept_ID WHERE employee.Employee_ID In (" + id + ") AND employee.statusemp_ID = '1' AND employee.employee_ID LIKE '1%'";
dt = connect_db.SelectData(sql);
dt.Columns.Add("picImg", System.Type.GetType("System.Byte[]"));
for (int i = 0; i < dt.Rows.Count; i++)
{
//Console.WriteLine(("\\192.168.0.8\pic\"+dt.Rows[i]["pic"].ToString()));
dt.Rows[i]["picImg"] = setImageToDatatable(@"\\127.0.0.1\pic\" + dt.Rows[i]["pic"]);
}
viewreport rptf = new viewreport();
CrystalReport2 rpt = new CrystalReport2();
rpt.SetDataSource(dt);
rptf.crv.ReportSource = rpt;
rptf.Show();
}
private Byte[] setImageToDatatable(string URL)
{
Byte[] buffer;
Byte[] pic;
buffer = System.IO.File.ReadAllBytes(URL);
System.IO.MemoryStream stream = new System.IO.MemoryStream(buffer);
System.IO.BinaryReader binReader = new System.IO.BinaryReader(stream);
pic = binReader.ReadBytes((int)stream.Length);
return pic;
}
}
}
Tag : .NET, Ms SQL Server 2008, Crystal Report, Win (Windows App), C#
|
|
|
|
|
|
Date :
2017-02-28 16:36:44 |
By :
kittisak30 |
View :
1509 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
กำหนดให้แสดงผลแบบ Column ได้ครับ
|
|
|
|
|
Date :
2017-02-28 21:30:04 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ ขอบคุรมากครับ Admin
|
|
|
|
|
Date :
2017-02-28 23:36:23 |
By :
kittisak30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
จัดไปครับ
|
|
|
|
|
Date :
2017-03-01 09:46:18 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|