Beispiel #1
0
        /// <summary>
        /// Handles the AjaxRequest event of the radAjaxManager control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Telerik.Web.UI.AjaxRequestEventArgs"/> instance containing the event data.</param>
        protected void radAjaxManager_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            if (e.Argument == "AddCompany")
            {
                if (Session["UpdatedContactId"] != null && Session["CompanyTitle"] != null)
                {
                    var company = new tbl_Company
                    {
                        ID        = Guid.NewGuid(),
                        CreatedAt = DateTime.Now,
                        SiteID    = CurrentUser.Instance.SiteID,
                        Name      = Session["CompanyTitle"].ToString(),
                        StatusID  = _dataManager.Status.SelectDefault(CurrentUser.Instance.SiteID).ID
                    };
                    _dataManager.Company.Add(company);

                    var contact = _dataManager.Contact.SelectById(CurrentUser.Instance.SiteID, Guid.Parse(Session["UpdatedContactId"].ToString()));
                    contact.CompanyID = company.ID;
                    _dataManager.Contact.Update(contact);

                    Session["CompanyTitle"]     = null;
                    Session["UpdatedContactId"] = null;

                    Response.Redirect(UrlsData.AP_Company(company.ID));
                }
            }

            if (e.Argument == "CancelAddCompany")
            {
                Session["CompanyTitle"]     = null;
                Session["UpdatedContactId"] = null;
                Response.Redirect(UrlsData.AP_Contacts());
            }
        }
 /// <summary>
 /// Adds the specified company.
 /// </summary>
 /// <param name="company">The company.</param>
 /// <returns></returns>
 public tbl_Company Add(tbl_Company company)
 {
     company.ID        = Guid.NewGuid();
     company.CreatedAt = DateTime.Now;
     _dataContext.tbl_Company.AddObject(company);
     _dataContext.SaveChanges();
     return(company);
 }
 public void Save()
 {
     using (var context = new CashCarryEntities3())
     {
         tbl_Company obj = new tbl_Company()
         {
             CompanyName = CompanyName,
             Contact     = Contact,
             Email       = Email,
             Address     = Address,
             DuePayment  = DuePayment
         };
         context.tbl_Company.Add(obj);
         context.SaveChanges();
     }
 }
        /// <summary>
        /// Selects the by name and create.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        /// <param name="name">The name.</param>
        /// <returns></returns>
        public tbl_Company SelectByNameAndCreate(Guid siteId, string name)
        {
            var company = SelectByName(siteId, name);

            if (company == null)
            {
                company = new tbl_Company {
                    SiteID = siteId, Name = name
                };
                var status = _dataContext.tbl_Status.FirstOrDefault(a => a.SiteID == siteId && a.IsDefault) ??
                             _dataContext.tbl_Status.FirstOrDefault(a => a.SiteID == siteId);
                company.StatusID = status.ID;
                Add(company);
            }
            return(company);
        }
Beispiel #5
0
    public bool _savebtn(tbl_Company objSaa)
    {
        bool   flag    = false;
        string strQuer = "";

        strQuer = "set dateformat dmy; insert into tbl_Company ([tbl_Company_Name],[Ato_sell],[Ato_By],[Totl_sell],[Totl_Qty],[tbl_Final_Qty],[tbl_Self_result],[tbl_NSE_result],[Date])values('" + objSaa.tbl_Company_Name + "','" + objSaa.Ato_sell + "','" + objSaa.Ato_By + "','" + objSaa.Totl_sell + "','" + objSaa.Totl_Qty + "','" + objSaa.tbl_Final_Qty + "','" + objSaa.tbl_Self_result + "','" + objSaa.tbl_NSE_result + "','" + objSaa.Date + "' where tbl_Company_Status=1);select @@Identity";
        try
        {
            ExecuteSelectQuery(strQuer);
            flag = true;
        }
        catch (Exception ee)
        {
            flag = false;
        }
        return(flag);
    }
