Esempio n. 1
0
        protected void SaveProperties(object sender, DirectEventArgs e)
        {
            string AssetId = currentAsset.Text;
            string catId   = currentCat.Text;

            string[]      values  = e.ExtraParams["values"].Split(',');
            List <string> sentIds = new List <string>();

            for (int i = 0; i < values.Length; i++)
            {
                sentIds.Add(values[i].Split(':')[0].Replace("\"", "").Replace("{", ""));
                PostRequest <AssetPropertyValue> req = new PostRequest <AssetPropertyValue>();
                req.entity = new AssetPropertyValue()
                {
                    categoryId = catId, assetId = AssetId, propertyId = values[i].Split(':')[0].Replace("\"", "").Replace("{", ""), value = values[i].Split(':')[1].Replace("\"", "").Replace("}", "")
                };
                PostResponse <AssetPropertyValue> resp = _assetManagementService.ChildAddOrUpdate <AssetPropertyValue>(req);
                if (!resp.Success)
                {
                    Common.errorMessage(resp);
                }
            }
            AssetManagementCategoryPropertyListRequest propReq = new AssetManagementCategoryPropertyListRequest();

            propReq.categoryId = catId;
            propReq.categoryId = catId;
            ListResponse <AssetManagementCategoryProperty> propResp = _assetManagementService.ChildGetAll <AssetManagementCategoryProperty>(propReq);

            if (!propResp.Success)
            {
                Common.errorMessage(propResp);
            }
            propResp.Items.ForEach(x =>
            {
                if (x.mask == 5 && !sentIds.Contains(x.propertyId))
                {
                    PostRequest <AssetPropertyValue> req = new PostRequest <AssetPropertyValue>();
                    req.entity = new AssetPropertyValue()
                    {
                        categoryId = catId, assetId = AssetId, propertyId = x.propertyId, value = "false"
                    };
                    PostResponse <AssetPropertyValue> resp = _assetManagementService.ChildAddOrUpdate <AssetPropertyValue>(req);
                    if (!resp.Success)
                    {
                        Common.errorMessage(resp);
                    }
                }
            });

            Notification.Show(new NotificationConfig
            {
                Title = Resources.Common.Notification,
                Icon  = Icon.Information,
                Html  = Resources.Common.RecordSavingSucc
            });
        }
        protected void SaveNewRecord(object sender, DirectEventArgs e)
        {
            try
            {
                //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 disposedDate = e.ExtraParams["disposedDate"];

                string obj             = e.ExtraParams["values"];
                AssetManagementAsset b = JsonConvert.DeserializeObject <AssetManagementAsset>(obj);
                if (!string.IsNullOrEmpty(disposedDate))
                {
                    b.depreciationDate = DateTime.Parse(disposedDate);
                }
                b.recordId   = id;
                b.supplierId = supplierId.GetSupplierId() == "0"?null: supplierId.GetSupplierId();


                // 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 <AssetManagementAsset> request = new PostRequest <AssetManagementAsset>();
                        request.entity = b;
                        PostResponse <AssetManagementAsset> r = _assetManagementService.ChildAddOrUpdate <AssetManagementAsset>(request);
                        b.recordId = r.recordId;

                        //check if the insert failed
                        if (!r.Success)//it maybe be another condition
                        {
                            //Show an error saving...

                            Common.errorMessage(r);
                            return;
                        }
                        else
                        {
                            //Add this record to the store


                            //Display successful notification
                            Notification.Show(new NotificationConfig
                            {
                                Title = Resources.Common.Notification,
                                Icon  = Icon.Information,
                                Html  = Resources.Common.RecordSavingSucc
                            });


                            Store1.Reload();
                            Panel8.Disabled   = false;
                            currentAsset.Text = r.recordId;
                            X.Call("setUrlAfterNewAsset");
                        }
                    }
                    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
                    {
                        int index = Convert.ToInt32(id);//getting the id of the record
                        PostRequest <AssetManagementAsset> request = new PostRequest <AssetManagementAsset>();
                        request.entity = b;
                        PostResponse <AssetManagementAsset> r = _assetManagementService.ChildAddOrUpdate <AssetManagementAsset>(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;
                            X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                            return;
                        }
                        else
                        {
                            ModelProxy record = this.Store1.GetById(index);
                            BasicInfoTab.UpdateRecord(record);
                            record.Commit();
                            Notification.Show(new NotificationConfig
                            {
                                Title = Resources.Common.Notification,
                                Icon  = Icon.Information,
                                Html  = Resources.Common.RecordUpdatedSucc
                            });
                            this.EditRecordWindow.Close();
                            Store1.Reload();
                        }
                    }
                    catch (Exception ex)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                    }
                }
            }
            catch (Exception exp)
            {
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
            }
        }
