微调

parent 2cfc4b6b
......@@ -293,40 +293,29 @@ public void Clear(int allotId)
/// <param name="iD"></param>
public void Copy(per_allot allot)
{
var list = perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId).OrderByDescending(t => t.Year).ThenBy(t => t.Month).ToList();
var list = perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId)
.OrderBy(t => t.Year).ThenBy(t => t.Month).ToList();
int allotId = 0;
for (int i = 0; i < list.Count; i++)
{
if (list[i].ID == allot.ID && (i - 1) >= 0)
allotId = list[i - 1].ID;
}
if (allotId > 0)
{
var director = _directorRepository.GetEntities(t => t.AllotID == allotId);
if (director != null)
{
var addData = director.Select(t => new cof_director { AllotID = allot.ID, JobTitle = t.JobTitle, TypeName = t.TypeName, Value = t.Value });
_directorRepository.AddRange(addData.ToArray());
}
var durgprop = _drugpropRepository.GetEntities(t => t.AllotID == allotId);
if (durgprop != null)
{
var addData = durgprop.Select(t => new cof_drugprop { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
_drugpropRepository.AddRange(addData.ToArray());
}
var income = _incomeRepository.GetEntities(t => t.AllotID == allotId);
if (income != null)
{
var addData = income.Select(t => new cof_income { AllotID = allot.ID, SheetNameKeyword = t.SheetNameKeyword, UnitName = t.UnitName, Value = t.Value });
_incomeRepository.AddRange(addData.ToArray());
}
var workyear = _workyearRepository.GetEntities(t => t.AllotID == allotId);
if (workyear != null)
{
var addData = workyear.Select(t => new cof_workyear { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
_workyearRepository.AddRange(addData.ToArray());
}
}
var director = _directorRepository.GetEntities(t => t.AllotID == allotId) ?? _directorRepository.GetEntities(t => t.AllotID == -1);
var newDirectors = director.Select(t => new cof_director { AllotID = allot.ID, JobTitle = t.JobTitle, TypeName = t.TypeName, Value = t.Value });
_directorRepository.AddRange(newDirectors.ToArray());
var durgprop = _drugpropRepository.GetEntities(t => t.AllotID == allotId) ?? _drugpropRepository.GetEntities(t => t.AllotID == -1);
var newDurgprops = durgprop.Select(t => new cof_drugprop { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
_drugpropRepository.AddRange(newDurgprops.ToArray());
var income = _incomeRepository.GetEntities(t => t.AllotID == allotId) ?? _incomeRepository.GetEntities(t => t.AllotID == -1);
var newIncomes = income.Select(t => new cof_income { AllotID = allot.ID, SheetNameKeyword = t.SheetNameKeyword, UnitName = t.UnitName, Value = t.Value });
_incomeRepository.AddRange(newIncomes.ToArray());
var workyear = _workyearRepository.GetEntities(t => t.AllotID == allotId) ?? _workyearRepository.GetEntities(t => t.AllotID == -1);
var newWorkyears = workyear.Select(t => new cof_workyear { AllotID = allot.ID, MaxRange = t.MaxRange, MinRange = t.MinRange, Value = t.Value });
_workyearRepository.AddRange(newWorkyears.ToArray());
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment