コード例 #1
0
        public ProductColor Add(ProductColor data)
        {
            var maxId = ProductColorDAO.SelectSpecificType(null, Projections.Max("ColorId"));

            data.ColorId = maxId == null ? 1 : (Int64.Parse(maxId.ToString()) + 1);

            ProductColorDAO.Add(data);
            return data;
        }
コード例 #2
0
 private ProductMaster CreateProductMaster(ProductSize size, ProductColor color)
 {
     return new ProductMaster
     {
         ProductName = productMasterControl.txtProductName.Text,
         ImagePath = productMasterControl.txtImagePath.Text,
         Description = productMasterControl.txtDescription.Text,
         Packager = productMasterControl.cbbPackager.SelectedIndex > 0 ? ((Packager)productMasterControl.cbbPackager.SelectedItem) : null,
         ProductSize = size,
         ProductType = productMasterControl.cbbProductType.SelectedIndex > 0 ? ((ProductType)productMasterControl.cbbProductType.SelectedItem) : null,
         ProductColor = color,
         Country = productMasterControl.cbbCountry.SelectedIndex > 0 ? ((Country)productMasterControl.cbbCountry.SelectedItem) : null,
         Manufacturer = productMasterControl.cbbManufacturer.SelectedIndex > 0 ? ((Manufacturer)productMasterControl.cbbManufacturer.SelectedItem) : null,
         Distributor = productMasterControl.cbbDistributor.SelectedIndex > 0 ? ((Distributor)productMasterControl.cbbDistributor.SelectedItem) : null
     };
 }
コード例 #3
0
 public void Update(ProductColor data)
 {
     ProductColorDAO.Update(data);
 }
コード例 #4
0
 public void Delete(ProductColor data)
 {
     ProductColorDAO.Delete(data);
 }
