protected void btnViewMember_Click(object sender, EventArgs e) { string cs = ConfigurationManager.ConnectionStrings["LoginConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(cs)) { SqlCommand cmd = new SqlCommand("Select ResourcePerson, Email, Designation from ProjectResourcePerson where ProjectName='" + ProjectList2.Text.ToString() + "'", con); //SqlCommand cmd = new SqlCommand("Select * from TimeTable", con); con.Open(); ViewMember.DataSource = cmd.ExecuteReader(); ViewMember.DataBind(); } }
public ActionResult ReportCertified(int id) { /*if (Request.UrlReferrer == null || (Request.UrlReferrer != null && Request.UrlReferrer.AbsoluteUri != "http://wcaecommerce.wcaworld.com/eng/report_cert.asp")) * { * return RedirectToAction("Login", "Account"); * }*/ if (Session["temp_report"] == null) { return(RedirectToAction("Login", "Application")); } //int Cid = Convert.ToInt32(HttpContext.Session["Cid"]); int CertId = id; int Cid = _db.EcomCerts.Where(r => r.CertID == CertId).FirstOrDefault().Cid; if (Cid == 0) { //redirec to login } ViewMember member = _db.Members.AsNoTracking() .Include(x => x.Memberships) .Include(x => x.Memberships.Select(y => y.Network)) .FirstOrDefault(x => x.Cid == Cid && x.Nid == 103); if (member == null) { //redirec to logi } CertifiedMemberApplicationView model = new CertifiedMemberApplicationView(); model.Company = member; model.Company.Memberships = member.Memberships; model.EcomCert.Cid = Cid; model.Company_Detail.CompName = member.Company; EcomCert cert = _db.EcomCerts.AsNoTracking() .FirstOrDefault(x => x.Cid == Cid); if (cert != null) { int StatusId = _db.EcomCert_Status.AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.StatusID) .FirstOrDefault(); // Status model.Status = StatusId == 1 ? "draft" : "submitted"; // Company detail EcomCert_CompDetail companyDetail = _db.EcomCert_CompDetail .Find(cert.CertID); model.Company_Detail = companyDetail; IEnumerable <int> productsHandled = _db.EcomCert_Product_Handled .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.ProductId) .ToList(); model.Products_Handled = productsHandled; // Company service EcomCert_Service companyService = _db.EcomCert_Service .Find(cert.CertID); // Company service: services provide IEnumerable <int> companyServicesProvide = _db.EcomCert_Service_Provide .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.ServiceId) .ToList(); model.Company_Service = companyService; model.Services = companyServicesProvide; // Company service cross-border service provide model.CrossBorderServices = _db.EcomCert_Service_CrossBorder .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.CrossBorderId) .ToList(); // Company service: GroundServices model.GroundServices = _db.EcomCert_Service_Ground .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.GroundServiceId) .ToList(); // Company service: TransportFleets model.TransportFleets = _db.EcomCert_Service_TransportFleet .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.TransportFleetId) .ToList(); // Company service: PayOnDelivery model.PayOnDelivery = _db.EcomCert_Service_PayOnDelivery .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.PaymentTypeId) .ToList(); // Company service: InternalBounds model.InternalBounds = _db.EcomCert_Service_InternalBound .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.InternalBoundId) .ToList(); // Company IT EcomCert_IT companyIT = _db.EcomCert_IT .Find(cert.CertID); model.Company_IT = companyIT; } return(View(model)); }
public ActionResult Certified(CertifiedMemberApplicationView model, string btn_save, HttpPostedFileBase file) { try { if (model != null && model.EcomCert != null) { // Application EcomCert cert = CreateEcomCertIfNotExists(model.EcomCert.Cid); // Application status InsertOrUpdateCertifidMemberApplicationStatus(cert.CertID, btn_save); // Company details InsertOrUpdateCompanyDetail(cert.CertID, model.Company_Detail); // Products Handles InsertOrUpdateProductsHandled(cert.CertID, model.Products_Handled); // Company Services InsertOrUpdateCompanyServices(cert.CertID, model.Company_Service); // Company Service Provide InsertOrUpdateCompanyServicesProvide(cert.CertID, model.Services); // Company Service Cross-Border InsertOrUpdateCompanyServicesCrossBorder(cert.CertID, model.CrossBorderServices); // EcomCert_Service_Ground InsertOrUpdateCompanyServicesGround(cert.CertID, model.GroundServices); // EcomCert_Service_TransportFleet InsertOrUpdateCompanyServicesFleet(cert.CertID, model.TransportFleets); // EcomCert_Service_PayOnDelivery InsertOrUpdateCompanyServicesPayOnDelivery(cert.CertID, model.PayOnDelivery); // EcomCert_Service_InternalBound InsertOrUpdateCompanyServicesInternalBound(cert.CertID, model.InternalBounds); // EcomCert_Service_GeoCoverage //InsertOrUpdateCompanyServicesGeoCoverage(cert.CertID,model.g) // EcomCert_IT InsertOrUpdateCompanyIT(cert.CertID, model.Company_IT); // File uploading // Verify that the user selected a file if (file != null && file.ContentLength > 0) { // extract only the filename string fileName = Path.GetFileName(file.FileName); // upload directory string basePath = "~/uploads"; string path = Path.Combine(Server.MapPath(basePath), fileName); file.SaveAs(path); model.Company_IT.YN_EDIImage_File = fileName; // EcomCert_IT InsertOrUpdateCompanyIT(cert.CertID, model.Company_IT); } if (btn_save == "submit") { // Get member data ViewMember member = _db.Members .AsNoTracking() .FirstOrDefault(x => x.Cid == cert.Cid && x.Nid == 103); int repID = _db.SalesRep .AsNoTracking() .Where(x => x.IsActive && x.Nid == 103 && x.TypeCode == "Rep") .Where(x => x.CountryCode == member.Country) .Select(x => x.EmpID) .FirstOrDefault(); //Sales Rep Employee emp = _hr.Employees .AsNoTracking() .FirstOrDefault(x => x.EmployeeID == repID); string repEmail = emp == null ? "" : emp.Email; // Mail to salesrep and Alex string body = "<p>A new certification from: {0}</p>"; body += "<p>The WCA eCommerce Certified Member Application report can be found here:</p>"; body += "<p><a href=\"http://wcaecommerce.wcaworld.com/application/report\">http://wcaecommerce.wcaworld.com/application/report</a>"; body += "<p>password: wcaecom_rpcm</p>"; var message = new MailMessage(); message.To.Add(new MailAddress("*****@*****.**")); message.To.Add(new MailAddress("*****@*****.**")); message.To.Add(new MailAddress(repEmail)); message.Bcc.Add(new MailAddress("*****@*****.**")); message.Subject = "A new certification waiting for verification."; message.Body = string.Format(body, model.Company_Detail.CompName); message.IsBodyHtml = true; using (var smtp = new SmtpClient()) { smtp.Send(message); } // Mail to member IEnumerable <ViewContact> contacts = _db.ViewContacts .AsNoTracking() .Where(x => x.Selected == true) .Where(x => x.Deleted == false) .Where(x => x.NId == 103) .Where(x => x.CId == cert.Cid) .ToList(); if (contacts.Count() != 0) { string bodyToMember = string.Format("The request is submitted and pending for approval. You may contact <a href='mailto:{0}'>{0}</a> for any questions.", repEmail); MailMessage messageToMember = new MailMessage(); foreach (ViewContact contact in contacts) { messageToMember.To.Add(new MailAddress(contact.Email + ".th")); } messageToMember.Bcc.Add(new MailAddress("*****@*****.**")); messageToMember.Subject = "The request is submitted and pending for approval."; messageToMember.Body = bodyToMember; messageToMember.IsBodyHtml = true; using (var smtp = new SmtpClient()) { // If live email will send to member if (AppSetting.GetIsLive) { smtp.Send(messageToMember); } } } } } return(RedirectToAction("Certified")); } catch (Exception ex) { return(RedirectToAction("Certified")); } }
//[Authorize] public ActionResult Certified(int cId = 0) { int Cid = cId == 0 ? Convert.ToInt32(HttpContext.Session["Cid"]) : cId; ViewMember member = _db.Members.AsNoTracking() .Include(x => x.Memberships) .Include(x => x.Memberships.Select(y => y.Network)) .FirstOrDefault(x => x.Cid == Cid && x.Nid == 103); if (member == null) { //redirec to login return(RedirectToAction("Login", "Account", new { returnUrl = "application/certified" })); } CertifiedMemberApplicationView model = new CertifiedMemberApplicationView(); model.Company = member; model.Company.Memberships = member.Memberships; model.EcomCert.Cid = Cid; model.Company_Detail.CompName = member.Company; EcomCert cert = _db.EcomCerts.AsNoTracking() .FirstOrDefault(x => x.Cid == Cid); if (cert != null) { int StatusId = _db.EcomCert_Status.AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.StatusID) .FirstOrDefault(); // Status model.Status = StatusId == 1 ? "draft" : "submitted"; // Company detail EcomCert_CompDetail companyDetail = _db.EcomCert_CompDetail .Find(cert.CertID); model.Company_Detail = companyDetail == null ? new EcomCert_CompDetail() : companyDetail; IEnumerable <int> productsHandled = _db.EcomCert_Product_Handled .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.ProductId) .ToList(); model.Products_Handled = productsHandled; // Company service EcomCert_Service companyService = _db.EcomCert_Service .Find(cert.CertID); // Company service: services provide IEnumerable <int> companyServicesProvide = _db.EcomCert_Service_Provide .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.ServiceId) .ToList(); model.Company_Service = companyService == null ? new EcomCert_Service() : companyService; model.Services = companyServicesProvide; // Company service cross-border service provide model.CrossBorderServices = _db.EcomCert_Service_CrossBorder .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.CrossBorderId) .ToList(); // Company service: GroundServices model.GroundServices = _db.EcomCert_Service_Ground .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.GroundServiceId) .ToList(); // Company service: TransportFleets model.TransportFleets = _db.EcomCert_Service_TransportFleet .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.TransportFleetId) .ToList(); // Company service: PayOnDelivery model.PayOnDelivery = _db.EcomCert_Service_PayOnDelivery .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.PaymentTypeId) .ToList(); // Company service: InternalBounds model.InternalBounds = _db.EcomCert_Service_InternalBound .AsNoTracking() .Where(x => x.CertID == cert.CertID) .Select(x => x.InternalBoundId) .ToList(); // Company IT EcomCert_IT companyIT = _db.EcomCert_IT .Find(cert.CertID); model.Company_IT = companyIT == null ? new EcomCert_IT() : companyIT; } return(View(model)); }