Пример #1
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;
            }
        }
Пример #2
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);
        }