Ejemplo n.º 1
0
        public ActionResult ItemUpdate(int id)
        {
            ModelState.Clear();
            CategoryBL         category   = new CategoryBL();
            MeasureBL          measure    = new MeasureBL();
            ItemBL             bl         = new ItemBL();
            List <CategoryDTO> categorydt = new List <CategoryDTO>();
            List <MeasureDTO>  measuredt  = new List <MeasureDTO>();
            ItemsDTO           dto        = new ItemsDTO();

            bl.SearchID(id, out dto);
            category.SearchList(out categorydt);
            measure.SearchList(out measuredt);
            ViewBag.CategoryList         = categorydt;
            ViewBag.MeasureList          = measuredt;
            ViewData["tool"]             = dto.manufacture_tool.ToString().ToLower();
            ViewData["make"]             = dto.manufacture_make.ToString().ToLower();
            ViewData["dangerous"]        = dto.dangerous.ToString().ToLower();
            ViewData["good"]             = dto.manufacture_finished_goods.ToString().ToLower();
            ViewData["category"]         = dto.category_id;
            ViewData["inventorymeasure"] = dto.inventory_measure_id;
            ViewData["sizemeasure"]      = dto.manufacture_size_measure_id;
            ViewData["weightmeasure"]    = dto.manufacture_weight_measure_id;
            return(View(dto));
        }
Ejemplo n.º 2
0
        public ActionResult MeasureDelete(int id)
        {
            MeasureBL         bl         = new MeasureBL();
            List <MeasureDTO> dtResult   = new List <MeasureDTO>();
            MeasureDTO        measureDTO = new MeasureDTO();

            measureDTO.id = id;
            bl.SearchData(measureDTO, out dtResult);

            if (dtResult.Count() <= 0)
            {
                Response.StatusCode = 404;
                return(null);
            }
            else
            {
                int result = bl.DeleteData(id);
                if (result == 1)
                {
                    TempData["Error"]   = "Delete fail";
                    TempData["Success"] = "";
                }
                else
                {
                    TempData["Error"]   = "";
                    TempData["Success"] = "Delete sucessfully";
                }
            }
            return(RedirectToAction("MeasureSearch"));
        }
Ejemplo n.º 3
0
        public ActionResult MeasureSearch(string Page, MeasureSearch model)
        {
            MeasureDTO dto = new MeasureDTO();

            ModelState.Clear();
            if (!string.IsNullOrEmpty(model.SearchButton) || Page.IsNotNullOrEmpty())
            {
                if (Page != null)
                {
                    dto.page   = int.Parse(Page);
                    model.Page = dto.page;
                }
                MeasureBL         bl     = new MeasureBL();
                List <MeasureDTO> result = new List <MeasureDTO>();
                if (model.MeasureCode.IsNotNullOrEmpty())
                {
                    dto.code = model.MeasureCode;
                }
                if (model.MeasureName.IsNotNullOrEmpty())
                {
                    dto.name = model.MeasureName;
                }
                bl.SearchData(dto, out result);
                model.PageCount     = bl.PageCount(dto);
                model.SearchResults = new StaticPagedList <MeasureDTO>(result, model.Page, 20, model.PageCount);
            }


            return(View(model));
        }
Ejemplo n.º 4
0
        public ActionResult UpdateMeasure(MeasureDTO measure)
        {
            MeasureBL mesureBL = new MeasureBL();

            try
            {
                if (ModelState.IsValid)
                {
                    measure.created_by = 123;
                    measure.updated_by = 123;
                    mesureBL.UpdateData(measure);
                    return(RedirectToAction("Measure"));
                }
            }
            catch (DataException dex)
            {
                ModelState.AddModelError("", "Unable to perform action. Please contact us.");
                return(RedirectToAction("SubmissionFailed", measure));
            }
            measure = new MeasureDTO()
            {
                id = measure.id
            };
            return(View("Update"));
        }
Ejemplo n.º 5
0
 public ActionResult MeasureAdd(MeasureDTO measure)
 {
     if (ModelState.IsValid)
     {
         MeasureBL bl = new MeasureBL();
         if (bl.CheckCode(measure) > 0)
         {
             TempData["Error"]   = "Code already exsit";
             TempData["Success"] = "";
         }
         else
         {
             measure.created_by = 0;
             measure.updated_by = 0;
             int result = bl.InsertData(measure);
             if (result == 1)
             {
                 TempData["Error"]   = "Insert fail";
                 TempData["Success"] = "";
             }
             else
             {
                 TempData["Error"]   = "";
                 TempData["Success"] = "Insert successfully";
                 return(RedirectToAction("MeasureAdd"));
             }
         }
     }
     return(View(measure));
 }
