private void SavePeriodType()
    {
        Form27PeriodTypeDTO form27CPeriodDetail = new Form27PeriodTypeDTO();
        form27CPeriodDetail = ESalesUnityContainer.Container.Resolve<IForm27CService>().GetForm27PeriodType();

        if (form27CPeriodDetail.form27cPeriodType_Id > 0)
        {         
            form27CPeriodDetail.ModifiedDate = DateTime.Now;
            form27CPeriodDetail.ModifiedBy = GetCurrentUserId();            
            form27CPeriodDetail.PeriodType = "0";

            ESalesUnityContainer.Container.Resolve<IForm27CService>().UpdateForm27PeriodType(form27CPeriodDetail);

            Form27PeriodTypeDTO newForm27CPeriodDetail = new Form27PeriodTypeDTO();
            newForm27CPeriodDetail.CreatedBy = GetCurrentUserId();
            newForm27CPeriodDetail.CreatedDate = DateTime.Now;            
            newForm27CPeriodDetail.PeriodType = "1";
            newForm27CPeriodDetail.PeriodTypeId = Convert.ToInt32(ddlPeriodType.SelectedValue);
           
            int result = ESalesUnityContainer.Container.Resolve<IForm27CService>().SaveForm27PeriodType(newForm27CPeriodDetail);

            if (result > 0)
            {
                ucMessageBox.ShowMessage("Saved Successfully.");
            }
            else
            {
                ucMessageBox.ShowMessage("Not saved.");
            }
        }
        else
        {
            Form27PeriodTypeDTO form27CPeriodDetails = new Form27PeriodTypeDTO();
            form27CPeriodDetails.CreatedDate = DateTime.Now;
            form27CPeriodDetails.CreatedBy = GetCurrentUserId();
            form27CPeriodDetails.PeriodTypeId = Convert.ToInt32(ddlPeriodType.SelectedValue);
            form27CPeriodDetails.PeriodType = "1";

            int result = ESalesUnityContainer.Container.Resolve<IForm27CService>().SaveForm27PeriodType(form27CPeriodDetails);

            if (result > 0)
            {
                ucMessageBox.ShowMessage("Saved Successfully.");
            }
            else
            {
                ucMessageBox.ShowMessage("Not saved.");
            }
        }
    }
Ejemplo n.º 2
0
        public int UpdateForm27PeriodType(Form27PeriodTypeDTO Form27CPeriodTypeDetails)
        {
            form27cperiodtype form27cperiodtypeEntity = new form27cperiodtype();
            int form27cPeriodType_Id;
            using (TransactionScope transactionScope = new TransactionScope())
            {
                AutoMapper.Mapper.Map(Form27CPeriodTypeDetails, form27cperiodtypeEntity);
                ESalesUnityContainer.Container.Resolve<IGenericRepository<form27cperiodtype>>().Update(form27cperiodtypeEntity);
                form27cPeriodType_Id = Form27CPeriodTypeDetails.form27cPeriodType_Id;

                transactionScope.Complete();
            }
            return form27cPeriodType_Id;
        }
Ejemplo n.º 3
0
        public int SaveForm27PeriodType(Form27PeriodTypeDTO form27CPeriodType)
        {
            form27cperiodtype form27CPerioTypeEntity = new form27cperiodtype();

            using (TransactionScope transactionScope = new TransactionScope())
            {
                AutoMapper.Mapper.Map(form27CPeriodType, form27CPerioTypeEntity);
                if (form27CPeriodType.form27cPeriodType_Id == 0)
                {
                    ESalesUnityContainer.Container.Resolve<IGenericRepository<form27cperiodtype>>().Save(form27CPerioTypeEntity);
                }
                transactionScope.Complete();
            }
            return form27CPerioTypeEntity.form27cPeriodType_Id;

        }
Ejemplo n.º 4
0
        public Form27PeriodTypeDTO GetForm27PeriodType()
        {
            Form27PeriodTypeDTO Form27PeriodTypeDetails = new Form27PeriodTypeDTO();
            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<form27cperiodtype>>()
                .GetSingle(item => item.form27cPeriodType_Id > 0 && item.PeriodType == "1"), Form27PeriodTypeDetails);

            return Form27PeriodTypeDetails;
        }