Пример #1
0
        //生成二维码
        private void BtnCreateQr_BtnClick(object sender, EventArgs e)
        {
            var rows = DataGrid.SelectRows;

            if (rows != null)
            {
                var ids = string.Empty;
                rows.ForEach(p => ids += $"{((AssetsInformation)((UCDataGridViewRow)p).DataSource).id},");
                ids = ids.TrimEnd(',');
                using (var db = new AssetsInformationDB(dbPath))
                {
                    var list = db.Query <AssetsInformation>($"select * from assetsinformation where id in ({ids})");
                    if (list != null && list.Any())
                    {
                        foreach (var item in list)
                        {
                            item.QdPath = QRCodeHelper.CreateQRCodeImage(new QRCodeMsg()
                            {
                                Content   = $"资产编码:{item.AssetCode}\r\n资产名称:{item.AssetName}\r\n资产类型:{item.AssetModel}\r\n管理部门:{item.ManagementDepartment}\r\n使用部门:{item.UseDepartment}\r\n使用状态:{item.UseState}\r\n使用年限:{item.UseDate}\r\n使用地点:{item.UsePlace}\r\n安装日期:{item.InstallationDate}",
                                ImageName = $"{item.AssetCode}{DateTime.Now.ToLongDateString()}{DateTime.Now.Hour}{DateTime.Now.Minute}{DateTime.Now.Second}",
                                FilePath  = $"{Environment.CurrentDirectory}"
                            });
                        }
                        db.UpdateAll(list);
                    }
                }
                FrmTips.ShowTips(this, $"二维码生成成功!", 3000, true, ContentAlignment.MiddleCenter, null,
                                 TipsSizeMode.Large, new Size(200, 80), TipsState.Success);
                GetList();
            }
        }