protected void ASPxTreeList1_NodeUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e)
    {
        ASPxTreeList treeList = (ASPxTreeList)sender;

        for (int i = 0; i < treeList.Columns.Count; i++)
        {
            if (treeList.Columns[i] is TreeListDataColumn)
            {
                ((TreeListDataColumn)treeList.Columns[i]).EditCellTemplate = null;
                Session["column"] = null;
            }
        }
        treeList.CancelEdit();
    }
Пример #2
0
        protected void tlSitemap_StartNodeEditing(object sender, TreeListNodeEditingEventArgs e)
        {
            ASPxTreeList detailView = (ASPxTreeList)sender;

            detailView.CancelEdit();
        }
Пример #3
0
        protected void treelistACCPeriod_NodeUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            try
            {
                e.Cancel = true;
                //CHECK CODE
                ASPxTreeList         treelist = sender as ASPxTreeList;
                object               keyValue = GetMasterRowKeyValue(treelist);
                AccountingPeriodType AccPTId  = uow.GetObjectByKey <AccountingPeriodType>(Guid.Parse(keyValue.ToString()));

                if (AccPTId == null)
                {
                    throw new Exception(String.Format("AccountingPeriodType is not exist in system"));
                }
                if (!e.OldValues["Code"].Equals(e.NewValues["Code"]))
                {
                    if (bo.checkAccountingPeriod_Code(uow, e.NewValues["Code"].ToString().Trim(), AccPTId.AccountingPeriodTypeId.ToString()))
                    {
                        e.Cancel = true;
                        throw new Exception(String.Format("Lỗi Chu Kỳ đã có"));
                    }
                }
                //END CHECK CODE
                AccountingPeriod ap = uow.GetObjectByKey <AccountingPeriod>(Guid.Parse(e.Keys[0].ToString()));
                if (ap != null)
                {
                    if (e.NewValues["IsActive"] != null)
                    {
                        bool IsActive = bool.Parse(e.NewValues["IsActive"].ToString());
                        if (IsActive)
                        {
                            if (bo.changeIsActiveAccountingPeriod(uow))//, Guid.Parse(treelistCurrency.FocusedNode.Key.ToString())
                            {
                                ap.IsActive = true;
                            }
                            if (bo.changeIsDefaultAccountingPeriodType(uow))
                            {
                                AccPTId.IsDefault = true;
                                AccPTId.Save();
                                //if (ap.ParentAccountingPeriodId != null)
                                //{
                                //    Guid parentID = Guid.Parse(ap.ParentAccountingPeriodId.AccountingPeriodId.ToString());
                                //    bo.changeIsActiveParentInParentAccP(uow, parentID, IsActive);
                                //}
                            }
                        }
                        else
                        {
                            ap.IsActive = false;
                        }
                    }
                    if (e.NewValues["Description"] == null)
                    {
                        e.NewValues["Description"] = "";
                    }
                    ap.Description  = e.NewValues["Description"].ToString();
                    ap.Code         = e.NewValues["Code"].ToString();
                    ap.FromDateTime = DateTime.Parse(e.NewValues["FromDateTime"].ToString());
                    ap.ToDateTime   = DateTime.Parse(e.NewValues["ToDateTime"].ToString());
                    uow.FlushChanges();
                }
                treelist.CancelEdit();
                GridACCPeriodType.DataBind();
                treelist.JSProperties.Add("cpSaved", true);
            }
            catch (Exception)
            {
                e.Cancel = true;
                throw;
            }
        }
Пример #4
0
        protected void treelistCurrency_NodeUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            e.Cancel = true;
            using (UnitOfWork uow = XpoHelper.GetNewUnitOfWork())
                try
                {
                    ASPxTreeList treelistCurrency = sender as ASPxTreeList;
                    object       keyValue         = GetMasterRowKeyValue(treelistCurrency);

                    #region Check ExchangeRate

                    bool         CanInsert = true;
                    CurrencyType type      = session.GetObjectByKey <CurrencyType>(keyValue);
                    NAS.DAL.Accounting.Currency.Currency defaultCurrency = bo.get_Currency_true_master(session, type.CurrencyTypeId.ToString(), true, Constant.ROWSTATUS_ACTIVE);
                    if (e.NewValues["IsDefault"] != null)
                    {
                        if (e.NewValues["IsDefault"].Equals(true))
                        {
                            if (defaultCurrency != null)
                            {
                                if (bo.IsUsedInExchangeRate(session, defaultCurrency.CurrencyId))
                                {
                                    CanInsert = false;
                                }
                            }
                            else
                            {
                                CanInsert = true;
                            }
                        }
                        else
                        {
                            CanInsert = true;
                        }
                        if (!CanInsert)
                        {
                            throw new Exception(String.Format("Không được chọn Đơn Vị Mặc Định! Vì Đơn Vị Tiền Tệ {0} đã sử dụng trong Tỷ Giá", defaultCurrency.Code));
                        }
                    }
                    #endregion

                    #region CHECK CODE
                    CurrencyType cur = uow.GetObjectByKey <CurrencyType>(Guid.Parse(keyValue.ToString()));
                    if (!e.OldValues["Code"].Equals(e.NewValues["Code"]))
                    {
                        if (bo.checkCurrency_Code(session, e.NewValues["Code"].ToString().Trim(), cur.CurrencyTypeId.ToString()))
                        {
                            e.Cancel = true;
                            throw new Exception(String.Format("Lỗi Đơn Vị Tiền Tệ đã có"));
                        }
                    }
                    #endregion
                    object MasterKey = GetMasterRowKeyValue(treelistCurrency);
                    Guid   key       = Guid.Parse(e.Keys[0].ToString());
                    if (e.NewValues["IsDefault"] == null)
                    {
                        e.NewValues["IsDefault"] = false;
                    }

                    bool IsDefault = bool.Parse(e.NewValues["IsDefault"].ToString());

                    NAS.DAL.Accounting.Currency.Currency currency = uow.GetObjectByKey <NAS.DAL.Accounting.Currency.Currency>(key);
                    #region Currency.IsDefault
                    if (IsDefault)
                    {
                        //if (bo.changeIsDefaultCurrency(uow))//, Guid.Parse(treelistCurrency.FocusedNode.Key.ToString())
                        //{
                        currency.IsDefault = true;
                        //}
                        //bo.changeCoefficientCurrency(uow); // Coefficient = 0;
                        if (IsDefault)
                        {
                            bo.updateIsDefaultCurrency(uow, Guid.Parse(MasterKey.ToString()), key, IsDefault);
                        }

                        //if (cur != null)
                        //{
                        //    if (bo.changeIsMasterCurrencyType(uow))
                        //        cur.IsMaster = true;
                        //    cur.Save();
                        //}
                    }
                    else
                    {
                        bo.updateIsDefaultCurrency(uow, Guid.Parse(MasterKey.ToString()), key, IsDefault);
                        currency.IsDefault         = false;
                        e.NewValues["Description"] = "";
                    }
                    #endregion
                    currency.Code        = e.NewValues["Code"].ToString();
                    currency.Name        = e.NewValues["Name"].ToString();
                    currency.NumRequired = double.Parse(e.NewValues["NumRequired"].ToString());

                    uow.FlushChanges();
                    treelistCurrency.CancelEdit();
                    treelistCurrency.DataBind();
                    GridCurrencyUnit.DataBind();
                    treelistCurrency.JSProperties.Add("cpSaved", true);
                }
                catch (Exception)
                {
                    uow.RollbackTransaction();
                    throw;
                }
        }
