private void MoneyRecordForm_Load(object sender, EventArgs e) { base.DisableUserPermission(this); LoadMoneyRecords(); dataGridView1.DataSource = MoneyRecordLogic.GetInstance().GetMoneyRecords(string.Empty); textBox3.Text = this.User.Username; }
private DataTable Search(string name, string mobile, string operater, int action) { string nm = ""; if (!string.IsNullOrEmpty(name) && name.Trim() != "") { nm = " and 会员姓名 like '%" + name.Trim() + "%'"; } string mb = ""; if (!string.IsNullOrEmpty(mobile) && mobile.Trim() != "") { mb = " and 会员电话 like '%" + mobile.Trim() + "%'"; } string czr = ""; if (!string.IsNullOrEmpty(name) && name.Trim() != "") { czr = " and 操作人 like '%" + operater.Trim() + "%'"; } string act = ""; if (action > 0) { act = " and 动作='" + (action == 1 ? "消费" : "充值") + "'"; } string where = "(1=1)" + nm + mb + czr + act; return(MoneyRecordLogic.GetInstance().GetMoneyRecords(where)); }
private void button2_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { if (selectMemberControl1.SelectedMembers.Count == 0) { MessageBox.Show("请先指定一个会员!"); selectMemberControl1.Focus(); return; } MoneyRecord mr = (MoneyRecord)comboBox1.SelectedItem; mr.会员账户 = MemberMoneyLogic.GetInstance().GetMemberMoney(selectMemberControl1.SelectedMembers[0]); mr.发生金额 = numericUpDown1.Value; mr.是否充值 = true; mr.操作人 = textBox3.Text; MoneyRecordLogic rl = MoneyRecordLogic.GetInstance(); if (rl.UpdateMoneyRecord(mr)) { LoadMoneyRecords(); MessageBox.Show("修改成功!"); } } else { MessageBox.Show("先选定要修改的进出账!"); } }
public static MoneyRecordLogic GetInstance() { if (instance == null) { instance = new MoneyRecordLogic(); } return(instance); }
private void LoadMoneyRecords() { List <MoneyRecord> elements = MoneyRecordLogic.GetInstance().GetAllMoneyRecords(); comboBox1.Items.Clear(); foreach (MoneyRecord element in elements) { comboBox1.Items.Add(element); } dataGridView1.DataSource = MoneyRecordLogic.GetInstance().GetMoneyRecords(string.Empty); }
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 button3_Click(object sender, EventArgs e) { if (comboBox1.SelectedIndex > -1) { if (MessageBox.Show("确定要删除该进出账?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK) { MoneyRecord record = (MoneyRecord)comboBox1.SelectedItem; if (MoneyRecordLogic.GetInstance().DeleteMoneyRecord(record)) { LoadMoneyRecords(); } } } 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("登记失败!"); } }