#region 打印图片
public bool printpicture(string ID)
{
bool res = false;
MExaminee = BExaminee.GetModel(Convert.ToInt32(ID));
if (MExaminee != null)
{
try
{
Bitmap bp = new Bitmap(Server.MapPath("../images/") + "tzs.jpg");
Bitmap photo = new Bitmap(Server.MapPath("../StuPic/") + MExaminee.TestNum.Trim() + ".JPG");
using (Graphics g = Graphics.FromImage(bp))
{
g.DrawString(MExaminee.Name, new System.Drawing.Font("华文楷体", 16),
Brushes.Black, new PointF(570, 865));
g.DrawString(MExaminee.Department + " " + MExaminee.Profession, new System.Drawing.Font("华文楷体", 16),
Brushes.Black, new PointF(670, 1165));
g.DrawString("2016 6", new System.Drawing.Font("华文楷体", 16),
Brushes.Black, new PointF(2100, 1725));
g.DrawImage(photo, 2322, 370, 370, 450);
Code.BarCode.Code128 _Code = new Code.BarCode.Code128();
Bitmap imgTemp = _Code.GetCodeImage(MExaminee.TestNum.Trim(), Code.BarCode.Code128.Encode.Code128C);
g.DrawImage(imgTemp, 2332, 830, 350, 80);
g.Flush();
imgTemp.Dispose();
}
string ImgUrl = Server.MapPath("../Photo/") + MExaminee.Department.Trim() + "_" + MExaminee.TestNum.Trim() + "_" + MExaminee.Name.Trim() + ".jpg";
if (System.IO.File.Exists(ImgUrl))
{
System.IO.File.Delete(ImgUrl);
}
bp.Save(ImgUrl);
bp.Dispose();
photo.Dispose();
MExaminee.Status = 1;//默认0,未处理;1,处理;2,处理出错;
BExaminee.Update(MExaminee);
res = true;
}
catch (Exception ex)
{
MExaminee.Status = 2;
BExaminee.Update(MExaminee);
res = false;
}
}
return res;
}
#endregion |
|