Ejemplo n.º 1
0
 /// <summary>
 /// Select by primary key.
 /// </summary>
 public Model.PackageType Get(string packageTypeId)
 {
     Model.PackageType type = accessor.Get(packageTypeId);
     type.PruoductsDetails = packageDetailsAccessor.Select(type);
     type.CustomerDetails  = packageTypeCustomerAccessor.Select(type);
     return(type);
 }
Ejemplo n.º 2
0
        public void MyClick(ref ChooseItem item)
        {
            ChoosePackageTypeForm f = new ChoosePackageTypeForm();

            if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Model.PackageType packageType = f.SelectedItem as Model.PackageType;
                item = new ChooseItem(packageType, packageType.Id, packageType.PackagePypeName);
            }
        }
Ejemplo n.º 3
0
        //protected override string GetInvoiceKind()
        //{
        //    return "PackageType";
        //}

        //protected override string GetSettingId()
        //{
        //    return "PackageTypeRule";
        //}
        private void validate(Model.PackageType package)
        {
            if (string.IsNullOrEmpty(package.Id))
            {
                throw new Helper.RequireValueException(Model.PackageType.PROPERTY_ID);
            }
            if (string.IsNullOrEmpty(package.PackagePypeName))
            {
                throw new Helper.RequireValueException(Model.PackageType.PROPERTY_PACKAGEPYPENAME);
            }
        }
Ejemplo n.º 4
0
 public void MyLeave(ref ChooseItem item)
 {
     BL.PackageTypeManager manager     = new Book.BL.PackageTypeManager();
     Model.PackageType     packageType = manager.GetById(item.ButtonText);
     if (packageType != null)
     {
         item.EditValue  = packageType;
         item.LabelText  = packageType.PackagePypeName;
         item.ButtonText = packageType.Id;
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Insert a PackageType.
        /// </summary>
        public void Insert(Model.PackageType packageType)
        {
            //
            // todo:add other logic here
            //
            //  validate(packageType);
            //if (this.Exists(packageType.Id))
            //{
            //    throw new Helper.InvalidValueException(Model.PackageType.PROPERTY_ID);
            //}
            try
            {
                V.BeginTransaction();
                //packageType.CreateDate = DateTime.Now;
                //packageType.InsertTime = DateTime.Now;

                //packageType.PackageTypeId = Guid.NewGuid().ToString();
                //accessor.Insert(packageType);

                foreach (Model.PackageDetails details in packageType.PruoductsDetails)
                {
                    if (string.IsNullOrEmpty(details.PackageDetailsId))
                    {
                        details.PackageDetailsId = Guid.NewGuid().ToString();
                    }
                    details.PackageTypeId = packageType.PackageTypeId;
                    details.ProductId     = details.Product.ProductId;

                    packageDetailsAccessor.Insert(details);
                }

                foreach (Model.PackageTypeCustomer packageCustomer in packageType.CustomerDetails)
                {
                    if (string.IsNullOrEmpty(packageCustomer.PrimaryKey))
                    {
                        packageCustomer.PrimaryKey = Guid.NewGuid().ToString();
                    }
                    packageCustomer.CustomerId    = packageCustomer.Customer.CustomerId;
                    packageCustomer.PackageTypeId = packageType.PackageTypeId;

                    packageTypeCustomerAccessor.Insert(packageCustomer);
                }
                V.CommitTransaction();
            }
            catch
            {
                V.RollbackTransaction();
                throw;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Update a PackageType.
        /// </summary>
        public void Update(Model.PackageType packageType)
        {
            //
            // todo: add other logic here.
            //
            validate(packageType);
            //if (this.ExistsExcept(packageType))
            //{
            //    throw new Helper.InvalidValueException(Model.PackageType.PROPERTY_ID);
            //}
            // packageType.UpdateTime = DateTime.Now;

            //   packageDetailsAccessor.Delete(packageType);


            // packageType.PruoductsDetails = packageDetailsAccessor.Select(packageType);
            foreach (Model.PackageDetails details in packageType.PruoductsDetails)
            {
                if (string.IsNullOrEmpty(details.PackageDetailsId))
                {
                    details.PackageDetailsId = Guid.NewGuid().ToString();
                }
                details.PackageTypeId = packageType.PackageTypeId;
                details.ProductId     = details.Product.ProductId;

                packageDetailsAccessor.Insert(details);
            }
            //packageTypeCustomerAccessor.Delete(packageType);
            //foreach (Model.PackageTypeCustomer packageCustomer in packageType.CustomerDetails)
            //{
            //    if (string.IsNullOrEmpty(packageCustomer.PrimaryKey))
            //    {
            //        packageCustomer.PrimaryKey = Guid.NewGuid().ToString();
            //    }
            //    packageCustomer.CustomerId = packageCustomer.Customer.CustomerId;
            //    packageCustomer.PackageTypeId = packageType.PackageTypeId;

            //    packageTypeCustomerAccessor.Insert(packageCustomer);
            //}

            accessor.Update(packageType);
        }
Ejemplo n.º 7
0
 public Model.PackageType GetNext(Model.PackageType e)
 {
     return(accessor.GetNext(e));
 }
Ejemplo n.º 8
0
 public Model.PackageType GetPrev(Model.PackageType e)
 {
     return(accessor.GetPrev(e));
 }
Ejemplo n.º 9
0
 public bool HasRowsAfter(Model.PackageType e)
 {
     return(accessor.HasRowsAfter(e));
 }
Ejemplo n.º 10
0
 public bool HasRowsBefore(Model.PackageType e)
 {
     return(accessor.HasRowsBefore(e));
 }
Ejemplo n.º 11
0
 public bool ExistsExcept(Model.PackageType e)
 {
     return(accessor.ExistsExcept(e));
 }