Esempio n. 1
0
        public void ShowInputControl(string message)
        {
            this.Controls.RemoveByKey(ManualInsertDataControl.MANUALINSERT_DATACONTROL_NAME);
            ManualInsertDataControl cnt = new ManualInsertDataControl();

            cnt.Name        = ManualInsertDataControl.MANUALINSERT_DATACONTROL_NAME;
            cnt.Message     = message;
            cnt.Location    = new Point(10, 10);
            cnt.MinimumSize = new Size(134, 65);
            this.Controls.Add(cnt);
        }
Esempio n. 2
0
        public void ExportAndCloseAsync()
        {
            if (this.Parent != null)
            {
                IntPtr main = this.Parent.Handle;

                Voucher bData = Canvas.Data;
                bData.VoucherImage = (Bitmap)Canvas.BackgroundImage;

                var cnts = Canvas.Controls.Find(ManualInsertDataControl.MANUALINSERT_DATACONTROL_NAME, true);
                if (cnts != null && cnts.Length != 0)
                {
                    ManualInsertDataControl cnt = (ManualInsertDataControl)cnts[0];
                    if (!string.IsNullOrEmpty(cnt.BarCodeString))
                    {
                        bData.Parse(cnt.BarCodeString);
                    }
                    else
                    {
                        string[] str = cnt.BarCodeNumberGroups;
                        bData.CountryID = int.Parse(str[0]);
                        //bData.Business = int.Parse(str[1]);
                        bData.RetailerID    = int.Parse(str[2]);
                        bData.VoucherID     = str[3];
                        bData.BarCodeString = string.Format("{0:000}{1:00}{2:000000}{3:000000000}",
                                                            bData.CountryID, "na", bData.RetailerID, bData.VoucherID);
                    }
                }

                new Action <Voucher>((data) =>
                {
                    Debug.Assert(data != null);
                    Debug.Assert(data.VoucherImage != null);

                    lock (data.VoucherImage)
                    {
                        try
                        {
                            DelegateUtils.CreateAuditIdReloadDelegate().FireAndForget();

                            data.SiteCode = AuditIDSTable.SelectRemoveFirstOrEmpty().ThrowIfDefault <string, AppExclamationException>();

                            data.Validate();

                            ClientDataAccess.UpdateFileAsync((DbClientVoucher)data,
                                                             new EventHandler((o, s) =>
                            {
                                string fileName = Path.ChangeExtension(
                                    string.Format("{0}{1}", PTFUtils.GetMachine(),
                                                  DateTime.Now).ReplaceAll(new char[] { '.', '/', '\\', '-' }, '_'), ".xml");

                                //Data has been saved successfully.
                                string text = string.Concat(Strings.VScan_ItemSaved, fileName);
                                WinMsg.SendText(main, text);
                                this.InvokeSf(() =>
                                {
                                    //Set DialogResult OK
                                    //Or else the form will resign to close
                                    this.DialogResult = DialogResult.OK;
                                    this.Close();
                                });
                            }),
                                                             //No error handling.
                                                             //General processing handler.
                                                             null);
                        }
                        catch (Exception ee)
                        {
                            ee.AddNext(new MethodInvoker(() =>
                            {
                                Canvas.InvokeSf(() =>
                                {
                                    Canvas.ShowInputControl(ee.Message);
                                });
                            }));
                            throw;
                        }
                    }
                }).FireAndForget(bData);
            }
        }