Пример #1
0
        internal static String Save(DB.ITM_DIS_Discount entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntityInventoryContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntityInventoryContext.ITM_DIS_Discount.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                return(dataContext.PackageValidationException());
            }

            return("Success");
        }
Пример #2
0
        private bool IsCustomerValueValid()
        {
            bool isValid = true;

            DB.ITM_DIS_Discount ITM_DIS_Discount = ((DB.ITM_DIS_Discount)BindingSource.DataSource);

            if (ITM_DIS_Discount.InventoryDiscountCode != null || ITM_DIS_Discount.InventoryId != null)
            {
                txtInventoryDiscountCode.ErrorText = String.Empty;
                ddlInventory.ErrorText             = String.Empty;
                isValid = true;
            }
            else
            {
                txtInventoryDiscountCode.ErrorText = "Enter discount code";
                ddlInventory.ErrorText             = "Select Item ...";
                isValid = false;
            }

            return(isValid);
        }
Пример #3
0
        private bool IsDiscountValid()
        {
            bool isValid = true;

            DB.ITM_DIS_Discount ITM_DIS_Discount = ((DB.ITM_DIS_Discount)BindingSource.DataSource);

            if (ITM_DIS_Discount.CompanyDiscount != null || ITM_DIS_Discount.WorkshopDiscount != null)
            {
                txtCompanyDiscount.ErrorText  = String.Empty;
                txtWorkshopDiscount.ErrorText = String.Empty;
                isValid = true;
            }
            else
            {
                txtCompanyDiscount.ErrorText  = "Enter discount amount";
                txtWorkshopDiscount.ErrorText = "Enter discount amount";
                isValid = false;
            }

            return(isValid);
        }
Пример #4
0
        protected override bool SaveSuccessful()
        {
            try
            {
                using (new CDS.Client.Desktop.Essential.UTL.WaitCursor())
                {
                    this.OnSaveRecord();
                    if (!IsValid)
                    {
                        return(false);
                    }

                    DB.ITM_DIS_Discount ITM_DIS_Discount = ((DB.ITM_DIS_Discount)BindingSource.DataSource);
                    ITM_DIS_Discount.DiscountAmountTypeId = Convert.ToByte(rgDiscountType.EditValue);
                    //1	STOCK CODE vs ACCOUNT NUMBER
                    if (ITM_DIS_Discount.InventoryId != null && ITM_DIS_Discount.EntityId != null)
                    {
                        ITM_DIS_Discount.DiscountTypeId = (byte)BL.ITM.ITM_DIS_Type.StockCodevsAccountNumber;
                    }
                    //2	STOCK CODE vs ACCOUNT Discount CODE
                    else if (ITM_DIS_Discount.InventoryId != null && ITM_DIS_Discount.CompanyDiscountCode != null)
                    {
                        ITM_DIS_Discount.DiscountTypeId = (byte)BL.ITM.ITM_DIS_Type.StockCodevsAccountDiscountCode;
                    }
                    //3	STOCK Discount CODE vs ACCOUNT NUMBER
                    else if (ITM_DIS_Discount.InventoryDiscountCode != null && ITM_DIS_Discount.EntityId != null)
                    {
                        ITM_DIS_Discount.DiscountTypeId = (byte)BL.ITM.ITM_DIS_Type.StockDiscountCodevsAccountNumber;
                    }
                    //4	STOCK Discount CODE vs ACCOUNT Discount CODE
                    else if (ITM_DIS_Discount.InventoryDiscountCode != null && ITM_DIS_Discount.CompanyDiscountCode != null)
                    {
                        ITM_DIS_Discount.DiscountTypeId = (byte)BL.ITM.ITM_DIS_Type.StockDiscountCodevsAccountDiscountCode;
                    }

                    try
                    {
                        using (TransactionScope transaction = DataContext.GetTransactionScope())
                        {
                            BL.EntityController.SaveITM_DIS_Discount((DB.ITM_DIS_Discount)BindingSource.DataSource, DataContext);
                            DataContext.EntityInventoryContext.SaveChanges();
                            DataContext.CompleteTransaction(transaction);
                        }
                        DataContext.EntityInventoryContext.AcceptAllChanges();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        DataContext.EntityInventoryContext.RejectChanges();
                        HasErrors = true;
                        if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                        {
                            throw ex;
                        }
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                HasErrors = true;
                if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                {
                    throw ex;
                }
                return(false);
            }
        }
Пример #5
0
 public static DB.ITM_DIS_Discount GetPreviousItem(DB.ITM_DIS_Discount itm_dis_discount, DataContext dataContext)
 {
     return(dataContext.EntityInventoryContext.ITM_DIS_Discount.OrderByDescending(o => o.Id).Where(n => n.Id < itm_dis_discount.Id && n.Id != itm_dis_discount.Id).FirstOrDefault());
 }