コード例 #1
0
        private void SetSystemIDControl(string CompName)
        {
            List <CompanyInfoModel> listcompany = new List <CompanyInfoModel>();
            //get Select Company
            CompanyInfoModel company = new CompanyInfoModel();

            if (!string.IsNullOrEmpty(AuthUser.UserId))
            {
                listcompany = CompanyService.getInstance().searchCompamyInfo(AuthUser.UserId, "", "");
                if (listcompany != null && listcompany.Count > 0)
                {
                    if (!string.IsNullOrEmpty(CompName))
                    {
                        company = listcompany.Find(x => x.name.ToLower().Equals(CompName.ToLower()));
                    }
                    else
                    {
                        company = listcompany.FirstOrDefault();
                    }
                }
            }
            //Set System ID
            if (company == null || string.IsNullOrEmpty(company.sid))
            {
                listcompany = CompanyService.getInstance().searchCompamyInfoRefSystem("", CompName);
                if (listcompany.Count > 0)
                {
                    company = listcompany[0];
                    AuthUser.SetAuthPublic(company);
                }
            }
            if (company != null)
            {
                ViewBag.CompanyName       = company.name;
                ViewBag.CompanyDes        = company.description;
                ViewData["MyCompanyInfo"] = listcompany;
            }
            else
            {
                ViewBag.MessageRedirect = "ไม่พบองค์กรที่ระบุ!!";
                ViewBag.UrlRedirect     = "/";
            }
        }