예제 #1
0
        private void Frm_Login_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (love.isloginexit)//如果是在登陆窗口按下的登陆按钮就不允许退出,因为登陆成功后需要退出登陆窗口给其它变量赋值以此来打开集成窗口
            {
                love.isloginexit = false;
                return;
            }

            if (love.zhuce_username != string.Empty)//说明注册成功,所以要来提示
            {
                //开始判断它是否填写了详细信息   没有的话就让他填写
                sellde s = new sellde();
                s.Username = love.zhuce_username;
                if (s.isorther() == true)
                {
                    return;
                }
            }


            if (MessageBox.Show("你真的要退出爱尚购吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.Cancel)
            {
                e.Cancel = true;
            }
        }
예제 #2
0
        private void btn_submit_Click(object sender, EventArgs e)//点击了提交按钮
        {
            //查看验证码是否正确           测试期间把验证码关闭
            string yzm = lab_y1.Text + lab_y2.Text + lab_y3.Text + lab_y4.Text;

            if (yzm.ToUpper() != txt_yanzhengma.Text.ToUpper())//两个内容转化为大写之后如果不一致的话
            {
                MessageBox.Show("验证码错误", "验证码输入提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_yanzhengma.Focus();
                updateyzm();
                txt_yanzhengma.SelectAll();
                return;
            }


            //下面的文本框不允许为空
            foreach (Control item in Controls)
            {
                if (item is TextBox)            //如果它是一个文本框
                {
                    if (item.Text.Trim() == "") //Trim()去除字符串两端的空格
                    {
                        MessageBox.Show("请为此文本框输入内容", "文本框输入提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        item.Focus();
                        return;
                    }
                }
            }

            /*没有插入的字段	nicheng	zhenname	sex	fahuodizhi	sfzh	telephone	mibaowt	mibaodan	zhucetime*/
            sellde s = new sellde();

            s.Nicheng  = txt_nicheng.Text;
            s.Zhenname = txt_zhenname.Text;

            s.Sex        = rad_man.Checked ? "男" : "女";
            s.Fahuodizhi = cmb_sheng.Text.Trim() + " " + cmb_shi.Text.Trim() + " " + cmb_xiangzhen.Text.Trim() + " " + txt_xiangxidizhi.Text.Trim();//三个combox框内容加上详细地址组成发货地址或者收货地址
            s.Sfzh       = txt_sfzh.Text;
            s.Telephone  = long.Parse(txt_telephone.Text);
            s.Mibaowt    = txt_mibaowenti.Text == "    当你忘记密码的时候可以通过这个问题的答案来判定是否为你本人,然后进行找回密码。" ? "" : txt_mibaowenti.Text;
            s.Mibaodan   = txt_mibaodaan.Text == "    上面密保的答案。" ? "" : txt_mibaodaan.Text;
            s.Username   = love.denglu_username;
            s.zhuceselldeOrther();//执行插入其它详细信息
            MessageBox.Show("详细信息填写成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            love.iszhucecg = true;//注册成功会引发关闭事件

            //既然详细信息填写成功了,那么就开始判断是买家还是卖家,如果是卖家就进入商品管理的页面,否则那就是买家那么就进入到购物界面

            love.zhuce_username = love.denglu_username;
            love.user_orther    = true;
            Close();
        }
예제 #3
0
        private void btn_zhuce_Click(object sender, EventArgs e)//点击了注册的按钮
        {
            //开始判断该用户名是否已经存在了
            string user  = "******" + txt_zc_name.Text + "'";//这里是连接法直接用原始的+号连接
            string user2 = string.Format("select * from sellde where username = '******'", txt_zc_name.Text);
            //上面两个出来的字符串都是一模一样的
            int s1 = sqlHelper.ExecutChaXun(user);
            int s2 = sqlHelper.ExecutChaXun(user2);

            if (s1 > 0 || s2 > 0)
            {
                //说明数据库中存在了该账号
                MessageBox.Show("该账号已经存在", "文本框提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_zc_name.Focus();
                txt_zc_name.SelectAll();
                return;
            }

            //判断是否输入了所有的信息
            foreach (Control item in pan_zhuce.Controls)
            {
                if (item is TextBox)
                {
                    if (item.Text.Trim() == string.Empty)      //Trim()去除字符串两端的空格     string.Empty == ""      都是空的意思
                    {
                        TextBox a = (TextBox)item;
                        MessageBox.Show("此文本框未输入内容,请输入", "文本框提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        a.Focus();     //让此框获得焦点==光标==鼠标
                        a.SelectAll(); //选择这个文本框的全部
                        return;        //提前结束此方法
                    }
                }
            }

            //开始判断是否插入了图片
            if (pic_photo.Image == null)
            {
                DialogResult result = MessageBox.Show("没有选择头像,是否立刻选择?", "图片提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    btn_pic_Click(sender, e);//执行点击了选择头像的按钮
                }
                return;
            }

            //开始判断两个密码是否一致
            if (txt_zc_pwd1.Text != txt_zc_pwd2.Text)
            {
                //说明密码不一致
                MessageBox.Show("两次密码不一致,请重新输入", "密码错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txt_zc_pwd2.Focus();     //让此框获得焦点==光标==鼠标
                txt_zc_pwd2.SelectAll(); //选择这个文本框的全部
                return;                  //结束本方法,不让注册
            }

            //开始分辨注册的到底是卖家还是买家
            if (rad_buyde.Checked)//如果这个按钮是选中了,那么说明它是买家
            {
                love.denglu_IsSelldeOrBuyde = "买";
            }
            else
            {
                love.denglu_IsSelldeOrBuyde = "卖";
            }
            //下面是为变量们赋值,然后调用业务逻辑层的插入命令,达到注册目的
            sellde s = new sellde();       //实例化一个卖家

            s.Username = txt_zc_name.Text; //用户名为注册的名字
            s.Pwd      = txt_zc_pwd1.Text; //密码等于密码

            if (pic_photo.Image == null)   //如果图片框为空那么就赋值为空
            {
                s.Photo = null;
            }
            else
            {
                string path = Application.StartupPath + @"\image\a.jpg";                 //创建一个文件的路径,包含文件名
                pic_photo.Image.Save(path);                                              //保存图片框,它的路径名字为上面定义的path
                FileStream fs    = new FileStream(path, FileMode.Open, FileAccess.Read); //创建一个文件流,把这个文件作为流,打开方式为打开,文件的访问权限为阅读
                byte[]     image = new byte[fs.Length];                                  //定义一个byte(字节)数组   长度为文件流fs的长度。length:长度
                fs.Read(image, 0, image.Length);                                         //文件流读取到image这个数组里面去,从 0 开始,一直到文件流的最大长度  -- 其实就是读取所有
                s.Photo = image;                                                         //正式把数组赋值到业务逻辑层的photo数组
                fs.Close();                                                              //吸取经验,记得关闭,以保证下一次处理文件    关闭文件流
                File.Delete(path);                                                       //删除磁盘文件
            }
            s.zhucesellde();                                                             //这个是业务逻辑层里面的注册功能方法
            MessageBox.Show("注册成功了", "注册提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            txt_username.Text = txt_zc_name.Text;//成功后给登陆框的账号赋值
            txt_password.Text = "";
            //pic_photo.Image = null;
            //txt_zc_name.Text = txt_zc_pwd1.Text = txt_zc_pwd2.Text = "";//成功后清空


            if (ckb_isfanhuidenglu.Checked)
            {
                qiehuan();
            }
        }
예제 #4
0
        private void btn_denlu_Click(object sender, EventArgs e)//点击了登陆的按钮
        {
            love.isloginexit = true;
            #region 判断是否已经输入了账号还有密码
            if (txt_username.Text.Trim() == "")
            {
                MessageBox.Show("请确保你输入了账号", "账号提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txt_username.Focus();
                return;
            }
            if (txt_password.Text.Trim() == "")
            {
                MessageBox.Show("请确保你输入了密码", "密码提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                txt_password.Focus();
                return;
            }
            #endregion
            string sql1 = "select * from sellde where username=@u and pwd = @p";
            string sql2 = "select * from buyde where username=@u and pwd = @p";
            //不要共用参数数组,会提示     另一个 SqlParameterCollection 中已包含 SqlParameter。
            SqlParameter[] p      = { new SqlParameter("@u", txt_username.Text), new SqlParameter("@p", txt_password.Text) };
            SqlParameter[] p1     = { new SqlParameter("@u", txt_username.Text), new SqlParameter("@p", txt_password.Text) };
            DataTable      sellde = sqlHelper.ExecutedataTable(sql1, CommandType.Text, p);
            DataTable      buyde  = sqlHelper.ExecutedataTable(sql2, CommandType.Text, p1);
            #region 说明他是卖家
            if (sellde.Rows.Count != 0)
            {
                Text = "卖";
                love.denglu_IsSelldeOrBuyde = "卖";
                love.denglu_username        = txt_username.Text;
                love.denglu_password        = txt_password.Text;

                //开始判断它是否填写了详细信息   没有的话就让他填写
                sellde s = new sellde();
                s.Username = txt_username.Text;
                if (s.isorther() == false)
                {                             //说明没有注册详细信息,因为没有查到任何记录
                    love.isloginexit = false; //没有查到就把它改为false这样在登陆页按退出才能出现退出提示
                    Hide();
                    Frm_UserOrther f = new Frm_UserOrther();
                    f.ShowDialog();
                    Show();
                    if (love.user_orther)
                    {
                        Close();
                    }
                }
                else
                {
                    love.user_orther = true;
                    Close();
                }

                //开始把账号密码写进去
                //创建文件流,写入文件路径(文件夹先创建好)和文件名  打开方式为写入
                FileStream   fs  = new FileStream(Application.StartupPath + "\\zhmmdll", FileMode.Create);
                string       sss = "zh" + love.denglu_username.Trim() + "zh\r\nmm" + love.denglu_password.Trim();
                StreamWriter sw  = new StreamWriter(fs, Encoding.Default);
                //StreamWriter sw = new StreamWriter(fs );
                sw.Write(sss);
                sw.Close(); //记得先关闭阅读流
                fs.Close(); //关闭文件流,两个都要关闭
            }
            #endregion

            #region 说明他是买家
            else if (buyde.Rows.Count != 0)
            {
                //select * from buyde
                Text = "买";
                love.denglu_username        = txt_username.Text;
                love.denglu_password        = txt_password.Text;
                love.denglu_IsSelldeOrBuyde = "买";

                //开始判断它是否填写了详细信息   没有的话就让他填写

                buyde b = new buyde();
                b.Username = txt_username.Text;
                if (b.isorther() == false)
                {                             //说明没有注册详细信息,因为没有查到任何记录
                    love.isloginexit = false; //没有查到就把它改为false这样在登陆页按退出才能出现退出提示
                    Hide();
                    Frm_UserOrther f = new Frm_UserOrther();
                    f.ShowDialog();
                    Show();
                    if (love.user_orther)
                    {
                        Close();
                    }
                }
                else
                {
                    love.user_orther = true;
                    Close();
                }
                //开始把账号密码写进去
                //创建文件流,写入文件路径(文件夹先创建好)和文件名  打开方式为写入
                FileStream   fs  = new FileStream(Application.StartupPath + "\\zhmmdll", FileMode.Create);
                string       sss = "zh" + love.denglu_username.Trim() + "zh\r\nmm" + love.denglu_password.Trim();
                StreamWriter sw  = new StreamWriter(fs, Encoding.Default);
                //StreamWriter sw = new StreamWriter(fs );
                sw.Write(sss);
                sw.Close(); //记得先关闭阅读流
                fs.Close(); //关闭文件流,两个都要关闭
            }
            #endregion

            else
            {
                MessageBox.Show("请检查账号密码的正确性", "登陆提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
        }
예제 #5
0
        private void btn_Ok_Click(object sender, EventArgs e)//点击确定按钮
        {
            foreach (Control i in Controls)
            {
                if (i is TextBox)
                {
                    if (i.Text.Trim() == string.Empty)
                    {
                        MessageBox.Show("请输入内容再进行操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        i.Focus();
                        return;
                    }
                }
            }

            try
            {
                long.Parse(txt_telephon.Text);
            }
            catch
            {
                MessageBox.Show("电话格式不正确,请检查后重新操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txt_telephon.Focus();
                txt_telephon.SelectAll();
                return;
            }


            string shi         = cmd_Shi.Text;
            string xiang       = cmd_Xiang.Text;
            string xiangxi     = txt_xiangxidizhi.Text;
            string nicheng     = txt_Ni.Text;
            long   telephong   = long.Parse(txt_telephon.Text);
            string sheng       = cmd_Sheng.Text;
            string quanbudizhi = sheng + " " + shi + " " + xiang + " " + xiangxi;
            string mibaowenti  = txt_Xinmibao.Text;
            string mibaodaan   = txt_mibaodaan.Text;

            if (love.denglu_IsSelldeOrBuyde == "卖")
            {
                sellde s = new sellde();
                s.Username   = love.denglu_username == string.Empty ? "a" : love.denglu_username;
                s.Nicheng    = txt_Ni.Text;
                s.Telephone  = long.Parse(txt_telephon.Text);
                s.Fahuodizhi = quanbudizhi;
                s.Mibaowt    = txt_Xinmibao.Text;
                s.Mibaodan   = txt_mibaodaan.Text;

                s.Photo = sqlHelper.tiqupic(pic_touxiang, Application.StartupPath + "\\a.jpg");
                s.upxiugaiziliao();
            }
            else
            {
                buyde s = new buyde();
                s.Username     = love.denglu_username == string.Empty ? "a" : love.denglu_username;
                s.Nicheng      = txt_Ni.Text;
                s.Telephone    = long.Parse(txt_telephon.Text);
                s.Shouhuodizhi = quanbudizhi;
                s.Mibaowt      = txt_Xinmibao.Text;
                s.Mibaodan     = txt_mibaodaan.Text;

                s.Photo = sqlHelper.tiqupic(pic_touxiang, Application.StartupPath + "\\a.jpg");
                s.upxiugaiziliao();
            }
            MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            tjtx(sender, e);
        }