Beispiel #6
0
    public bool seve_Ammount(tbl_Company obj_data)
    {
        bool   flag = false;
        string Sql  = "";

        Sql = "set dateformat dmy; insert into tbl_Company([tbl_Company_Name],[Ato_sell],[Ato_By],[Totl_sell],[Totl_Qty],[tbl_Final_Qty],[tbl_Self_result],[tbl_NSE_result],[Date],[tbl_Company_Status]) values('" + obj_data.tbl_Company_Name + "', '" + obj_data.Ato_sell + "', '" + obj_data.Ato_By + "', '" + obj_data.Totl_sell + "', '" + obj_data.Totl_Qty + "', '" + obj_data.tbl_Final_Qty + "', '" + obj_data.tbl_Self_result + "', '" + obj_data.tbl_NSE_result + "', '" + obj_data.Date + "', 1)";

        //int ret_type = 0;
        DataSet dataSet = new DataSet();

        try
        {
            dataSet = ExecuteSelectQuery(Sql);
            flag    = true;
        }
        catch (Exception ee)
        {
            //ret_type = 0;
            flag = false;
        }
        return(flag);
    }
Beispiel #7
0
        public CompanyViewModel AddCompany(CompanyViewModel company)
        {
            var data = new tbl_Company
            {
                CompanyId      = company.companyId,
                CompanyName    = company.companyName,
                CompanyAddress = company.companyAddress,
                PhoneNo        = company.phoneNo,
                Email          = company.email,
                Website        = company.website,
                CompanyLogo    = company.companyLogo,
                IsActive       = company.isActive,
                CreatedBy      = "admin",
                CreatedOn      = DateTime.Now,
                ModifiedBy     = "admin",
                ModifiedOn     = DateTime.Now
            };

            context.tbl_Company.Add(data);
            context.SaveChanges();
            return(company);
        }
