public Estimate(string filename) { estimateSet = new List<EstimateString>(); resumeString = new EstimateString(0); equip = new EstimateEquipment(); this.filename = filename; this.Name = filename; // todo }
public void Remove(int number) { EstimateString deletingES = new EstimateString(number); foreach (EstimateString es in estimateSet) { if (es.Number == number) deletingES = es; } estimateSet.Remove(deletingES); }
public void AddResumeString(EstimateString resume) { resumeString = resume; }
public void Add(EstimateString newEsStr) { estimateSet.Add(newEsStr); }
//function for parsing part of table and return string of estimate EstimateString ParsingString(Cell firstCell) { string numberpattern = "^[0-9]{1,}"; int number = Convert.ToInt32(Regex.Match(RemoveUnvisibleCharacters(firstCell.Range.Text), numberpattern).Value); EstimateString resultString = new EstimateString(number); string namecaption = CellShift(firstCell, stringShiftDictionary[NAME]).Range.Text; //found name and caption by positions of cells versus cell with number int divider = namecaption.IndexOf(Convert.ToChar(13)); resultString.Name = namecaption.Substring(0, divider - 1); resultString.Caption = namecaption.Substring(divider + 1, namecaption.Length - divider-1); int conditionShift = Int32.MaxValue; if (stringShiftDictionary.ContainsKey(CONDITION)) { Cell conditionCell = CellShift(firstCell, stringShiftDictionary[CONDITION]); if (!Regex.IsMatch(conditionCell.Range.Text, configDictionary[ISSTRINGCONDITIONPATTERN])) conditionShift = stringShiftDictionary[CONDITION]; } resultString.Volume = ParsingElement(firstCell, VOLUME, stringShiftDictionary, conditionShift); resultString.CurrentCost = ParsingElement(firstCell, COST, stringShiftDictionary, conditionShift); resultString.CurrentWorkers = ParsingElement(firstCell, PAY, stringShiftDictionary, conditionShift); resultString.CurrentMachine = ParsingElement(firstCell, MACHINE, stringShiftDictionary, conditionShift); resultString.CurrentMaterials = ParsingElement(firstCell, MATERIAL, stringShiftDictionary, conditionShift); resultString.CurrentMachineWorkers = ParsingElement(firstCell, MACHINEPAY, stringShiftDictionary, conditionShift); resultString.CurrentOverheads = ParsingElement(firstCell, OVERHEADS, stringShiftDictionary, conditionShift); resultString.CurrentProfit = ParsingElement(firstCell, PROFIT, stringShiftDictionary, conditionShift); resultString.CurrentTotalCost = ParsingElement(firstCell, TOTALCOST, stringShiftDictionary, conditionShift); return resultString; }
//like ParsingsString function return resume estimate string EstimateString ParsingResume(Cell firstCell) { EstimateString resultString = new EstimateString(0); resultString.Name = firstCell.Range.Text; resultString.Volume = 0.0; resultString.CurrentCost = ParsingElement(firstCell, COST, resumeShiftDictionary); resultString.CurrentWorkers = ParsingElement(firstCell, PAY, resumeShiftDictionary); resultString.CurrentMachine = ParsingElement(firstCell, MACHINE, resumeShiftDictionary); resultString.CurrentMaterials = ParsingElement(firstCell, MATERIAL, resumeShiftDictionary); resultString.CurrentMachineWorkers = ParsingElement(firstCell, MACHINEPAY, resumeShiftDictionary); #if (DEBUG) #region resume parsing if (resultString.CurrentCost != resultString.CurrentWorkers + resultString.CurrentMachine + resultString.CurrentMaterials) Console.WriteLine("Cost not equals sum of elements"); else Console.WriteLine("Resume string parse good"); #endregion #endif return resultString; }