Пример #1
0
        public static List <VipsMDL> GetVips(int VipID)
        {
            string sql             = "select * from Vips v left join dbo.VIPGrade g on v.GradeID=g.VGID where 1=1";
            List <SqlParameter> sp = new List <SqlParameter>();

            if (VipID != 0)
            {
                sql += " and VipID=@VipID";
                sp.Add(new SqlParameter("@VipID", VipID));
            }

            SqlDataReader  dr   = DBhelper.MySqlDataReader(sql, sp.ToArray());
            List <VipsMDL> list = new List <VipsMDL>();

            while (dr.Read())
            {
                VipsMDL v = new VipsMDL();
                v.VipID        = Convert.ToInt32(dr[0]);
                v.VipName      = dr[1].ToString();
                v.VipSex       = dr[2].ToString();
                v.GradeID      = Convert.ToInt32(dr[3]);
                v.VipTel       = dr[4].ToString();
                v.VipStartDate = dr[5].ToString();
                v.VipEndDate   = dr[6].ToString();

                //v.VipType = Convert.ToInt32(dr[7]);


                if (dr[8].ToString() == "")
                {
                    v.VGName = "其他会员";
                }
                else
                {
                    v.VGName = dr[8].ToString();
                }

                if (dr[9].ToString() == "")
                {
                    v.VGDiscount = 1.0;
                }
                else
                {
                    v.VGDiscount = Convert.ToDouble(dr[9]);
                }

                list.Add(v);
            }
            dr.Close();
            return(list);
        }
Пример #2
0
        public static int AddVip(VipsMDL v)
        {
            string sql = "insert into Vips values(@VipName,@VipSex,@GradeID,@VipTel,GETDATE(),@VipEndDate)";

            SqlParameter[] sp =
            {
                new SqlParameter("@VipName",    v.VipName),
                new SqlParameter("@VipSex",     v.VipSex),
                new SqlParameter("@GradeID",    v.GradeID),
                new SqlParameter("@VipTel",     v.VipTel),
                new SqlParameter("@VipEndDate", v.VipEndDate),
            };
            return(DBhelper.MyExecuteNonQuery(sql, sp));
        }
Пример #3
0
        public static int UpdateVip(VipsMDL v)
        {
            string sql = "update Vips set VipName=@VipName,VipSex=@VipSex,GradeID=@GradeID,VipTel=@VipTel,VipEndDate=@VipEndDate where VipID=@VipID";

            SqlParameter[] sp =
            {
                new SqlParameter("@VipName",    v.VipName),
                new SqlParameter("@VipSex",     v.VipSex),
                new SqlParameter("@VipTel",     v.VipTel),
                new SqlParameter("@VipEndDate", v.VipEndDate),
                new SqlParameter("@GradeID",    v.GradeID),
                new SqlParameter("@VipID",      v.VipID)
            };
            return(DBhelper.MyExecuteNonQuery(sql, sp));
        }
Пример #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     //验证内容
     if (textBox1.Text.Trim().Length <= 0 || textBox2.Text.Trim().Length <= 0)
     {
         new Warning("信息填写不完整", 图标.Erro).Show();
         return;
     }
     //添加
     if (showState == 1)
     {
         try
         {
             VipsMDL v = new VipsMDL();
             v.VipName    = textBox1.Text;
             v.VipTel     = textBox2.Text;
             v.GradeID    = Convert.ToInt32(comboBox1.SelectedValue);
             v.VipSex     = radioButton1.Checked ? "男" : "女";
             v.VipEndDate = dateTimePicker1.Value.ToString();
             if (VipsBLL.AddVip(v) > 0)
             {
                 this.Close();
             }
         }
         catch (Exception)
         {
             MessageBox.Show("发生未只的异常,请联系开发者", "未知异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         //修改会员
         VipsMDL v = new VipsMDL();
         v.VipName    = textBox1.Text;
         v.VipTel     = textBox2.Text;
         v.GradeID    = Convert.ToInt32(comboBox1.SelectedValue);
         v.VipSex     = radioButton1.Checked ? "男" : "女";
         v.VipEndDate = dateTimePicker1.Value.ToString();
         v.VipID      = Convert.ToInt32(label7.Text);
         if (VipsBLL.UpdateVip(v) > 0)
         {
             new Warning("修改成功", 图标.Yes).Show();
             this.Close();
         }
         //执行修改
     }
 }
Пример #5
0
 public static int UpdateVip(VipsMDL v)
 {
     return(VipsDAL.UpdateVip(v));
 }
Пример #6
0
 public static int AddVip(VipsMDL v)
 {
     return(VipsDAL.AddVip(v));
 }