public ActionResult AddDeviceInProject1(int Idpr, int Iddv, String Notes)
        {
            bool result    = false;
            int  checkdele = Ql.AddDeviceOfProject(Idpr, Iddv, Notes);

            if (checkdele > 0)
            {
                result = true;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public JsonResult AddDeviceProject1(string Id, int PJ)
        {
            bool result   = true;
            var  IdParent = Id.Split(',');
            var  check    = 0;

            for (int i = 0; i < IdParent.Length; i++)
            {
                var IdP = Convert.ToInt32(IdParent[i]);
                //Check thiết bị xem có phải là thiết bị con nằm trong
                check += data.DeviceDevices.Where(x => x.DeviceCodeChildren == IdP & x.IsDeleted == false & x.TypeComponant == 1).Count();
            }
            if (check > 0)
            {
                result = false;
            }
            else
            {
                // Lấy danh sách thiết bị con từ danh sách thiết bị cha
                for (int i = 0; i < IdParent.Length; i++)
                {
                    var IdP          = Convert.ToInt32(IdParent[i]);
                    var lstComponant = data.DeviceDevices.Where(x => x.DeviceCodeParents == IdP & x.IsDeleted == false & x.TypeComponant == 1).Select(x => x.DeviceCodeChildren).ToList();
                    foreach (var item in lstComponant)
                    {
                        // Thêm thiết bị con vào DeviceOfProject
                        data.AddDeviceOfProject(PJ, Convert.ToInt32(item), "");
                    }
                }
                //Thêm thiết bị cha vào DeviceOfProject
                var lstId = Id.Split(',');
                for (int i = 0; i < lstId.Length; i++)
                {
                    if (!lstId[i].Equals(""))
                    {
                        data.AddDeviceOfProject(PJ, Convert.ToInt32(lstId[i]), "");
                    }
                }
                result = true;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult AddDeviceInDepartment1(int Idpr, int Iddv, String Notes)
        {
            bool result = true;
            //Check xem thiết bị có phải là thiết bị con nằm trong
            var Check = Ql.DeviceDevices.Where(x => x.DeviceCodeChildren == Iddv & x.IsDeleted == false & x.TypeComponant == 1).Select(x => x.DeviceCodeChildren).Count();

            if (Check > 0)
            {
                result = false;
            }
            else
            {
                int checkdele = Ql.AddDeviceOfProject(Idpr, Iddv, Notes);
                if (checkdele > 0)
                {
                    result = true;
                }
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }