Пример #1
0
        public ActionResult RegisterTH(Customer obj)
        {
            try
            {
                ModelState.Remove("IdentityID");
                if (ModelState.IsValid)
                {
                    obj.IdentityID = obj.tempIden.UrlDescriptHttp();

                    /*
                     * var rst = _RegisterTH(obj);
                     * if(rst.Status == true)
                     * {
                     * rst.text = Url.Action("Index", "Home");
                     * }
                     */

                    //return Json(rst,JsonRequestBehavior.AllowGet);

                    CustomerMapDao map = new CustomerMapDao();
                    if (map.FindIdentityCard(obj.IdentityID).Count == 0)
                    {
                        //obj.IdentityID = obj.IdentValid.UrlDescriptHttp();
                        int            ID      = SaveAccount.Register(obj.IdentityID, obj.TitleID, obj.Fname, obj.Lname, obj.Sex, obj.DateOfBirthStr, obj.Address, obj.DistrictID, obj.PrefectureID, obj.ProvinceID, obj.ZipCode, obj.Tel, obj.Tel_ext, obj.Mobile, obj.Fax, obj.Email, obj.OccupationID, obj.SalaryID, obj.TypeCustomer, obj.FromApp, obj.IsOversea);
                        CustomerMapDao _CusMap = new CustomerMapDao();
                        obj = _CusMap.FindById(ID);
                        if (!string.IsNullOrEmpty(obj.Email))
                        {
                            SendEmail.SendMail(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("regisTemplate", obj));
                            //SendMail.Send(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("ChangePassword", obj));
                        }

                        if (!string.IsNullOrEmpty(obj.Mobile))
                        {
                            //SmsLibs.SendSMS(obj.Mobile, SmsLibs.TypeMessage.register);
                            SmsLibs.SendSMS(obj.Mobile, string.Format(SmsLibs.CallStr(SmsLibs.TypeMessage.register), obj.IdentityID, Encryption.Decrypt(obj.Password)));
                        }

                        return(Json(new ResultData()
                        {
                            Status = true, text = Url.Action("Index", "Home")
                        }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new ResultData()
                        {
                            Status = false, text = Resources.Message.MsgDuplicate
                        }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch (Exception ex)
            {
                SaveUtility.logError(ex);
            }
            return(View(obj));
        }
Пример #2
0
        public ResultData _RegisterTH(Customer obj)
        {
            CustomerMapDao map = new CustomerMapDao();

            if (map.FindIdentityCard(obj.IdentityID).Count == 0)
            {
                //obj.IdentityID = obj.IdentValid.UrlDescriptHttp();
                int            ID      = SaveAccount.Register(obj.IdentityID, obj.TitleID, obj.Fname, obj.Lname, obj.Sex, obj.DateOfBirthStr, obj.Address, obj.DistrictID, obj.PrefectureID, obj.ProvinceID, obj.ZipCode, obj.Tel, obj.Tel_ext, obj.Mobile, obj.Fax, obj.Email, obj.OccupationID, obj.SalaryID, obj.TypeCustomer, obj.FromApp, obj.IsOversea);
                CustomerMapDao _CusMap = new CustomerMapDao();
                obj = _CusMap.FindById(ID);
                if (!string.IsNullOrEmpty(obj.Email))
                {
                    string filePath = Path.Combine(HttpRuntime.AppDomainAppPath, "Templates/regisTemplate.cshtml");
                    string html     = System.IO.File.ReadAllText(filePath);
                    SendEmail.SendMail(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", string.Format(html, obj.FullNameStr, obj.IdentityID, Encryption.Decrypt(obj.Password)));
                    if (!string.IsNullOrEmpty(obj.Mobile))
                    {
                        //SmsLibs.SendSMS(obj.Mobile, SmsLibs.TypeMessage.register);
                        SmsLibs.SendSMS(obj.Mobile, string.Format(SmsLibs.CallStr(SmsLibs.TypeMessage.register), obj.IdentityID, Encryption.Decrypt(obj.Password)));
                    }



                    //SendEmail.SendMail(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("regisTemplate", obj));
                }
                return(new ResultData()
                {
                    Status = true
                });
            }
            else
            {
                return(new ResultData()
                {
                    Status = false, text = Resources.Message.MsgDuplicate
                });
            }
        }
Пример #3
0
        public ActionResult RegisterEN(Customer_Oversea obj)
        {
            if (ModelState.IsValid)
            {
                if (TempData["Customer"] != null)
                {
                    CustomerMapDao Map    = new CustomerMapDao();
                    Customer       Cusobj = new Customer();

                    Cusobj = (Customer)TempData["Customer"];

                    Cusobj.Keygen            = Guid.NewGuid().ToString();
                    Cusobj.CreateDate        = DateTime.Now;
                    Cusobj.Active            = true;
                    Cusobj.IsConfirmRegister = false;
                    Cusobj.IsOversea         = true;
                    Cusobj.DateOfBirth       = Cusobj.DateOfBirthStr.todate();
                    //obj.Password = Helplibery.CreatePassword(8);
                    //Cusobj.Password = Encryption.Encrypt("12345678");
                    Cusobj.Password = Encryption.Encrypt(Helplibery.CreatePassword(8));
                    //Cusobj.Password = Helplibery.CreatePassword(10);

                    Map.Add(Cusobj);
                    Map.CommitChange();

                    int ID = GetAccount.GetCustomerLastID();
                    Customer_OverseaMapDao OverMap = new Customer_OverseaMapDao();
                    obj.CustomerID = ID;

                    if (obj.PurposeIList != null)
                    {
                        obj.purpose_id = Convert.ToInt32(string.Join(",", obj.PurposeIList));
                    }

                    OverMap.Add(obj);
                    OverMap.CommitChange();

                    //////////////////////////////////////////////////////////////////////////////////////////////////////////

                    CustomerMapDao map = new CustomerMapDao();
                    if (map.FindIdentityCard(Cusobj.IdentityID).Count == 0)
                    {
                        //obj.IdentityID = obj.IdentValid.UrlDescriptHttp();
                        int            CusID   = SaveAccount.Register(Cusobj.IdentityID, Cusobj.TitleID, Cusobj.Fname, Cusobj.Lname, Cusobj.Sex, Cusobj.DateOfBirthStr, Cusobj.Address, Cusobj.DistrictID, Cusobj.PrefectureID, Cusobj.ProvinceID, Cusobj.ZipCode, Cusobj.Tel, Cusobj.Tel_ext, Cusobj.Mobile, Cusobj.Fax, Cusobj.Email, Cusobj.OccupationID, Cusobj.SalaryID, Cusobj.TypeCustomer, Cusobj.FromApp, Cusobj.IsOversea);
                        CustomerMapDao _CusMap = new CustomerMapDao();
                        Cusobj = _CusMap.FindById(CusID);
                        if (!string.IsNullOrEmpty(Cusobj.Email))
                        {
                            SendEmail.SendMail(Cusobj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("regisTemplate", Cusobj));
                            //SendMail.Send(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("ChangePassword", obj));
                        }
                        return(Json(new ResultData()
                        {
                            Status = true, text = Url.Action("Index", "Home")
                        }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        //return Json(new ResultData() { Status = false, text = Resources.Message.MsgDuplicate }, JsonRequestBehavior.AllowGet);
                        CustomerMapDao _CusMap = new CustomerMapDao();
                        int            CusID   = GetAccount.GetCustomerLastID();
                        if (!string.IsNullOrEmpty(Cusobj.Email))
                        {
                            SendEmail.SendMail(Cusobj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("regisTemplate", Cusobj));
                            //SendMail.Send(obj.Email, "สํานักงานคณะกรรมการคุ้มครองผู้บริโภค ยินดีต้อนรับเข้าสู่การเป็นสมาชิก", RenderPartialViewToString("ChangePassword", obj));
                        }
                        return(Json(new ResultData()
                        {
                            Status = true, text = Url.Action("Index", "Home")
                        }, JsonRequestBehavior.AllowGet));
                    }

                    //////////////////////////////////////////////////////////////////////////////////////////////////////////

                    return(Json(new ResultData()
                    {
                        Status = true, text = Url.Action("Index", "Home")
                    }, JsonRequestBehavior.AllowGet));

                    //return Json(new { RedirectUrl = Url.Action("Index", "Home") });
                }
            }
            return(View(obj));
        }