Ejemplo n.º 6
0
        // GET: Measure
        public ActionResult MeasureSearch(MeasureDTO measure)
        {
            MeasureBL   bl    = new MeasureBL();
            MeasureList model = new MeasureList();
            DataTable   dt;

            bl.SearchData(measure, out dt);
            model.Measures = CommonMethod.DataTableToList <MeasureDTO>(dt);
            return(View(model));
        }
Ejemplo n.º 7
0
        public ActionResult MeasureUpdate(int id)
        {
            ModelState.Clear();
            MeasureBL         bl       = new MeasureBL();
            List <MeasureDTO> dtResult = new List <MeasureDTO>();
            MeasureDTO        measure  = new MeasureDTO();

            measure.id = id;
            bl.SearchData(measure, out dtResult);
            measure = dtResult[0];
            return(View(measure));
        }
Ejemplo n.º 8
0
        public ActionResult ItemAdd(ItemsDTO model)
        {
            CategoryBL         category   = new CategoryBL();
            MeasureBL          measure    = new MeasureBL();
            List <CategoryDTO> categorydt = new List <CategoryDTO>();
            List <MeasureDTO>  measuredt  = new List <MeasureDTO>();

            category.SearchList(out categorydt);
            measure.SearchList(out measuredt);
            ViewBag.CategoryList = categorydt;
            ViewBag.MeasureList  = measuredt;
            ItemBL bl = new ItemBL();

            if (ModelState.IsValid)
            {
                int count = bl.CheckCode(model);
                if (count > 0)
                {
                    TempData["Error"]   = "Code already exists";
                    TempData["Success"] = "";
                    return(View(model));
                }
                else
                {
                    if (model.discontinued_datetime.IsNotNullOrEmpty() == true)
                    {
                        string datetime = DateTime.Parse(model.discontinued_datetime).ToString("yyyy-MM-dd HH:mm:ss");
                        model.discontinued_datetime = datetime;
                    }
                    model.created_by = 0;
                    model.updated_by = 0;
                    int equal = bl.InsertData(model);
                    if (equal == 1)
                    {
                        TempData["Error"]   = "Insert badly";
                        TempData["Success"] = "";
                        return(View(model));
                    }
                    else
                    {
                        TempData["Error"]   = "";
                        TempData["Success"] = "Insert successfully";
                        return(RedirectToAction("ItemAdd"));
                    }
                }
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 9
0
        public ActionResult ItemAdd()
        {
            ModelState.Clear();
            CategoryBL         category   = new CategoryBL();
            MeasureBL          measure    = new MeasureBL();
            List <CategoryDTO> categorydt = new List <CategoryDTO>();
            List <MeasureDTO>  measuredt  = new List <MeasureDTO>();

            category.SearchList(out categorydt);
            measure.SearchList(out measuredt);
            ViewBag.CategoryList = categorydt;
            ViewBag.MeasureList  = measuredt;
            return(View());
        }
Ejemplo n.º 10
0
        public ActionResult DeleteMeasure(string id)
        {
            try
            {
                MeasureBL categoryBL = new MeasureBL();
                categoryBL.DeleteData(id.ParseInt32());

                return(RedirectToAction("Measure"));
            }
            catch (DataException dex)
            {
                ModelState.AddModelError("", "Unable to perform action. Please contact us.");
                return(RedirectToAction("SubmissionFailed"));
            }
        }
Ejemplo n.º 11
0
        public ActionResult ItemAdd()
        {
            CategoryBL catelogy = new CategoryBL();
            MeasureBL  measure  = new MeasureBL();
            DataTable  catelogydt;
            DataTable  measuredt;

            catelogy.SearchList(out catelogydt);
            measure.SearchList(out measuredt);
            ViewBag.CatelogyList = CommonMethod.DataTableToList <CategoryDTO>(catelogydt);
            ViewBag.MeasureList  = CommonMethod.DataTableToList <MeasureDTO>(measuredt);
            ItemsDTO model = new ItemsDTO();

            return(View(model));
        }
Ejemplo n.º 12
0
        private Item LoadItemAddForm(Item item)
        {
            if (item == null)
            {
                item = new Item();
            }
            SelectList listCategory = new SelectList(new CategoryBL().SelectDropdownData(), "id", "name");

            ViewBag.ListCategory = listCategory;


            MeasureBL  measureBL   = new MeasureBL();
            SelectList listMeasure = new SelectList(new MeasureBL().SelectDropdownData(), "id", "name");

            ViewBag.listMeasure = listMeasure;


            return(item);
        }
Ejemplo n.º 13
0
        public ActionResult Update(string id)
        {
            MeasureDTO dto = new MeasureDTO();

            if (id.IsNumber())
            {
                List <MeasureDTO> list;
                MeasureBL         bl = new MeasureBL();
                dto.id = int.Parse(id);
                bl.SearchData(dto, out list);
                if (list.Count > 0)
                {
                    dto = list[0];
                }
                else
                {
                    TempData["Success"] = "0 row(s) has found.";
                    return(RedirectToAction("Measure"));
                }
            }
            return(View(dto));
        }
Ejemplo n.º 14
0
        public ActionResult MeasureUpdate(MeasureDTO measure)
        {
            if (ModelState.IsValid)
            {
                MeasureBL bl = new MeasureBL();
                measure.created_by = 0;
                measure.updated_by = 0;
                int result = bl.UpdateData(measure);
                if (result == 1)
                {
                    TempData["Error"]   = "Update fail";
                    TempData["Success"] = "";
                }
                else
                {
                    TempData["Error"]   = "";
                    TempData["Success"] = "Update successfully";
                }
                return(RedirectToAction("MeasureSearch"));
            }

            return(View(measure));
        }
Ejemplo n.º 15
0
        public ActionResult AddMeasure(MeasureDTO mesure)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    mesure.created_by = 113;
                    MeasureBL categorybl = new MeasureBL();
                    if (mesure.code.Contains(" "))
                    {
                        TempData["Error"] = "Don't input Space in Measure Code";
                        return(View("Add"));
                    }
                    int count = categorybl.CountData(new MeasureDTO()
                    {
                        code = mesure.code
                    });
                    if (count == 0)
                    {
                        categorybl.InsertData(mesure);
                    }
                    else
                    {
                        TempData["Error"] = "The Code already is exister!";
                        return(View("Add"));
                    }
                    return(RedirectToAction("Measure"));
                }
            }
            catch (DataException dex)
            {
                ModelState.AddModelError("", "Unable to perform action. Please contact us.");
                return(RedirectToAction("SubmissionFailed", mesure));
            }

            return(View("Add"));
        }