コード例 #5
0
 public void universalMasterSaveView_SaveUniversalMasterEvent(object sender, UniversalMasterSaveEventArgs e)
 {
     object obj = null;
     switch (e.MasterType)
     {
         case MasterType.PRODUCT_TYPE:
             if (e.Id != 0)
             {
                 obj = new ProductType{TypeId = e.Id, TypeName = e.Name, UpdateDate = DateTime.Now};
                 ProductTypeLogic.Update((ProductType)obj);
             }
             else
             {
                 var criteria = new ObjectCriteria();
                 criteria.AddEqCriteria("TypeName", e.Name).AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                 IList list = ProductTypeLogic.FindAll(criteria);
                 if (list.Count == 0)
                 {
                     obj = new ProductType { TypeName = e.Name, UpdateDate = DateTime.Now, CreateDate = DateTime.Now };
                     ProductTypeLogic.Add((ProductType)obj);
                 }
                 else
                 {
                     obj = list[0];
                 }
             }
             break;
         case MasterType.PRODUCT_SIZE:
             if (e.Id != 0)
             {
                 obj = new ProductSize { SizeId = e.Id, SizeName = e.Name };
                 ProductSizeLogic.Update((ProductSize)obj);
             }
             else
             {
                 var criteria = new ObjectCriteria();
                 criteria.AddEqCriteria("SizeName", e.Name).AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                 IList list = ProductSizeLogic.FindAll(criteria);
                 if (list.Count == 0)
                 {
                     obj = new ProductSize { SizeName = e.Name };
                     ProductSizeLogic.Add((ProductSize)obj);
                 }
                 else
                 {
                     obj = list[0];
                 }
             }
             break;
         case MasterType.PRODUCT_COLOR:
             if (e.Id != 0)
             {
                 obj = new ProductColor { ColorId = e.Id, ColorName = e.Name };
                 ProductColorLogic.Update((ProductColor)obj);
             }
             else
             {
                 var criteria = new ObjectCriteria();
                 criteria.AddEqCriteria("ColorName", e.Name).AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                 IList list = ProductColorLogic.FindAll(criteria);
                 if (list.Count == 0)
                 {
                     obj = new ProductColor { ColorName = e.Name };
                     ProductColorLogic.Add((ProductColor)obj);
                 }
                 else
                 {
                     obj = list[0];
                 }
             }
             break;
         case MasterType.COUNTRY:
             if (e.Id != 0)
             {
                 obj = new Country { CountryId = e.Id, CountryName = e.Name };
                 CountryLogic.Update((Country)obj);
             }
             else
             {
                 var criteria = new ObjectCriteria();
                 criteria.AddEqCriteria("CountryName", e.Name).AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                 IList list = CountryLogic.FindAll(criteria);
                 if (list.Count == 0)
                 {
                     obj = new Country { CountryName = e.Name };
                     CountryLogic.Add((Country)obj);
                 }
                 else
                 {
                     obj = list[0];
                 }
             }
             break;
         case MasterType.DISTRIBUTOR:
             if (e.Id != 0)
             {
                 obj = new Distributor { DistributorId = e.Id, DistributorName = e.Name };
                 DistributorLogic.Update((Distributor)obj);
             }
             else
             {
                 var criteria = new ObjectCriteria();
                 criteria.AddEqCriteria("DistributorName", e.Name).AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                 IList list = DistributorLogic.FindAll(criteria);
                 if (list.Count == 0)
                 {
                     obj = new Distributor { DistributorName = e.Name };
                     DistributorLogic.Add((Distributor)obj);
                 }
                 else
                 {
                     obj = list[0];
                 }
             }
             break;
         case MasterType.MANUFACTURER:
             if (e.Id != 0)
             {
                 obj = new Manufacturer { ManufacturerId = e.Id, ManufacturerName = e.Name };
                 ManufacturerLogic.Update((Manufacturer)obj);
             }
             else
             {
                 var criteria = new ObjectCriteria();
                 criteria.AddEqCriteria("ManufacturerName", e.Name).AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                 IList list = ManufacturerLogic.FindAll(criteria);
                 if (list.Count == 0)
                 {
                     obj = new Manufacturer { ManufacturerName = e.Name };
                     ManufacturerLogic.Add((Manufacturer)obj);
                 }
                 else
                 {
                     obj = list[0];
                 }
             }
             break;
         case MasterType.PACKAGER:
             if (e.Id != 0)
             {
                 obj = new Packager { PackagerId = e.Id, PackagerName = e.Name };
                 PackagerLogic.Update((Packager)obj);
             }
             else
             {
                 var criteria = new ObjectCriteria();
                 criteria.AddEqCriteria("PackagerName", e.Name).AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                 IList list = PackagerLogic.FindAll(criteria);
                 if (list.Count == 0)
                 {
                     obj = new Packager { PackagerName = e.Name };
                     PackagerLogic.Add((Packager)obj);
                 }
                 else
                 {
                     obj = list[0];
                 }
             }
             break;
         default:
             break;
     }
     e.CreatedData = obj;
 }
コード例 #6
0
 private bool NotInList(BindingSource source, ProductColor color, out int index)
 {
     int count = 0;
     foreach (ProductColor productColor in source)
     {
         if (productColor.ColorName.Equals(color.ColorName))
         {
             index = count;
             return false;
         }
         count++;
     }
     index = -1;
     return true;
 }
コード例 #7
0
 private bool ExistInList(IList colorList, ProductColor color)
 {
     foreach (ProductColor list in colorList)
     {
         if (list.ColorName.Equals(color.ColorName))
         {
             return true;
         }
     }
     return false;
 }
コード例 #8
0
 /// <summary>
 /// Delete ProductColor from database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Delete(ProductColor data)
 {
     HibernateTemplate.Delete(data);
 }
コード例 #9
0
 /// <summary>
 /// Add ProductColor to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public ProductColor Add(ProductColor data)
 {
     HibernateTemplate.Save(data);
     return data;
 }
コード例 #10
0
 /// <summary>
 /// Update ProductColor to database.
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public void Update(ProductColor data)
 {
     HibernateTemplate.Update(data);
 }