Beispiel #8
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        tbl_Company obj_C = new tbl_Company();
        obj_C.tbl_Company_Name= lblCompany.Text.Trim(); 
        obj_C.Ato_sell = lblAto_sell.Text.Trim(); 
        obj_C.Ato_By = lblAto_By.Text.Trim(); 
        obj_C.Totl_sell = lblTotl_sell.Text.Trim(); 
        obj_C.Totl_Qty = lblTotl_Qty.Text.Trim(); 
        obj_C.tbl_Final_Qty = txtFinalQuantity.Text.Trim(); 
        obj_C.tbl_Self_result = txtSelfResult.Text.Trim(); 
        obj_C.tbl_NSE_result = txtNSE.Text.Trim(); 
        obj_C.Date = txtDate.Text.Trim(); 

        if(new DataLayer().seve_Ammount(obj_C))
        {
            MessageBox.Show("Save SuccessFully   ");
        }
        else
        {
            MessageBox.Show("Error in Saving");
        }

    }
        /// <summary>
        /// Replaces the specified subject.
        /// </summary>
        /// <param name="subject">The subject.</param>
        /// <param name="body">The body.</param>
        public override void Replace(ref string subject, ref string body)
        {
            if (!SiteAction.ObjectID.HasValue)
            {
                return;
            }

            PortalSettings = DataManager.PortalSettings.SelectMapBySiteId(SiteAction.SiteID, true);

            ReplaceUserInfo(ref body);

            var printLink = string.Empty;

            var invoice = DataManager.Invoice.SelectById(SiteAction.SiteID, (Guid)SiteAction.ObjectID);

            if (invoice != null)
            {
                if (PortalSettings != null)
                {
                    PortalLink = DataManager.PortalSettings.SelectPortalLink(PortalSettings.SiteID, true);
                    printLink  = string.Format(InvoicePrintLinkTemplate.Replace("#PortalLink#", PortalLink), invoice.ID);
                }

                body = body.Replace("#Invoice.PrintVersion.Link#", printLink);
                if (SiteAction.tbl_SiteActionAttachment.Any())
                {
                    var siteActionAttacment = SiteAction.tbl_SiteActionAttachment.FirstOrDefault();
                    siteActionAttacment.FileName = printLink + "?autoexport=pdf";
                    DataManager.SiteActionAttachment.Update(siteActionAttacment);

                    var webClient = new WebClient();
                    var file      = webClient.DownloadData(SiteAction.tbl_SiteActionAttachment.First().FileName);
                    MailMessage.Attachments.Add(new Attachment(new MemoryStream(file), string.Format("Счет #{0}.pdf", invoice.Number), MediaTypeNames.Application.Pdf));
                }


                if (invoice.ExecutorContactID.HasValue)
                {
                    var contact = DataManager.Contact.SelectById(SiteAction.SiteID, invoice.ExecutorContactID.Value);
                    subject = subject.Replace("#Invoice.Executor.UserFullName#", contact.UserFullName).Replace("#Invoice.Executor.Phone#", contact.Phone);
                    body    = body.Replace("#Invoice.Executor.UserFullName#", contact.UserFullName).Replace("#Invoice.Executor.Phone#", contact.Phone);
                }
                else
                {
                    subject = subject.Replace("#Invoice.Executor.UserFullName#", string.Empty).Replace("#Invoice.Executor.Phone#", string.Empty);
                    body    = body.Replace("#Invoice.Executor.UserFullName#", string.Empty).Replace("#Invoice.Executor.Phone#", string.Empty);
                }

                tbl_Company company = null;

                if (invoice.ExecutorContactID.HasValue)
                {
                    var executorContact = DataManager.Contact.SelectById(SiteAction.SiteID, invoice.ExecutorContactID.Value);
                    MailMessage.Bcc.Add(new MailAddress(executorContact.Email, executorContact.UserFullName));
                }

                if (invoice.BuyerCompanyID.HasValue)
                {
                    company = DataManager.Company.SelectById(SiteAction.SiteID, invoice.BuyerCompanyID.Value);
                }

                if (company != null)
                {
                    body    = body.Replace("#Invoice.Notification.Company#", company.Name);
                    subject = subject.Replace("#Invoice.Notification.Company#", company.Name);
                }
                else
                {
                    body    = body.Replace("#Invoice.Notification.Company#", string.Empty);
                    subject = subject.Replace("#Invoice.Notification.Company#", string.Empty);
                }
            }

            if (body.Contains("#Invoice.PayableList#"))
            {
                var serviceLevelContact = DataManager.ServiceLevelContact.SelectById((Guid)SiteAction.ObjectID);
                if (serviceLevelContact != null)
                {
                    body    = body.Replace("#Invoice.Notification.Company#", serviceLevelContact.tbl_ServiceLevelClient.tbl_Company.Name);
                    subject = subject.Replace("#Invoice.Notification.Company#", serviceLevelContact.tbl_ServiceLevelClient.tbl_Company.Name);

                    ProceedInvoices(ref body, DataManager.Invoice.SelectByBuyerCompanyId(serviceLevelContact.tbl_ServiceLevelClient.ClientID).Where(o => o.InvoiceStatusID == (int)InvoiceStatus.PartialPaid || o.InvoiceStatusID == (int)InvoiceStatus.PendingPayment), serviceLevelContact);
                }
            }
        }
