Beispiel #1
0
        public static void AutomaticUpdateNo(String strTableName)
        {
            BusinessObjectController ctrl = BusinessControllerFactory.GetBusinessController(strTableName);

            foreach (BusinessObject obj in ctrl.GetListAllObjects())
            {
                GenerateNo(obj);
                ctrl.UpdateObject(obj);
            }
        }
Beispiel #2
0
        public void ActionSave(bool isShowWaitingDlg)
        {
            if (ChangedItems.Count > 0 && ABCScreenManager.Instance.CheckTablePermission(this.TableName, TablePermission.AllowEdit) == false)
            {
                return;
            }
            if (RemovedItems.Count > 0 && ABCScreenManager.Instance.CheckTablePermission(this.TableName, TablePermission.AllowDelete) == false)
            {
                return;
            }
            if (NewItems.Count > 0 && ABCScreenManager.Instance.CheckTablePermission(this.TableName, TablePermission.AllowNew) == false)
            {
                return;
            }

            if (isShowWaitingDlg)
            {
                ABCHelper.ABCWaitingDialog.Show("", "Đang lưu ....");
            }

            List <T> lstDeletings = new List <T>();
            List <T> lstUpdatings = new List <T>();
            List <T> lstCreatings = new List <T>();

            #region Init
            foreach (T objT in RemovedItems.Values)
            {
                lstDeletings.Add(objT);
            }

            foreach (Guid iID in ChangedItems)
            {
                BusinessObject objT = GetItemByID(iID);
                if (objT != null)
                {
                    BusinessObjectHelper.SetAutoValue(objT);
                    lstUpdatings.Add((T)objT);
                }
            }

            foreach (int iIndex in NewItems)
            {
                BusinessObjectHelper.SetDefaultValue(this[iIndex]);
                BusinessObjectHelper.SetAutoValue(this[iIndex]);
                Guid iID = BusinessObjectHelper.GetIDValue(this[iIndex]);
                if (iID == Guid.Empty)
                {
                    lstCreatings.Add(this[iIndex]);
                }
                else
                {
                    lstUpdatings.Add(this[iIndex]);
                }
            }

            #endregion

            ABCStandardEventArg arg = new ABCStandardEventArg();
            OnSaving(this, ref lstDeletings, ref lstUpdatings, ref lstCreatings, arg);
            if (arg.Cancel)
            {
                return;
            }

            foreach (T objT in lstDeletings)
            {
                DeleteItem(objT);
            }

            foreach (T objT in lstUpdatings)
            {
                Controller.UpdateObject(objT);
            }

            foreach (T objT in lstCreatings)
            {
                Controller.CreateObject(objT);
            }

            ClearDetections();

            DataCachingProvider.RefreshLookupTable(this.TableName);

            OnSaved(this, ref lstDeletings, ref lstUpdatings, ref lstCreatings, new ABCStandardEventArg());

            if (isShowWaitingDlg)
            {
                ABCHelper.ABCWaitingDialog.Close();
            }
        }