Esempio n. 1
0
        public ActionResult DeleteSupplier(long id)
        {
            var gVal = new GenericValidator();

            try
            {
                if (id < 1)
                {
                    gVal.Code  = -1;
                    gVal.Error = message_Feedback.Invalid_Selection;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                var k = new SupplierServices().DeleteSupplier(id);
                if (k)
                {
                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Delete_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Delete_Failure;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = 5;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
 public SupplierController(SupplierServices supplierServices, BasicInfoServices basicInfoServices
                           , ILogger <SupplierController> logger)
     : base(logger)
 {
     _supplierServices  = supplierServices;
     _basicInfoServices = basicInfoServices;
 }
Esempio n. 3
0
        public ActionResult EditSupplier(SupplierObject supplier)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateSupplier(supplier);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    if (Session["_supplier"] == null)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }

                    var oldSupplier = Session["_supplier"] as SupplierObject;

                    if (oldSupplier == null || oldSupplier.SupplierId < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = message_Feedback.Session_Time_Out;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    oldSupplier.CompanyName = supplier.CompanyName.Trim();
                    if (!string.IsNullOrEmpty(oldSupplier.Note))
                    {
                        oldSupplier.Note = supplier.Note.Trim();
                    }
                    var k = new SupplierServices().UpdateSupplier(oldSupplier);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Update_Failure;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code  = 5;
                    gVal.Error = message_Feedback.Insertion_Success;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -5;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 4
0
        private void LoadDataSource()
        {
            var services      = new SupplierServices(new SupplierRepository(), new ModelDataAnnotationCheck());
            var listSuppliers = services.GetAll().ToList();

            if (listSuppliers != null && listSuppliers.Count > 0)
            {
                comboBox.Items.AddRange(listSuppliers.ToArray());
                comboBox.DisplayMember = "nama";
                comboBox.SelectedIndex = 0;
            }
        }
        public void LoadSupplier(int limit, int offset)
        {
            var data = SupplierServices.GetListWithPagePaging(ContentSearch, offset, limit);

            if (data != null)
            {
                Suppliers = new ObservableCollection <Supplier>(data);
            }
            else
            {
                Suppliers?.Clear();
            }
        }
Esempio n. 6
0
        public HttpResponseMessage ListSupplier(HttpRequestMessage request, SupplierListInModel paramIn)
        {
            if (ModelState.IsValid)
            {
                ISupplierServices _supplierService = new SupplierServices();
                var suppliers_rslt = _supplierService.GetSupplierList(paramIn);
                if (suppliers_rslt != null)
                {
                    return(request.CreateResponse(HttpStatusCode.OK, suppliers_rslt));
                }
                return(Request.CreateResponse(HttpStatusCode.NotFound, "No data"));
            }

            return(Request.CreateResponse(HttpStatusCode.NotAcceptable, "Model Binding Error"));
        }
Esempio n. 7
0
        public ActionResult GetSupplierObjects(JQueryDataTableParamModel param)
        {
            try
            {
                IEnumerable <SupplierObject> filteredSupplierObjects;
                var countG = new SupplierServices().GetObjectCount();

                var pagedSupplierObjects = GetSuppliers(param.iDisplayLength, param.iDisplayStart);

                if (!string.IsNullOrEmpty(param.sSearch))
                {
                    filteredSupplierObjects = new SupplierServices().Search(param.sSearch);
                }
                else
                {
                    filteredSupplierObjects = pagedSupplierObjects;
                }

                if (!filteredSupplierObjects.Any())
                {
                    return(Json(new List <SupplierObject>(), JsonRequestBehavior.AllowGet));
                }

                var sortColumnIndex = Convert.ToInt32(Request["iSortCol_0"]);
                Func <SupplierObject, string> orderingFunction = (c => sortColumnIndex == 1 ? c.CompanyName :  c.TIN);

                var sortDirection = Request["sSortDir_0"]; // asc or desc
                filteredSupplierObjects = sortDirection == "asc" ? filteredSupplierObjects.OrderBy(orderingFunction) : filteredSupplierObjects.OrderByDescending(orderingFunction);

                var displayedUserProfilenels = filteredSupplierObjects;

                var result = from c in displayedUserProfilenels
                             select new[] { Convert.ToString(c.SupplierId), c.CompanyName, c.TIN, c.DateRegistered };
                return(Json(new
                {
                    param.sEcho,
                    iTotalRecords = countG,
                    iTotalDisplayRecords = filteredSupplierObjects.Count(),
                    aaData = result
                },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                ErrorLogger.LogError(ex.StackTrace, ex.Source, ex.Message);
                return(Json(new List <SupplierObject>(), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 8
0
        public void Save()
        {
            if (_backuptSupplier == null)
            {
                CurrentSupplier.UserCreated = "Admin";
                CurrentSupplier.CreatedTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                SupplierServices.Insert(CurrentSupplier);
            }
            else
            {
                CurrentSupplier.UserModified = "Admin";
                CurrentSupplier.ModifiedTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
                SupplierServices.Update(CurrentSupplier);
            }

            (App.Current.MainWindow.DataContext as MainViewModel).SupplierViewModel.SearchSupplier();
            (App.Current.MainWindow.DataContext as MainViewModel).CloseDialog();
        }
Esempio n. 9
0
        public ActionResult GetSupplier(long id)
        {
            try
            {
                if (id < 1)
                {
                    return(Json(new SupplierObject(), JsonRequestBehavior.AllowGet));
                }

                var supplier = new SupplierServices().GetSupplier(id);
                if (id < 1)
                {
                    return(Json(new SupplierObject(), JsonRequestBehavior.AllowGet));
                }
                Session["_supplier"] = supplier;
                return(Json(supplier, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                return(Json(new SupplierObject(), JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 10
0
        public ActionResult AddSupplier(SupplierObject supplier)
        {
            var gVal = new GenericValidator();

            try
            {
                if (ModelState.IsValid)
                {
                    var valStatus = ValidateSupplier(supplier);
                    if (valStatus.Code < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = valStatus.Error;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    supplier.DateJoined = DateTime.Now;
                    var k = new SupplierServices().AddSupplier(supplier);
                    if (k < 1)
                    {
                        gVal.Code  = -1;
                        gVal.Error = k == -3 ? message_Feedback.Item_Duplicate : message_Feedback.Insertion_Failure;
                        return(Json(gVal, JsonRequestBehavior.AllowGet));
                    }
                    gVal.Code = 5;
                    return(Json(gVal, JsonRequestBehavior.AllowGet));
                }

                gVal.Code  = -1;
                gVal.Error = message_Feedback.Model_State_Error;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                gVal.Code  = -1;
                gVal.Error = message_Feedback.Process_Failed;
                return(Json(gVal, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 11
0
 public void DeleteSupplier(Supplier supplier)
 {
     SupplierServices.Delete(supplier);
     SearchSupplier();
 }
Esempio n. 12
0
 public int GetCountUnit() => SupplierServices.GetTotalCountWithName(ContentSearch);
 public SupplierServiceFixture()
 {
     Model    = new SupplierModel();
     Services = new SupplierServices(null, new ModelDataAnnotationCheck());
 }
 public ImsController(SupplierServices supplierServices, CustomerServices customerServices)
 {
     _supplierServices = supplierServices;
     _customerServices = customerServices;
 }
        private void ShouldReturnSuccessForInsert()
        {
            var operationSecceded = false;
            var dataAccessJsonStr = string.Empty;
            var formattedJsonStr  = string.Empty;

            try
            {
                var supplierModel = new SupplierServices(new SupplierRepository(), _modelDAC).GetById(1);

                for (int i = 1; i <= 5; i++)
                {
                    var listPembelianDetails = new List <PembelianDetailModel>
                    {
                        new PembelianDetailModel
                        {
                            barang_id = 1,
                            qty       = 5,
                            hpp       = 10000
                        },
                        new PembelianDetailModel
                        {
                            barang_id = 2,
                            qty       = 10,
                            hpp       = 20000
                        },
                        new PembelianDetailModel
                        {
                            barang_id = 3,
                            qty       = 15,
                            hpp       = 30000
                        }
                    };

                    var pembelianModel = new PembelianModel
                    {
                        Supplier         = supplierModel,
                        tanggal          = DateTime.Now,
                        PembelianDetails = listPembelianDetails
                    };

                    _services.Insert(pembelianModel);
                }

                operationSecceded = true;
            }
            catch (DataAccessException ex)
            {
                operationSecceded = ex.DataAccessStatusInfo.OperationSucceeded;
                dataAccessJsonStr = JsonConvert.SerializeObject(ex.DataAccessStatusInfo);
                formattedJsonStr  = JToken.Parse(dataAccessJsonStr).ToString();
            }

            try
            {
                Assert.True(operationSecceded);
                _testOutputHelper.WriteLine("Data berhasil ditambahkan.");
            }
            finally
            {
                _testOutputHelper.WriteLine(formattedJsonStr);
            }
        }