private bool checkModelStateCreateEdit(ActionEnumForm action, sys_inventory_position_item_capacity_model item)
        {
            if (item.db.min_stock == null || item.db.min_stock == 0)
            {
                ModelState.AddModelError("db.min_stock", "required");
            }
            if (item.db.max_stock == null || item.db.max_stock == 0)
            {
                ModelState.AddModelError("db.max_stock", "required");
            }
            if (string.IsNullOrEmpty(item.db.id_item))
            {
                ModelState.AddModelError("db.id_item", "required");
            }
            var searchName = repo.FindAll().Where(d =>
                                                  d.db.id_position == item.db.id_position &&
                                                  d.db.id_warehouse == item.db.id_warehouse &&
                                                  d.db.id_item == item.db.id_item &&
                                                  d.db.id_specification == item.db.id_specification &&
                                                  d.db.id != item.db.id).Count();

            if (searchName > 0)
            {
                ModelState.AddModelError("db.id_item", "existed");
                ModelState.AddModelError("db.id_specification", "existed");
            }

            return(ModelState.IsValid);
        }
Exemple #2
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_customer_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            if (string.IsNullOrEmpty(item.db.tax_number))
            {
                ModelState.AddModelError("db.tax_number", "required");
            }
            var search = repo.FindAll().Where(d => d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }
            var searchTax = repo.FindAll().Where(d => d.db.tax_number == item.db.tax_number && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.tax_number", "existed");
            }

            return(ModelState.IsValid);
        }
        private bool checkModelStateCreateEdit(ActionEnumForm action, production_order_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            var search = repo.FindAll().Where(d => d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }
            if (item.db.id_business_sale_order == null)
            {
                ModelState.AddModelError("db.id_business_sale_order", "required");
            }

            if (item.list_item.Count == 0)
            {
                ModelState.AddModelError("list_item", "required");
            }

            //if (item.list_need_supplier.Count == 0)
            //{
            //    ModelState.AddModelError("list_need_supplier_date", "required");
            //}
            return(ModelState.IsValid);
        }
Exemple #4
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_opc_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            var search = repo.FindAll().Where(d => d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }

            if (string.IsNullOrEmpty(item.db.id_opcclient))
            {
                ModelState.AddModelError("db.opcclient", "required");
            }

            if (string.IsNullOrEmpty(item.db.opcnode))
            {
                ModelState.AddModelError("db.opcnode", "required");
            }
            var searchnode = repo.FindAll().Where(d => d.db.opcnode == item.db.opcnode &&
                                                  d.db.id_opcclient == item.db.id_opcclient &&
                                                  d.db.id != item.db.id).Count();

            if (searchnode > 0)
            {
                ModelState.AddModelError("db.opcnode", "existed");
                ModelState.AddModelError("db.id_opcclient", "existed");
            }
            return(ModelState.IsValid);
        }
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_factory_line_item_capacity_model item)
        {
            //if (item.db.quantity ==null || item.db.quantity == 0)
            //{
            //    ModelState.AddModelError("db.quantity", "required");
            //}
            if (item.db.productTime == null || item.db.productTime == 0)
            {
                ModelState.AddModelError("db.productTime", "required");
            }
            if (string.IsNullOrEmpty(item.db.id_item))
            {
                ModelState.AddModelError("db.id_item", "required");
            }
            var searchName = repo.FindAll().Where(d =>
                                                  d.db.id_sys_factory_line == item.db.id_sys_factory_line &&
                                                  d.db.id_item == item.db.id_item &&
                                                  d.db.id_specification == item.db.id_specification &&
                                                  d.db.id != item.db.id).Count();

            if (searchName > 0)
            {
                ModelState.AddModelError("db.id_item", "existed");
                ModelState.AddModelError("db.id_specification", "existed");
            }

            return(ModelState.IsValid);
        }
