Beispiel #1
0
 protected override void MoveLast()
 {
     //  if (CustomerPackage == null)
     {
         this._customerPackage = this.CustomerPackageManager.GetLast();
     }
 }
Beispiel #2
0
        //public EidtForm(Model.CustomerPackage CustomerPackage):this()
        //{
        //    // this =CustomerPackage;


        //    //this.CustomerPackage.detail = this.proceduresManager.Select(this.CustomerPackage);
        //    //this.bindingSourceProcedures.DataSource = this.proceduresManager.Select();
        //   // this.action = "update";
        //}
        //public EidtForm(Model.CustomerPackage CustomerPackage, string action):this()
        //{
        //    //this.CustomerPackage = CustomerPackage;

        //    //this.CustomerPackage.detail = this.proceduresManager.Select(this.CustomerPackage);
        //    //this.bindingSourceProcedures.DataSource = this.proceduresManager.Select();
        //    //this.action = action;
        //}
        #region Override
        //  int flag1 = 0;
        protected override void AddNew()
        {
            //flag1 = 1;


            this._customerPackage = new Model.CustomerPackage();

            if (customer != null)
            {
                this._customerPackage.Customer = customer;
            }

            this._customerPackage.CustomerPackageId = Guid.NewGuid().ToString();

            this._customerPackage.detail = new List <Model.CustomerPackageDetail>();

            // if (this.action == "insert")
            {
                Model.CustomerPackageDetail detail = new Model.CustomerPackageDetail();
                detail.CustomerPackageDetailId = Guid.NewGuid().ToString();
                detail.Product = new Book.Model.Product();
                this._customerPackage.detail.Add(detail);
                this.bindingSource1.Position = this.bindingSource1.IndexOf(detail);
            }
        }
        /// <summary>
        /// Update a CustomerPackage.
        /// </summary>
        public void Update(Model.CustomerPackage customerPackage)
        {
            if (string.IsNullOrEmpty(customerPackage.Id))
            {
                throw new Helper.RequireValueException(Model.CustomerPackage.PROPERTY_ID);
            }
            if (this.ExistsExcept(customerPackage))
            {
                throw new Helper.InvalidValueException(Model.CustomerPackage.PROPERTY_ID);
            }
            //
            // todo: add other logic here.
            //
            customerPackage.UpdateTime = DateTime.Now;
            //  accessor.Update(customerPackage);

            try
            {
                BL.V.BeginTransaction();
                accessor.Delete(customerPackage.CustomerPackageId);
                this.Insert(customerPackage);
                BL.V.CommitTransaction();
            }
            catch
            {
                BL.V.RollbackTransaction();
                throw;
            }
        }
Beispiel #4
0
        protected override void MoveNext()
        {
            Model.CustomerPackage CustomerPackage = this.CustomerPackageManager.GetNext(this._customerPackage);
            if (CustomerPackage == null)
            {
                throw new InvalidOperationException(Properties.Resources.ErrorNoMoreRows);
            }

            this._customerPackage = CustomerPackage;
        }
Beispiel #5
0
        private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            if (flag == 1)
            {
                flag = 0;
                return;
            }

            if (flag == 0)
            {
                // if (flag1 == 0)
                {
                    if (e.Node != null && e.Node.ParentNode != null)
                    {
                        this._customerPackage = CustomerPackageManager.Get(e.Node.Tag.ToString());
                        if (this._customerPackage != null)
                        {
                            this._customerPackage.detail = this.CustomerPackageDetailManager.GetByPackageId(this._customerPackage.CustomerPackageId);


                            this.bindingSource1.DataSource = this._customerPackage.detail;
                            this.action = "view";
                            this.Refresh();
                        }
                    }
                    if (e.Node != null && e.Node.ParentNode == null)
                    {
                        customer = customerManager.Get(e.Node.Tag.ToString());

                        if (this.action == "insert")
                        {
                            this._customerPackage.Customer   = customer;
                            this.newChooseCustomer.EditValue = this._customerPackage.Customer as Model.Customer;
                        }
                    }
                }
                //  flag1 = 0;
            }
        }
Beispiel #6
0
        protected override void Delete()
        {
            if (this._customerPackage == null)
            {
                return;
            }
            if (MessageBox.Show(Properties.Resources.ConfirmToDelete, this.Text, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != DialogResult.OK)
            {
                return;
            }
            try
            {
                this.CustomerPackageManager.Delete(this._customerPackage.CustomerPackageId);


                foreach (TreeListNode listNode in this.treeList1.Nodes)
                {
                    for (int i = 0; i < listNode.Nodes.Count; i++)
                    {
                        if (listNode.Nodes[i].Tag.ToString() == this._customerPackage.CustomerPackageId && listNode.Nodes[i].ParentNode != null)
                        {
                            listNode.Nodes.Remove(listNode.Nodes[i]);
                        }
                    }
                }
                this._customerPackage = this.CustomerPackageManager.GetNext(this._customerPackage);
                if (this._customerPackage == null)
                {
                    this._customerPackage = this.CustomerPackageManager.GetLast();
                }
            }
            catch
            {
                throw;
            }

            return;
        }
        /// <summary>
        /// Insert a CustomerPackage.
        /// </summary>
        public void Insert(Model.CustomerPackage customerPackage)
        {
            if (string.IsNullOrEmpty(customerPackage.Id))
            {
                throw new Helper.RequireValueException(Model.CustomerPackage.PROPERTY_ID);
            }
            if (this.Exists(customerPackage.Id))
            {
                throw new Helper.InvalidValueException(Model.CustomerPackage.PROPERTY_ID);
            }


            customerPackage.InsertTime = DateTime.Now;
            customerPackage.UpdateTime = DateTime.Now;
            accessor.Insert(customerPackage);
            foreach (Model.CustomerPackageDetail customerPackageDetail in customerPackage.detail)
            {
                if (customerPackageDetail.Product == null || string.IsNullOrEmpty(customerPackageDetail.ProductId))
                {
                    continue;
                }
                accessorDetail.Insert(customerPackageDetail);
            }
        }
Beispiel #8
0
 protected override void MoveFirst()
 {
     this._customerPackage = this.CustomerPackageManager.GetFirst();
 }
 public Model.CustomerPackage GetNext(Model.CustomerPackage e)
 {
     return(accessor.GetNext(e));
 }
 public Model.CustomerPackage GetPrev(Model.CustomerPackage e)
 {
     return(accessor.GetPrev(e));
 }
 public bool HasRowsAfter(Model.CustomerPackage e)
 {
     return(accessor.HasRowsAfter(e));
 }
 public bool HasRowsBefore(Model.CustomerPackage e)
 {
     return(accessor.HasRowsBefore(e));
 }
 public bool ExistsExcept(Model.CustomerPackage e)
 {
     return(accessor.ExistsExcept(e));
 }