Ejemplo n.º 1
0
        protected void grdDataWarehouseUnit_CustomCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomCallbackEventArgs e)
        {
            string[] args = e.Parameters.Split('|');
            switch (args[0])
            {
            case "delete":
                try
                {
                    if (args.Length > 1)
                    {
                        Guid          recordId            = Guid.Parse(args[1]);
                        InventoryUnit editManufacturerOrg =
                            session.GetObjectByKey <InventoryUnit>(recordId);
                        //editManufacturerOrg.Code = txtCode.Text;
                        editManufacturerOrg.RowStatus = Utility.Constant.ROWSTATUS_DELETED;
                        editManufacturerOrg.Save();
                        this.grdDataWarehouseUnit.JSProperties.Add("cpEvent", "deleted");
                    }
                    else
                    {
                        throw new Exception("Must be pass id of the record");
                    }
                }
                catch (Exception)
                {
                    throw;
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        protected void popWarehouseUnitEdit_WindowCallback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            string[] args = e.Parameter.Split('|');
            switch (args[0])
            {
            case "new":
                InventoryUnit invUnit = InventoryUnit.InitNewRow(this.session);
                PrivateSession.Instance.InventoryUnitId = invUnit.InventoryUnitId;

                this.dsInventoryUnit.CriteriaParameters["InventoryUnitId"].DefaultValue = PrivateSession.Instance.InventoryUnitId.ToString();
                this.ClearForm();
                break;

            case "edit":
                this.ClearForm();

                if (args.Length > 1)
                {
                    PrivateSession.Instance.InventoryUnitId = Guid.Parse(args[1]);
                    dsInventoryUnit.CriteriaParameters["InventoryUnitId"].DefaultValue = PrivateSession.Instance.InventoryUnitId.ToString();
                    //this.txtName.Text = CurrentInventoryUnit.Name;
                    //txtCode.Text = CurrentManufacturerOrg.Code;
                }
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;
                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(this.pagWarehouseUnitEdit, true))
                    {
                        formWarehouseUnitEdit.JSProperties.Add("cpInvalid", true);
                        pagWarehouseUnitEdit.ActiveTabIndex = 0;
                        return;
                    }
                    //Logic to save data
                    if (args.Length > 1)
                    {
                        //Update mode
                        //Update general information
                        recordIdStr = args[1];
                        Guid          recordId            = Guid.Parse(recordIdStr);
                        InventoryUnit editManufacturerOrg =
                            session.GetObjectByKey <InventoryUnit>(PrivateSession.Instance.InventoryUnitId);
                        //editManufacturerOrg.Code = txtCode.Text;
                        editManufacturerOrg.Name = txtName.Text;
                        //editManufacturerOrg.RowStatus = short.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        editManufacturerOrg.Save();
                    }
                    else
                    {
                        //Insert mode
                        InventoryUnit newManufacturerOrg =
                            session.GetObjectByKey <InventoryUnit>(PrivateSession.Instance.InventoryUnitId);
                        //newManufacturerOrg.Code = txtCode.Text;
                        newManufacturerOrg.Name = txtName.Text;
                        //newManufacturerOrg.RowStatus = short.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        newManufacturerOrg.RowStatus = Utility.Constant.ROWSTATUS_ACTIVE;
                        newManufacturerOrg.Save();
                    }
                }
                catch (Exception)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    OnSaved(new WebModule.Interfaces.FormEditEventArgs()
                    {
                        isSuccess = isSuccess
                    });
                    formWarehouseUnitEdit.JSProperties.Add("cpCallbackArgs",
                                                           String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));
                    PrivateSession.ClearInstance();
                }
                break;

            default:
                break;
            }
        }