Example #1
0
        private DataTable Search(string name, int sex = 0, CardType cardType = null, string cardNo = null, string mobile = null)
        {
            string nm = "";

            if (!string.IsNullOrEmpty(name))
            {
                nm = " and 姓名 like '%" + name + "%'";
            }
            string sx = "";

            if (sex > 0)
            {
                sx = " and 性别=" + sex;
            }
            string ct = "";

            if (cardType != null)
            {
                ct = " and 卡种=" + cardType.ID;
            }
            string cn = "";

            if (!string.IsNullOrEmpty(cardNo) && cardNo.Trim() != "")
            {
                cn = " and 卡号 like '%" + cardNo.Trim() + "%'";
            }
            string mb = "";

            if (!string.IsNullOrEmpty(mb) && mb.Trim() != "")
            {
                mb = " and 电话 like '%" + mb.Trim() + "%'";
            }
            string where = "(1=1)" + nm + sx + ct + cn + mb + " order by ID desc";
            return(MemberLogic.GetInstance().GetMembers(where));
        }
Example #2
0
        public List <PersonalTrain> GetAllPersonalTrains()
        {
            List <PersonalTrain> elements = new List <PersonalTrain>();
            string    sql = "select * from TF_PersonalTrain";
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    PersonalTrain element = new PersonalTrain();
                    element.ID       = Convert.ToInt32(dt.Rows[i]["ID"]);
                    element.Member   = MemberLogic.GetInstance().GetMember(Convert.ToInt32(dt.Rows[i]["MemberID"]));
                    element.私教项目     = dt.Rows[i]["私教项目"].ToString();
                    element.次数       = Convert.ToInt32(dt.Rows[i]["次数"]);
                    element.开始日期     = Convert.ToDateTime(dt.Rows[i]["开始日期"]);
                    element.结束日期     = Convert.ToDateTime(dt.Rows[i]["结束日期"]);
                    element.教练       = StaffLogic.GetInstance().GetStaff(Convert.ToInt32(dt.Rows[i]["教练"]));
                    element.备注       = dt.Rows[i]["备注"].ToString();
                    element.SaleTime = Convert.ToDateTime(dt.Rows[i]["SaleTime"]);
                    elements.Add(element);
                }
            }
            return(elements);
        }
Example #3
0
        public static MemberLogic GetInstance()
        {
            if (instance == null)
            {
                instance = new MemberLogic();
            }

            return(instance);
        }
        private void LoadMembers()
        {
            List <Member> elements = MemberLogic.GetInstance().GetAllMembers();

            comboBox2.Items.Clear();
            foreach (Member element in elements)
            {
                comboBox2.Items.Add(element);
            }
        }
Example #5
0
        private DataTable Search(string name, int sex, CardType cardType, string cardNo, string mobile, bool deadline, out int allCount)
        {
            string nm = "";

            if (!string.IsNullOrEmpty(name))
            {
                nm = " and 姓名 like '%" + name + "%'";
            }
            string sx = "";

            if (sex > 0)
            {
                sx = " and 性别='" + (性别)Enum.ToObject(typeof(性别), (sex - 1)) + "'";
            }
            string ct = "";

            if (cardType != null)
            {
                ct = " and 卡种='" + cardType.卡种 + "'";
            }
            string cn = "";

            if (!string.IsNullOrEmpty(cardNo) && cardNo.Trim() != "")
            {
                cn = " and 卡号 like '%" + cardNo.Trim() + "%'";
            }
            string mb = "";

            if (!string.IsNullOrEmpty(mobile) && mobile.Trim() != "")
            {
                mb = " and 电话 like '%" + mobile.Trim() + "%'";
            }
            string dl = "";

            if (deadline)
            {
                dl = " and 到期日<'" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
            }
            string where = "(1=1)" + nm + sx + ct + cn + mb + dl;

            if (loading == null || loading.IsDisposed)
            {
                loading = new KellControls.FloatingCircleLoading(150);
            }
            loading.Show();
            loading.BringToFront();
            loading.Focus();
            loading.Refresh();
            timer1.Start();
            DataTable dt = MemberLogic.GetInstance().GetMembers(winFormPager1.PageSize, winFormPager1.PageIndex, where, out allCount);

            timer1.Stop();
            loading.Hide();
            return(dt);
        }