Exemple #6
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, inventory_delivery_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            if (item.db.type == null)
            {
                ModelState.AddModelError("db.type", "required");
            }
            var search = repo.FindAll().Where(d => d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }
            if (item.db.id_delivery_type == null)
            {
                ModelState.AddModelError("db.id_delivery_type", "required");
            }
            if (item.db.export_date == null)
            {
                ModelState.AddModelError("db.export_date", "required");
            }
            if (item.db.id_warehouse == null)
            {
                ModelState.AddModelError("db.id_warehouse", "required");
            }
            if (item.list_item.Count == 0)
            {
                ModelState.AddModelError("list_item", "required");
            }
            return(ModelState.IsValid);
        }
Exemple #7
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_item_model item)
        {
            if (string.IsNullOrEmpty(item.db.code_item))
            {
                ModelState.AddModelError("db.code_item", "required");
            }
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            if (item.db.type == null)
            {
                ModelState.AddModelError("db.type", "required");
            }
            if (string.IsNullOrEmpty(item.db.id_item_type))
            {
                ModelState.AddModelError("db.id_item_type", "required");
            }
            if (string.IsNullOrEmpty(item.db.id_unit))
            {
                ModelState.AddModelError("db.id_unit", "required");
            }
            var search = repo.FindAll().Where(d => d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }


            return(ModelState.IsValid);
        }
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_item_specification_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            if (string.IsNullOrEmpty(item.db.id_unit))
            {
                ModelState.AddModelError("db.id_unit", "required");
            }
            if ((item.db.conversion_factor ?? 0) <= 0)
            {
                ModelState.AddModelError("db.conversion_factor", "required");
            }
            var search = repo.FindAll().Where(d =>
                                              d.db.id_item == item.db.id_item &&
                                              d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }


            return(ModelState.IsValid);
        }
        private bool checkModelStateCreateEdit(ActionEnumForm action, business_sale_order_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            var search = repo.FindAll().Where(d => d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }
            if (item.db.id_customer == null)
            {
                ModelState.AddModelError("db.id_customer", "required");
            }
            if (item.db.estimated_delivery_date == null)
            {
                ModelState.AddModelError("db.estimated_delivery_date", "required");
            }
            if (item.list_export_date.Count == 0)
            {
                ModelState.AddModelError("list_export_date", "required");
            }
            return(ModelState.IsValid);
        }
        private bool checkModelStateCreateEdit(ActionEnumForm action, maintenance_planning_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            if (string.IsNullOrEmpty(item.db.id_factory))
            {
                ModelState.AddModelError("db.id_factory", "required");
            }
            if (string.IsNullOrEmpty(item.db.id_factory_line))
            {
                ModelState.AddModelError("db.id_factory_line", "required");
            }

            var searchName = repo.FindAll().Where(d =>

                                                  d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (searchName > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }


            return(ModelState.IsValid);
        }
        private bool checkModelStateCreateEdit(ActionEnumForm action, maintenance_error_list_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }


            if (string.IsNullOrEmpty(item.db.error_detail))
            {
                ModelState.AddModelError("db.error_detail", "required");
            }



            var searchName = repo.FindAll().Where(d =>
                                                  d.db.id_maintenance_system == item.db.id_maintenance_system &&
                                                  d.db.id_maintenance_system_device == item.db.id_maintenance_system_device &&
                                                  d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (searchName > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }

            return(ModelState.IsValid);
        }
Exemple #12
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, maintenance_process_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            if (item.db.start_time == default(DateTime))
            {
                ModelState.AddModelError("db.start_time", "required");
            }
            if (item.db.end_time == default(DateTime))
            {
                ModelState.AddModelError("db.start_time", "required");
            }

            var searchName = repo._context.maintenance_processes.Where(d =>
                                                                       d.name == item.db.name && d.id != item.db.id).Count();

            if (searchName > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }

            return(ModelState.IsValid);
        }
 private bool checkModelStateCreateEdit(ActionEnumForm action, sys_approval_model item)
 {
     if (string.IsNullOrEmpty(item.db.id_sys_approval_config))
     {
         ModelState.AddModelError("db.id_sys_approval_config", "required");
     }
     return(ModelState.IsValid);
 }
 private bool checkModelStateCreateEdit(ActionEnumForm action, production_order_need_supplier_master_model item)
 {
     if (item.list_need_supplier.Count == 0)
     {
         ModelState.AddModelError("list_need_supplier", "required");
     }
     return(ModelState.IsValid);
 }