Beispiel #10
0
        /// <summary>
        /// Handles the NeedDataSource event of the InvoiceReport control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void InvoiceReport_NeedDataSource(object sender, EventArgs e)
        {
            var dataManager = new DataManager();
            var invoice     = dataManager.Invoice.SelectById(_siteId, _invoiceId);

            if (invoice != null)
            {
                (sender as Telerik.Reporting.Processing.Report).DocumentName = "Счет #" + invoice.Number;
                (sender as Telerik.Reporting.Processing.Report).DataSource   = invoice;

                _sum = invoice.InvoiceAmount;

                htbSchetHeader.Value = String.Format("СЧЕТ № {0} от {1}", invoice.Number, invoice.CreatedAt.ToShortDateString());
                htbTotal.Value       = String.Format("Всего наименований {0} на сумму {1}", invoice.tbl_InvoiceProducts.Count, (_sum).ToString("F"));
                htbSumWord.Value     = NumByWords.RurPhrase(_sum);

                tbl_CompanyLegalAccount executorLegalAccount = null;

                if (invoice.ExecutorCompanyLegalAccountID.HasValue)
                {
                    executorLegalAccount = dataManager.CompanyLegalAccount.SelectById((Guid)invoice.ExecutorCompanyLegalAccountID);
                }

                if (executorLegalAccount != null)
                {
                    tbTitle.Value   = executorLegalAccount.OfficialTitle;
                    tbAdress.Value  = executorLegalAccount.LegalAddress;
                    tbAdress2.Value = executorLegalAccount.LegalAddress;

                    tbReciver.Value     = executorLegalAccount.OfficialTitle + " ИНН " + executorLegalAccount.INN;
                    tbSchet.Value       = !string.IsNullOrEmpty(executorLegalAccount.RS) ? executorLegalAccount.RS : "Нет данных";
                    tbExecutorRS.Value  = !string.IsNullOrEmpty(executorLegalAccount.RS) ? executorLegalAccount.RS : "Нет данных";
                    tbExecutorKPP.Value = !string.IsNullOrEmpty(executorLegalAccount.KPP) ? executorLegalAccount.KPP : "Нет данных";
                    tbExecutorINN.Value = !string.IsNullOrEmpty(executorLegalAccount.INN) ? executorLegalAccount.INN : "Нет данных";


                    if (_isStampEnabled)
                    {
                        var fsp = new FileSystemProvider();

                        if (!string.IsNullOrEmpty(executorLegalAccount.HeadSignatureFileName))
                        {
                            string img = fsp.GetPhysicalPath(invoice.SiteID, "CompanyLegalAccounts",
                                                             executorLegalAccount.HeadSignatureFileName, FileType.Attachment);
                            Image myImg = Image.FromFile(img);
                            pbHeadSignature.Value = myImg.Clone();
                            myImg.Dispose();
                        }

                        if (!string.IsNullOrEmpty(executorLegalAccount.AccountantSignatureFileName))
                        {
                            string img = fsp.GetPhysicalPath(invoice.SiteID, "CompanyLegalAccounts",
                                                             executorLegalAccount.AccountantSignatureFileName, FileType.Attachment);
                            Image myImg = Image.FromFile(img);
                            pbAccountantSignature.Value = myImg.Clone();
                            myImg.Dispose();
                        }

                        if (!string.IsNullOrEmpty(executorLegalAccount.StampFileName))
                        {
                            string img = fsp.GetPhysicalPath(invoice.SiteID, "CompanyLegalAccounts",
                                                             executorLegalAccount.StampFileName, FileType.Attachment);
                            Image myImg = Image.FromFile(img);
                            pbStamp.Value = myImg.Clone();
                            myImg.Dispose();
                        }
                    }
                    else
                    {
                        pbHeadSignature.Visible       = false;
                        pbAccountantSignature.Visible = false;
                        pbStamp.Visible = false;
                    }

                    if (executorLegalAccount.BankID.HasValue)
                    {
                        var bank = dataManager.Bank.SelectById((Guid)executorLegalAccount.BankID);
                        if (bank != null)
                        {
                            tbReciverBank.Value  = bank.Title;
                            tbExecutorBank.Value = bank.Title;
                            if (bank.CityID.HasValue)
                            {
                                tbExecutorBank.Value += " г. " + bank.tbl_City.Name;
                                tbReciverBank.Value  += " г. " + bank.tbl_City.Name;
                            }
                            tbBIK.Value        = !string.IsNullOrEmpty(bank.BIK) ? bank.BIK : "Нет данных";
                            tbBIK2.Value       = tbBIK.Value;
                            tbSchet2.Value     = !string.IsNullOrEmpty(bank.KS) ? bank.KS : "Нет данных";
                            tbExecutorKS.Value = tbSchet2.Value;
                        }
                        else
                        {
                            tbReciverBank.Value = tbBIK.Value = tbBIK2.Value = tbSchet2.Value = "Нет данных";
                        }
                    }

                    if (executorLegalAccount.HeadID.HasValue)
                    {
                        var head = dataManager.Contact.SelectById(invoice.SiteID, (Guid)executorLegalAccount.HeadID);
                        if (head != null)
                        {
                            tbHeadFullName.Value = string.Format("/{0} {1}.{2}./", head.Surname,
                                                                 !string.IsNullOrEmpty(head.Name) && head.Name.Length > 1 ? (object)head.Name[0] : "",
                                                                 !string.IsNullOrEmpty(head.Patronymic) && head.Patronymic.Length > 1 ? (object)head.Patronymic[0] : "");
                        }

                        var accountant = dataManager.Contact.SelectById(invoice.SiteID, (Guid)executorLegalAccount.AccountantID);
                        if (accountant != null)
                        {
                            tbAccountantFullName.Value = string.Format("/{0} {1}.{2}./", accountant.Surname,
                                                                       !string.IsNullOrEmpty(accountant.Name) && accountant.Name.Length > 1 ? (object)accountant.Name[0] : "",
                                                                       !string.IsNullOrEmpty(accountant.Patronymic) && accountant.Patronymic.Length > 1 ? (object)accountant.Patronymic[0] : "");
                        }
                    }
                }

                tbl_Company executorCompany = null;

                if (invoice.ExecutorCompanyID.HasValue)
                {
                    executorCompany = dataManager.Company.SelectById(invoice.SiteID, (Guid)invoice.ExecutorCompanyID);
                }

                if (executorCompany != null)
                {
                    tbPhone.Value = executorCompany.Phone1;
                    //tbFax.Value = executorCompany.Fax;
                }

                tbl_CompanyLegalAccount buyerLegalAccount = null;

                if (invoice.BuyerCompanyLegalAccountID.HasValue)
                {
                    buyerLegalAccount = dataManager.CompanyLegalAccount.SelectById((Guid)invoice.BuyerCompanyLegalAccountID);
                }

                if (buyerLegalAccount != null)
                {
                    tbBuyerTitle.Value         = buyerLegalAccount.OfficialTitle;
                    tbBuyerOfficialTitle.Value = buyerLegalAccount.OfficialTitle;
                }
            }
        }