Example #6
0
        private void LoadMembers()
        {
            List <MemberSimply> elements = MemberLogic.GetInstance().GetAllMembersSimply();

            comboBox1.Items.Clear();
            foreach (MemberSimply element in elements)
            {
                comboBox1.Items.Add(element);
            }
            int allCount;

            dataGridView1.DataSource  = MemberLogic.GetInstance().GetMembers(winFormPager1.PageSize, winFormPager1.PageIndex, string.Empty, out allCount);
            winFormPager1.RecordCount = allCount;
        }
Example #7
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         Member member = (Member)comboBox1.SelectedItem;
         member.姓名  = textBox1.Text.Trim();
         member.性别  = (性别)Enum.ToObject(typeof(性别), comboBox2.SelectedIndex);
         member.卡种  = comboBox3.SelectedItem as CardType;
         member.卡号  = textBox2.Text.Trim();
         member.开卡日 = DateTime.Parse(textBox11.Text.Trim());
         member.到期日 = DateTime.Parse(textBox3.Text.Trim());
         member.生日  = DateTime.Parse(textBox4.Text.Trim());
         member.电话  = textBox5.Text.Trim();
         member.住址  = textBox10.Text.Trim();
         member.备注  = textBox6.Text;
         MemberLogic ml = MemberLogic.GetInstance();
         if (ml.ExistsNameOther(member.姓名, member.ID))
         {
             if (MessageBox.Show("系统中已经存在该会员,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
             {
                 if (ml.UpdateMember(member))
                 {
                     LoadMembers();
                     MessageBox.Show("修改成功!");
                 }
             }
             else
             {
                 textBox1.Focus();
                 textBox1.SelectAll();
             }
         }
         else
         {
             if (ml.UpdateMember(member))
             {
                 LoadMembers();
                 MessageBox.Show("修改成功!");
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要修改的会员!");
     }
 }
Example #8
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         if (MessageBox.Show("确定要删除该会员?", "删除提醒", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
         {
             Member member = (Member)comboBox1.SelectedItem;
             if (MemberLogic.GetInstance().DeleteMember(member))
             {
                 LoadMembers();
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要删除的会员!");
     }
 }
Example #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            Member member = new Member();

            member.姓名  = textBox6.Text.Trim();
            member.性别  = (性别)Enum.ToObject(typeof(性别), comboBox2.SelectedIndex);
            member.卡种  = comboBox3.SelectedItem as CardType;
            member.卡号  = textBox6.Text.Trim();
            member.到期日 = DateTime.Parse(textBox3.Text.Trim());
            member.生日  = DateTime.Parse(textBox4.Text.Trim());
            member.电话  = textBox5.Text.Trim();
            member.住址  = textBox6.Text.Trim();
            MemberLogic ml = MemberLogic.GetInstance();

            if (ml.ExistsName(member.姓名))
            {
                if (MessageBox.Show("系统中已经存在该会员,确定还要继续保存么?", "重名提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.OK)
                {
                    int id = ml.AddMember(member);
                    if (id > 0)
                    {
                        member.ID = id;
                        LoadMembers();
                        MessageBox.Show("添加成功!");
                    }
                }
                else
                {
                    textBox1.Focus();
                    textBox1.SelectAll();
                }
            }
            else
            {
                int id = ml.AddMember(member);
                if (id > 0)
                {
                    member.ID = id;
                    LoadMembers();
                    MessageBox.Show("添加成功!");
                }
            }
        }
Example #10
0
        public Renew GetRenew(int id)
        {
            string    sql = "select * from TF_Renew where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                Renew element = new Renew();
                element.ID     = id;
                element.Member = MemberLogic.GetInstance().GetMember(Convert.ToInt32(dt.Rows[0]["MemberID"]));
                element.卡种     = CardTypeLogic.GetInstance().GetCardType(Convert.ToInt32(dt.Rows[0]["CardType"]));
                element.卡号     = dt.Rows[0]["卡号"].ToString();
                element.续卡时间   = Convert.ToDateTime(dt.Rows[0]["续卡时间"]);
                element.经手人    = StaffLogic.GetInstance().GetStaff(Convert.ToInt32(dt.Rows[0]["经手人"]));
                element.备注     = dt.Rows[0]["备注"].ToString();
                return(element);
            }
            return(null);
        }
Example #11
0
        public Followup GetFollowup(int id)
        {
            string    sql = "select * from TF_Followup where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                Followup element = new Followup();
                element.ID     = id;
                element.Member = MemberLogic.GetInstance().GetMember(Convert.ToInt32(dt.Rows[0]["MemberID"]));
                element.回访方式   = FollowupTypeLogic.GetInstance().GetFollowupType(Convert.ToInt32(dt.Rows[0]["跟进方式"]));
                element.跟进结果   = FollowupResultLogic.GetInstance().GetFollowupResult(Convert.ToInt32(dt.Rows[0]["跟进结果"]));
                element.跟进时间   = Convert.ToDateTime(dt.Rows[0]["跟进时间"]);
                element.跟进人    = StaffLogic.GetInstance().GetStaff(Convert.ToInt32(dt.Rows[0]["跟进人"]));
                element.备注     = dt.Rows[0]["备注"].ToString();
                return(element);
            }
            return(null);
        }
Example #12
0
        private DataTable Search(int sex, string name, string mobile, CardType cardType, string cardNo, bool deadline)
        {
            string nm = "";

            if (!string.IsNullOrEmpty(name) && name.Trim() != "")
            {
                nm = " and 姓名 like '%" + name + "%'";
            }
            string sx = "";

            if (sex > 0)
            {
                sx = " and 性别='" + Enum.GetName(typeof(性别), Convert.ToInt32(sex - 1)) + "'";
            }
            string ct = "";

            if (cardType != null)
            {
                ct = " and 卡种='" + cardType.卡种 + "'";
            }
            string cn = "";

            if (!string.IsNullOrEmpty(cardNo) && cardNo.Trim() != "")
            {
                cn = " and 卡号 like '%" + cardNo.Trim() + "%'";
            }
            string mb = "";

            if (!string.IsNullOrEmpty(mobile) && mobile.Trim() != "")
            {
                mb = " and 电话 like '%" + mobile.Trim() + "%'";
            }
            string dl = "";

            if (deadline)
            {
                dl = " and 到期日<'" + DateTime.Now.ToString("yyyy-MM-dd") + "'";
            }
            string where = "(1=1)" + nm + sx + ct + cn + mb + dl;
            return(MemberLogic.GetInstance().GetMembers(where));
        }
Example #13
0
        public PersonalTrain GetPersonalTrain(int id)
        {
            string    sql = "select * from TF_PersonalTrain where ID=" + id;
            DataTable dt  = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                PersonalTrain element = new PersonalTrain();
                element.ID       = id;
                element.Member   = MemberLogic.GetInstance().GetMember(Convert.ToInt32(dt.Rows[0]["MemberID"]));
                element.私教项目     = dt.Rows[0]["私教项目"].ToString();
                element.次数       = Convert.ToInt32(dt.Rows[0]["次数"]);
                element.开始日期     = Convert.ToDateTime(dt.Rows[0]["开始日期"]);
                element.结束日期     = Convert.ToDateTime(dt.Rows[0]["结束日期"]);
                element.教练       = StaffLogic.GetInstance().GetStaff(Convert.ToInt32(dt.Rows[0]["教练"]));
                element.备注       = dt.Rows[0]["备注"].ToString();
                element.SaleTime = Convert.ToDateTime(dt.Rows[0]["SaleTime"]);
                return(element);
            }
            return(null);
        }
Example #14
0
        private DataTable Search(string name, object alertType, string subject)
        {
            string nm = "";

            if (!string.IsNullOrEmpty(name) && name.Trim() != "")
            {
                nm = " and 提醒项目 like '%" + name.Trim() + "%'";
            }
            string at = "";
            string sb = "";

            if (alertType is 提醒方式)
            {
                提醒方式 type = (提醒方式)alertType;
                at = " and 提醒方式='" + type.ToString();
                if (!string.IsNullOrEmpty(subject) && subject.Trim() != "")
                {
                    int id = 0;
                    if (type == 提醒方式.系统提示 || type == 提醒方式.员工短信)
                    {
                        Staff staff = StaffLogic.GetInstance().GetStaffByName(subject.Trim());
                        if (staff != null)
                        {
                            id = staff.ID;
                        }
                    }
                    else if (type == 提醒方式.会员短信)
                    {
                        Member member = MemberLogic.GetInstance().GetMemberByName(subject.Trim());
                        if (member != null)
                        {
                            id = member.ID;
                        }
                    }
                    sb = " and ','+提醒对象+',' like '%," + id + ",%'";
                }
            }
            string where = "(1=1)" + nm + sb + at;
            return(AlertLogic.GetInstance().GetAlerts(where));
        }
Example #15
0
        public List <Followup> GetAllFollowups()
        {
            List <Followup> elements = new List <Followup>();
            string          sql      = "select * from TF_Followup";
            DataTable       dt       = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Followup element = new Followup();
                    element.ID     = Convert.ToInt32(dt.Rows[i]["ID"]);
                    element.Member = MemberLogic.GetInstance().GetMember(Convert.ToInt32(dt.Rows[i]["MemberID"]));
                    element.回访方式   = FollowupTypeLogic.GetInstance().GetFollowupType(Convert.ToInt32(dt.Rows[i]["跟进方式"]));
                    element.跟进结果   = FollowupResultLogic.GetInstance().GetFollowupResult(Convert.ToInt32(dt.Rows[i]["跟进结果"]));
                    element.跟进时间   = Convert.ToDateTime(dt.Rows[i]["跟进时间"]);
                    element.跟进人    = StaffLogic.GetInstance().GetStaff(Convert.ToInt32(dt.Rows[i]["跟进人"]));
                    element.备注     = dt.Rows[i]["备注"].ToString();
                    elements.Add(element);
                }
            }
            return(elements);
        }
