Beispiel #1
0
        public bool UpdateMemberMoney(MemberMoney element)
        {
            string sql = "update TF_MemberMoney set 会员姓名='" + element.会员姓名 + "', 会员电话='" + element.会员电话 + "', 账户余额=" + element.账户余额 + ", 备注='" + element.备注 + "' where ID=" + element.ID;
            int    r   = sqlHelper.ExecuteSql(sql);

            return(r > 0);
        }
Beispiel #2
0
        public bool DeleteMemberMoney(MemberMoney element)
        {
            string sql = "delete from TF_MemberMoney where ID=" + element.ID;
            int    r   = sqlHelper.ExecuteSql(sql);

            return(r > 0);
        }
Beispiel #3
0
        public List <MemberMoney> GetMemberMoneys(string name, string mobile, decimal lessThan = 0)
        {
            List <MemberMoney> elements = new List <MemberMoney>();
            string             sql      = "select * from TF_MemberMoney where (1=1)";

            if (!string.IsNullOrEmpty(name))
            {
                sql += " and 会员姓名 like '%" + name.Trim() + "%'";
            }
            if (!string.IsNullOrEmpty(mobile))
            {
                sql += " and 会员电话 like '%" + mobile.Trim() + "%'";
            }
            if (lessThan > 0)
            {
                sql += " and 账户余额<" + lessThan;
            }
            DataTable dt = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    MemberMoney element = new MemberMoney();
                    element.ID   = Convert.ToInt32(dt.Rows[i]["ID"]);
                    element.会员姓名 = dt.Rows[i]["会员姓名"].ToString();
                    element.会员电话 = dt.Rows[i]["会员电话"].ToString();
                    element.账户余额 = Convert.ToDecimal(dt.Rows[i]["账户余额"]);
                    element.备注   = dt.Rows[i]["备注"].ToString();
                    elements.Add(element);
                }
            }
            return(elements);
        }
Beispiel #4
0
        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("无法创建会员账户!");
            }
        }
Beispiel #5
0
        public int AddMemberMoney(MemberMoney element)
        {
            string sql = "insert into TF_MemberMoney (会员姓名, 会员电话, 账户余额, 备注) values ('" + element.会员姓名 + "', '" + element.会员电话 + "', " + element.账户余额 + ", '" + element.备注 + "'); select SCOPE_IDENTITY()";
            object obj = sqlHelper.ExecuteSqlReturn(sql);
            int    R;

            if (obj != null && obj != DBNull.Value && int.TryParse(obj.ToString(), out R))
            {
                return(R);
            }
            else
            {
                return(0);
            }
        }
Beispiel #6
0
        public MemberMoney GetMemberMoney(int id)
        {
            string    sql = "select * from TF_MemberMoney where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                MemberMoney element = new MemberMoney();
                element.ID   = id;
                element.会员姓名 = dt.Rows[0]["会员姓名"].ToString();
                element.会员电话 = dt.Rows[0]["会员电话"].ToString();
                element.账户余额 = Convert.ToDecimal(dt.Rows[0]["账户余额"]);
                element.备注   = dt.Rows[0]["备注"].ToString();
                return(element);
            }
            return(null);
        }
Beispiel #7
0
        public MemberMoney GetMemberMoney(string name, string mobile)
        {
            MemberMoney element = null;
            string      sql     = "select * from TF_MemberMoney where 会员姓名='" + name + "' and 会员电话='" + mobile + "'";
            DataTable   dt      = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                element      = new MemberMoney();
                element.ID   = Convert.ToInt32(dt.Rows[0]["ID"]);
                element.会员姓名 = dt.Rows[0]["会员姓名"].ToString();
                element.会员电话 = dt.Rows[0]["会员电话"].ToString();
                element.账户余额 = Convert.ToDecimal(dt.Rows[0]["账户余额"]);
                element.备注   = dt.Rows[0]["备注"].ToString();
            }
            return(element);
        }
Beispiel #8
0
        public List <MemberMoney> GetMemberMoneysByMobile(string mobile)
        {
            List <MemberMoney> elements = new List <MemberMoney>();
            string             sql      = "select * from TF_MemberMoney where 会员电话 like '%" + mobile.Trim() + "%'";
            DataTable          dt       = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    MemberMoney element = new MemberMoney();
                    element.ID   = Convert.ToInt32(dt.Rows[i]["ID"]);
                    element.会员姓名 = dt.Rows[i]["会员姓名"].ToString();
                    element.会员电话 = dt.Rows[i]["会员电话"].ToString();
                    element.账户余额 = Convert.ToDecimal(dt.Rows[i]["账户余额"]);
                    element.备注   = dt.Rows[i]["备注"].ToString();
                    elements.Add(element);
                }
            }
            return(elements);
        }
Beispiel #9
0
 public Member GetMember(MemberMoney mm)
 {
     return(MemberLogic.GetInstance().GetMember(mm.会员姓名, mm.会员电话));
 }
Beispiel #10
0
        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("登记失败!");
            }
        }