private void generatePreview(BarcodeData data) { IDataMatrixService service = new DataMatrixService(); byte[] imgContent = service.GetDataMatrix(data, ImageFormat.Png); imgPreview.Src = string.Format("data:image/png;base64,{0}", Convert.ToBase64String(imgContent)); }
void historyGrid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) { return; } IDataMatrixService service = new DataMatrixService(); DataMatrixHistoryItem historyItem = e.Row.DataItem as DataMatrixHistoryItem; System.Web.UI.WebControls.Image codePreview = e.Row.FindControl("imgCode") as System.Web.UI.WebControls.Image; XmlSerializer serializer = new XmlSerializer(typeof(BarcodeData)); BarcodeData data = serializer.Deserialize(new StringReader(historyItem.Content)) as BarcodeData; byte[] imgContent = service.GetDataMatrix(data, ImageFormat.Png); codePreview.ImageUrl = string.Format("data:image/png;base64,{0}", Convert.ToBase64String(imgContent)); (e.Row.FindControl("lName") as Literal).Text = data.Name; (e.Row.FindControl("lAddress") as Literal).Text = data.Address; (e.Row.FindControl("lPost") as Literal).Text = data.Post; (e.Row.FindControl("lAmount") as Literal).Text = data.Amount.ToString(); (e.Row.FindControl("lReceiving") as Literal).Text = data.Receiving.ToString(); (e.Row.FindControl("lNotes") as Literal).Text = data.Notes.IndexOf('|') >= 0 ? data.Notes.Remove(0, data.Notes.IndexOf('|') + 1) : data.Notes; (e.Row.FindControl("lDepartment") as Literal).Text = data.Department; Literal status = e.Row.FindControl("lStatusWysylki") as Literal; //if (!data.SendDate.HasValue && string.IsNullOrEmpty(data.SentBy)) //{ // status.Text = string.Format(""); //} if (data.SendDate.HasValue && !string.IsNullOrEmpty(data.SentBy) && string.IsNullOrEmpty(data.RKWNumber)) { status.Text = string.Format("Przekazano do wysyłki. Użytkownik: {0}", data.SentBy); } if (!data.SendDate.HasValue && !string.IsNullOrEmpty(data.SentBy)) { status.Text = string.Format("Anulowano przekazanie do wysyłki. Użytkownik: {0}", data.SentBy); } if (data.SendDate.HasValue && !string.IsNullOrEmpty(data.SentBy) && !string.IsNullOrEmpty(data.RKWNumber)) { status.Text = string.Format("Zarejestrowano w Rejestrze Korespondencji Wychodzącej dn. {2:yyyy-MM-dd} o godz. {2:HH:mm). Nr poz.: {0}. Użytkownik: {1}", data.RKWNumber, data.SentBy, data.SendDate); } }