Exemple #1
0
        private List <CostCenter> ReadTextCostCenter_2018()
        {
            List <CostCenter> costcenters = new List <CostCenter>();

            path = Path.Combine(basepath, @"Data\CostCenter_exclude.txt");

            using (StreamReader reader = new StreamReader(path))
            {
                using (TextFieldParser parser = new TextFieldParser(reader))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters("\t");
                    while (!parser.EndOfData)
                    {
                        string[] fields     = parser.ReadFields();
                        var      costcenter = new CostCenter();
                        //if (!fields[1].ToString().Contains("┬бр┼╘б"))
                        //{
                        costcenter.CostCenterID   = fields[0].ToString();
                        costcenter.CostCenterName = fields[1].ToString();
                        costcenter.ShortName      = fields[1].ToString().Split(new char[] { '-' })[0];
                        costcenter.Status         = RecordStatus.Active;
                        costcenter.NewCreateTimeStamp("Seed");
                        costcenters.Add(costcenter);
                        //}
                    }
                }
            }

            return(costcenters);
        }
        public CostCenter Add(string id, string name, string dept_name)
        {
            CostCenter costcenter = new CostCenter();

            costcenter.CostCenterID   = id;
            costcenter.CostCenterName = name;
            costcenter.ShortName      = dept_name;
            costcenter.Status         = Models.Base.RecordStatus.Active;
            costcenter.NewCreateTimeStamp();
            _db.CostCenters.Add(costcenter);
            _db.SaveChanges();
            return(costcenter);
        }