Esempio n. 3
0
        protected void SaveNewRecord(object sender, DirectEventArgs e)
        {
            try
            {
                //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"];
                AssetManagementLoan b = JsonConvert.DeserializeObject <AssetManagementLoan>(obj);
                if (!string.IsNullOrEmpty(apId.GetApprovalStatus()))
                {
                    b.status = Convert.ToInt16(apId.GetApprovalStatus());
                }
                b.assetId = assetId.GetAssetId();



                // 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 <AssetManagementLoan> request = new PostRequest <AssetManagementLoan>();
                        request.entity = b;
                        PostResponse <AssetManagementLoan> r = _assetManagementService.ChildAddOrUpdate <AssetManagementLoan>(request);
                        b.recordId = r.recordId;

                        //check if the insert failed
                        if (!r.Success)//it maybe be another condition
                        {
                            //Show an error saving...

                            Common.errorMessage(r);
                            return;
                        }
                        else
                        {
                            //Add this record to the store


                            //Display successful notification
                            Notification.Show(new NotificationConfig
                            {
                                Title = Resources.Common.Notification,
                                Icon  = Icon.Information,
                                Html  = Resources.Common.RecordSavingSucc
                            });

                            this.EditRecordWindow.Close();
                            Store1.Reload();
                        }
                    }
                    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
                    {
                        int index = Convert.ToInt32(id);//getting the id of the record
                        PostRequest <AssetManagementLoan> request = new PostRequest <AssetManagementLoan>();
                        request.entity          = b;
                        request.entity.recordId = index.ToString();
                        PostResponse <AssetManagementLoan> r = _assetManagementService.ChildAddOrUpdate <AssetManagementLoan>(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;
                            X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                            return;
                        }
                        else
                        {
                            Store1.Reload();
                            Notification.Show(new NotificationConfig
                            {
                                Title = Resources.Common.Notification,
                                Icon  = Icon.Information,
                                Html  = Resources.Common.RecordUpdatedSucc
                            });
                            this.EditRecordWindow.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                    }
                }
            }
            catch (Exception exp)
            {
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
            }
        }
        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 obj = e.ExtraParams["values"];
            AssetManagementOnBoarding b = JsonConvert.DeserializeObject <AssetManagementOnBoarding>(obj);

            if (string.IsNullOrEmpty(CurrentPositionId.Text))
            {
                return;
            }
            //if (tsId.SelectedItem != null)
            //    b.tsName = tsId.SelectedItem.Text;
            b.categoryId = AssetCategoryControl.GetCategoryId();
            b.positionId = CurrentPositionId.Text;
            // Define the object to add or edit as null

            if (string.IsNullOrEmpty(b.categoryId))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <AssetManagementOnBoarding> request = new PostRequest <AssetManagementOnBoarding>();
                    request.entity = b;
                    PostResponse <AssetManagementOnBoarding> r = _branchService.ChildAddOrUpdate <AssetManagementOnBoarding>(request);


                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        //Add this record to the store
                        this.OnboardingStore.Reload();

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditOnBoardingRecordWindow.Close();
                    }
                }
                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 <AssetManagementOnBoarding> request = new PostRequest <AssetManagementOnBoarding>();
                    request.entity = b;
                    PostResponse <AssetManagementOnBoarding> r = _assetManagementService.ChildAddOrUpdate <AssetManagementOnBoarding>(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;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                        return;
                    }
                    else
                    {
                        OnboardingStore.Reload();
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordUpdatedSucc
                        });
                        this.EditOnBoardingRecordWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
        }
Esempio n. 5
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();
                }
            }
        }