Esempio n. 1
0
        void reloadModelName()
        {
            List <string> data = BomModelModelDAO.getInstance().getListModelName();

            txtModel.DataSource = data;
            //txtModel.Text = "";
        }
Esempio n. 2
0
        public void addNewPlan(PlanModel plan)
        {
            if (plan.component_id < 1)
            {
                throw new Exception("Please select component");
            }
            if (String.IsNullOrEmpty(plan.model_name) || String.IsNullOrWhiteSpace(plan.model_name))
            {
                throw new Exception("Plan model cannot leave empty");
            }
            if (plan.plan_data < 0)
            {
                throw new Exception("Plan data must greater than 0");
            }
            if (plan.plan_line < 0)
            {
                throw new Exception("Plan line must greater than 0");
            }
            decimal model_id = BomModelModelDAO.getInstance().getIdByName(plan.model_name);

            plan.model_id = model_id;
            if (PlanDao.getInstance().isExist(plan))
            {
                throw new Exception("Plan existed");
            }
            PlanDao.getInstance().add(plan);
        }
Esempio n. 3
0
        void reloadModelName(decimal component_id)
        {
            List <string> data = BomModelModelDAO.getInstance().getListModelName(component_id);

            txtModel.DataSource = data;
            //txtModel.Text = "";
        }
Esempio n. 4
0
 public void saveBomModel(BOM_Model_Model model)
 {
     if (model.component_id < 1)
     {
         throw new Exception("Please select component first");
     }
     BomModelModelDAO.getInstance().add(model);
 }
Esempio n. 5
0
 public void delete(BOM_Model_Model model)
 {
     if (model.component_id < 1)
     {
         throw new Exception("Please select component first");
     }
     if (String.IsNullOrEmpty(model.model_name) || String.IsNullOrWhiteSpace(model.model_name))
     {
         throw new Exception("No model was delete");
     }
     if (!BomModelModelDAO.getInstance().delete(model))
     {
         throw new Exception("Cannot delete model");
     }
 }
Esempio n. 6
0
 public void updateBomModel(BOM_Model_Model model)
 {
     if (model.component_id < 1)
     {
         throw new Exception("Invalid component");
     }
     if (String.IsNullOrEmpty(model.model_name) || String.IsNullOrWhiteSpace(model.model_name))
     {
         throw new Exception("Invalid model name");
     }
     if (model.model_value < 0)
     {
         throw new Exception("Model value must greater than 0");
     }
     BomModelModelDAO.getInstance().update(model);
 }
Esempio n. 7
0
        private async Task process()
        {
            BomModelModelDAO.getInstance().clearData();
            BOMDao.getInstance().clearData();
            string       filePath = txtPath.Text;
            XSSFWorkbook workbook;

            using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
            {
                workbook = new XSSFWorkbook(file);
            }
            int errCount = 0;
            var sheet    = workbook.GetSheet("BOM");
            var mainRow  = sheet.GetRow(1);
            int rowCount = 0;

            for (int row = 2; row <= sheet.LastRowNum; row++)
            {
                if (sheet.GetRow(row) != null) //null is when the row only contains empty cells
                {
                    rowCount += 1;
                    var     curRow               = sheet.GetRow(row);
                    string  componentName        = curRow.GetCell(2).StringCellValue;
                    string  componentDescription = curRow.GetCell(3).StringCellValue;
                    decimal id = -1;
                    if (!BOMDao.getInstance().isExist(componentName))
                    {
                        BOMDao.getInstance().add(new BOM_Model {
                            component_name = componentName, object_description = componentDescription
                        });
                    }
                    id = BOMDao.getInstance().getComponentIdByName(componentName);

                    for (int i = 4; i <= curRow.LastCellNum; i++)
                    {
                        try
                        {
                            var     x     = curRow.GetCell(i).NumericCellValue;
                            string  model = mainRow.GetCell(i).StringCellValue;
                            decimal num   = Convert.ToDecimal(x);
                            if (num < 1)
                            {
                                continue;
                            }
                            BomModelModelDAO.getInstance().add(new BOM_Model_Model {
                                component_id = id, model_name = model, model_value = num
                            });
                            Console.WriteLine(String.Format("{0} || {1}", x, model));
                        }
                        catch (Exception ex)
                        {
                            errCount += 1;
                            Console.WriteLine(String.Format("loi tai row {0} col {1}", row, i));
                            Console.WriteLine(ex.Message);
                        }
                    }
                    Console.WriteLine(string.Format("Row {0} = {1} : {2}", row, sheet.GetRow(row).GetCell(2).StringCellValue, sheet.GetRow(row).GetCell(3).StringCellValue));
                }
            }
            MessageBox.Show($"Done {rowCount} row");
            btnProcess.Enabled = true;
        }