コード例 #1
0
        public void IsEnabledControl()
        {
            gridStation.Children.OfType <TextBox>().ToList().ForEach(p => p.IsEnabled = Tools.LoginUserHasRights());
            txtViolation.IsEnabled = true;
            gridStation.Children.OfType <ComboBox>().ToList().ForEach(p => p.IsEnabled = Tools.LoginUserHasRights());
            GuaranteeIdentity.ImageAllowDrop = Tools.LoginUserHasRights();

            HostInformation.EnableAllControl();

            clerkListBox.IsEnabled = Tools.LoginUserHasRights();

            ViewerStationPic.ImageAllowDrop = Tools.LoginUserHasRights();
        }
コード例 #2
0
        //机主信息
        private void Button_Click_7(object sender, RoutedEventArgs e)
        {
            Button         btn     = sender as Button;
            LotteryStation station = alLotteryStations.FirstOrDefault(p => p.Id == Convert.ToInt32(btn.Tag));

            if (null == station)
            {
                return;
            }
            string[] hostPhoneNum = station.HostPhoneNum.Split('⊙');

            HostInformation hostInfo = new HostInformation
            {
                txtHostPhoneNum1       = { Text = hostPhoneNum[0] },
                txtHostPhoneNum2       = { Text = hostPhoneNum[1] },
                txtHostIdentityAddress = { Text = station.HostIdentityAddress },
                txtHostName            = { Text = station.HostName },
                txtHostIdentityNo      = { Text = station.HostIdentityNo },
                HostBase64Pic          = { Source = u.ByteArrayToBitmapImage(Convert.FromBase64String(station.HostBase64Pic)) }
            };

            hostInfo.EnableAllControl();

            var result = JsonConvert.DeserializeObject <Dictionary <string, string> >(station.HostBase64IdentityPic);

            PhotoCollection photo = hostInfo.hostIdentityPic.Photos;

            result.Keys.ToList().ForEach(k => photo.Add(new Photo(k)
            {
                Image = u.ByteArrayToBitmapImage(Convert.FromBase64String(result[k]))
            }));

            Window win = new Window
            {
                Width  = 350,
                Height = 450,
                Owner  = Application.Current.MainWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Content = hostInfo
            };

            win.Closing += (a, b) =>
            {
                bool changed = false;

                string hostPhoneNum1 = hostInfo.txtHostPhoneNum1.GetTextBoxText();
                string hostPhoneNum2 = hostInfo.txtHostPhoneNum2.GetTextBoxText();

                string hostN = hostInfo.txtHostName.GetTextBoxText();
                if (!hostN.IsNullOrEmpty())
                {
                    changed          = station.HostName != hostN;
                    station.HostName = hostN;
                }
                if ((!hostPhoneNum1.IsNullOrEmpty() && !hostPhoneNum2.IsNullOrEmpty()))
                {
                    var t = $"{hostPhoneNum1}⊙{hostPhoneNum2}";
                    changed = changed || station.HostPhoneNum != t;
                    station.HostPhoneNum = t;
                }
                if (!hostInfo.txtHostIdentityNo.GetTextBoxText().IsNullOrEmpty())
                {
                    changed = changed || station.HostIdentityNo != hostInfo.txtHostIdentityNo.GetTextBoxText();
                    station.HostIdentityNo = hostInfo.txtHostIdentityNo.GetTextBoxText();
                }
                if (!hostInfo.txtHostIdentityAddress.GetTextBoxText().IsNullOrEmpty())
                {
                    changed = changed || station.HostIdentityAddress != hostInfo.txtHostIdentityAddress.GetTextBoxText();
                    station.HostIdentityAddress = hostInfo.txtHostIdentityAddress.GetTextBoxText();
                }
                if (null != hostInfo.HostPic)
                {
                    station.HostBase64Pic = hostInfo.HostPic;
                    changed = true;
                }
                if (hostInfo.hostIdentityPic.IsChanged)
                {
                    station.HostBase64IdentityPic = hostInfo.Identity;
                    changed = true;
                }

                if (changed)
                {
                    LoginedUserInfo us = Tools.GetLoginedUserInfo();
                    entities.Logs.Add(new Log
                    {
                        UGuid    = us.UGuid,
                        Username = us.UName,
                        Memo     = $"编辑编号为【{station.Id}】-站点编号为【{station.StationCode}】的机主信息",
                        OptType  = (int)OptType.修改,
                        OptTime  = DateTime.Now
                    });
                }

                entities.SaveChanges();
                btn.Content = station.HostName;
            };
            win.ShowDialog();
        }