Beispiel #1
0
 public void ClearForm()
 {
     //clear all fields inside form layout
     ASPxEdit.ClearEditorsInContainer(frmlInfoGeneral);
     this.pagWarehouseEdit.ActiveTabIndex = 0;
     this.cbRowStatus.SelectedIndex       = 0;
     //HtmlEditorDescription.Html = String.Empty;
     txtCode.IsValid = true;
     txtName.IsValid = true;
     txtName.Text    = "";
     PrivateSession.ClearInstance();
 }
Beispiel #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;
            }
        }
Beispiel #3
0
        protected void popBuyingService_WindowCallback(object source, DevExpress.Web.ASPxPopupControl.PopupWindowCallbackArgs e)
        {
            string[] args = e.Parameter.Split('|');
            switch (args[0])
            {
            case "new":
                PrivateSession.Instance.BuyingServiceId = Guid.Empty;
                this.LoadBuyingServiceBuyingServiceCategoryEntities(Guid.Empty);
                this.LoadBuyingServiceSupplierEntities(Guid.Empty);
                this.LoadBuyingServiceEquivalenceEntities(Guid.Empty);
                frmBuyingService.DataSourceID = null;
                ClearForm();
                break;

            case "edit":
                ClearForm();
                frmBuyingService.DataSourceID = dsBuyingServiceProperty.ID;
                if (args.Length > 1)
                {
                    Guid buyingServiceId = Guid.Parse(args[1]);
                    PrivateSession.Instance.BuyingServiceId = buyingServiceId;

                    this.LoadBuyingServiceBuyingServiceCategoryEntities(buyingServiceId);
                    this.LoadBuyingServiceEquivalenceEntities(buyingServiceId);
                    this.LoadBuyingServiceSupplierEntities(buyingServiceId);

                    dsBuyingServiceProperty.CriteriaParameters["BuyingServiceId"].DefaultValue = buyingServiceId.ToString();
                    dsBuyingServiceProperty.CriteriaParameters["Language"].DefaultValue        = Utility.CurrentSession.Instance.Lang;

                    //HtmlEditorDescription.Html = BuyingServiceEntity.Description;
                    //txtCode.Text = BuyingServiceEntity.Code;
                }
                break;

            case "save":
                bool   isSuccess   = true;
                string recordIdStr = null;
                try
                {
                    //Check validation
                    if (!ASPxEdit.AreEditorsValid(pagBuyingService, true))
                    {
                        popBuyingService.JSProperties.Add("cpInvalid", true);
                        pagBuyingService.ActiveTabIndex = 0;
                        return;
                    }
                    //Logic to save data
                    if (args.Length > 1)
                    {
                        //Update mode
                        recordIdStr = args[1];
                        Guid recordId = Guid.Parse(recordIdStr);
                        //BuyingServiceEntity entity = new BuyingServiceEntity();
                        //entity.BuyingServiceId = recordId;
                        //entity.Code = txtCode.Text;
                        //entity.RowStatus = char.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        //entity.Language = Utility.CurrentSession.Instance.Lang;
                        //entity.Name = txtName.Text;
                        //entity.Description = HtmlEditorDescription.Html;

                        //entity.BuyingServiceBuyingServiceCategoryEntities =
                        //    PrivateSession.Instance.BuyingServiceBuyingServiceCategoryEntities;

                        //entity.BuyingServiceSupplierEntities =
                        //    PrivateSession.Instance.BuyingServiceSupplierEntities;

                        //entity.BuyingServiceEquivalenceEntities =
                        //    PrivateSession.Instance.BuyingServiceEquivalenceEntities;

                        //buyingServiceBLO.Update(entity);
                    }
                    else
                    {
                        //Insert mode
                        //BuyingServiceEntity entity = new BuyingServiceEntity();
                        //entity.Code = txtCode.Text;
                        //entity.Language = Utility.CurrentSession.Instance.Lang;
                        //entity.RowStatus = char.Parse(cbRowStatus.SelectedItem.Value.ToString());
                        //entity.Name = txtName.Text;
                        //entity.Description = HtmlEditorDescription.Html;

                        //entity.BuyingServiceBuyingServiceCategoryEntities =
                        //    PrivateSession.Instance.BuyingServiceBuyingServiceCategoryEntities;

                        //entity.BuyingServiceSupplierEntities =
                        //    PrivateSession.Instance.BuyingServiceSupplierEntities;

                        //entity.BuyingServiceEquivalenceEntities =
                        //    PrivateSession.Instance.BuyingServiceEquivalenceEntities;

                        //buyingServiceBLO.Insert(entity);
                    }
                }
                catch (Exception)
                {
                    isSuccess = false;
                    throw;
                }
                finally
                {
                    popBuyingService.JSProperties.Add("cpCallbackArgs",
                                                      String.Format("{{ \"recordId\": \"{0}\", \"isSuccess\": {1} }}", recordIdStr, isSuccess.ToString().ToLower()));

                    PrivateSession.ClearInstance();
                }
                break;

            default:
                break;
            }
        }