Ejemplo n.º 16
0
        public ActionResult Measure(string page, ResearchMeasureModel model)
        {
            ModelState.Clear();
            MeasureBL bl = new MeasureBL();

            if (model == null)
            {
                model             = new ResearchMeasureModel();
                model.measure     = new MeasureDTO();
                model.listMeasure = new List <MeasureDTO>();
            }
            else
            {
                if (model.measure == null)
                {
                    model.measure = new MeasureDTO();
                }
                if (model.listMeasure == null)
                {
                    model.listMeasure = new List <MeasureDTO>();
                }
            }
            if (page == null)
            {
                page = "1";
            }
            model.page_count = bl.CountData(model.measure);
            List <MeasureDTO> list;

            model.measure.page = int.Parse(page);
            bl.SearchData(model.measure, out list);
            model.listMeasure = list;

            TempData["Success"] = model.page_count + " row(s) has found.";

            return(View(model));
        }
Ejemplo n.º 17
0
        public ActionResult MeasureDeleteMulti(FormCollection frm)
        {
            string[]  ids = frm["MeasureID"].Split(new char[] { ',' });
            MeasureBL bl  = new MeasureBL();

            foreach (string item in ids)
            {
                MeasureDTO measureDTO = new MeasureDTO();
                int        id         = item.ParseInt32();
                measureDTO.id = id;
                List <MeasureDTO> dtos = new List <MeasureDTO>();
                int returncode         = bl.SearchData(measureDTO, out dtos);
                if (returncode == 1)
                {
                    Response.StatusCode = 404;
                    return(null);
                }
                else
                {
                    bl.DeleteData(id);
                }
            }
            return(RedirectToAction("MeasureSearch"));
        }