Пример #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        JuryList JuryLists = JuryList.GetJuryList("", "");

        foreach (Jury jury in JuryLists)
        {
            List <CompanyHistory> companies = CompanyHistoryList.GetCompanyHistoryList(jury.Id).OrderByDescending(x => x.DateCreated).ToList();
            if (companies.Count > 0)
            { //EDIT HERE
                int            count = 1;
                CompanyHistory CurrCompanyHistory = null;
                //EDIT DATE CREATED
                foreach (CompanyHistory com in companies)
                {
                    if (count == 1)
                    {
                        //NEW COMPANY HISTORY
                        CompanyHistory compnyHistroy = CompanyHistory.NewCompanyHistory();
                        SaveCompanyHistory(jury, compnyHistroy, com.DateCreatedString);
                    }
                    else
                    {
                        SaveCompanyHistory(jury, CurrCompanyHistory, com.DateCreatedString);
                    }

                    if (count != companies.Count || companies.Count == 1)
                    {
                        CurrCompanyHistory = com;
                    }

                    count++;
                }

                //FOR LATEST COMPANY HISTORY
                SaveCompanyHistory(jury, CurrCompanyHistory, jury.DateCreatedString);
            }
            else
            {   //NEW COMPANY HISTORY
                CompanyHistory compnyHistroy = CompanyHistory.NewCompanyHistory();
                SaveCompanyHistory(jury, compnyHistroy, "Empty");
            }
        }
    }
Пример #2
0
    public void SaveCompanyHistory(Jury jury, ClosedXML.Excel.IXLRangeRow CurrentRow)
    {
        CompanyHistory compnyHistroy = CompanyHistory.NewCompanyHistory();

        compnyHistroy.JuryId      = jury.Id;
        compnyHistroy.Type        = RemoveControlChars(CurrentRow.Cell(2).GetString());
        compnyHistroy.Designation = RemoveControlChars(CurrentRow.Cell(7).GetString());
        compnyHistroy.Company     = RemoveControlChars(CurrentRow.Cell(8).GetString());

        compnyHistroy.Country            = RemoveControlChars(CurrentRow.Cell(17).GetString());
        compnyHistroy.DateModifiedString = DateTime.Now.ToString();
        compnyHistroy.Network            = RemoveControlChars(CurrentRow.Cell(9).GetString());
        compnyHistroy.HoldingCompany     = RemoveControlChars(CurrentRow.Cell(10).GetString());

        if (compnyHistroy.IsNew)
        {
            compnyHistroy.DateCreatedString = DateTime.Now.AddYears(-3).ToString();
        }

        if (compnyHistroy.IsValid)
        {
            compnyHistroy.Save();
        }
    }