Пример #1
0
        public IActionResult ForgetPwd(string uname, string upwd)
        {
            member mb = _context.member.SingleOrDefault(m => m.mem_username == uname.ToUpper());

            if (mb != null)
            {
                var newpwd = Utils.GeneratePassword();
                mb.mem_password = Utils.EncodeMd5(newpwd);
                _context.Update(mb);
                _context.SaveChanges();

                var mr = _scontext.SecurityMemberRoles.SingleOrDefault(mrr => mrr.MemberId == mb.id);
                if (mr != null)
                {
                    mr.EditedBy   = mr.MemberId;
                    mr.EditedDate = DateTime.Now;
                    _scontext.Update(mr);
                    _scontext.SaveChanges();
                }

                SendEmail(mb.email, uname, newpwd);

                return(Json(new { result = "success" }));
            }
            else
            {
                return(Json(new { result = "fail" }));
            }
        }
Пример #2
0
        public IActionResult Create([Bind("album_code,album_date,album_desc,album_name,created_by,id,rowversion,x_log,x_note,x_status")] album album)
        {
            album.album_type = "V"; //video
            album.x_status   = "Y";
            album.created_by = "Administrator";

            _context.Add(album);
            _context.SaveChanges();

            var pImages = _context.pic_image.Where(p => (p.ref_doc_code == album.album_code) && (p.x_status == "N")).ToList();

            if (pImages != null)
            {
                foreach (var pImage in pImages)
                {
                    pImage.x_status = "Y";
                    _context.Update(pImage);
                }
                _context.SaveChanges();

                var uploads = Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_upload").Value);
                uploads = Path.Combine(uploads, album.album_code);

                DirectoryInfo di = new DirectoryInfo(uploads);
                if (di.Exists)
                {
                    var dest = Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_album").Value);
                    dest = Path.Combine(dest, album.album_code);
                    Directory.Move(uploads, dest);
                }
            }
            return(RedirectToAction("Index"));
        }
Пример #3
0
        public async Task <IActionResult> SettingsDisplayName(string uname)
        {
            var memberId = HttpContext.Session.GetString("memberId");

            if (memberId != null)
            {
                var m = await _context.member.SingleOrDefaultAsync(mm => mm.id == new Guid(memberId));

                if (m != null)
                {
                    uname   = uname.Trim();
                    m.fname = uname;
                    _context.Update(m);
                    await _context.SaveChangesAsync();

                    HttpContext.Session.SetString("displayname", uname);
                    ViewBag.UserName = uname;

                    return(Json(new { result = "success", uname = uname }));
                }
                else
                {
                    return(Json(new { result = "fail" }));
                }
            }
            else
            {
                return(Json(new { result = "fail" }));
            }
        }
Пример #4
0
        public async Task <IActionResult> Edit(string id, [Bind("product_code,member_code,grow_area,id,rowversion,x_log,x_note,x_status")] mem_product mem_product)
        {
            if (id != mem_product.product_code)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mem_product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!mem_productExists(mem_product.product_code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(mem_product));
        }
        public async Task <IActionResult> Edit(string id, [Bind("district_code,province_code,country_code,area_part,dist_desc,id,rowversion,x_log,x_note,x_status")] ini_district ini_district)
        {
            if (id != ini_district.district_code)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ini_district);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ini_districtExists(ini_district.district_code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(ini_district));
        }
Пример #6
0
        public async Task <IActionResult> Edit(string id, [Bind("cgroup_code,cgroup_desc,id,x_status")] course_group course_group)
        {
            if (course_group.id != new Guid(id))
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    course_group cg = _context.course_group.SingleOrDefault(c => (c.id == new Guid(id)));
                    cg.cgroup_code = course_group.cgroup_code.Trim();
                    cg.cgroup_desc = course_group.cgroup_desc.Trim();
                    cg.x_status    = course_group.x_status;
                    _context.Update(cg);

                    //_context.Update(course_group);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!course_groupExists(course_group.id.ToString()))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(course_group));
        }