Beispiel #11
0
 /// <summary>
 /// Updates the specified company.
 /// </summary>
 /// <param name="company">The company.</param>
 public void Update(tbl_Company company)
 {
     _dataContext.SaveChanges();
 }
Beispiel #12
0
        /// <summary>
        /// Saves this instance.
        /// </summary>
        public bool Save()
        {
            if (!access.Write)
            {
                return(false);
            }

            var contact = _dataManager.Contact.SelectById(SiteId, ContactId) ?? new tbl_Contact();

            if (contact.UserFullName != txtUserFullName.Text || !contact.IsNameChecked)
            {
                var nameChecker = new NameChecker(ConfigurationManager.AppSettings["ADONETConnectionString"]);
                var nameCheck   = nameChecker.CheckName(txtUserFullName.Text, NameCheckerFormat.FIO, Correction.Correct);
                if (!string.IsNullOrEmpty(nameCheck))
                {
                    contact.UserFullName  = nameCheck;
                    contact.Surname       = nameChecker.Surname;
                    contact.Name          = nameChecker.Name;
                    contact.Patronymic    = nameChecker.Patronymic;
                    contact.IsNameChecked = nameChecker.IsNameCorrect;
                }
                else
                {
                    contact.UserFullName  = txtUserFullName.Text;
                    contact.Name          = string.Empty;
                    contact.Surname       = string.Empty;
                    contact.Patronymic    = string.Empty;
                    contact.IsNameChecked = false;
                }
            }
            else
            {
                contact.IsNameChecked = imgbtnOk.Visible;
            }

            //contact.ContactTypeID = ddlContactType.SelectedValue != string.Empty ? (Guid?)Guid.Parse(ddlContactType.SelectedValue) : null;
            contact.StatusID  = _dataManager.Status.SelectDefault(SiteId).ID;
            contact.OwnerID   = ucOwner.SelectedValue;
            contact.CompanyID = ucCompany.SelectedValue;
            contact.JobTitle  = txtJobTitle.Text;
            //contact.ContactFunctionInCompanyID = ddlFunctionInCompany.SelectedValue != string.Empty ? (Guid?)Guid.Parse(ddlFunctionInCompany.SelectedValue) : null;
            //contact.ContactJobLevelID = ddlJobLevel.SelectedValue != string.Empty ? (Guid?)Guid.Parse(ddlJobLevel.SelectedValue) : null;
            contact.Phone         = txtPhone.Text;
            contact.CellularPhone = txtCellularPhone.Text;
            //contact.CellularPhoneStatusID = int.Parse(ddlCellularPhoneStatus.SelectedValue);
            contact.Email = txtEmail.Text;


            //contact.EmailStatusID = int.Parse(ddlEmailStatus.SelectedValue);
            contact.AddressID = ucPostalAddress.Save();
            contact.RefferID  = ucReffer.SelectedValue;

            if (rdpBirthday.SelectedDate != null)
            {
                contact.BirthDate = rdpBirthday.SelectedDate;
            }

            if (dcbAdvertisingPlatform.SelectedIdNullable.HasValue)
            {
                contact.AdvertisingPlatformID = dcbAdvertisingPlatform.SelectedIdNullable;
            }
            else if (!string.IsNullOrEmpty(dcbAdvertisingPlatform.Text) && !string.Equals(dcbAdvertisingPlatform.EmptyItemText, dcbAdvertisingPlatform.Text, StringComparison.OrdinalIgnoreCase))
            {
                var advertisingPlatform = _dataManager.AdvertisingPlatform.SelectByTitle(CurrentUser.Instance.SiteID, dcbAdvertisingPlatform.Text);
                if (advertisingPlatform == null)
                {
                    advertisingPlatform = new tbl_AdvertisingPlatform {
                        SiteID = CurrentUser.Instance.SiteID
                    };
                    advertisingPlatform.Code = advertisingPlatform.Title = dcbAdvertisingPlatform.Text;
                    _dataManager.AdvertisingPlatform.Add(advertisingPlatform);
                }
                contact.AdvertisingPlatformID = advertisingPlatform.ID;
            }

            if (dcbAdvertisingCampaign.SelectedIdNullable.HasValue)
            {
                contact.AdvertisingCampaignID = dcbAdvertisingCampaign.SelectedIdNullable;
            }
            else if (!string.IsNullOrEmpty(dcbAdvertisingCampaign.Text) && !string.Equals(dcbAdvertisingCampaign.EmptyItemText, dcbAdvertisingCampaign.Text, StringComparison.OrdinalIgnoreCase))
            {
                var advertisingCampaign = _dataManager.AdvertisingCampaign.SelectByTitle(CurrentUser.Instance.SiteID, dcbAdvertisingCampaign.Text);
                if (advertisingCampaign == null)
                {
                    advertisingCampaign = new tbl_AdvertisingCampaign {
                        SiteID = CurrentUser.Instance.SiteID
                    };
                    advertisingCampaign.Code = advertisingCampaign.Title = dcbAdvertisingCampaign.Text;
                    _dataManager.AdvertisingCampaign.Add(advertisingCampaign);
                }
                contact.AdvertisingCampaignID = advertisingCampaign.ID;
            }

            if (dcbAdvertisingType.SelectedIdNullable.HasValue)
            {
                contact.AdvertisingTypeID = dcbAdvertisingType.SelectedIdNullable;
            }
            else if (!string.IsNullOrEmpty(dcbAdvertisingType.Text) && !string.Equals(dcbAdvertisingType.EmptyItemText, dcbAdvertisingType.Text, StringComparison.OrdinalIgnoreCase))
            {
                var advertisingType = _dataManager.AdvertisingType.SelectByTitle(CurrentUser.Instance.SiteID, dcbAdvertisingType.Text);
                if (advertisingType == null)
                {
                    advertisingType = new tbl_AdvertisingType {
                        SiteID = CurrentUser.Instance.SiteID
                    };
                    advertisingType.Code = advertisingType.Title = dcbAdvertisingType.Text;
                    _dataManager.AdvertisingType.Add(advertisingType);
                }
                contact.AdvertisingTypeID = advertisingType.ID;
            }

            if (contact.ID == Guid.Empty)
            {
                contact.SiteID    = SiteId;
                contact.RefferURL = string.Empty;
                contact.UserIP    = string.Empty;
                contact.OwnerID   = CurrentUser.Instance.ContactID;
                _dataManager.Contact.Add(contact);

                ContactId = contact.ID;
            }
            else
            {
                _dataManager.Contact.Update(contact);
            }

            if (!ucCompany.SelectedValue.HasValue && !string.IsNullOrEmpty(ucCompany.Text))
            {
                var company = new tbl_Company
                {
                    ID        = Guid.NewGuid(),
                    CreatedAt = DateTime.Now,
                    SiteID    = CurrentUser.Instance.SiteID,
                    Name      = ucCompany.Text,
                    StatusID  = _dataManager.Status.SelectDefault(CurrentUser.Instance.SiteID).ID
                };
                _dataManager.Company.Add(company);

                contact.CompanyID = company.ID;
                _dataManager.Contact.Update(contact);
            }
            SaveCommuncation(ContactId, (int)CommunicationType.Web, txtWeb.Text);
            SaveCommuncation(ContactId, (int)CommunicationType.Facebook, txtFacebook.Text);
            SaveCommuncation(ContactId, (int)CommunicationType.VKontakte, txtVKontakte.Text);
            SaveCommuncation(ContactId, (int)CommunicationType.Twitter, txtTwitter.Text);

            return(true);
        }
