protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string strErr = "";

                int number = int.Parse(txt_number.Value);
                int addressID;
                if (number <= 0 && number > int.Parse(lblcom_number.Text))
                {
                    strErr = "回收的数量不符合要求";
                }
                if (strErr != "")
                {
                    MessageBox.Show(this, strErr);
                    return;
                }

                if (r6.Checked)
                {
                    addressID = int.Parse(lb_address.SelectedValue);
                }
                else
                {
                    Model.t_address address = new Model.t_address();
                    address.add_province     = ddl_p.Items[ddl_p.SelectedIndex].Text;
                    address.add_city         = ddl_c.Items[ddl_c.SelectedIndex].Text;
                    address.add_counties     = ddl_d.Items[ddl_d.SelectedIndex].Text;
                    address.add_address      = input_Address.Text;
                    address.add_date         = DateTime.Now;
                    address.add_default      = "0";
                    address.add_u_ID         = int.Parse(userid.Text);
                    address.add_postcode     = 000000;
                    address.add_contactName  = input_userName.Text;
                    address.add_contactPhone = input_phone.Text;
                    address.add_ID           = new BLL.t_address().GetMaxId();
                    bool istrue = new BLL.t_address().Add(address);
                    addressID = address.add_ID;
                }
                user = new BLL.t_user().GetModel(int.Parse(userid.Text));
                int      tra_U_ID = int.Parse(userid.Text);
                decimal  tra_transactionAmount = decimal.Parse(this.lblcom_conversionInt.Text);
                DateTime tra_transactionDate   = DateTime.Now;
                string   tra_accomplish        = "发布";
                int      tra_staff_id          = 0;
                int      sta_comwas_id         = int.Parse(this.lblcom_id.Text);
                int      tra_number            = int.Parse(this.txt_number.Value);
                if (user.u_integral < tra_number * tra_transactionAmount)
                {
                    strErr += "你的积分不够哦!\\n";
                    MessageBox.Show(this, strErr);
                    return;
                }
                user.u_integral = Convert.ToInt32(user.u_integral - tra_number * tra_transactionAmount);
                bool isuser = new BLL.t_user().Update(user);
                // int tra_addressID = int.Parse(this.rad_address.SelectedValue);
                string tra_type  = "商品";
                string tra_vaild = "是";
                int    tra_sort  = 1;

                WalleProject.Model.t_tradingrecord model = new WalleProject.Model.t_tradingrecord();
                model.tra_addressID         = addressID;
                model.tra_U_ID              = tra_U_ID;
                model.tra_transactionAmount = tra_transactionAmount;
                model.tra_transactionDate   = tra_transactionDate;
                model.tra_accomplish        = tra_accomplish;
                model.tra_staff_id          = tra_staff_id;
                model.sta_comwas_id         = sta_comwas_id;
                model.tra_number            = tra_number;
                model.tra_type              = tra_type;
                model.tra_vaild             = tra_vaild;
                model.tra_sort              = tra_sort;

                WalleProject.BLL.t_tradingrecord bll = new WalleProject.BLL.t_tradingrecord();
                bll.Add(model);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "发布成功,等待回收员接单", "CommodityView.aspx?id=9");
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
            }
        }
        protected void btn_Login_Click1(object sender, EventArgs e)
        {
            Console.WriteLine(Session["CheckCode"]);
            #region 检查验证码
            if ((Session["CheckCode"] != null) && (Session["CheckCode"].ToString() != ""))
            {
                if (Session["CheckCode"].ToString().ToLower() != this.CheckCode.Value.ToLower())
                {
                    this.lblMsg.Text     = "输入的验证码有误!";
                    Session["CheckCode"] = null;
                    return;
                }
                else
                {
                    this.lblMsg.Text     = "";
                    Session["CheckCode"] = null;
                    string userName  = PageValidate.InputText(input_userName.Text.Trim(), 30);
                    string Password  = MD5Enctypt.MD5.Md5Encrypt(PageValidate.InputText(input_passWord.Text.Trim(), 30));
                    string Password2 = MD5Enctypt.MD5.Md5Encrypt(PageValidate.InputText(input_passWord2.Text.Trim(), 30));
                    string address   = PageValidate.InputText(input_Address.Text.Trim(), 100);
                    string phone     = PageValidate.InputText(input_phone.Text.Trim(), 15);
                    string name      = PageValidate.InputText(input_Name.Text.Trim(), 30);
                    string idnumber  = PageValidate.InputText(input_IDnumber.Text.Trim(), 4);

                    BLL.t_user t_User        = new BLL.t_user();
                    bool       isPhoneExists = t_User.Exists(phone);
                    if (isPhoneExists)
                    {
                        this.lblMsg.Text = "您输入的电话号码已经注册!";
                        Response.Write("<script> alert('您输入电话号码已经注册!')</script>");
                    }
                    if (Password != Password2)
                    {
                        this.lblMsg.Text = "两次密码不匹配!";
                        Response.Write("<script> alert('两次密码不匹配!')</script>");
                    }
                    if (!PageValidate.IsNumber(idnumber))
                    {
                        this.lblMsg.Text = "您输入的身份证号码不是数字!";
                        Response.Write("<script> alert('您输入的身份证号码不是数字!')</script>");
                    }
                    else
                    {
                        Model.t_user user = new Model.t_user();
                        user.u_address = ddl_p.Items[ddl_p.SelectedIndex].Text
                                         + ddl_c.Items[ddl_c.SelectedIndex].Text
                                         + ddl_d.Items[ddl_d.SelectedIndex].Text + input_Address.Text;
                        user.u_birthDate        = DateTime.Parse(this.input_birthdate.Text);
                        user.u_creaditsLogID    = int.Parse(this.input_IDnumber.Text);
                        user.u_name             = input_Name.Text;
                        user.u_phone            = input_phone.Text;
                        user.u_registrationDate = DateTime.Now;
                        user.u_nickName         = input_userName.Text;
                        user.u_passWord         = Password;
                        t_User.Add(user);

                        Model.t_address addressF = new Model.t_address();
                        addressF.add_contactName  = user.u_name;
                        addressF.add_u_ID         = new BLL.t_user().GetModel(user.u_phone).u_ID;
                        addressF.add_contactPhone = user.u_phone;
                        addressF.add_address      = input_Address.Text;
                        addressF.add_province     = ddl_p.Items[ddl_p.SelectedIndex].Text;
                        addressF.add_counties     = ddl_d.Items[ddl_d.SelectedIndex].Text;
                        addressF.add_city         = ddl_c.Items[ddl_c.SelectedIndex].Text;
                        addressF.add_date         = DateTime.Now;
                        addressF.add_default      = "1";

                        new BLL.t_address().Add(addressF);
                        Response.Write("<script> alert('成功注册,回到登录页面!')</script>");
                        Response.Redirect("../User/UserLogin.aspx");
                    }

                    #region
                    ////验证登录信息,如果验证通过则返回当前用户对象的安全上下文信息
                    //// AccountsPrincipal newUser = AccountsPrincipal.ValidateLogin(userName, Password);
                    //BLL.t_user user = new BLL.t_user();
                    //if (isNumber)
                    //{
                    //    if (user.Exists(int.Parse(userName)))
                    //    {
                    //        if (user.IsLogin(int.Parse(userName), Password))
                    //        {
                    //            WalleProject.Model.t_user _user = new WalleProject.Model.t_user();
                    //            _user = user.GetModel(int.Parse(userName));
                    //            Session["UserInfo"] = _user;

                    //            HttpCookie cookie = new HttpCookie("USER_NAME");
                    //            cookie.Value = input_userName.Text;
                    //            Response.Cookies.Add(cookie);

                    //            Response.Redirect("../User/Default.aspx");
                    //        }
                    //        else
                    //        {
                    //            this.lblMsg.Text = "您输入的密码不正确!";
                    //            Response.Write("<script>alert('您输入的密码不正确!')</script>");
                    //        }
                    //    }
                    //    else
                    //    {
                    //        this.lblMsg.Text = "您输入的用户名不存在!";
                    //        Response.Write("<script> alert('您输入的用户名不存在!')</script>");
                    //    }
                    //}
                    #endregion
                }
            }
            else
            {
                Response.Redirect("../User/UserRigister.aspx");
            }
            #endregion


            #region

            /*
             * if (newUser == null)//登录信息不对
             * {
             *  this.lblMsg.Text = "登陆失败: " + userName;
             *  if ((Session["PassErrorCountAdmin"] != null) && (Session["PassErrorCountAdmin"].ToString() != ""))
             *  {
             *      int PassErroeCount = Convert.ToInt32(Session["PassErrorCountAdmin"]);
             *      Session["PassErrorCountAdmin"] = PassErroeCount + 1;
             *  }
             *  else
             *  {
             *      Session["PassErrorCountAdmin"] = 1;
             *  }
             * }
             * else
             * {
             *
             *  //根据用户对象的上下文得到用户对象信息,用于得到其他信息
             *  User currentUser = new LTP.Accounts.Bus.User(newUser);
             *  //if (currentUser.UserType != "AA")
             *  //{
             *  //    this.lblMsg.Text = "你非管理员用户,你没有权限登录后台系统!";
             *  //    return;
             *  //}
             *
             *  //把当前用户对象实例赋给Context.User,这样做将会把完整的用户信息加载到ASP.NET提供的验证体系中
             *  Context.User = newUser;
             *  //验证当前用户密码
             *  if (((SiteIdentity)User.Identity).TestPassword(Password) == 0)
             *  {
             *      this.lblMsg.Text = "你的密码无效!";
             *      if ((Session["PassErrorCountAdmin"] != null) && (Session["PassErrorCountAdmin"].ToString() != ""))
             *      {
             *          int PassErroeCount = Convert.ToInt32(Session["PassErrorCountAdmin"]);
             *          Session["PassErrorCountAdmin"] = PassErroeCount + 1;
             *      }
             *      else
             *      {
             *          Session["PassErrorCountAdmin"] = 1;
             *      }
             *  }
             *  else
             *  {
             *      //保存当前用户对象信息
             *      FormsAuthentication.SetAuthCookie(userName, false);
             *      Session["UserInfo"] = currentUser;
             *      Session["Style"] = currentUser.Style;
             *      if (Session["returnPage"] != null)
             *      {
             *          string returnpage = Session["returnPage"].ToString();
             *          Session["returnPage"] = null;
             *          Response.Redirect(returnpage);
             *      }
             *      else
             *      {
             *          Response.Redirect("main.htm");
             *      }
             *  }
             *
             * }*/
            #endregion
        }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (int.Parse(txt_number.Value) <= 0)
            {
                strErr = "回收的数量不符合要求";
            }
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            int number = int.Parse(txt_number.Value);
            int addressID;

            if (r6.Checked)
            {
                addressID = int.Parse(ListBox1.SelectedValue);
            }
            else
            {
                Model.t_address address = new Model.t_address();

                address.add_province     = ddl_p.Items[ddl_p.SelectedIndex].Text;
                address.add_city         = ddl_c.Items[ddl_c.SelectedIndex].Text;
                address.add_counties     = ddl_d.Items[ddl_d.SelectedIndex].Text;
                address.add_address      = input_Address.Text;
                address.add_date         = DateTime.Now;
                address.add_default      = "0";
                address.add_u_ID         = int.Parse(userid.Text);
                address.add_postcode     = 000000;
                address.add_contactName  = input_userName.Text;
                address.add_contactPhone = input_phone.Text;
                address.add_ID           = new BLL.t_address().GetMaxId();
                bool istrue = new BLL.t_address().Add(address);
                addressID = address.add_ID;
            }

            int      tra_U_ID = int.Parse(userid.Text);
            decimal  tra_transactionAmount = decimal.Parse(this.lblwas_price2.Text);
            DateTime tra_transactionDate   = DateTime.Now;
            string   tra_accomplish        = "发布";
            int      tra_staff_id          = 0;
            int      sta_comwas_id         = int.Parse(this.lblwas_ID.Text);
            int      tra_number            = int.Parse(txt_number.Value);
            // int tra_addressID = int.Parse(this.rad_address.SelectedValue);
            string tra_type  = "废品";
            string tra_vaild = "是";
            int    tra_sort  = 1;

            WalleProject.Model.t_tradingrecord model = new WalleProject.Model.t_tradingrecord();
            model.tra_addressID         = addressID;
            model.tra_U_ID              = tra_U_ID;
            model.tra_transactionAmount = tra_transactionAmount;
            model.tra_transactionDate   = tra_transactionDate;
            model.tra_accomplish        = tra_accomplish;
            model.tra_staff_id          = tra_staff_id;
            model.sta_comwas_id         = sta_comwas_id;
            model.tra_number            = tra_number;
            // model.tra_addressID = tra_addressID;
            model.tra_type  = tra_type;
            model.tra_vaild = tra_vaild;
            model.tra_sort  = tra_sort;

            WalleProject.BLL.t_tradingrecord bll = new WalleProject.BLL.t_tradingrecord();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "发布成功,等待回收员上门!", "WasteView.aspx?id=5");
        }