Пример #1
0
        protected void Store1_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            //GEtting the filter from the page
            string filter     = string.Empty;
            int    totalCount = 1;



            //Fetching the corresponding list

            //in this test will take a list of News
            AssetManagementAssetListRequest request = new AssetManagementAssetListRequest();
            var d = jobInfo1.GetJobInfo();

            request.branchId     = d.BranchId.HasValue ? d.BranchId.Value.ToString() : "0";
            request.departmentId = d.DepartmentId.HasValue ? d.DepartmentId.Value.ToString() : "0";
            request.positionId   = d.PositionId.HasValue ? d.PositionId.Value.ToString() : "0";
            request.categoryId   = categoryIdFilter.GetCategoryId();
            request.employeeId   = employeeFilter.GetEmployee().employeeId.ToString();
            request.supplierId   = supplierIdFilter.GetSupplierId();
            request.Filter       = "";
            ListResponse <AssetManagementAsset> resp = _assetManagementService.ChildGetAll <AssetManagementAsset>(request);

            if (!resp.Success)
            {
                Common.errorMessage(resp);
                return;
            }
            this.Store1.DataSource = resp.Items;
            e.Total = resp.count;

            this.Store1.DataBind();
        }
Пример #2
0
        private void FillAssets()
        {
            AssetManagementAssetListRequest request1 = new AssetManagementAssetListRequest();

            request1.branchId        = "0";
            request1.departmentId    = "0";
            request1.positionId      = "0";
            request1.categoryId      = "0";
            request1.employeeId      = "0";
            request1.supplierId      = "0";
            request1.PurchaseOrderId = "0";
            request1.Filter          = "";
            ListResponse <AssetManagementAsset> resp = _assetManagementService.ChildGetAll <AssetManagementAsset>(request1);

            if (!resp.Success)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                Common.errorMessage(resp);
                return;
            }

            assetIdStore.DataSource = resp.Items;
            assetIdStore.DataBind();
        }
Пример #3
0
        protected void SaveNewRecord(object sender, DirectEventArgs e)
        {
            //Getting the id to check if it is an Add or an edit as they are managed within the same form.
            string id = e.ExtraParams["id"];

            string obj = e.ExtraParams["values"];

            AssetManagementPurchaseOrder b = JsonConvert.DeserializeObject <AssetManagementPurchaseOrder>(obj);

            b.supplierId = supplierId.GetSupplierId() == "0" ? null : supplierId.GetSupplierId();
            b.categoryId = categoryId.GetCategoryId();
            b.currencyId = CurrencyControl.getCurrency() == "0"?null : CurrencyControl.getCurrency();
            b.apStatus   = apStatus.GetApprovalStatus() == "0" ? null : apStatus.GetApprovalStatus();

            b.recordId = id;
            // Define the object to add or edit as null



            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <AssetManagementPurchaseOrder> request = new PostRequest <AssetManagementPurchaseOrder>();
                    request.entity = b;
                    PostResponse <AssetManagementPurchaseOrder> resp = _assetManagementService.ChildAddOrUpdate <AssetManagementPurchaseOrder>(request);
                    b.recordId = resp.recordId;

                    //check if the insert failed
                    if (!resp.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(resp);
                        return;
                    }
                    else
                    {
                        Store1.Reload();
                        this.EditRecordWindow.Close();
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });
                        //Add this record to the store
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    PostRequest <AssetManagementPurchaseOrder> request = new PostRequest <AssetManagementPurchaseOrder>();
                    b.recordId     = id;
                    request.entity = b;
                    PostResponse <AssetManagementPurchaseOrder> r = _assetManagementService.ChildAddOrUpdate <AssetManagementPurchaseOrder>(request);                      //Step 1 Selecting the object or building up the object for update purpose

                    //Step 2 : saving to store

                    //Step 3 :  Check if request fails
                    if (!r.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        Store1.Reload();
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordUpdatedSucc
                        });

                        //    this.EditRecordWindow.Close();
                    }
                    AssetPOReception POReception = JsonConvert.DeserializeObject <AssetPOReception>(obj);
                    POReception.recordId   = id;
                    POReception.supplierId = supplierId.GetSupplierId() == "0" ? null : supplierId.GetSupplierId();
                    POReception.categoryId = categoryId.GetCategoryId();
                    POReception.currencyId = CurrencyControl.getCurrency() == "0" ? null : CurrencyControl.getCurrency();
                    POReception.apStatus   = apStatus.GetApprovalStatus() == "0" ? null : apStatus.GetApprovalStatus();
                    if (b.status == 2)
                    {
                        PostRequest <AssetPOReception> req = new PostRequest <AssetPOReception>();
                        req.entity = POReception;
                        PostResponse <AssetPOReception> resp = _assetManagementService.ChildAddOrUpdate <AssetPOReception>(req);
                        if (!resp.Success)//it maybe another check
                        {
                            Common.errorMessage(resp);
                            return;
                        }
                        AssetManagementAssetListRequest request1 = new AssetManagementAssetListRequest();

                        request1.branchId        = "0";
                        request1.departmentId    = "0";
                        request1.positionId      = "0";
                        request1.categoryId      = "0";
                        request1.employeeId      = "0";
                        request1.supplierId      = "0";
                        request1.PurchaseOrderId = b.poRef;
                        request1.Filter          = "";
                        ListResponse <AssetManagementAsset> resp1 = _assetManagementService.ChildGetAll <AssetManagementAsset>(request1);
                        if (!resp1.Success)//it maybe another check
                        {
                            Common.errorMessage(resp1);
                            return;
                        }
                        FillCondition();
                        AssetPOReceptionStore.DataSource = resp1.Items;
                        AssetPOReceptionStore.DataBind();

                        AssetPOReceptionWindow.Show();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
        }