Beispiel #13
0
        /// <summary>
        /// Replaces the text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="request">The request.</param>
        /// <param name="serviceLevel">The service level.</param>
        /// <param name="responsible">The responsible.</param>
        /// <param name="contact">The contact.</param>
        /// <param name="company">The company.</param>
        /// <returns></returns>
        protected string ReplaceText(string text, tbl_Request request, tbl_ServiceLevel serviceLevel, tbl_Contact responsible, tbl_Contact contact, tbl_Company company)
        {
            var shortDescription = request.ShortDescription;

            if (PortalSettings != null)
            {
                var requestLink = string.Format(RequestLinkTemplate, request.ID);
                shortDescription = string.Format("<a href='{0}'>{1}</a>", requestLink, shortDescription);
            }
            return(text.Replace("#Request.ShortDescription#", shortDescription)
                   .Replace("#Request.CreatedAt#", request.CreatedAt.ToString("dd.MM.yyyy"))
                   .Replace("#Request.ReactionTime#", serviceLevel.ReactionTime.ToString())
                   .Replace("#Request.Responsible.UserFullName#", responsible != null ? responsible.UserFullName : string.Empty)
                   .Replace("#Request.ReactionDatePlanned#", request.ReactionDatePlanned.HasValue ? ((DateTime)request.ReactionDatePlanned).ToString("dd.MM.yyyy") : string.Empty)
                   .Replace("#Request.Contact.UserFullName#", contact != null ? contact.UserFullName : string.Empty)
                   .Replace("#Request.Company.Name#", company != null ? company.Name : string.Empty));
        }
