Esempio n. 1
0
        /**
         * 对VIP账号信息进行模糊查询
         * */
        private void LoadVIP()
        {
            if (MemberPhone.Text == "" && MemberName.Text == "")
            {
                return;
            }
            String MbPhone = MemberPhone.Text;
            String MbName  = MemberName.Text;
            List <MemberInfoData> memberInfoDatas = MemberInfoConnector.GetMembers(MbPhone, MbName);

            if (memberInfoDatas.Count > 1)
            {
                return;
            }
            else if (memberInfoDatas.Count == 0)
            {
                return;
            }
            else
            {
                MemberInfo                  = memberInfoDatas[0];
                MemberMoney.Content         = "¥" + MemberInfo.MbMoney;                           //加载账户余额
                MemberType                  = MemberInfoConnector.GetMemberType(MemberInfo.MbId); //获得账户会员类型
                MemberTypeLabel.Content     = MemberType.MTitle;
                MemberDiscountLabel.Content = MemberType.MDiscount;                               //折扣
                shouldPayLabel.Content      = summaryMoney * MemberType.MDiscount;
                shouldPay = summaryMoney * MemberType.MDiscount;
                leftMoney = MemberInfo.MbMoney;
            }
        }
Esempio n. 2
0
        /**
         * 添加会员类型
         * 1. 检查两个输入框是否为空
         * 2. 检查折扣是否为数字
         * 3. 后台查重
         * */
        private void AddTypeButton_Click(object sender, RoutedEventArgs e)
        {
            if (MemberTypeBox.Text == "" || MemberDiscountBox.Text == "")
            {
                MessageBox.Show("信息填写不完整");
                return;
            }

            if (!double.TryParse(MemberDiscountBox.Text, out double MDiscount) || MDiscount > 1)
            {
                MessageBox.Show("请填写正确的折扣");
                return;
            }

            int InsertTypeResult = MemberInfoConnector.InsertMemberType(MemberTypeBox.Text, MDiscount);

            if (InsertTypeResult == -1)
            {
                MessageBox.Show("已存在的类型");
                return;
            }
            else if (InsertTypeResult != 1)
            {
                MessageBox.Show("添加失败");
                return;
            }
            else
            {
                MessageBox.Show("添加成功");
                MemberTypeBox.Text           = "";
                MemberDiscountBox.Text       = "";
                MemberTypeList.SelectedIndex = -1;
                LoadAllTypes();
            }
        }
Esempio n. 3
0
        /*
         * 删除会员类型的函数(2、3、4均后台实现)
         * 1. 检查选中
         * 2. 检查是否存在
         * 3. 将已有的该类型的会员的类型id改为5(普通会员)
         * 4. 删除会员
         * */
        private void DeleteSelectedButton_Click(object sender, RoutedEventArgs e)
        {
            if (MemberTypeList.SelectedIndex == -1)
            {
                MessageBox.Show("未选中任何类型");
                return;
            }

            int DeleteTypeResult =
                MemberInfoConnector.DeleteMemberType(((InfomationTable)MemberTypeList.SelectedItem).Left_TB.Text);

            if (DeleteTypeResult == -1)
            {
                //从界面上选择删除,一般不会不存在,这个提示出现的时候一般是逻辑出了问题
                MessageBox.Show("不存在的类型");
                return;
            }

            else
            {
                MessageBox.Show("删除成功");
                MemberTypeBox.Text           = "";
                MemberDiscountBox.Text       = "";
                MemberTypeList.SelectedIndex = -1;
                LoadAllTypes();
            }
        }
Esempio n. 4
0
 /**
  * 加载所有会员的方法
  * */
 private void LoadAllMember()
 {
     if(memberInfoDatas != null)
         for (int i = 0; i < memberInfoDatas.Count; i++)
             MemberList.Items.RemoveAt(0);
     memberInfoDatas = MemberInfoConnector.GetMembers();
     foreach (MemberInfoData infoData in memberInfoDatas)
     {
         /*
          * 没有给它写专门的控件,把买单的拿来用了
          * 对应关系:
          * DName    --会员类型
          * DPrice   --姓名
          * DNumber  --余额
          * DSum     --手机号
          * */
         MemberTypeData memberTypeData = MemberInfoConnector.GetMemberType(infoData.MtId);
         ListBoxItem listBoxItem = new ListBoxItem();
         PayInfo info = new PayInfo();
         info.DName.Text = memberTypeData.MTitle;
         info.DPrice.Text = infoData.MbName;
         info.DNumber.Text = infoData.MbMoney.ToString();
         info.DSum.Text = infoData.MbPhone;
         listBoxItem.Content = info;
         MemberList.Items.Add(listBoxItem);
     }
 }