Пример #7
0
        public IActionResult Edit(string memberId, string productId, string mem_productId)
        {
            var m  = _context.member.SingleOrDefault(mb => mb.id == new Guid(memberId));
            var pd = _context.product.SingleOrDefault(pr => pr.id == new Guid(productId));

            var mproCheck = _context.mem_product.Where(mpr => (mpr.member_code == m.member_code) && (mpr.product_code == pd.product_code)).Count();

            if (mproCheck == 0)
            {
                mem_product mp = new mem_product();
                mp.member_code  = m.member_code;
                mp.product_code = pd.product_code;
                mp.x_status     = "Y";
                _context.Add(mp);

                var mpro  = _context.mem_product.SingleOrDefault(mpr => (mpr.member_code == m.member_code) && (mpr.id == new Guid(mem_productId)));
                var recno = mpro.rec_no;
                _context.Remove(mpro);

                _context.SaveChanges();

                var mpro2 = _context.mem_product.SingleOrDefault(mpr => (mpr.member_code == m.member_code) && (mpr.product_code == pd.product_code));
                mpro2.rec_no = recno;
                _context.Update(mpro2);
                _context.SaveChanges();

                return(Json(new { result = "success" }));
            }
            else
            {
                return(Json(new { result = "duplicate" }));
            }
        }
Пример #8
0
        public async Task <IActionResult> Edit(string id, [Bind("project_code,active_member_join,budget,id,passed_member,project_approve_date,project_date,project_desc,project_manager,ref_doc,target_member_join,x_log,x_note,x_status")] project project)
        {
            if (new Guid(id) != project.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!projectExists(project.project_code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(project));
        }
        public IActionResult Edit(string memberId, string member_code, string medical_history, string blood_group, string hobby, string restrict_food, string special_skill)
        {
            ViewBag.memberId = memberId;

            mem_health mem_health = _context.mem_health.SingleOrDefault(m => m.member_code == member_code);

            if (mem_health == null)
            {
                mem_health mh = new mem_health();
                mh.member_code     = member_code;
                mh.medical_history = medical_history;
                mh.blood_group     = blood_group;
                mh.hobby           = hobby;
                mh.restrict_food   = restrict_food;
                mh.special_skill   = special_skill;
                mh.x_status        = "Y";
                _context.Add(mh);
            }
            else
            {
                mem_health mh = mem_health;
                mh.member_code     = member_code;
                mh.medical_history = medical_history;
                mh.blood_group     = blood_group;
                mh.hobby           = hobby;
                mh.restrict_food   = restrict_food;
                mh.special_skill   = special_skill;
                mh.x_status        = "Y";
                _context.Update(mh);
            }

            _context.SaveChanges();
            return(Json(new { result = "success" }));
        }
Пример #10
0
        public async Task <IActionResult> Edit(string id, [Bind("spon_code,confirm_date,contactor,contactor_detail,id,ref_doc,spon_desc,x_log,x_note,x_status")] project_sponsor project_sponsor)
        {
            if (new Guid(id) != project_sponsor.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project_sponsor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!project_sponsorExists(project_sponsor.spon_code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(project_sponsor));
        }
        public async Task <IActionResult> Edit(string id, [Bind("client_code,system,module,cnfig_item,id,rowversion,text_value,x_log,x_note,x_status")] ini_config ini_config)
        {
            if (id != ini_config.client_code)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ini_config);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ini_configExists(ini_config.client_code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(ini_config));
        }
Пример #12
0
 public async Task <IActionResult> Edit(string id, [Bind("ctype_code,cgroup_code,ctype_desc,id,rowversion,x_log,x_note,x_status")] course_type course_type)
 {
     if (course_type.id != new Guid(id))
     {
         return(Json(new { result = "fail" }));
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(course_type);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!course_typeExists(course_type.ctype_code))
             {
                 return(Json(new { result = "fail" }));
             }
             else
             {
                 throw;
             }
         }
         return(Json(new { result = "success" }));
     }
     return(Json(new { result = "fail" }));
 }
        public async Task <IActionResult> Edit(string id, [Bind("product_type_code,product_group_code,id,product_type_desc,rowversion,x_log,x_note,x_status")] product_type product_type)
        {
            if (id != product_type.product_type_code)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product_type);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!product_typeExists(product_type.product_type_code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(product_type));
        }
