Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (selectMemberControl1.SelectedMembers.Count == 0)
            {
                MessageBox.Show("请选择会员!");
                selectMemberControl1.Focus();
                return;
            }
            PersonalTrain personalTrain = new PersonalTrain();

            personalTrain.Member = selectMemberControl1.SelectedMembers[0];//comboBox2.SelectedItem as Member;
            personalTrain.私教项目   = textBox1.Text.Trim();
            personalTrain.次数     = (int)numericUpDown1.Value;
            personalTrain.开始日期   = DateTime.Parse(textBox3.Text.Trim());
            personalTrain.结束日期   = DateTime.Parse(textBox4.Text.Trim());
            personalTrain.教练     = (selectStaffControl1.SelectedStaffs != null && selectStaffControl1.SelectedStaffs.Count > 0) ? selectStaffControl1.SelectedStaffs[0] : null;
            personalTrain.备注     = textBox6.Text;
            PersonalTrainLogic rl = PersonalTrainLogic.GetInstance();
            int id = rl.AddPersonalTrain(personalTrain);

            if (id > 0)
            {
                personalTrain.ID = id;
                LoadPersonalTrains();
                MessageBox.Show("添加成功!");
            }
        }
Ejemplo n.º 2
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (comboBox1.SelectedIndex > -1)
     {
         if (selectMemberControl1.SelectedMembers.Count == 0)
         {
             MessageBox.Show("请选择会员!");
             selectMemberControl1.Focus();
             return;
         }
         PersonalTrain personalTrain = (PersonalTrain)comboBox1.SelectedItem;
         personalTrain.Member = selectMemberControl1.SelectedMembers[0];//comboBox2.SelectedItem as Member;
         personalTrain.私教项目   = textBox1.Text.Trim();
         personalTrain.次数     = (int)numericUpDown1.Value;
         personalTrain.开始日期   = DateTime.Parse(textBox3.Text.Trim());
         personalTrain.结束日期   = DateTime.Parse(textBox4.Text.Trim());
         personalTrain.教练     = (selectStaffControl1.SelectedStaffs != null && selectStaffControl1.SelectedStaffs.Count > 0) ? selectStaffControl1.SelectedStaffs[0] : null;
         personalTrain.备注     = textBox6.Text;
         PersonalTrainLogic rl = PersonalTrainLogic.GetInstance();
         if (rl.UpdatePersonalTrain(personalTrain))
         {
             LoadPersonalTrains();
             MessageBox.Show("修改成功!");
         }
     }
     else
     {
         MessageBox.Show("先选定要修改的私教!");
     }
 }
Ejemplo n.º 3
0
        private DataTable Search(string name, int sex = 0, string personalTr = null, Staff trainer = null)
        {
            string nm = "";

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

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

            if (!string.IsNullOrEmpty(personalTr) && personalTr.Trim() != "")
            {
                cn = " and 私教项目 like '%" + personalTr.Trim() + "%'";
            }
            string mb = "";

            if (trainer != null)
            {
                mb = " and 教练='" + trainer.姓名 + "'";
            }
            string where = "(1=1)" + nm + sx + cn + mb;
            return(PersonalTrainLogic.GetInstance().GetPersonalTrains(where));
        }
Ejemplo n.º 4
0
        private DataTable Search(string name, int sex = 0, string personalTr = null, Staff trainer = null)
        {
            string nm = "";

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

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

            if (!string.IsNullOrEmpty(personalTr) && personalTr.Trim() != "")
            {
                cn = " and TF_PersonalTrain.私教项目 like '%" + personalTr.Trim() + "%'";
            }
            string mb = "";

            if (trainer != null)
            {
                mb = " and TF_PersonalTrain.教练=" + trainer.ID;
            }
            string where = nm + sx + cn + mb + " order by TF_PersonalTrain.ID desc";
            return(PersonalTrainLogic.GetInstance().GetPersonalTrains(where));
        }
Ejemplo n.º 5
0
        public static PersonalTrainLogic GetInstance()
        {
            if (instance == null)
            {
                instance = new PersonalTrainLogic();
            }

            return(instance);
        }
Ejemplo n.º 6
0
        private void LoadPersonalTrains()
        {
            List <PersonalTrain> elements = PersonalTrainLogic.GetInstance().GetAllPersonalTrains();

            comboBox1.Items.Clear();
            foreach (PersonalTrain element in elements)
            {
                comboBox1.Items.Add(element);
            }
        }
Ejemplo n.º 7
0
        private void LoadPersonalTrains()
        {
            List <PersonalTrain> elements = PersonalTrainLogic.GetInstance().GetAllPersonalTrains();

            comboBox1.Items.Clear();
            foreach (PersonalTrain element in elements)
            {
                comboBox1.Items.Add(element);
            }
            dataGridView1.DataSource = PersonalTrainLogic.GetInstance().GetPersonalTrains(string.Empty);
        }
Ejemplo n.º 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)
         {
             PersonalTrain personalTrain = (PersonalTrain)comboBox1.SelectedItem;
             if (PersonalTrainLogic.GetInstance().DeletePersonalTrain(personalTrain))
             {
                 LoadPersonalTrains();
             }
         }
     }
     else
     {
         MessageBox.Show("先选定要删除的私教!");
     }
 }