Esempio n. 5
0
        /**
         * 删除会员:
         * 判断是否选中,没有选中直接返回
         * 对选中的值进行提取,删除数据库中的数据
         * */
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            if(MemberList.SelectedIndex == -1)
            {
                MessageBox.Show("请先选中会员信息!");
                return;
            }
            ListBoxItem listBoxItem = (ListBoxItem)MemberList.SelectedItem;
            PayInfo payInfo = (PayInfo)listBoxItem.Content;
            /*MemberTypes.SelectedIndex = MemberInfoConnector.GetMemberType(payInfo.DName.Text).MtId - 1;
            MemberName.Text = payInfo.DPrice.Text;
            MemberMoney.Text = payInfo.DNumber.Text;
            MemberPhone.Text = payInfo.DSum.Text;*/

            int IsDeleted = 
                MemberInfoConnector.DeleteMember(payInfo.DPrice.Text, payInfo.DSum.Text);

            if(IsDeleted != 1)
            {
                MessageBox.Show("删除失败");
                return;
            }
            else
            {
                MessageBox.Show("删除成功");
                MemberList.SelectedIndex = -1;
                MemberName.Text = "";
                MemberPhone.Text = "";
                MemberMoney.Text = "";
                MemberTypes.SelectedIndex = 0;
                LoadAllMember();
            }

        }
Esempio n. 6
0
 /*
  * 加载会员类型到ComboBox中
  * */
 private void LoadMemberTypes()
 {
     memberTypeDatas = MemberInfoConnector.GetMemberTypeDatas();
     foreach (MemberTypeData item in memberTypeDatas)
     {
         ComboBoxItem comboBoxItem = new ComboBoxItem();
         comboBoxItem.Content = item.MTitle;
         MemberTypes.Items.Add(comboBoxItem);
     }
 }
Esempio n. 7
0
 //选中会员,加载到界面中
 private void MemberList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     ListBoxItem listBoxItem = (ListBoxItem)MemberList.SelectedItem;
     if (listBoxItem == null)
     {
         return;
     }
     PayInfo payInfo = (PayInfo)listBoxItem.Content;
     MemberTypes.SelectedIndex = MemberInfoConnector.GetMemberType(payInfo.DName.Text).MtId ;
     MemberName.Text = payInfo.DPrice.Text;
     MemberMoney.Text = payInfo.DNumber.Text;
     MemberPhone.Text = payInfo.DSum.Text;
 }
Esempio n. 8
0
        /**
         * 结账按钮的实现,提交到数据库
         * 1. 改变账号余额
         * 2. 改变桌子状态为空闲
         * 3. 删除该桌子的订单
         * */
        private void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            if (MemberInfo != null)
            {
                MemberInfoConnector.ModifyMoney(MemberInfo.MbId, leftMoney);
            }
            TableInfoConnector.ModifyStatus(TId, 1);
            OrderInfoConnector.DeleteOrderByTId(TId);
            MessageBox.Show("结账完成!");
            MainMenuWindow mainMenuWindow = new MainMenuWindow(loginType);

            mainMenuWindow.Show();
            Close();
        }