Пример #14
0
        public async Task <IActionResult> Edit(string id, [Bind("place_code,confirm_date,contactor,contactor_detail,id,place_desc,ref_doc,x_log,x_note,x_status")] train_place train_place)
        {
            if (new Guid(id) != train_place.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(train_place);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!train_placeExists(train_place.place_code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(train_place));
        }
Пример #15
0
 public IActionResult Edit(ini_country ini_country)
 {
     if (ModelState.IsValid)
     {
         _context.Update(ini_country);
         _context.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(ini_country));
 }
Пример #16
0
        public IActionResult Edit(string id, [Bind("member_code,birthdate,building,cid_card,cid_card_pic,cid_type,country_code,current_age,district_code,email,fax,floor,fname,h_no,id,lane,latitude,lname,longitude,lot_no,marry_status,mem_group_code,mem_photo,mem_type_code,mlevel_code,mobile,mstatus_code,nationality,parent_code,place_name,province_code,religion,room,rowversion,sex,social_app_data,street,subdistrict_code,tel,texta_address,textb_address,textc_address,village,x_log,x_note,x_status,zip_code,zone")] member member)
        {
            if (ModelState.IsValid)
            {
                member.x_status = "Y";

                if ((!string.IsNullOrEmpty(member.mem_photo)) && (member.mem_photo.Substring(0, 1) != "M"))
                {
                    var       fileName = member.mem_photo.Substring(9);
                    pic_image m        = new pic_image();
                    m.image_code   = "M" + DateTime.Now.ToString("yyMMddhhmmss");
                    m.x_status     = "Y";
                    m.image_name   = fileName.Substring(0, (fileName.Length <= 50 ? fileName.Length : 50));
                    m.ref_doc_type = Path.GetExtension(fileName);
                    fileName       = m.image_code + m.ref_doc_type;
                    _context.pic_image.Add(m);
                    _context.SaveChanges();

                    var s = Path.Combine(Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_upload").Value), member.mem_photo);
                    var d = Path.Combine(Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_member").Value), fileName);
                    System.IO.File.Copy(s, d, true);
                    System.IO.File.Delete(s);
                    clearImageUpload();

                    member.mem_photo = m.image_code;
                }
                if ((!string.IsNullOrEmpty(member.cid_card_pic)) && (member.cid_card_pic.Substring(0, 1) != "C"))
                {
                    var       fileName  = member.cid_card_pic.Substring(9);
                    pic_image pic_image = new pic_image();
                    pic_image.image_code   = "C" + DateTime.Now.ToString("yyMMddhhmmss");
                    pic_image.x_status     = "Y";
                    pic_image.image_name   = fileName.Substring(0, (fileName.Length <= 50 ? fileName.Length : 50));
                    pic_image.ref_doc_type = Path.GetExtension(fileName);
                    fileName = pic_image.image_code + pic_image.ref_doc_type;
                    _context.pic_image.Add(pic_image);
                    _context.SaveChanges();

                    var s = Path.Combine(Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_upload").Value), member.cid_card_pic);
                    var d = Path.Combine(Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_member").Value), fileName);
                    System.IO.File.Copy(s, d, true);
                    System.IO.File.Delete(s);
                    clearImageUpload();

                    member.cid_card_pic = pic_image.image_code;
                }


                _context.Update(member);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            prepareViewBag();
            return(View(member));
        }
Пример #17
0
        public IActionResult Edit(member member)
        {
            if (ModelState.IsValid)
            {
                member.x_status = "Y";

                if ((!string.IsNullOrEmpty(member.mem_photo)) && (member.mem_photo.Substring(0, 1) != "M"))
                {
                    var       fileName = member.mem_photo.Substring(9);
                    pic_image m        = new pic_image();
                    m.image_code   = "M" + DateTime.Now.ToString("yyMMddhhmmss");
                    m.x_status     = "Y";
                    m.image_name   = fileName.Substring(0, (fileName.Length <= 50 ? fileName.Length : 50));
                    m.ref_doc_type = Path.GetExtension(fileName);
                    fileName       = m.image_code + m.ref_doc_type;
                    _context.pic_image.Add(m);
                    _context.SaveChanges();

                    var s = Path.Combine(Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_upload").Value), member.mem_photo);
                    var d = Path.Combine(Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_member").Value), fileName);
                    System.IO.File.Copy(s, d, true);
                    System.IO.File.Delete(s);
                    clearImageUpload();

                    member.mem_photo = m.image_code;
                }
                if ((!string.IsNullOrEmpty(member.cid_card_pic)) && (member.cid_card_pic.Substring(0, 1) != "C"))
                {
                    var       fileName  = member.cid_card_pic.Substring(9);
                    pic_image pic_image = new pic_image();
                    pic_image.image_code   = "C" + DateTime.Now.ToString("yyMMddhhmmss");
                    pic_image.x_status     = "Y";
                    pic_image.image_name   = fileName.Substring(0, (fileName.Length <= 50 ? fileName.Length : 50));
                    pic_image.ref_doc_type = Path.GetExtension(fileName);
                    fileName = pic_image.image_code + pic_image.ref_doc_type;
                    _context.pic_image.Add(pic_image);
                    _context.SaveChanges();

                    var s = Path.Combine(Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_upload").Value), member.cid_card_pic);
                    var d = Path.Combine(Path.Combine(_env.WebRootPath, _configuration.GetSection("Paths").GetSection("images_member").Value), fileName);
                    System.IO.File.Copy(s, d, true);
                    System.IO.File.Delete(s);
                    clearImageUpload();

                    member.cid_card_pic = pic_image.image_code;
                }


                _context.Update(member);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            prepareViewBag();
            return(View(member));
        }
        public async Task <IActionResult> Edit(string id, [Bind("id,mem_testcenter_code,mem_testcenter_desc,rowversion,x_status,CreatedBy,CreatedDate")] mem_testcenter mem_testcenter)
        {
            if (ModelState.IsValid)
            {
                mem_testcenter.mem_testcenter_desc = mem_testcenter.mem_testcenter_desc.Trim();
                mem_testcenter.x_status            = mem_testcenter.x_status.Trim();

                _context.Update(mem_testcenter);
                await _context.SaveChangesAsync();
            }
            return(Json(new { result = "success" }));
        }
Пример #19
0
        public IActionResult Edit(string memberId, string id, int rec_no, string reward_desc)
        {
            var member     = _context.member.Single(m => m.id == new Guid(memberId));
            var mem_reward = _context.mem_reward.Single(m => m.id == new Guid(id));

            mem_reward.reward_desc = reward_desc;
            _context.Update(mem_reward);

            _context.SaveChanges();

            return(Json(new { result = "success" }));
        }
        public IActionResult Edit(string memberId, string id, int rec_no, string site_visit_desc, int country_code)
        {
            var member         = _context.member.Single(m => m.id == new Guid(memberId));
            var mem_site_visit = _context.mem_site_visit.Single(m => m.id == new Guid(id));

            mem_site_visit.country_code    = country_code;
            mem_site_visit.site_visit_desc = site_visit_desc;
            _context.Update(mem_site_visit);

            _context.SaveChanges();

            return(Json(new { result = "success" }));
        }
Пример #21
0
        public IActionResult Edit(string memberId, string id, int rec_no, string colledge_name, string degree, string faculty)
        {
            var member        = _context.member.Single(m => m.id == new Guid(memberId));
            var mem_education = _context.mem_education.Single(m => m.id == new Guid(id));

            mem_education.colledge_name = colledge_name;
            mem_education.degree        = degree;
            mem_education.faculty       = faculty;
            _context.Update(mem_education);

            _context.SaveChanges();

            return(Json(new { result = "success" }));
        }
Пример #22
0
        public async Task <IActionResult> Create(string courseId, string projectCode)
        {
            var c = _context.project_course.SingleOrDefault(m => m.id == new Guid(courseId));

            //project_course pc = new project_course();
            //pc.project_code = projectCode;
            //pc.active_member_join = c.active_member_join;
            //pc.budget = c.budget;
            //pc.cgroup_code = c.cgroup_code;
            //pc.charge_head = c.charge_head;
            //pc.course_approve_date = c.course_approve_date;
            //pc.course_begin = c.course_begin;
            //pc.course_code = c.course_code;
            //pc.course_date = c.course_date;
            //pc.course_desc = c.course_desc;
            //pc.course_end = c.course_end;
            //pc.ctype_code = c.ctype_code;
            //pc.passed_member = c.passed_member;
            //pc.project_manager = c.project_manager;
            //pc.ref_doc = c.ref_doc;
            //pc.support_head = c.support_head;
            //pc.target_member_join = c.target_member_join;
            //pc.x_status = c.x_status;
            c.project_code = projectCode;
            try
            {
                //_context.Add(pc);
                _context.Update(c);
                await _context.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(Json(new { result = "fail" }));
            }
            return(Json(new { result = "success" }));
        }
Пример #23
0
 public async Task <IActionResult> Edit(string id, [Bind("product_type_code,product_group_code,id,product_type_desc,rowversion,x_log,x_note,x_status")] product_type product_type)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(product_type);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             return(Json(new { result = "fail" }));
         }
         return(Json(new { result = "success" }));
     }
     return(Json(new { result = "fail" }));
 }
        public IActionResult Edit(string memberId, string id, string course_code, string course_desc, string course_grade)
        {
            var member           = _context.member.Single(m => m.id == new Guid(memberId));
            var mem_train_record = _context.mem_train_record.Single(m => m.id == new Guid(id));

            mem_train_record.course_code  = course_code;
            mem_train_record.course_grade = course_grade;
            _context.Update(mem_train_record);

            //Temp create project, this need to review business logic
            var project_course = _context.project_course.Single(p => p.course_code == mem_train_record.course_code);

            project_course.course_desc = course_desc;
            _context.project_course.Update(project_course);

            _context.SaveChanges();

            return(Json(new { result = "success" }));
        }
Пример #25
0
 public async Task <IActionResult> Edit(string id, [Bind("album_code,album_desc,album_name,created_by,album_date,id,rowversion,x_log,x_note,x_status")] album album)
 {
     try
     {
         _context.Update(album);
         await _context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         if (!albumExists(album.album_code))
         {
             return(NotFound());
         }
         else
         {
             throw;
         }
     }
     return(RedirectToAction("Index"));
 }
Пример #26
0
        public IActionResult Edit(string memberId, string id, int rec_no, string company_name_th, string company_name_eng, string position_name_th, string position_name_eng, string work_year, string office_address)
        {
            var member       = _context.member.Single(m => m.id == new Guid(memberId));
            var mem_worklist = _context.mem_worklist.Single(m => m.id == new Guid(id));

            mem_worklist.member_code       = member.member_code;
            mem_worklist.rec_no            = rec_no;
            mem_worklist.company_name_th   = company_name_th;
            mem_worklist.company_name_eng  = company_name_eng;
            mem_worklist.position_name_th  = position_name_th;
            mem_worklist.position_name_eng = position_name_eng;
            mem_worklist.work_year         = work_year;
            mem_worklist.office_address    = office_address;
            mem_worklist.x_status          = "Y";
            _context.Update(mem_worklist);

            _context.SaveChanges();

            return(Json(new { result = "success" }));
        }
Пример #27
0
        public async Task <IActionResult> Edit(string id, [Bind("spon_code,project_code,contactor,contactor_detail,id,ref_doc,support_budget,x_log,x_note,x_status")] project_supporter project_supporter)
        {
            if (id != project_supporter.spon_code)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(project_supporter);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return(NotFound());
                }
                return(RedirectToAction("Index"));
            }
            return(View(project_supporter));
        }