Exemple #15
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_item_bom_model item)
        {
            if (item.db.quota <= 0)
            {
                ModelState.AddModelError("db.quota", "required");
            }

            return(ModelState.IsValid);
        }
Exemple #16
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_workstation_template_opc_model item)
        {
            if (string.IsNullOrEmpty(item.db.id_template_opc))
            {
                ModelState.AddModelError("db.id_template_opc", "required");
            }
            var search = repo.FindAll().Where(d => d.db.id_template_opc == item.db.id_template_opc && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.id_template_opc", "existed");
            }


            return(ModelState.IsValid);
        }
        private bool checkModelStateCreateEdit(ActionEnumForm action, quality_solution_model item)
        {
            if (string.IsNullOrEmpty(item.db.solution_name))
            {
                ModelState.AddModelError("db.name", "required");
            }

            var searchName = repo.FindAll().Where(d =>
                                                  d.db.solution_name == item.db.solution_name && d.db.id != item.db.id).Count();

            if (searchName > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }

            return(ModelState.IsValid);
        }
Exemple #18
0
 private bool checkModelStateCreateEdit(ActionEnumForm action, quality_item_config_detail_model item)
 {
     if (string.IsNullOrEmpty(item.db.id_quality_item_config))
     {
         ModelState.AddModelError("db.id_quality_item_config", "required");
     }
     if (string.IsNullOrEmpty(item.db.content_config))
     {
         ModelState.AddModelError("db.content_config", "required");
     }
     if (string.IsNullOrEmpty(item.db.description))
     {
         ModelState.AddModelError("db.description", "required");
     }
     if (string.IsNullOrEmpty(item.db.type_evaluate))
     {
         ModelState.AddModelError("db.description", "required");
     }
     return(ModelState.IsValid);
 }
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_user_model item)
        {
            if (string.IsNullOrEmpty(item.db.Username))
            {
                ModelState.AddModelError("db.Username", "required");
            }
            if (string.IsNullOrEmpty(item.password) && action == ActionEnumForm.create)
            {
                ModelState.AddModelError("password", "required");
            }
            var search = repo.FindAll().Where(d => d.db.Username == item.db.Username && d.db.Id != item.db.Id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.Username", "existed");
            }


            return(ModelState.IsValid);
        }
Exemple #20
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_warehouse_position_model item)
        {
            if (string.IsNullOrEmpty(item.db.id_warehouse))
            {
                ModelState.AddModelError("db.id_warehouse", "required");
            }
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            if (item.db.row == null)
            {
                ModelState.AddModelError("db.row", "required");
            }
            if (item.db.col == null)
            {
                ModelState.AddModelError("db.col", "required");
            }
            var searchName = repo.FindAll().Where(d =>
                                                  d.db.id_warehouse == item.db.id_warehouse &&
                                                  d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (searchName > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }
            var searchrowcol = repo.FindAll().Where(d =>
                                                    d.db.id_warehouse == item.db.id_warehouse &&
                                                    d.db.col == item.db.col &&
                                                    d.db.row == item.db.row && d.db.id != item.db.id

                                                    ).Count();

            if (searchrowcol > 0)
            {
                ModelState.AddModelError("db.col", "existed");
                ModelState.AddModelError("db.row", "existed");
            }
            return(ModelState.IsValid);
        }
Exemple #21
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_approval_config_model item)
        {
            if (string.IsNullOrEmpty(item.db.name))
            {
                ModelState.AddModelError("db.name", "required");
            }
            var search = repo.FindAll().Where(d => d.db.name == item.db.name && d.db.id != item.db.id).Count();

            if (search > 0)
            {
                ModelState.AddModelError("db.name", "existed");
            }
            if (item.list_item.Count == 0)
            {
                ModelState.AddModelError("list_item", "required");
            }
            else
            {
                var maxstep = item.list_item.Max(d => d.db.step_num);
                if (maxstep > 10)
                {
                    ModelState.AddModelError("list_item", "system.step_num_maximum_is_10");
                }
                if (item.list_item.Where(d => d.db.step_num <= 0).Count() > 0)
                {
                    ModelState.AddModelError("list_item", "system.step_num_minimun_is_1");
                }
                for (int i = 1; i < maxstep; i++)
                {
                    if (item.list_item.Where(d => d.db.step_num == i).Count() == 0)
                    {
                        ModelState.AddModelError("list_item", "system.step_num_must_sequence");
                    }
                }
            }



            return(ModelState.IsValid);
        }
