Example #1
0
        public JsonResult Delete(int id)
        {
            byte status = 0;
            var  ck     = new UnitDao().CheckIsUsed(id);

            if (!ck)
            {
                var res = new UnitDao().Delete(id);
                if (res)
                {
                    status = 1;//xóa
                }
                else
                {
                    status = 0;//không xóa được
                }
            }
            else
            {
                status = 2;//đang được sử dụng
            }
            return(Json(new
            {
                status = status
            }, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public JsonResult LoadData(int type, string keyword, int pageIndex, int pageSize)
        {
            string str   = NonUnicode.RemoveUnicode(keyword).ToLower();
            var    model = new UnitDao().ListAll();

            switch (type)
            {
            case 0: model = model.Where(x => NonUnicode.RemoveUnicode(x.Name).ToLower().Contains(str) || x.ID.ToString().Contains(keyword)); break;

            case 1: model = model.Where(x => NonUnicode.RemoveUnicode(x.Name).ToLower().Contains(str)); break;
            }

            int totalRow = model.Count();

            model = model.OrderByDescending(x => x.ID)
                    .Skip((pageIndex - 1) * pageSize)
                    .Take(pageSize);
            int totalRowCurent = model.Count();

            return(Json(new
            {
                data = model,
                total = totalRow,
                totalCurent = totalRowCurent,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        public void SetDropdownList(int?selectedUnit = null, long?selectedProduct = null)
        {
            //set product category
            var model = new ProductCategoryDao().ListAll();
            List <ProductCategory> list = new List <ProductCategory>();

            model = model.OrderBy(x => x.ID);
            foreach (var item in model)
            {
                if (item.ParentID == null)
                {
                    list.Add(item);
                    var child = model.Where(x => x.ParentID == item.ID);
                    foreach (var subitem in child)
                    {
                        subitem.Name = "-- " + subitem.Name;
                        list.Add(subitem);
                    }
                }
            }
            //Kết thúc sắp xếp.
            ViewBag.ProductCategoryID = new SelectList(list, "ID", "Name", selectedProduct);

            //set unit
            var unit = new UnitDao();

            ViewBag.UnitID = new SelectList(unit.ListAll(), "ID", "Name", selectedUnit);
        }
Example #4
0
 public string GetNewUnitCode()
 {
     using (PersistentManager persistentManager = new PersistentManager())
     {
         UnitDao dao = new UnitDao();
         return(dao.GetNewUnitCode());
     }
 }
Example #5
0
 public DataSet QueryUnit(int pageIndex, int pageSize, string filter, string OrderByFields)
 {
     using (PersistentManager persistentManager = new PersistentManager())
     {
         UnitDao dao = new UnitDao();
         return(dao.Query(strTableView, strPrimaryKey, strQueryFields, pageIndex, pageSize, OrderByFields, filter, strTableView));
     }
 }
Example #6
0
 public int GetRowCount(string filter)
 {
     using (PersistentManager persistentManager = new PersistentManager())
     {
         UnitDao dao = new UnitDao();
         return(dao.GetRowCount(strTableView, filter));
     }
 }
Example #7
0
        public JsonResult GetDetail(int id)
        {
            var model = new UnitDao().GetByID(id);

            return(Json(new
            {
                data = model,
                status = true
            }, JsonRequestBehavior.AllowGet));
        }
Example #8
0
        public bool Delete(DataSet dataSet)
        {
            bool flag = false;

            using (PersistentManager persistentManager = new PersistentManager())
            {
                UnitDao dao = new UnitDao();
                dao.DeleteEntity(dataSet);
                flag = true;
            }
            return(flag);
        }
Example #9
0
        public JsonResult SaveData(string strUnit)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            Unit   unit    = serializer.Deserialize <Unit>(strUnit);
            bool   status  = false;
            string action  = string.Empty;
            string message = string.Empty;

            //add new unit if id = 0
            if (unit.ID == 0)
            {
                var model = new UnitDao();
                try
                {
                    model.Insert(unit);
                    status = true;
                    action = "insert";
                }
                catch (Exception ex)
                {
                    status  = false;
                    message = ex.Message;
                }
            }
            else
            {
                //update existing DB
                //save db
                try
                {
                    var model = new UnitDao().Update(unit);
                    status = true;
                    action = "update";
                }
                catch (Exception ex)
                {
                    status  = false;
                    message = ex.Message;
                }
            }

            return(Json(new
            {
                status = status,
                message = message,
                action = action
            }));
        }
Example #10
0
    public bool AddUnit(UnitDao unit, Building building)
    {
        if (building.constructed && this.CheckCosts(unit.cost) && this.population < this.populationLimit)
        {
            this.population++;
            this.DiscountCosts(unit.cost);

            if (building.trainUnitOrder == null)
            {
                building.trainUnitOrder = new TrainUnitOrder(this, building);
                this.orders.Add(building.trainUnitOrder);
            }

            building.trainUnitOrder.AddUnit(unit.Instantiate());

            return(true);
        }

        return(false);
    }
Example #11
0
        private void Initdata(string p_Type, int p_idsupplier)
        {
            switch (p_Type)
            {
            case l_Str_Group:
                lookUpGroup.DataSource = GroupItemDao.GetList(_ConfigItem);
                break;

            case l_Str_Unit:
                lookUpUnit.DataSource = UnitDao.GetList(_ConfigItem);
                break;

            case l_Str_Item:
                grdItem.DataSource = ItemDao.GetList(_ConfigItem);
                break;

            default:
                break;
            }
        }
Example #12
0
        public bool Insert()
        {
            bool flag = false;

            using (PersistentManager persistentManager = new PersistentManager())
            {
                UnitDao dao = new UnitDao();

                string sql = string.Format("Insert into WMS_UNIT (UNITCODE,UNITNAME,ISDEFAULT,ISACTIVE,STANDARDRATE,MEMO) values('{0}','{1}','{2}','{3}','{4}','{5}')"
                                           , this.UNITCODE,
                                           this.UNITNAME,
                                           this.ISDEFAULT,
                                           this.ISACTIVE,
                                           this.STANDARDRATE,
                                           this.MEMO);

                dao.SetData(sql);
                flag = true;
            }
            return(flag);
        }
Example #13
0
        public bool Update()
        {
            bool flag = false;

            using (PersistentManager persistentManager = new PersistentManager())
            {
                UnitDao dao = new UnitDao();

                string sql = string.Format("update WMS_UNIT set UNITCODE='{1}',UNITNAME='{2}',ISDEFAULT='{3}',ISACTIVE='{4}',STANDARDRATE='{5}',MEMO='{6}'  where ID='{0}'"
                                           , this.ID,
                                           this.UNITCODE,
                                           this.UNITNAME,
                                           this.ISDEFAULT,
                                           this.ISACTIVE,
                                           this.STANDARDRATE,
                                           this.MEMO);

                dao.SetData(sql);
                flag = true;
            }
            return(flag);
        }
Example #14
0
 public UnitBo()
 {
     _unitDao = new UnitDao();
 }
 public UnitManagerImpl(UnitManager unitManager)
 {
     this.unitManager = unitManager;
     dao = UnitDao.getInstance();
 }
 public UnitManagerImpl(AddUnit addUnit)
 {
     this.addUnit = addUnit;
     dao          = UnitDao.getInstance();
 }
 public UnitManagerImpl()
 {
     dao = UnitDao.getInstance();
 }