예제 #1
0
        public static int InsertConsumer(USERS_DTO user,KHACH_HANG_DTO consumer)
        {
            provider.connect();
            string sqlCommand = "sp_InsertConsumer";
            List<SqlParameter> list = new List<SqlParameter>();
            list.Add(new SqlParameter("@username", user.UserName));
            list.Add(new SqlParameter("@password",user.PassWord));
            list.Add(new SqlParameter("@email",user.EMail));
            list.Add(new SqlParameter("@tendn",consumer.TenDoanhNghiep));
            list.Add(new SqlParameter("@diachi",consumer.DiaChi));
            list.Add(new SqlParameter("@sdt",consumer.SoDienThoai));
            list.Add(new SqlParameter("@tendaidien",consumer.NguoiDaiDien));
            list.Add(new SqlParameter("@website",consumer.WebSite));
            SqlParameter result=new SqlParameter("@result",SqlDbType.Int);
            result.Direction = ParameterDirection.ReturnValue;
            list.Add(result);
            try
            {
                provider.executeNonQueryProcedure(sqlCommand, list);

            }
            catch (Exception e)
            {
                //throw new Exception(e.ToString());
                return -1;

            }
            finally
            {
                provider.disconnect();
            }
            return (int)result.Value;
        }
예제 #2
0
 public static int InsertConsumer(USERS_DTO user, KHACH_HANG_DTO consumer)
 {
     try
     {
         user.PassWord = MD5.encryptPassword(user.PassWord);
         return UserDAO.InsertConsumer(user,consumer);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
예제 #3
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            /* showMessage("cureenExFilPath" + Request.CurrentExecutionFilePath.ToString());
            //GUI/Register.aspx
               // showMessage("Filepa " + Request.FilePath);
               // showMessage("path " + Request.Path);
            //showMessage("pathinf " + Request.PathInfo); hong co
               // showMessage("physicapp " + Request.PhysicalApplicationPath);
               // showMessage("phsicpath " + Request.PhysicalPath);//dia chi day du
            //showMessage("rawurl " + Request.RawUrl);*/
               // showMessage("absolutepath " + Request.Url.AbsolutePath);//BUI/Consumer
               // showMessage("absoluteuri " + Request.Url.AbsoluteUri);// http://localhost:1155/GUI/Consumers/Register.aspx
               // showMessage("hostname " + Request.UserHostName);//127.1.1
               // showMessage(Request.UserHostAddress);

               captcha.ValidateCaptcha(txtCaptcha.Text);
            if (captcha.UserValidated)
            {
                USERS_DTO user = new USERS_DTO();
                KHACH_HANG_DTO consumer = new KHACH_HANG_DTO();
                user.UserName = txtusername.Value;
                user.PassWord = txtPass.Text;
                user.MaLoaiUser = 3;
                user.EMail = txtEmail.Text;
                user.TrangThai = 0;

                consumer.DiaChi = txtAddress.Text;
                consumer.TenDoanhNghiep = txtBusinessName.Text;
                consumer.SoDienThoai = txtPhone.Text;
                consumer.WebSite = txtWebAdress.Text;
                consumer.NguoiDaiDien = txtPersonName.Text;

                try
                {
                    int result= UserBUS.InsertConsumer(user, consumer);
                    if (result == 1)
                    {
                        string body = "<h4>Hi,"+user.UserName+"</h4><b>Doanh nghiệp bạn đã đăng ký thành công tại beatifulHouseGroup</b><br/>";
                        body += "<b style='color:red'>Hãy click link bên dưới để hoàn tất việc đăng ký </b><br/>";
                        string fullpath = Request.Url.AbsoluteUri;
                        int index = fullpath.LastIndexOf("/");
                        fullpath = fullpath.Remove(index);
                        body += "<a href='" + fullpath + "/Active.aspx?username="******"&id="+MD5.encryptPassword(user.UserName)+"'><b>" + fullpath + "/Active.aspx</b></a>";//chỗ này khi code sẽ kèm tham số là username+ băm gì đó
                        string subject = "Kich hoat tai khoan";
                        bool test = Email.sendMail(user.EMail, body, subject);

                        lbCaptcha.Visible = false;
                        showMessage(message);
                    }
                }
                catch (Exception ex)
                {
                    //Chưa xử lý
                }

            }
            else
            {
                lbCaptcha.Text = "Mã an toàn không đúng !";
                lbCaptcha.Visible = true;
                return;
            }
        }
예제 #4
0
        public static USERS_DTO LayThongTinUserTheoUserName(string username)
        {
            provider.connect();

            string sqlCommand = "sp_LayThongTinUserTheoUserName";
            List<SqlParameter> list = new List<SqlParameter>();
            list.Add(new SqlParameter("@username", username));
            try
            {
                USERS_DTO user = new USERS_DTO();
                DataTable table = provider.executeQueryDataTableProcedure(sqlCommand, list);
                if (table != null && table.Rows.Count > 0)
                {
                    DataRow row = table.Rows[0];
                    user.UserName = row["USERNAME"].ToString();
                    user.EMail = row["EMAIL"].ToString();
                    user.TrangThai = int.Parse(row["TRANGTHAI"].ToString());
                    user.MaLoaiUser =int.Parse( row["MALOAI"].ToString());
                    user.PassWord = row["PASS_WORD"].ToString();
                }
                return user;

            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                provider.disconnect();
            }
        }
예제 #5
0
        public static List<USERS_DTO> LayDanhSachUserTheoLoaiUser(string tenloai)
        {
            provider.connect();
            List<USERS_DTO> ds = new List<USERS_DTO>();

            string sqlCommand = "sp_LayDanhSachUserTheoLoaiUser";
            List<SqlParameter> list = new List<SqlParameter>();
            list.Add(new SqlParameter("@tenloai", tenloai));
            try
            {
                DataTable table = provider.executeQueryDataTableProcedure(sqlCommand, list);
                foreach (DataRow dr in table.Rows)
                {
                    USERS_DTO user = new USERS_DTO();
                    user.UserName = dr["USERNAME"].ToString();
                    user.MaLoaiUser = int.Parse(dr["MALOAI"].ToString());
                    user.PassWord = dr["PASS_WORD"].ToString();
                    user.EMail = dr["EMAIL"].ToString();
                    user.TrangThai = int.Parse(dr["TRANGTHAI"].ToString());
                    ds.Add(user);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                provider.disconnect();
            }
            return ds;
        }