private void btnDelRewardCard_Click(object sender, RoutedEventArgs e)
        {
            RewardCardInfo lvc = (RewardCardInfo)lvRewardCard.SelectedItem;

            if (lvc == null)
            {
                Button btn = sender as Button;
                lvc = station.RewardCardInfoes.Single(p => p.Id == Convert.ToInt32(btn.Tag));
                if (lvc != null)
                {
                    goto perform;
                }
                MessageBox.Show("请选中您要删除的奖励卡");
                return;
            }

perform:
            if (MessageBox.Show("您确定要删除?", "提示", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
            {
                return;
            }
            station.RewardCardInfoes.Remove(lvc);
            LoginedUserInfo us = Tools.GetLoginedUserInfo();

            entities.Logs.Add(new Log
            {
                UGuid    = us.UGuid,
                Username = us.UName,
                Memo     = $"删除编号为【{lvc.Id}】-姓名为【{lvc.CardName}】的奖励卡信息",
                OptType  = (int)OptType.除,
                OptTime  = DateTime.Now
            });
            entities.SaveChanges();
            _rewardCardInfos.Remove(lvc);
        }
        private void btnAddInfo_Click(object sender, RoutedEventArgs e)
        {
            StationModifiedType type = cboAddedType.SelectedItem as StationModifiedType;
            string   memo            = txtAddedMemo.GetTextBoxText();
            DateTime?time            = txtDateTime.SelectedDate;

            if (type == null || memo.IsNullOrEmpty() || null == time)
            {
                "输入变更的信息".MessageBoxDialog();
                return;
            }

            StationModifiedInfo info = new StationModifiedInfo
            {
                StationModifiedType = type,
                ModifiedTime        = (DateTime)time,
                Memo = memo
            };

            station.StationModifiedInfoes.Add(info);
            entities.SaveChanges();

            LoginedUserInfo us = Tools.GetLoginedUserInfo();

            entities.Logs.Add(new Log
            {
                UGuid    = us.UGuid,
                Username = us.UName,
                Memo     = $"添加编号为【{info.Id}】的网点变更信息",
                OptType  = (int)OptType.新增,
                OptTime  = DateTime.Now
            });
            entities.SaveChanges();
            stationModifiedInfos.Add(info);
        }
示例#3
0
        private void btnChange_Click(object sender, RoutedEventArgs e)
        {
            string info;

            if (VerifyInput(out info, true))
            {
                return;
            }

            StationModifiedType type = cboAllTypes.SelectedItem as StationModifiedType;
            int index = lvModifiedTypes.IndexOf(type);

            type.TypeName = info;
            LoginedUserInfo us = Tools.GetLoginedUserInfo();

            entities.Logs.Add(new Log
            {
                UGuid    = us.UGuid,
                Username = us.UName,
                Memo     = $"编辑编号为【{type.Id}】的网点变更类型",
                OptType  = (int)OptType.修改,
                OptTime  = DateTime.Now
            });
            entities.SaveChanges();
            lvModifiedTypes.Remove(type);
            lvModifiedTypes.Insert(index, type);
        }
示例#4
0
        //查看网点照片
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Button         btn     = sender as Button;
            LotteryStation station = alLotteryStations.FirstOrDefault(p => p.Id == Convert.ToInt32(btn.Tag));

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

            PhotoCollection photo = new PhotoCollection();

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

            ImageViewer viewer = new ImageViewer(photo)
            {
                ImageAllowDrop = Tools.LoginUserHasRights()
            };
            Window win = new Window
            {
                Width   = 400,
                Height  = 400,
                Content = viewer,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Owner = Application.Current.MainWindow
            };

            win.ShowDialog();

            if (!viewer.IsChanged)
            {
                return;
            }
            if (MessageBox.Show("是否提交更改变?", "提交", MessageBoxButton.OKCancel) != MessageBoxResult.OK)
            {
                return;
            }
            var dicAllPhoto = viewer.Photos.ToDictionary(ph => ph.PhotoName, ph => ph.base64Value);

            station.StationPicListSerialized = JsonConvert.SerializeObject(dicAllPhoto);
            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();
        }
示例#5
0
        private void btnAllSubmit_Click(object sender, RoutedEventArgs e)
        {
            #region 网点信息

            string stationCode            = txtStationCode.GetTextBoxText();
            string stationSpecificAddress = txtStationSpecificAddress.GetTextBoxText();
            string stationTarget          = txtStationTarget.GetTextBoxText();
            string stationPhoneNo         = txtStationPhoneNo.GetTextBoxText();

            if (stationCode.IsNullOrEmpty())
            {
                "输入网点编号".MessageBoxDialog();
                return;
            }
            if (stationSpecificAddress.IsNullOrEmpty())
            {
                "输入销售站详细地址".MessageBoxDialog();
                return;
            }
            if (stationTarget.IsNullOrEmpty())
            {
                "输入标的物".MessageBoxDialog();
                return;
            }
            if (stationPhoneNo.IsNullOrEmpty())
            {
                "输入网点电话".MessageBoxDialog();
                return;
            }

            StationRegion region = cmbStationRegion.SelectedItem as StationRegion;
            if (null == region)
            {
                "选择区域".MessageBoxDialog();
                return;
            }

            string manageType      = cmbStationManageType.Text;
            string manageTypeChild = cmbStationManageTypeChild.Text;
            if (manageType.IsNullOrEmpty() || manageTypeChild.IsNullOrEmpty())
            {
                "选择销售站类型".MessageBoxDialog();
                return;
            }

            string usableArea = txtUsableArea.GetTextBoxText();
            if (usableArea.IsNullOrEmpty())
            {
                "输入店面经营使用面积".MessageBoxDialog();
                return;
            }
            string rentDiscount = txtRentDiscount.GetTextBoxText();
            if (usableArea.IsNullOrEmpty())
            {
                "输入租金折价".MessageBoxDialog();
                return;
            }
            DateTime?establishedTime = datePickerCtl.SelectedDate;
            if (!establishedTime.HasValue)
            {
                "选择设立日期".MessageBoxDialog();
                return;
            }
            //销售站店面产权[0:租赁 1:自有]
            bool propertyRight = Convert.ToBoolean(cmbPropertyRight.SelectedIndex);
            //站点单双机情况[0:单机 1:双机]
            bool machineTpe = Convert.ToBoolean(cmbMachineType.SelectedIndex);
            //通讯类型[0:ADSL 1:CDMA]
            bool   communicationType  = Convert.ToBoolean(cmbCommunicationType.SelectedIndex);
            string relatedPhoneNetNum = txtRelatedPhoneNetNum.GetTextBoxText();
            if (relatedPhoneNetNum.IsNullOrEmpty())
            {
                "输入关联电话网络号".MessageBoxDialog();
                return;
            }
            //代销证编号
            string agencyNum = txtAgencyNum.GetTextBoxText();
            if (agencyNum.IsNullOrEmpty())
            {
                "输入代销证编号".MessageBoxDialog();
                return;
            }
            string depositCardNo = txtDepositCardNo.GetTextBoxText();
            if (depositCardNo.IsNullOrEmpty())
            {
                "输入交款卡卡号".MessageBoxDialog();
                return;
            }
            string violation = txtViolation.GetTextBoxText();//可不添

            Administrator admin = cboAdmin.SelectedItem as Administrator;
            if (null == admin)
            {
                "请选择管理员".MessageBoxDialog();
                return;
            }

            string guaranteeName = txtGuaranteeName.GetTextBoxText();
            if (guaranteeName.IsNullOrEmpty())
            {
                "输入担保人姓名".MessageBoxDialog();
                return;
            }
            PhotoCollection guaranteeCollection = GuaranteeIdentity.Photos;
            if (guaranteeCollection.Count != 2)
            {
                "请添加担保人身份证正反面照片!".MessageBoxDialog();
                return;
            }
            string guaranteePicBase64 = GuaranteeIdentity.IsChanged?JsonConvert.SerializeObject(guaranteeCollection.ToDictionary(key => key.PhotoName, value => value.base64Value)):null;

            #endregion

            #region 机主信息

            string hostName            = HostInformation.txtHostName.GetTextBoxText();
            string hostPhoneNum1       = HostInformation.txtHostPhoneNum1.GetTextBoxText();
            string hostPhoneNum2       = HostInformation.txtHostPhoneNum2.GetTextBoxText();
            string hostIdentityNo      = HostInformation.txtHostIdentityNo.GetTextBoxText();
            string hostIdentityAddress = HostInformation.txtHostIdentityAddress.GetTextBoxText();

            if (hostName.IsNullOrEmpty() || hostPhoneNum1.IsNullOrEmpty() || hostPhoneNum2.IsNullOrEmpty() || hostIdentityNo.IsNullOrEmpty() || hostIdentityAddress.IsNullOrEmpty())
            {
                "添写机主的完整信息".MessageBoxDialog();
                return;
            }

            // PhotoCollection hostPicCol = HostInformation.hostIdentityPic.Photos;
            if (HostInformation.DropImageCount != 2)
            {
                "请添加机主身份证正反面照片!".MessageBoxDialog();
                return;
            }
            #endregion

            PhotoCollection collection = ViewerStationPic.Photos;

            if (collection.Count < 1)
            {
                "请添加网点照片!".MessageBoxDialog();
                return;
            }

            string allPhotoBase64 = ViewerStationPic.IsChanged?JsonConvert.SerializeObject(collection.ToDictionary(photo => photo.PhotoName, photo => photo.base64Value)):null;

            station.Administrator = admin;

            // Salesclerks = _addedSalesclerks,
            station.StationCode            = stationCode;
            station.StationPhoneNo         = stationPhoneNo;
            station.StationSpecificAddress = stationSpecificAddress;
            station.StationTarget          = stationTarget;
            station.StationRegion          = region;
            //RegionId = region.Id;
            station.MachineType    = machineTpe;
            station.ManageTypeName = manageType;
            station.ManageTypeProgencyListSerialized = manageTypeChild;    //现没有多选 所以没有序列化
            if (!allPhotoBase64.IsNullOrEmpty())
            {
                station.StationPicListSerialized = allPhotoBase64;
            }
            station.WelfareGameTypeListSerialized = JsonConvert.SerializeObject(cbxListBox.GameTypeSelectedCollection);

            station.AgencyNum           = agencyNum;
            station.UsableArea          = usableArea;
            station.EstablishedTime     = establishedTime;
            station.RentDiscount        = rentDiscount;
            station.RelatedPhoneNetNum  = relatedPhoneNetNum;
            station.Violation           = violation;
            station.PropertyRight       = propertyRight;
            station.CommunicationType   = communicationType;
            station.DepositCardNo       = depositCardNo;
            station.HostName            = hostName;
            station.HostIdentityNo      = hostIdentityNo;
            station.HostPhoneNum        = $"{hostPhoneNum1}⊙{hostPhoneNum2}";
            station.HostIdentityAddress = hostIdentityAddress;
            if (!HostInformation.HostPic.IsNullOrEmpty())
            {
                station.HostBase64Pic = HostInformation.HostPic;
            }
            if (HostInformation.hostIdentityPic.IsChanged)
            {
                station.HostBase64IdentityPic = HostInformation.Identity;
            }
            station.GuaranteeName = guaranteeName;
            if (!guaranteePicBase64.IsNullOrEmpty())
            {
                station.GuaranteeBase64IdentityPic = guaranteePicBase64;
            }

            //如不用同一个上下文  这时会出现An entity object cannot be referenced by multiple instances of IEntityChangeTracker 或一个实体对象不能由多个 IEntityChangeTracker 实例引用的异常
            entities.LotteryStations.AddOrUpdate(station);
            LoginedUserInfo u = Tools.GetLoginedUserInfo();
            entities.Logs.Add(new Log
            {
                UGuid    = u.UGuid,
                Username = u.UName,
                Memo     = $"更新网点编号为【{stationCode}】的网点",
                OptType  = (int)OptType.修改,
                OptTime  = DateTime.Now
            });
            entities.SaveChanges();
            "更新成功".MessageBoxDialog();
        }
示例#6
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = sender as MenuItem;

            DBModels.Salesclerk salesclerk = clerkListBox.SelectedItem as DBModels.Salesclerk;
            if (salesclerk == null || null == item)
            {
                return;
            }
            LoginedUserInfo user = Tools.GetLoginedUserInfo();

            switch (item.Header.ToString())
            {
            case "增加":
                AddSalesclerk cler = new AddSalesclerk {
                    Owner = this
                };
                var resurnValue = cler.ShowDialog();
                if (!resurnValue.GetValueOrDefault())
                {
                    return;
                }
                DBModels.Salesclerk value = cler.TryFindResource("InputResult") as DBModels.Salesclerk;
                station.Salesclerks.Add(value);
                entities.SaveChanges();

                entities.Logs.Add(new Log
                {
                    UGuid    = user.UGuid,
                    Username = user.UName,
                    Memo     = $"添加编号为【{value.Id}】的销售员",
                    OptType  = (int)OptType.新增,
                    OptTime  = DateTime.Now
                });
                entities.SaveChanges();

                collection.Add(value);
                break;

            case "修改":
                AddSalesclerk clerk = new AddSalesclerk(salesclerk)
                {
                    txtName               = { Text = salesclerk.Name },
                    txtPhone              = { Text = salesclerk.Phone },
                    txtIdentityNo         = { Text = salesclerk.IdentityNo },
                    txtIdentityAddress    = { Text = salesclerk.IdentityAddress },
                    HeadPortraitBase64Pic =
                    {
                        Source = u.ByteArrayToBitmapImage(Convert.FromBase64String(salesclerk.HeadPortraitBase64Pic))
                    },
                    Owner = this
                };

                bool?b = clerk.ShowDialog();
                if (!b.GetValueOrDefault())
                {
                    return;
                }
                DBModels.Salesclerk result = clerk.FindResource("InputResult") as DBModels.Salesclerk;

                entities.Salesclerks.AddOrUpdate(result);
                entities.Logs.Add(new Log
                {
                    UGuid    = user.UGuid,
                    Username = user.UName,
                    Memo     = $"编辑编号为【{result.Id}】的销售员",
                    OptType  = (int)OptType.修改,
                    OptTime  = DateTime.Now
                });
                entities.SaveChanges();

                var aaa   = collection.FirstOrDefault(p => p.Id == result.Id);
                var index = collection.IndexOf(aaa);
                collection.Remove(aaa);
                collection.Insert(index, result);
                break;

            case "删除":
                if (MessageBox.Show("您确定要删除?", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
                {
                    station.Salesclerks.Remove(salesclerk);
                    entities.Logs.Add(new Log
                    {
                        UGuid    = user.UGuid,
                        Username = user.UName,
                        Memo     = $"删除编号为【{salesclerk.Id}】-名字为【{salesclerk.Name}】的销售员",
                        OptType  = (int)OptType.除,
                        OptTime  = DateTime.Now
                    });
                    entities.SaveChanges();
                    collection.Remove(salesclerk);
                }
                break;
            }
            e.Handled = true;
        }