partial void DeleteVolunteers(Volunteers instance);
 partial void InsertVolunteers(Volunteers instance);
 partial void UpdateVolunteers(Volunteers instance);
        private void LoginCookie(HttpContextBase httpContext, Volunteers item, bool RememberMe)
        {
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                Method.CookieVersion_Home,
                item.Mobile,//item.Account,
                DateTime.UtcNow,
                DateTime.UtcNow.AddMinutes(60),
                RememberMe,
                item.Name + "," + item.Password,
                FormsAuthentication.FormsCookiePath);

            string encTicket = FormsAuthentication.Encrypt(ticket);

            httpContext.Response.Cookies.Add(new HttpCookie(Method.CookieName_Home, encTicket));
            httpContext.Response.Cookies[Method.CookieName_Home].Path = "/";
        }
 private void LoginSession(HttpContextBase httpContext, Volunteers item)
 {
     httpContext.Session.RemoveAll();
     httpContext.Session.Add(Method.SessionUserId_Home, item.Id);
     httpContext.Session.Add(Method.SessionUserAccount_Home, item.MemberNumber);
     httpContext.Session.Add(Method.SessionUserName_Home, item.Name);
     httpContext.Session.Add(Method.SessionUserEmail_Home, item.Email);
 }
 public int Insert(VolunteersShow item, HttpPostedFileBase file, string vid, HttpServerUtilityBase Server)
 {
     var photos = "";
     s26webDataContext db = new s26webDataContext();
     if (file != null)
         if (file.ContentLength > 0 && file.ContentType.ToLower() == "image/jpeg" || file.ContentType == "image/png")
             photos = Method.Upload_File(file, vid, Server);
         else
             photos = "";
     if (item.LastMemberId > 0)
         item.AdminUpdateTime = DateTime.Now;
     try
     {
          Volunteers new_item = new Volunteers
         {
             Mobile = item.Mobile,
             Password = Get_HashPassword(item.Password),
             Name = item.Name,
             BabyBirthday = item.BabyBirthday.Value,
             NowBrand = item.NowBrand,
             BrandName = item.BrandName,
             Email = item.Email,
             CityId = item.CityId,
             AreaId = item.AreaId,
             Address = item.Address,
             GiftMobile = item.GiftMobile,
             CityId2 = item.CityId2,
             AreaId2 = item.AreaId2,
             Address2 = item.Address2,
             Status = item.Status,
             SendCount = item.SendCount,
             Photos = photos,
             SerialNo = item.SerialNo,
             MemberNumber = item.NowBrand,
             FBConnect = item.FBConnect,
             FBFriend = item.FBFriend,
             Memo = item.Memo,
             AdminUpdateTime = item.AdminUpdateTime,                    
             CreateTime = DateTime.UtcNow,
             UpdateTime = DateTime.UtcNow,   
             Point = 0  
         };
         db.Volunteers.InsertOnSubmit(new_item);
         db.SubmitChanges();
         db.Connection.Close();
         return new_item.Id;
     }
     catch 
     {
         return -1;
     }
 }   
        public Volunteers Insert(RegisterModel model, HttpPostedFileBase file, string vid, HttpServerUtilityBase Server, int year , int month , int date)
        {
            var photos = "";
            if (file != null)
                if (file.ContentLength > 0 && file.ContentType.ToLower() == "image/jpeg" || file.ContentType == "image/png")
                    photos = Method.Upload_File(file, vid, Server);
                else
                    photos = "";
            try
            {
                DateTime bir = new DateTime(year, month, date);
                s26webDataContext db = new s26webDataContext();

                //若畫面日期大於當下日期表示懷孕中
                int int_NowBrand;
                int Dat_Compare = DateTime.Compare(bir, DateTime.UtcNow);
                if (Dat_Compare > 0)
                {
                    int_NowBrand = 1;
                }
                else
                {
                    int_NowBrand = model.Product;
                }

                var vol = new Volunteers
                {
                    Mobile = model.Mobile,
                    Password = Get_HashPassword(model.Password),
                    Name = model.Name,
                    BabyBirthday = bir,
                    Email = model.Email,
                    Status = 1,
                    NowBrand = int_NowBrand,
                    BrandName = model.BrandName ,
                    MemberNumber = int_NowBrand,
                    Photos = photos,
                    SerialNo = model.SerialNo,
                    CreateTime = DateTime.UtcNow,
                    UpdateTime = DateTime.UtcNow,
                    Point = 0
                };
                db.Volunteers.InsertOnSubmit(vol);
                db.SubmitChanges();
                db.Connection.Close();
                return vol;
            }
            catch
            {
                return null;
            }

        }
        private void LoginAccount(Volunteers item, bool RememberMe = false)
        {
            //Session.RemoveAll();
            Session[Method.SessionUserId_Home] = null;
            Session[Method.SessionUserAccount_Home] = null;
            Session[Method.SessionUserName_Home] = null;
            Session[Method.SessionUserEmail_Home] = null;
            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                s26web.Models.Method.CookieVersion_Home,
                item.Mobile,//item.Account,
                DateTime.UtcNow,
                DateTime.UtcNow.AddMinutes(60),
                RememberMe,
                item.Name + "," + item.Password,
                FormsAuthentication.FormsCookiePath);

            string encTicket = FormsAuthentication.Encrypt(ticket);

            Response.Cookies.Add(new HttpCookie(s26web.Models.Method.CookieName_Home, encTicket));
            Response.Cookies[s26web.Models.Method.CookieName_Home].Path = "/";
            Session.Add(Method.SessionUserId_Home, item.Id);
            Session.Add(Method.SessionUserAccount_Home, item.Mobile);
            Session.Add(Method.SessionUserName_Home, item.Name);
            Session.Add(Method.SessionUserEmail_Home, item.Email);
        }