private void SaveAuthRepDocumentDetails(int authRepId)
    {
        IList<AuthRepDocDetailDTO> listAuthRep = new List<AuthRepDocDetailDTO>();
        IList<AuthRepDocumentsDTO> listAuthRepDocument = new List<AuthRepDocumentsDTO>();

        foreach (GridViewRow row in grdDocument.Rows)
        {
            if (row.RowType == DataControlRowType.DataRow)
            {
                if (((TextBox)(row.Cells[3].Controls[1])).Text != string.Empty)
                {
                    AuthRepDocDetailDTO authRepDocDetails = new AuthRepDocDetailDTO();
                    authRepDocDetails.AuthRep_Doc_AuthId = authRepId;
                    authRepDocDetails.AuthRep_Doc_DocId = Convert.ToInt32(grdDocument.DataKeys[row.RowIndex].Value);
                    authRepDocDetails.AuthRep_Doc_DocNo = ((TextBox)(row.Cells[3].Controls[1])).Text;

                    DateTimeFormatInfo dateTimeFormatterProvider = DateTimeFormatInfo.CurrentInfo.Clone() as DateTimeFormatInfo;
                    dateTimeFormatterProvider.ShortDatePattern = "dd/MM/yyyy";
                    if (((TextBox)(row.Cells[4].Controls[1])).Text != string.Empty)
                    {
                        authRepDocDetails.AuthRep_Doc_ExDate = DateTime.Parse(((TextBox)(row.Cells[4].Controls[1])).Text, dateTimeFormatterProvider);
                    }

                    AuthRepDocumentsDTO authRepDocument = new AuthRepDocumentsDTO();
                    authRepDocument.AuthRepDoc_CreatedBy = base.GetCurrentUserId();
                    authRepDocument.AuthRepDoc_CreatedDate = DateTime.Now;

                    if (((Label)(row.Cells[6].Controls[1])).Text.Trim() != string.Empty)
                    {
                        string filePath = Path.Combine(Convert.ToString(ViewState[Globals.StateMgmtVariables.FILEPATH]), ((Label)(row.Cells[6].Controls[1])).Text);
                        authRepDocument.AuthRepDoc_File = ImageToBlob.ConvertImageToByteArray(filePath);
                    }
                    else
                    {
                        authRepDocument.AuthRepDoc_File = null;
                    }

                    listAuthRepDocument.Add(authRepDocument);

                    authRepDocDetails.AuthRep_Doc_FileName = ((Label)(row.Cells[6].Controls[1])).Text;
                    authRepDocDetails.AuthRep_Doc_CreatedBy = GetCurrentUserId();
                    authRepDocDetails.AuthRep_Doc_CreatedDate = DateTime.Now;
                    authRepDocDetails.AuthRep_Doc_LastUpdatedDate = DateTime.Now;

                    listAuthRep.Add(authRepDocDetails);
                }
            }
        }

        //Save Auth Rep Document Details
        ESalesUnityContainer.Container.Resolve<IAuthRepService>().SaveAndUpdateAuthRepDocDetails(listAuthRep, listAuthRepDocument);
    }
예제 #2
0
        /// <summary>
        /// Get Auth Rep Doc Details By AuthRepId And DocId
        /// </summary>
        /// <param name="authRepId"></param>
        /// <param name="docId"></param>
        /// <returns></returns>
        public AuthRepDocDetailDTO GetAuthRepDocDetailsByAuthRepIdAndDocId(int authRepId, int docId)
        {
            AuthRepDocDetailDTO authRepDocDetails = new AuthRepDocDetailDTO();

            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocdetail>>()
           .GetSingle(item => item.AuthRep_Doc_DocId == docId && item.AuthRep_Doc_AuthId == authRepId
               && item.AuthRep_Doc_IsDeleted == false), authRepDocDetails);

            //return value
            return authRepDocDetails;
        } 
예제 #3
0
 /// <summary>
 /// To check AuthRep Document No Exists or not
 /// </summary>
 /// <param name="authRepDocId"></param>
 /// <param name="docId"></param>
 /// <param name="docNo"></param>
 /// <returns></returns>
 public bool AuthRepDocumentNoExists(int authRepDocId, int docId, string docNo)
 {
     AuthRepDocDetailDTO objAuthRepDocDetailDTO = new AuthRepDocDetailDTO();
     if (authRepDocId > 0)
     {
         AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocdetail>>().GetSingle
             (item => item.AuthRep_Doc_Id != authRepDocId && item.AuthRep_Doc_DocId == docId && item.AuthRep_Doc_DocNo  == docNo &&
                 item.AuthRep_Doc_IsDeleted == false), objAuthRepDocDetailDTO);
     }
     else
     {
         AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocdetail>>().GetSingle
              (item => item.AuthRep_Doc_DocId == docId && item.AuthRep_Doc_DocNo == docNo &&
                  item.AuthRep_Doc_IsDeleted == false), objAuthRepDocDetailDTO);
     }
     return objAuthRepDocDetailDTO.AuthRep_Doc_Id > 0 ? true : false;          
 }
예제 #4
0
        /// <summary>
        /// Delete Auth Rep Doc Details
        /// </summary>
        /// <param name="authRepDocs"></param>
        private static void DeleteAuthRepDocDetails(AuthRepDocDetailDTO authRepDocs)
        {
            authrepdocdetail authRepDocEntity = new authrepdocdetail();
            AutoMapper.Mapper.Map(authRepDocs, authRepDocEntity);

            ESalesUnityContainer.Container.Resolve<IGenericRepository<authrepdocdetail>>().Update(authRepDocEntity);
        }