Пример #5
0
        protected void treelistACCPeriod_NodeInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            try
            {
                e.Cancel = true;
                ASPxTreeList         treelist   = sender as ASPxTreeList;
                object               keyValue   = GetMasterRowKeyValue(treelist);
                AccountingPeriodType AccPTypeId = uow.GetObjectByKey <AccountingPeriodType>(Guid.Parse(keyValue.ToString()));
                if (AccPTypeId == null)
                {
                    throw new Exception(String.Format("AccountingPeriodType is not exist in System"));
                }

                if (bo.checkAccountingPeriod_Code(uow, e.NewValues["Code"].ToString().Trim(), AccPTypeId.AccountingPeriodTypeId.ToString()))
                {
                    throw new Exception(String.Format("Lỗi Chu Kỳ Đã Có"));
                }
                else
                {
                    AccountingPeriod ap = new AccountingPeriod(uow);

                    #region add parentACCPeriodId
                    string parentKeyStr = treelist.NewNodeParentKey.ToString();


                    if (parentKeyStr != null && !parentKeyStr.Equals(String.Empty))
                    {
                        NAS.DAL.Accounting.Journal.AccountingPeriod parentAccPeriod =
                            uow.GetObjectByKey <NAS.DAL.Accounting.Journal.AccountingPeriod>(Guid.Parse(parentKeyStr.ToString()));
                        if (parentAccPeriod == null)
                        {
                            throw new Exception(String.Format("AccountingPeriod is not exist in system"));
                        }
                        // ap.ParentAccountingPeriodId = parentAccPeriod;
                    }
                    #endregion

                    #region add AccountingPeriodTypeId
                    if (AccPTypeId != null)
                    {
                        ap.AccountingPeriodTypeId = AccPTypeId;
                    }
                    #endregion

                    #region add OrganizationId
                    Organization org = uow.FindObject <Organization>(new BinaryOperator("Name", "QUASAPHARCO", BinaryOperatorType.Equal));
                    if (org != null)
                    {
                        ap.OrganizationId = org;
                    }
                    #endregion

                    #region add IsActive
                    if (e.NewValues["IsActive"] != null)
                    {
                        bool IsActive = bool.Parse(e.NewValues["IsActive"].ToString());
                        if (IsActive)
                        {
                            if (bo.changeIsActiveAccountingPeriod(uow))//, Guid.Parse(treelistCurrency.FocusedNode.Key.ToString())
                            {
                                e.NewValues["IsActive"] = true;
                            }
                            if (bo.changeIsDefaultAccountingPeriodType(uow))
                            {
                                AccPTypeId.IsDefault = true;
                                AccPTypeId.Save();
                                // bo.changeIsActiveParentInParentAccP(uow, Guid.Parse(parentKeyStr.ToString()), IsActive);
                            }
                        }
                        else
                        {
                            e.NewValues["IsActive"] = false;
                        }
                        ap.IsActive = bool.Parse(e.NewValues["IsActive"].ToString());
                    }
                    #endregion
                    ap.Code         = e.NewValues["Code"].ToString();
                    ap.FromDateTime = DateTime.Parse(e.NewValues["FromDateTime"].ToString());
                    ap.ToDateTime   = DateTime.Parse(e.NewValues["ToDateTime"].ToString());

                    if (e.NewValues["Description"] == null)
                    {
                        e.NewValues["Description"] = "";
                    }
                    ap.Description = e.NewValues["Description"].ToString();
                    ap.RowStatus   = Utility.Constant.ROWSTATUS_ACTIVE;
                    uow.FlushChanges();
                    treelist.CancelEdit();
                }
                GridACCPeriodType.DataBind();
                treelist.JSProperties.Add("cpSaved", true);
            }
            catch (Exception)
            {
                e.Cancel = true;
                throw;
            }
        }