Beispiel #14
0
        /// <summary>
        /// Replaces the specified subject.
        /// </summary>
        /// <param name="subject">The subject.</param>
        /// <param name="body">The body.</param>
        public override void Replace(ref string subject, ref string body)
        {
            if (!SiteAction.ObjectID.HasValue)
            {
                return;
            }

            PortalSettings = DataManager.PortalSettings.SelectMapBySiteId(SiteAction.SiteID, true);

            ReplaceUserInfo(ref body);

            if (PortalSettings != null)
            {
                PortalLink = DataManager.PortalSettings.SelectPortalLink(PortalSettings.SiteID);
                RequirementLinkTemplate = RequirementLinkTemplate.Replace("#PortalLink#", PortalLink);
                RequestLinkTemplate     = RequestLinkTemplate.Replace("#PortalLink#", PortalLink);
            }

            var request = DataManager.Request.SelectById(SiteAction.SiteID, (Guid)SiteAction.ObjectID);

            if (request != null)
            {
                var         serviceLevel = request.tbl_ServiceLevel;
                tbl_Contact responsible  = null;
                tbl_Contact contact      = null;
                tbl_Company company      = null;

                if (request.ResponsibleID.HasValue)
                {
                    responsible = DataManager.Contact.SelectById(SiteAction.SiteID, (Guid)request.ResponsibleID);
                }
                if (request.ContactID.HasValue)
                {
                    contact = DataManager.Contact.SelectById(SiteAction.SiteID, (Guid)request.ContactID);
                }
                company = request.tbl_Company;

                subject = ReplaceText(subject, request, serviceLevel, responsible, contact, company);
                body    = ReplaceText(body, request, serviceLevel, responsible, contact, company);
                if (body.Contains("#Requirement.RegisteredList#"))
                {
                    var requirements = DataManager.Requirement.SelectByRequestId(request.SiteID, request.ID);

                    ProceedRegisteredRequirements(ref body, requirements);
                }

                if (company != null)
                {
                    body    = body.Replace("#Request.Notification.Company#", company.Name);
                    subject = subject.Replace("#Request.Notification.Company#", company.Name);
                }
                else
                {
                    body    = body.Replace("#Request.Notification.Company#", string.Empty);
                    subject = subject.Replace("#Request.Notification.Company#", string.Empty);
                }
            }


            var requirement = DataManager.Requirement.SelectById(SiteAction.SiteID, (Guid)SiteAction.ObjectID);

            if (requirement != null)
            {
                var shortDescription = requirement.ShortDescription;
                var requirementLink  = string.Format(RequirementLinkTemplate, requirement.ID);
                shortDescription = string.Format("<a href='{0}'>{1}</a>", requirementLink, shortDescription);

                body = body.Replace("#Requirement.ShortDescription#", shortDescription);

                if (requirement.CompanyID.HasValue)
                {
                    body    = body.Replace("#Requirement.Notification.Company#", requirement.tbl_Company.Name);
                    subject = subject.Replace("#Requirement.Notification.Company#", requirement.tbl_Company.Name);
                }
                else
                {
                    body    = body.Replace("#Requirement.Notification.Company#", string.Empty);
                    subject = subject.Replace("#Requirement.Notification.Company#", string.Empty);
                }
            }


            if (((body.Contains("#Requirement.WorkedList#") || body.Contains("#Requirement.CompanyList#") ||
                  body.Contains("#Requirement.CompletedList#")) && SiteAction.ContactID.HasValue))
            {
                var serviceLevelContact = DataManager.ServiceLevelContact.SelectById((Guid)SiteAction.ObjectID);

                if (serviceLevelContact != null)
                {
                    body    = body.Replace("#Requirement.Notification.Company#", serviceLevelContact.tbl_ServiceLevelClient.tbl_Company.Name);
                    subject = subject.Replace("#Requirement.Notification.Company#", serviceLevelContact.tbl_ServiceLevelClient.tbl_Company.Name);

                    var startDate = SiteAction.ActionDate.Date;
                    var endDate   = SiteAction.ActionDate.Date;
                    RequestNotificationService.GetDatesRangeByServiceLevelContact(serviceLevelContact, SiteAction.ActionDate.Date, ref startDate, ref endDate);

                    var requirements = new List <tbl_Requirement>();

                    switch ((ServiceLevelIncludeToInform)serviceLevelContact.IncludeToInformID)
                    {
                    case ServiceLevelIncludeToInform.All:
                        requirements = DataManager.Requirement.SelectAllByCompanyId(serviceLevelContact.tbl_ServiceLevelClient.ClientID, startDate, endDate).ToList();
                        break;

                    case ServiceLevelIncludeToInform.Personal:
                        requirements = DataManager.Requirement.SelectPersonal(serviceLevelContact.ContactID, startDate, endDate).ToList();
                        break;
                    }

                    body = body.Replace("#Requirement.CompanyList#", string.Empty);

                    ProceedWorkedRequirements(ref body, requirements.Where(o => !o.tbl_RequirementStatus.IsLast).ToList(), startDate, endDate);
                    ProceedCompletedRequirements(ref body, requirements.Where(o => o.tbl_RequirementStatus.IsLast).ToList());
                }
            }
        }