protected void Page_Load(object sender, EventArgs e) { if (SessionManager.CurrentUser == null) { Common.RedirectToLoginPage(this); return; } else if (!IsPostBack) { FillLabelLanguage(); InitControls(); //Fill data for combobox ddlTypeAction.DataValueField = "ParamActionID"; ddlTypeAction.DataTextField = "Label"; ParamTypeActionRepository paramTypeActionRepo = new ParamTypeActionRepository(); ddlTypeAction.DataSource = paramTypeActionRepo.FindAll(); ddlTypeAction.DataBind(); ddlResponsible.DataValueField = "UserID"; ddlResponsible.DataTextField = "LastName"; ParamUserRepository userRepo = new ParamUserRepository(); ddlResponsible.DataSource = userRepo.GetAllUser(true); ddlResponsible.DataBind(); ddlResponsible.SelectedValue = SessionManager.CurrentUser.UserID; bool isCompany = false; bool isCandidate = false; if (!string.IsNullOrEmpty(Request.QueryString["type"])) { if (Request.QueryString["type"] == "company") { isCompany = true; btnCompany.Enabled = false; ddlCompany.Enabled = false; } else if (Request.QueryString["type"] == "candidate") { isCandidate = true; btnCandidate.Enabled = false; ddlCandidate.Enabled = false; } else if (Request.QueryString["type"] == "action" && string.IsNullOrEmpty(Request.QueryString["ActionID"])) { if (SessionManager.CurrentUser != null) ddlResponsible.SelectedValue = SessionManager.CurrentUser.UserID; } } if (SessionManager.CurrentCompany != null && isCompany) { ddlCompany.Items.Clear(); ddlCompany.Items.Add(new RadComboBoxItem(SessionManager.CurrentCompany.CompanyName, SessionManager.CurrentCompany.CompanyID.ToString())); ddlCompany.SelectedIndex = 0; hiddenCompanyId.Value = SessionManager.CurrentCompany.CompanyID.ToString(); txtCompany.Text = SessionManager.CurrentCompany.CompanyName; BindContactListByCompany(SessionManager.CurrentCompany.CompanyID); } if (SessionManager.CurrentCandidate != null && isCandidate) { hiddenCandidateId.Value = SessionManager.CurrentCandidate.CandidateId.ToString(); txtCandidate.Text = SessionManager.CurrentCandidate.FirstName + " " + SessionManager.CurrentCandidate.LastName; ddlCandidate.Items.Add(new RadComboBoxItem(SessionManager.CurrentCandidate.FirstName + " " + SessionManager.CurrentCandidate.LastName, SessionManager.CurrentCandidate.CandidateId.ToString())); ddlCandidate.SelectedIndex = 0; } if (!string.IsNullOrEmpty(Request.QueryString["ActionID"])) { int actionID = int.Parse(Request.QueryString["ActionID"]); ActionRepository repo = new ActionRepository(); Neos.Data.Action action = repo.GetActionByActionID(actionID); if (action.CompanyID.HasValue) { hiddenCompanyId.Value = action.CompanyID.Value.ToString(); BindContactListByCompany(action.CompanyID.Value); } if (action.CandidateID.HasValue) { hiddenCandidateId.Value = action.CandidateID.Value.ToString(); } if (action.ContactID.HasValue) { ddlContact.SelectedValue = action.ContactID.Value.ToString(); } else ddlContact.SelectedValue = "-1"; txtTaskNbr.Text = action.ActionID.ToString(); chkActive.Checked = action.Actif; datDateAction.SelectedDate = action.DateAction; radTimeHour.SelectedDate = action.Hour; if (action.TypeAction.HasValue) ddlTypeAction.SelectedValue = action.TypeAction.Value.ToString(); datCreationDate.SelectedDate = action.DateCreation; txtCompany.Text = action.CompanyName; txtCandidate.Text = action.CandidateFullName; txtAppointmentPlace.Text = action.LieuRDV; txtCompanyResult.Text = action.ResultCompany; txtCandidateResult.Text = action.ResultCandidate; txtDescription.Text = action.DescrAction; ddlResponsible.SelectedValue = action.Responsable; //Company dropdownlist if (action.CompanyID.HasValue) { ddlCompany.Items.Add(new RadComboBoxItem(action.CompanyName, action.CompanyID.ToString())); ddlCompany.SelectedIndex = 0; } //candidate dropdownlist if (action.CandidateID.HasValue) { ddlCandidate.Items.Add(new RadComboBoxItem(action.CandidateFullName, action.CandidateID.ToString())); ddlCandidate.SelectedIndex = 0; } } } string script = "<script type='text/javascript'>"; script += "onLoadActionDetailPage();"; script += "</script>"; if (!ClientScript.IsClientScriptBlockRegistered("LoadActionDetailPage")) ClientScript.RegisterStartupScript(this.GetType(), "LoadActionDetailPage", script); }
protected void OnBtnExportClicked(object sender, EventArgs e) { if (listEmail.Items.Count > 0 && !string.IsNullOrEmpty(Request.QueryString["ActionID"])) { try { int actionID = int.Parse(Request.QueryString["ActionID"]); ActionRepository repo = new ActionRepository(); Neos.Data.Action action = repo.GetActionByActionID(actionID); if (action == null) return; //First thing you need to do is add a reference to Microsoft Outlook 11.0 Object Library. Then, create new instance of Outlook.Application object: Application outlookApp = new Application(); //Next, create an instance of AppointmentItem object and set the properties: AppointmentItem oAppointment = (AppointmentItem)outlookApp.CreateItem(OlItemType.olAppointmentItem); oAppointment.Subject = "This is the subject for my appointment"; oAppointment.Body = action.DescrAction; oAppointment.Location = action.LieuRDV; // Set the start date //if(action.DateAction.HasValue) // oAppointment.Start = action.DateAction.Value; // End date if (action.Hour.HasValue) { oAppointment.Start = action.Hour.Value; DateTime end = oAppointment.Start.AddHours(1); oAppointment.End = end; } // Set the reminder 15 minutes before start oAppointment.ReminderSet = true; oAppointment.ReminderMinutesBeforeStart = 15; //Setting the sound file for a reminder: oAppointment.ReminderPlaySound = true; //set ReminderSoundFile to a filename. //Setting the importance: //use OlImportance enum to set the importance to low, medium or high oAppointment.Importance = OlImportance.olImportanceHigh; /* OlBusyStatus is enum with following values: olBusy olFree olOutOfOffice olTentative */ oAppointment.BusyStatus = OlBusyStatus.olBusy; //Finally, save the appointment: // Save the appointment //oAppointment.Save(); // When you call the Save () method, the appointment is saved in Outlook. string recipientsMail = string.Empty; foreach (ListItem item in listEmail.Items) { if (recipientsMail == string.Empty) { recipientsMail += item.Value; } else { recipientsMail += "; " + item.Value; } } //mailItem.SenderEmailAddress = "*****@*****.**"; //mailItem.SenderName = "Thanh Hung"; oAppointment.RequiredAttendees = recipientsMail; // Another useful method is ForwardAsVcal () which can be used to send the Vcs file via email. MailItem mailItem = oAppointment.ForwardAsVcal(); mailItem.To = "*****@*****.**"; mailItem.Send(); //oAppointment.Send(); } catch (System.Exception ex) { string script1 = "<script type=\"text/javascript\">"; script1 += " alert(\"" + ex.Message + "\")"; script1 += " </script>"; if (!ClientScript.IsClientScriptBlockRegistered("redirectUser")) ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script1); return; } } string script = "<script type=\"text/javascript\">"; script += " OnBtnExportClientClicked();"; script += " </script>"; if (!ClientScript.IsClientScriptBlockRegistered("redirectUser")) ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script); }