Example #16
0
        public static List <Member> GetMemberByIdStr(string ids)
        {
            List <Member> members = new List <Member>();

            if (!string.IsNullOrEmpty(ids))
            {
                MemberLogic ml  = MemberLogic.GetInstance();
                string[]    Ids = ids.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string id in Ids)
                {
                    int ID;
                    if (int.TryParse(id, out ID))
                    {
                        Member member = ml.GetMember(ID);
                        if (member != null)
                        {
                            members.Add(member);
                        }
                    }
                }
            }
            return(members);
        }
Example #17
0
        public List <Renew> GetAllRenews()
        {
            List <Renew> elements = new List <Renew>();
            string       sql      = "select * from TF_Renew";
            DataTable    dt       = sqlHelper.Query(sql);

            if (dt != null && dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Renew element = new Renew();
                    element.ID     = Convert.ToInt32(dt.Rows[i]["ID"]);
                    element.Member = MemberLogic.GetInstance().GetMember(Convert.ToInt32(dt.Rows[i]["MemberID"]));
                    element.卡种     = CardTypeLogic.GetInstance().GetCardType(Convert.ToInt32(dt.Rows[i]["卡种"]));
                    element.卡号     = dt.Rows[i]["卡号"].ToString();
                    element.续卡时间   = Convert.ToDateTime(dt.Rows[i]["续卡时间"]);
                    element.经手人    = StaffLogic.GetInstance().GetStaff(Convert.ToInt32(dt.Rows[i]["经手人"]));
                    element.备注     = dt.Rows[i]["备注"].ToString();
                    elements.Add(element);
                }
            }
            return(elements);
        }
