Ejemplo n.º 1
0
        public List <Models.ProductionPlan> GetDataSourceList(string batchNo)
        {
            List <Models.ProductionPlan> list = new List <ProductionPlan>();

            using (PingYuanDbContext context = new PingYuanDbContext())
            {
                list = context.ProductionPlans.
                       Where(p => p.BatchNo == batchNo).ToList();
            }
            return(list);
        }
Ejemplo n.º 2
0
        public BindingList <Models.ProductionPlan> GetDataSource(string batchNo)
        {
            BindingList <Models.ProductionPlan> result = new BindingList <Models.ProductionPlan>();

            using (PingYuanDbContext context = new PingYuanDbContext())
            {
                List <Models.ProductionPlan> list = context.ProductionPlans.
                                                    Where(p => p.BatchNo == batchNo).ToList();

                for (int i = 0; i < list.Count; i++)
                {
                    result.Add(list[i]);
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        public int InsertProgramCode(ProgramCode programCode)
        {
            int ret = 0;

            try
            {
                using (PingYuanDbContext context = new PingYuanDbContext())
                {
                    context.ProgramCodes.Add(programCode);
                    ret = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
            return(ret);
        }
Ejemplo n.º 4
0
        public BindingList <Models.ProductionPlan> FindByDateTime(string startTime, string endTime)
        {
            BindingList <Models.ProductionPlan> result = new BindingList <Models.ProductionPlan>();

            using (PingYuanDbContext context = new PingYuanDbContext())
            {
                List <Models.ProductionPlan> list = context.ProductionPlans.
                                                    Where(p => p.UpTime.CompareTo(startTime) >= 0 &&
                                                          p.UpTime.CompareTo(endTime) <= 0).ToList();

                for (int i = 0; i < list.Count; i++)
                {
                    result.Add(list[i]);
                }
            }
            return(result);
        }
Ejemplo n.º 5
0
        public int DeleteProgramCodeById(ProgramCode programCode)
        {
            int result = 0;

            try
            {
                using (PingYuanDbContext context = new PingYuanDbContext())
                {
                    ProgramCode pro = context.ProgramCodes.FirstOrDefault(p => p.Id == programCode.Id);
                    context.ProgramCodes.Remove(pro);
                    result = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
Ejemplo n.º 6
0
        public int DeleteById(int id)
        {
            int result = 0;

            using (PingYuanDbContext context = new PingYuanDbContext())
            {
                try
                {
                    ProductionPlan production = context.ProductionPlans.FirstOrDefault(p => p.Id == id);
                    context.ProductionPlans.Remove(production);
                    result = context.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"InsertProductionPlans出错:{ex.Message}");
                }
            }
            return(result);
        }
Ejemplo n.º 7
0
        public int InsertProductionPlan(ProductionPlan productionPlan)
        {
            int result = 0;

            try
            {
                //if (_context.ProductionPlans.FirstOrDefault(p => p.BatchNo == productionPlan.BatchNo) == null)
                //{
                using (PingYuanDbContext context = new PingYuanDbContext())
                {
                    context.ProductionPlans.Add(productionPlan);
                    result = context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"InsertProductionPlan出错:{ex.Message}");
            }
            return(result);
        }
Ejemplo n.º 8
0
        public int InsertProductionPlans(List <ProductionPlan> productionPlans)
        {
            int result = 0;

            using (PingYuanDbContext context = new PingYuanDbContext())
            {
                try
                {
                    foreach (var production in productionPlans)
                    {
                        context.ProductionPlans.Add(production);
                    }
                    result = context.SaveChanges();
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"InsertProductionPlans出错:{ex.Message}");
                }
            }

            return(result);
        }
Ejemplo n.º 9
0
        public int UpdateProductionPlan(ProductionPlan role)
        {
            int result = 0;

            using (PingYuanDbContext context = new PingYuanDbContext()) {
                try
                {
                    ProductionPlan production = context.ProductionPlans.Where(p => p.Id == role.Id).FirstOrDefault();
                    production.BatchNo               = role.BatchNo;
                    production.WorkpieceType         = role.WorkpieceType;
                    production.PrimerColor           = role.PrimerColor;
                    production.PigmentedCoatingColor = role.PigmentedCoatingColor;
                    production.VarnishColor          = role.VarnishColor;
                    production.TotalNum              = role.TotalNum;
                    result = context.SaveChanges();
                }
                catch (Exception ex)
                {
                    LogManager.WriteLog(LogFile.SQL, $"UpdateProductionPlan出错:{ex.Message}");
                }
            }
            return(result);
        }
Ejemplo n.º 10
0
 public UserDao()
 {
     _context = new PingYuanDbContext();
 }
Ejemplo n.º 11
0
 public BaseDao()
 {
     _context = new PingYuanDbContext();
 }