Exemple #22
0
        public bool checkModelStateCreateEdit(ActionEnumForm action, List <sys_work_schedule_factory_line_model> lst_item)
        {
            //for (int i = 0; i < lst_item.Count; i++)
            //{
            //    var itemNew = lst_item[i];
            //    if (itemNew.db.timeStart_1 == null)
            //    {
            //        ModelState.AddModelError("timeStart_1_" + i, "required");
            //    }

            //    if (itemNew.db.timeEnd_1 == null)
            //    {
            //        ModelState.AddModelError("timeEnd_1_" + i, "required");
            //    }

            //    if (itemNew.db.timeStart_1 != null && itemNew.db.timeEnd_1 != null)
            //    {
            //        if (itemNew.db.timeStart_1 > itemNew.db.timeEnd_1)
            //        {
            //            ModelState.AddModelError("db.timeStart_1_" + i, "msgdb.timeStart_1PhaiNhoHondb.timeEnd_1");
            //        }

            //    }
            //    if (itemNew.db.timeStart_2 != null && itemNew.db.timeEnd_2 != null)
            //    {
            //        if (itemNew.db.timeStart_1 > itemNew.db.timeEnd_1)
            //            ModelState.AddModelError("db.timeStart_2_" + i, "msgdb.timeStart_2PhaiNhoHondb.timeEnd_2");
            //    }
            //    if (itemNew.db.timeEnd_1 != null && itemNew.db.timeStart_2 != null)
            //    {
            //        if (itemNew.db.timeEnd_1 > itemNew.db.timeStart_2)
            //            ModelState.AddModelError("db.timeStart_2_" + i, "msgdb.timeStart_2PhaiLonHondb.timeEnd_1");
            //    }

            //}


            return(ModelState.IsValid);
        }
Exemple #23
0
        private bool checkModelStateCreateEdit(ActionEnumForm action, sys_vendor_item_model item)
        {
            if (item.db.min_stock_order.ToString() == null || item.db.min_stock_order == 0)
            {
                ModelState.AddModelError("db.min_stock_order", "required");
            }
            if (item.db.price_item.ToString() == null || item.db.price_item == 0)
            {
                ModelState.AddModelError("db.price_item", "required");
            }
            if (item.db.delivery_time.ToString() == null || item.db.delivery_time == 0)
            {
                ModelState.AddModelError("db.delivery_time", "required");
            }

            if (string.IsNullOrEmpty(item.db.id_item))
            {
                ModelState.AddModelError("db.id_item", "required");
            }
            int searchName = 0;

            if (action == ActionEnumForm.create)
            {
                searchName = repo.FindAll().Where(d =>
                                                  d.db.create_by == item.db.create_by &&
                                                  d.db.id_item == item.db.id_item &&
                                                  d.db.id_specification == item.db.id_specification &&
                                                  d.db.id != item.db.id).Count();
            }

            if (searchName > 0)
            {
                ModelState.AddModelError("db.id_item", "existed");
                ModelState.AddModelError("db.id_specification", "existed");
            }

            return(ModelState.IsValid);
        }
 private bool checkModelStateCreateEdit(ActionEnumForm action, maintenance_schedual_system_device_model item)
 {
     return(ModelState.IsValid);
 }
Exemple #25
0
 private bool checkModelStateCreateEdit(ActionEnumForm action, inventory_receiving_model item)
 {
     return(ModelState.IsValid);
 }
 private bool checkModelStateCreateEdit(ActionEnumForm action, production_report_work_done_model item)
 {
     return(ModelState.IsValid);
 }