Example #18
0
        private string BackupData(string type)
        {
            DataTable data = null;

            if (type == "会员")
            {
                data = MemberLogic.GetInstance().GetMemberData();
            }
            else if (type == "员工")
            {
                data = StaffLogic.GetInstance().GetStaffData();
            }
            string filename = Directory.GetCurrentDirectory() + "\\" + type + "资料.xls";
            bool   f        = Common.ExportData(data, filename);

            if (f)
            {
                return(filename);
            }
            else
            {
                return("");
            }
        }
Example #19
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         MemberSimply memberSimply = comboBox1.SelectedItem as MemberSimply;
         Member       member       = MemberLogic.GetInstance().GetMember(memberSimply.ID);
         if (member != null)
         {
             textBox1.Text                 = member.姓名;
             comboBox2.SelectedIndex       = (int)member.性别;
             comboBox3.SelectedIndex       = GetIndexByCardType(member.卡种, comboBox3);
             textBox2.Text                 = member.卡号;
             textBox11.Text                = member.开卡日.ToString("yyyy-MM-dd");
             monthCalendar3.SelectionStart = member.开卡日;
             textBox3.Text                 = member.到期日.ToString("yyyy-MM-dd");
             monthCalendar1.SelectionStart = member.到期日;
             textBox4.Text                 = member.生日.ToString("yyyy-MM-dd");
             monthCalendar2.SelectionStart = member.生日;
             textBox5.Text                 = member.电话;
             textBox10.Text                = member.住址;
             textBox6.Text                 = member.备注;
         }
     }
 }
