private void button1_Click(object sender, EventArgs e) { if (selectMemberControl1.SelectedMembers.Count == 0) { MessageBox.Show("请先指定一个会员!"); selectMemberControl1.Focus(); return; } Member member = selectMemberControl1.SelectedMembers[0]; MemberMoneyLogic mml = MemberMoneyLogic.GetInstance(); string name = member.姓名; string mobile = member.电话; MemberMoney mm = null; if (!mml.ExistsName(name, mobile)) { mm = new MemberMoney(); mm.会员姓名 = name; mm.会员电话 = mobile; mm.备注 = "账户创建于" + DateTime.Now.ToString(); int id = mml.AddMemberMoney(mm); if (id > 0) { mm.ID = id; } } else { mm = mml.GetMemberMoney(name, mobile); } if (mm != null) { MoneyRecord mr = new MoneyRecord(); mr.会员账户 = mm; mr.发生金额 = numericUpDown1.Value; mr.是否充值 = true; mr.操作人 = textBox3.Text; if (MoneyRecordLogic.GetInstance().AddMoneyRecord(mr) > 0) { LoadMoneyRecords(); MessageBox.Show("保存会员消费记录以及扣款成功!"); } else { MessageBox.Show("保存会员消费记录失败或者扣款失败!"); } } else { MessageBox.Show("无法创建会员账户!"); } }
private void button1_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex == -1) { MessageBox.Show("请先选择要出库的产品!"); comboBox1.Focus(); return; } int num = 0; int R; if (int.TryParse(textBox1.Text.Trim(), out R)) { num = R; } else { MessageBox.Show("数量必须为整数!"); textBox1.Focus(); textBox1.SelectAll(); return; } decimal price = 0; decimal r; if (decimal.TryParse(textBox2.Text.Trim(), out r)) { price = r; } else { MessageBox.Show("实价必须为整数!"); textBox2.Focus(); textBox2.SelectAll(); return; } if (checkBox1.Checked) { if (selectMemberControl1.SelectedMembers.Count == 0) { MessageBox.Show("请选择当前消费的会员!"); selectMemberControl1.Focus(); return; } } Income element = new Income(); element.PID = ((Product)comboBox1.SelectedItem).ID; element.IsProduct = true; element.IsIncome = false; element.数量 = num; element.实价 = price; element.经手人 = textBox3.Text.Trim(); element.备注 = textBox4.Text.Trim(); if (IncomeLogic.GetInstance().AddIncome(element) > 0) { MessageBox.Show("登记成功!"); if (checkBox1.Checked) { Member member = selectMemberControl1.SelectedMembers[0]; decimal sum = num * price; if (sum > 0) { MemberMoneyLogic mml = MemberMoneyLogic.GetInstance(); string name = member.姓名; string mobile = member.电话; MemberMoney mm = null; if (!mml.ExistsName(name, mobile)) { mm = new MemberMoney(); mm.会员姓名 = name; mm.会员电话 = mobile; mm.备注 = "账户创建于" + DateTime.Now.ToString(); mml.AddMemberMoney(mm); } else { mm = mml.GetMemberMoney(name, mobile); } if (mm != null) { MoneyRecord mr = new MoneyRecord(); mr.会员账户 = mm; mr.发生金额 = sum; mr.是否充值 = false; mr.操作人 = element.经手人; if (MoneyRecordLogic.GetInstance().AddMoneyRecord(mr) > 0) { MessageBox.Show("保存会员消费记录以及扣款成功!"); } else { MessageBox.Show("保存会员消费记录失败或者扣款失败!"); } } else { MessageBox.Show("无法创建会员账户!"); } } else { MessageBox.Show("消费额不能为负!"); } } } else { MessageBox.Show("登记失败!"); } }