protected void OnButtonSaveClick(object sender, EventArgs e)
    {
        CompanyContactTelephoneRepository contactInfoRepo = new CompanyContactTelephoneRepository();
        CompanyContactTelephone contactInfo = new CompanyContactTelephone();
        if (!string.IsNullOrEmpty(Request.QueryString["contactInfoId"]))
        {
            try
            {
                int contactInfoID = Int32.Parse(Request.QueryString["contactInfoId"]);
                contactInfo = contactInfoRepo.FindOne(new CompanyContactTelephone(contactInfoID));
                if (contactInfo != null)
                {
                    contactInfo.Type = ddlType.SelectedValue;
                    contactInfo.TelephoneZone = txtZone.Text.Trim();
                    contactInfo.Tel = txtPhoneMail.Text.Trim();
                    contactInfo.Location = txtPlace.Text.Trim();

                    contactInfoRepo.Update(contactInfo);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        else if (!string.IsNullOrEmpty(Request.QueryString["contactId"]))
        {
            contactInfo.Type = ddlType.SelectedValue;
            contactInfo.TelephoneZone = txtZone.Text.Trim();
            contactInfo.Tel = txtPhoneMail.Text.Trim();
            contactInfo.Location = txtPlace.Text.Trim();

            int contactId = Int16.Parse(Request.QueryString["contactId"]);
            if (contactId > 0)
            {
                contactInfo.ContactID = contactId;
                contactInfoRepo.Insert(contactInfo);
            }
            else
            {
                CompanyContact existedItem = SessionManager.NewCompanyContactList.Find(delegate(CompanyContact t) { return t.ContactID == contactId; });
                if (existedItem != null)
                {
                    contactInfo.ContactID = existedItem.ContactID;
                    contactInfo.ContactTelephoneID = 0 - existedItem.ContactInfo.Count - 2;
                    existedItem.ContactInfo.Add(contactInfo);
                }
            }
        }

        string script = "<script type=\"text/javascript\">";
        script += " OnBtnSaveClientClicked();";
        script += " </script>";

        if (!ClientScript.IsClientScriptBlockRegistered("saveAndCloseWindow"))
            ClientScript.RegisterStartupScript(this.GetType(), "saveAndCloseWindow", script);
    }
 private void BindData()
 {
     if (!IsPostBack)
     {
         ddlType.Items.Add(new RadComboBoxItem(ResourceManager.GetString("candidateContactPhone"), "T"));
         ddlType.Items.Add(new RadComboBoxItem(ResourceManager.GetString("candidateContactFax"), "F"));
         ddlType.Items.Add(new RadComboBoxItem(ResourceManager.GetString("candidateContactMobile"), "G"));
         ddlType.Items.Add(new RadComboBoxItem(ResourceManager.GetString("candidateContactEmail"), "E"));
     }
     if (!string.IsNullOrEmpty(Request.QueryString["contactInfoId"]))
     {
         try
         {
             CompanyContactTelephone contactInfo = null;
             int contactInfoID = Int32.Parse(Request.QueryString["contactInfoId"]);
             if (contactInfoID > 0)
             {
                 contactInfo = new CompanyContactTelephoneRepository().FindOne(new CompanyContactTelephone(contactInfoID));
             }
             else
             {
                 if (!string.IsNullOrEmpty(Request.QueryString["contactId"]))
                 {
                     int contactId = Int16.Parse(Request.QueryString["contactId"]);
                     CompanyContact existedItem = SessionManager.NewCompanyContactList.Find(delegate(CompanyContact t) { return t.ContactID == contactId; });
                     if (existedItem != null)
                     {
                         List<CompanyContactTelephone> listTel = existedItem.ContactInfo;
                         contactInfo = listTel.Find(delegate(CompanyContactTelephone a) { return a.ContactTelephoneID == contactInfoID; });
                     }
                 }
             }
             if (contactInfo != null)
             {
                 ddlType.SelectedValue = contactInfo.Type;
                 txtZone.Text = contactInfo.TelephoneZone;
                 txtPhoneMail.Text = contactInfo.Tel;
                 txtPlace.Text = contactInfo.Location;
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
Beispiel #3
0
    protected void OnMyAjaxManagerAjaxRequest(object sender, AjaxRequestEventArgs e)
    {
        if (e.Argument.IndexOf("RebindContactGrid") != -1)
        {
            //System.Threading.Thread.Sleep(1000);
            //divContact.Visible = true;
            //divContact.Style.Add("display", "block");
            CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, CompanyContactGrid);
            CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, pnlAddContact);
            string[] args = e.Argument.Split('/');
            if (args.Length == 3)
            {
                try
                {
                    int companyID = Int32.Parse(args[1]);
                    int rowIndex = Int32.Parse(args[2]);
                    CompanyGrid.MasterTableView.ClearSelectedItems();
                    CompanyGrid.MasterTableView.Items[rowIndex - 1].Selected = true;
                }
                catch (Exception ex) { throw ex; }
                CompanyContactGrid.Rebind();
            }
        }
        else if (e.Argument.IndexOf("RebindContactInfoGrid") != -1)
        {
            //divContactInfo.Style.Add("display","block");
            CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, ContactInfoGrid);
            CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, pnlAddContactInfo);
            string[] args = e.Argument.Split('/');
            if (args.Length == 3)
            {
                try
                {
                    int contactID = Int32.Parse(args[1]);
                    int rowIndex = Int32.Parse(args[2]);
                    CompanyContactGrid.MasterTableView.ClearSelectedItems();
                    CompanyContactGrid.MasterTableView.Items[rowIndex - 1].Selected = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                ContactInfoGrid.Rebind();
            }

        }
        else if (e.Argument.IndexOf("AddCompanyContact") != -1)
        {
            CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, CompanyContactGrid);
            string[] args = e.Argument.Split('/');
            if (args.Length == 2)
            {
                try
                {
                    int companyID = Int32.Parse(args[1]);
                    CompanyContactRepository contactRepo = new CompanyContactRepository();
                    CompanyContact contact = new CompanyContact();
                    contact.CompanyID = companyID;
                    contact.LastName = txtLastName.Text.Trim();
                    contact.FirstName = txtFirstName.Text.Trim();
                    contact.Position = ddlFunction.Text;

                    contactRepo.Insert(contact);

                    CompanyContactGrid.Rebind();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        else if (e.Argument.IndexOf("AddContactInfo") != -1)
        {
            CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, ContactInfoGrid);
            string[] args = e.Argument.Split('/');
            if (args.Length == 2)
            {
                try
                {
                    int contactID = Int32.Parse(args[1]);
                    CompanyContactTelephoneRepository contactInfoRepo = new CompanyContactTelephoneRepository();
                    CompanyContactTelephone contactInfo = new CompanyContactTelephone();
                    contactInfo.ContactID = contactID;
                    contactInfo.Type = ddlType.SelectedValue;
                    contactInfo.TelephoneZone = txtPhoneZone.Text.Trim();
                    contactInfo.Tel = txtInfo.Text.Trim();
                    contactInfo.Location = txtPlace.Text.Trim();

                    contactInfoRepo.Insert(contactInfo);

                    ContactInfoGrid.Rebind();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        else if (e.Argument.IndexOf("DeleteSelectedCompany") != -1)
        {
            if (CompanyGrid.SelectedItems.Count == 1)
            {
                CompanyAjaxManager.AjaxSettings.AddAjaxSetting(CompanyAjaxManager, CompanyGrid);
                CompanyRepository companyRepo = new CompanyRepository();
                companyRepo.Delete(new Company(GetSelectedCompanyID()));
                CompanyGrid.Rebind();
            }
        }
        else if (e.Argument.IndexOf("OpenSeletectedCompany") != -1)
        {
            if (CompanyGrid.SelectedItems.Count == 1)
            {
                Response.Redirect(string.Format("~/CompanyProfile.aspx?CompanyId={0}&mode=edit&backurl=visible", GetSelectedCompanyID()), true);
            }
        }
        else if (e.Argument.IndexOf("ViewCompanyActions") != -1)
        {
            if (CompanyGrid.SelectedItems.Count == 1)
            {
                Response.Redirect(string.Format("~/CompanyProfile.aspx?CompanyId={0}&tab=action&mode=edit&backurl=visible", GetSelectedCompanyID()), true);
            }
        }
        else if (e.Argument.IndexOf("ViewCompanyJobs") != -1)
        {
            if (CompanyGrid.SelectedItems.Count == 1)
            {
                Response.Redirect(string.Format("~/CompanyProfile.aspx?CompanyId={0}&tab=job&mode=edit&backurl=visible", GetSelectedCompanyID()), true);
            }
        }
        else if (e.Argument.IndexOf("ViewCompanyInvoices") != -1)
        {
            if (CompanyGrid.SelectedItems.Count == 1)
            {
                Response.Redirect(string.Format("~/InvoicesPage.aspx?type=search&customer={0}", GetSelectedCompanyID()), true);
            }
        }
    }
Beispiel #4
0
 public CompanyContactTelephone GetContactEmail()
 {
     List<CompanyContactTelephone> list = new List<CompanyContactTelephone>();
     if ((contactInfo == null || contactInfo.Count == 0) && (this.contactID > 0))
         list = new CompanyContactTelephoneRepository().GetContactInfo(this.contactID);
     else
         list = contactInfo;
     if (list.Count <= 0) return null;
     //.Find(delegate(RailOneWS.proposedprice p) { return p.proposedpriceid == pid; });
     CompanyContactTelephone info = list.Find(delegate(CompanyContactTelephone ctInfo) { return ctInfo.Type == "E"; });
     return info;
 }
 private void BindContactInfo(int contactID)
 {
     if (contactID > 0)
     {
         List<CompanyContactTelephone> contactInfoList = new CompanyContactTelephoneRepository().GetContactInfo(contactID);
         ContactInfoGrid.DataSource = contactInfoList;
     }
     else
     {
         List<CompanyContact> list = SessionManager.NewCompanyContactList;
         CompanyContact existedItem = list.Find(delegate(CompanyContact t) { return t.ContactID == contactID; });
         if (existedItem != null)
         {
             ContactInfoGrid.DataSource = existedItem.ContactInfo;
         }
         else
         {
             ContactInfoGrid.DataSource = new List<CompanyContactTelephone>();
         }
     }
     ContactInfoGrid.DataBind();
 }
Beispiel #6
0
 protected void OnContactInfoGridNeedDataSource(object source, GridNeedDataSourceEventArgs e)
 {
     if (CompanyContactGrid.SelectedItems.Count == 1)
     {
         GridDataItem dataItem = ((GridDataItem)CompanyContactGrid.SelectedItems[0]);
         if (dataItem != null)
         {
             int contactID = Int32.Parse(dataItem["ContactID"].Text);
             List<CompanyContactTelephone> contactInfoList = new CompanyContactTelephoneRepository().GetContactInfo(contactID);
             ContactInfoGrid.DataSource = contactInfoList;
         }
     }
     else
     {
         ContactInfoGrid.DataSource = null;
     }
 }
 protected void OnContactInfoGridNeedDataSource(object source, GridNeedDataSourceEventArgs e)
 {
     if (CompanyContactGrid.SelectedItems.Count == 1)
     {
         GridDataItem dataItem = ((GridDataItem)CompanyContactGrid.SelectedItems[0]);
         if (dataItem != null)
         {
             int contactID = Int32.Parse(dataItem["ContactID"].Text);
             if (contactID > 0)
             {
                 List<CompanyContactTelephone> contactInfoList = new CompanyContactTelephoneRepository().GetContactInfo(contactID);
                 ContactInfoGrid.DataSource = contactInfoList;
             }
             else
             {
                 List<CompanyContact> list = SessionManager.NewCompanyContactList;
                 CompanyContact existedItem = list.Find(delegate(CompanyContact t) { return t.ContactID == contactID; });
                 if (existedItem != null)
                 {
                     ContactInfoGrid.DataSource = existedItem.ContactInfo;
                 }
             }
         }
     }
     else
     {
         ContactInfoGrid.DataSource = new List<CompanyContactTelephone>();
     }
 }
 protected void OnContactInfoGridDeleteCommand(object source, GridCommandEventArgs e)
 {
     CompanyContactTelephoneRepository contactInfoRepo = new CompanyContactTelephoneRepository();
     string[] idArray = e.CommandArgument.ToString().Split('&');
     int contactInfoId = Int32.Parse(idArray[0]);
     int contactID = Int32.Parse(idArray[1]);
     if (contactInfoId > 0)
     {
         contactInfoRepo.Delete(new CompanyContactTelephone(contactInfoId));
     }
     else
     {
         List<CompanyContact> list = SessionManager.NewCompanyContactList;
         CompanyContact existedItem = list.Find(delegate(CompanyContact t) { return t.ContactID == contactID; });
         if (existedItem != null)
         {
             List<CompanyContactTelephone> listTel = existedItem.ContactInfo;
             CompanyContactTelephone existInfo = listTel.Find(delegate(CompanyContactTelephone a) { return a.ContactTelephoneID == contactInfoId; });
             if (existInfo != null)
             {
                 existedItem.ContactInfo.Remove(existInfo);
             }
         }
         SessionManager.NewCompanyContactList = list;
     }
     ContactInfoGrid.Rebind();
 }
    private void SaveCompanyContact(Company currentCompany)
    {
        if (SessionManager.NewCompanyContactList != null
            && SessionManager.NewCompanyContactList.Count > 0
            && currentCompany != null)
        {
            CompanyContactRepository contactRepo = new CompanyContactRepository();
            foreach (CompanyContact contact in SessionManager.NewCompanyContactList)
            {
                contact.CompanyID = currentCompany.CompanyID;
                contactRepo.Insert(contact);
                CompanyContact realContact = contactRepo.FindOne(contact);

                CompanyContactTelephoneRepository telephoneRepo = new CompanyContactTelephoneRepository();
                foreach (CompanyContactTelephone telephone in contact.ContactInfo)
                {
                    telephone.ContactID = realContact.ContactID;
                    telephoneRepo.Insert(telephone);
                }

            }
        }
    }
Beispiel #10
0
    public static string ExportActionToAppoinment(Neos.Data.Action action)
    {
        string message = string.Empty;
        try
        {
            if (action.ContactID.HasValue)
            {
                string emailContact = string.Empty;
                List<CompanyContactTelephone> contactInfoList =
                    new CompanyContactTelephoneRepository().GetContactInfo(action.ContactID.Value);
                foreach (CompanyContactTelephone item in contactInfoList)
                {
                    if (item.Type == "E")
                    {
                        emailContact = item.Tel;
                        break;
                    }
                }
                //ParamUser currentUser = SessionManager.CurrentUser;
                if (!string.IsNullOrEmpty(emailContact))
                {
                    DateTime today = DateTime.Now;
                    string fileName = WebConfig.AbsoluteExportDirectory + "\\ExportAppointment";
                    fileName += today.Hour.ToString() + "-" + today.Minute.ToString() + "-" + today.Second.ToString() + ".vcs";

                    StreamWriter writer = new StreamWriter(fileName);
                    writer.WriteLine("BEGIN:VCALENDAR");
                    writer.WriteLine(@"PRODID:-//Microsoft Corporation//Outlook MIMEDIR//EN");
                    writer.WriteLine("VERSION:1.0");
                    writer.WriteLine("BEGIN:VEVENT");

                    //Start and End Date in YYYYMMDDTHHMMSSZ format
                    if (action.Hour.HasValue)
                        today = action.Hour.Value;
                    else
                        today = today.AddDays(1);

                    writer.WriteLine("DTSTART:" + today.ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"));
                    writer.WriteLine("DTEND:" + today.AddHours(1).ToUniversalTime().ToString("yyyyMMdd\\THHmmss\\Z"));

                    string subject = action.TypeActionLabel + "-" + action.CompanyName + "-" + action.CandidateFullName;
                    writer.WriteLine("LOCATION:" + action.LieuRDV);
                    writer.WriteLine("CATEGORIES:" + subject);
                    writer.WriteLine("DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" + action.DescrAction);
                    writer.WriteLine("SUMMARY:" + subject);
                    writer.WriteLine("PRIORITY:3");
                    writer.WriteLine("END:VEVENT");
                    writer.WriteLine("END:VCALENDAR");
                    writer.Close();

                    //Send email
                    MailMessage mail = new MailMessage();
                    //mail.To.Add(new MailAddress("*****@*****.**"));
                    mail.To.Add(new MailAddress(emailContact));
                    mail.Subject = action.TypeActionLabel + "-"
                        + action.CompanyName + "-" + action.CandidateFullName;
                    mail.Attachments.Add(new Attachment(fileName));
                    SendMail(mail);
                    mail.Dispose();
                    if (File.Exists(fileName))
                    {
                        File.Delete(fileName);
                    }

                }
                else
                {
                    message = ResourceManager.GetString("messageExportActionNotHaveEmail");
                }
            }
        }
        catch (System.Exception ex)
        {
            message = ex.Message;
        }
        if(message == string.Empty)
        {
            message = ResourceManager.GetString("messageExportActionSuccessfull");
        }
        return message;
    }
Beispiel #11
0
    public static bool ExportActionToOutlook(Page page, Neos.Data.Action action)
    {
        string message = string.Empty;
        try
        {
            //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:
            Microsoft.Office.Interop.Outlook.Application outlookApp =
                new Microsoft.Office.Interop.Outlook.Application();

            //Next, create an instance of AppointmentItem object and set the properties:
            Microsoft.Office.Interop.Outlook.AppointmentItem oAppointment =
                (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApp.CreateItem(
                    Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);

            oAppointment.Subject = action.TypeActionLabel + "-" + action.CompanyName + "-" + action.CandidateFullName;
            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;
            }
            // 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 = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceHigh;

            /* OlBusyStatus is enum with following values:
            olBusy
            olFree
            olOutOfOffice
            olTentative
            */
            oAppointment.BusyStatus = Microsoft.Office.Interop.Outlook.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;
            //    }
            //}
            if (action.ContactID.HasValue)
            {
                string emailContact = string.Empty;
                List<CompanyContactTelephone> contactInfoList =
                    new CompanyContactTelephoneRepository().GetContactInfo(action.ContactID.Value);
                foreach (CompanyContactTelephone item in contactInfoList)
                {
                    if (item.Type == "E")
                    {
                        emailContact = item.Tel;
                        break;
                    }
                }
                //ParamUser currentUser = SessionManager.CurrentUser;
                if (!string.IsNullOrEmpty(emailContact))
                {
                    //oAppointment.RequiredAttendees = "*****@*****.**";
                    //oAppointment.OptionalAttendees = "*****@*****.**";
                    // Another useful method is ForwardAsVcal () which can be used to send the Vcs file via email.
                    Microsoft.Office.Interop.Outlook.MailItem mailItem = oAppointment.ForwardAsVcal();

                    mailItem.To = emailContact;
                    mailItem.Send();
                    //oAppointment.Send();
                }
                else
                {
                    message = ResourceManager.GetString("messageExportActionNotHaveEmail");
                }
            }
        }
        catch (System.Exception ex)
        {
            message = ex.Message;
        }
        if (message != string.Empty)
        {
            string script1 = "<script type=\"text/javascript\">";

            script1 += " alert(\"" + message + "\")";
            script1 += " </script>";

            if (!page.ClientScript.IsClientScriptBlockRegistered("redirectUser"))
                page.ClientScript.RegisterStartupScript(page.GetType(), "redirectUser", script1);
            return false;
        }
        else
        {
            return true;
        }
    }