Esempio n. 9
0
        /**
         * 修改会员事件:
         * 验证不为空、验证手机号和余额、后台验证会员是否存在
         * 返回-1表示不存在、返回1表示成功、返回其他值修改失败
         * 仅可修改余额和会员类型,手机号和姓名做会员的唯一标志
         * */
        private void ModifyButton_Click(object sender, RoutedEventArgs e)
        {
            if (MemberName.Text == "" || MemberPhone.Text == "" || MemberMoney.Text == "")
            {
                MessageBox.Show("信息未填写完整");
                return;
            }

            if (!IsMobilePhone(MemberPhone.Text))
            {
                MessageBox.Show("手机号码填写不正确");
                return;
            }

            if (!Double.TryParse(MemberMoney.Text, out double MbMoney))
            {
                MessageBox.Show("余额格式不正确");
                return;
            }

            int ModifiedMember = 
                MemberInfoConnector.ModifyMember(MemberTypes.SelectedIndex + 1, MemberName.Text, MemberPhone.Text, MbMoney);
            if(ModifiedMember == -1)
            {
                MessageBox.Show("该会员不存在(仅可更改会员类型和余额)");
                return;
            }
            if (ModifiedMember != 1)
            {
                MessageBox.Show("修改失败");
                return;
            }

            else
            {
                MessageBox.Show("修改成功");
                MemberList.SelectedIndex = -1;
                MemberName.Text = "";
                MemberPhone.Text = "";
                MemberMoney.Text = "";
                MemberTypes.SelectedIndex = 0;
                LoadAllMember();
            }
        }
Esempio n. 10
0
        /**
         * 添加会员事件:
         * 验证不为空、验证手机号和余额、后台验证重复
         * 返回-1表示重复、返回1表示成功、返回其他值插入失败
         * */
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            if(MemberName.Text == ""||MemberPhone.Text == ""||MemberMoney.Text == "")
            {
                MessageBox.Show("信息未填写完整");
                return;
            }

            if(!IsMobilePhone(MemberPhone.Text))
            {
                MessageBox.Show("手机号码填写不正确");
                return;
            }

            if (!Double.TryParse(MemberMoney.Text, out double MbMoney))
            {
                MessageBox.Show("余额格式不正确");
                return;
            }

            int IsInserted =
                MemberInfoConnector.InsertMember(MemberTypes.SelectedIndex,MemberName.Text, MemberPhone.Text, MbMoney);

            if(IsInserted == -1)
            {
                MessageBox.Show("已存在的会员");
                return;
            }
            else if(IsInserted != 1)
            {
                MessageBox.Show("插入失败");
                return;
            }
            else
            {
                MessageBox.Show("添加成功");
                MemberList.SelectedIndex = -1;
                MemberName.Text = "";
                MemberPhone.Text = "";
                MemberMoney.Text = "";
                MemberTypes.SelectedIndex = 0;
                LoadAllMember();
            }
        }
Esempio n. 11
0
 /**
  * 加载所有的会员类型(除了普通会员,也就是id为5的会员类型)
  * */
 private void LoadAllTypes()
 {
     if (memberTypeDatas != null)
     {
         for (int i = 0; i < memberTypeDatas.Count - 1; i++)
         {
             MemberTypeList.Items.RemoveAt(0);
         }
     }
     memberTypeDatas = MemberInfoConnector.GetMemberTypeDatas();
     foreach (MemberTypeData infoData in memberTypeDatas)
     {
         if (infoData.MtId != 5)
         {
             InfomationTable infomationTable = new InfomationTable(infoData);
             MemberTypeList.Items.Add(infomationTable);
         }
     }
 }
Esempio n. 12
0
 /**
  * 实现模糊查询,通过手机号和姓名
  * */
 private void LoadMember()
 {
     if(SearchName.Text == ""&&SearchPhone.Text == "")
         return;
     for (int i = 0; i < memberInfoDatas.Count; i++)
         MemberList.Items.RemoveAt(0);
     String MbPhone = SearchPhone.Text;
     String MbName = SearchName.Text;
     memberInfoDatas = MemberInfoConnector.GetMembers(MbPhone, MbName);
     foreach (MemberInfoData infoData in memberInfoDatas)
     {
         ListBoxItem listBoxItem = new ListBoxItem();
         PayInfo info = new PayInfo();
         MemberTypeData memberTypeData = MemberInfoConnector.GetMemberType(infoData.MtId);
         info.DName.Text = memberTypeData.MTitle;
         info.DPrice.Text = infoData.MbName;
         info.DNumber.Text = infoData.MbMoney.ToString();
         info.DSum.Text = infoData.MbPhone;
         listBoxItem.Content = info;
         MemberList.Items.Add(listBoxItem);
     }
 }