Example #20
0
        private void LoadAllMembers()
        {
            DataTable dt = MemberLogic.GetInstance().GetMembers(string.Empty);

            dataGridView1.DataSource = dt;
        }
Example #21
0
        public static bool ImportData(string elementType, bool clearOldData, DataTable data, FieldMap <string, string> map, ImportDataProcessHandler process)
        {
            if (data == null && data.Rows.Count == 0)
            {
                return(false);
            }
            if (map.Count == 0)
            {
                return(false);
            }

            try
            {
                Assembly ass      = null;
                Type     t        = null;
                string   typeName = null;
                //清空数据库中的原有数据
                switch (elementType)
                {
                case "会员":
                    ass      = Assembly.Load("Model");
                    t        = ass.GetType("TopFashion.Member", false, true);
                    typeName = t.FullName;
                    if (clearOldData)
                    {
                        MemberLogic.GetInstance().ClearMembers();
                    }
                    break;

                case "员工":
                    ass      = Assembly.Load("Model");
                    t        = ass.GetType("TopFashion.Staff", false, true);
                    typeName = t.FullName;
                    if (clearOldData)
                    {
                        StaffLogic.GetInstance().ClearStaffs();
                    }
                    break;

                default:
                    break;
                }
                if (!string.IsNullOrEmpty(typeName))
                {
                    for (int i = 0; i < data.Rows.Count; i++)
                    {
                        DataRow row = data.Rows[i];//FormatData(data.Rows[i]);
                        //保存数据到数据库
                        switch (elementType)
                        {
                        case "会员":
                            Member elementM = ass.CreateInstance(typeName, true) as Member;
                            Member member   = GetData <Member>(row, map, elementM, t);
                            MemberLogic.GetInstance().AddMember(member);
                            break;

                        case "员工":
                            Staff elementS = ass.CreateInstance(typeName, true) as Staff;
                            Staff staff    = GetData <Staff>(row, map, elementS, t);
                            StaffLogic.GetInstance().AddStaff(staff);
                            break;

                        default:
                            break;
                        }
                        //反馈进度给外部程序
                        if (process != null)
                        {
                            process(i + 1);
                        }
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Example #22
0
 public Member GetMember(MemberMoney mm)
 {
     return(MemberLogic.GetInstance().GetMember(mm.会员姓名, mm.会员电话));
 }