protected void grdDocType_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals(Globals.GridCommandEvents.ADDNEW))
        {
            if (Page.IsValid)
            {
                GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);

                DocTypeDTO docTypeDetails = new DocTypeDTO();
                docTypeDetails.Doc_Name = ((TextBox)row.FindControl("txtNewDocType")).Text;
                docTypeDetails.Doc_Group = Convert.ToInt32(ddldocGroup.SelectedValue);
                docTypeDetails.Doc_Acronym = ((TextBox)row.FindControl("txtNewDocAcronym")).Text;
                docTypeDetails.Doc_Mandatory = ((CheckBox)row.FindControl("chkNewMandatory")).Checked ? true : false;
                docTypeDetails.Doc_IsUnique = ((CheckBox)row.FindControl("chkNewUnique")).Checked ? true : false;
                docTypeDetails.Doc_CreatedDate = DateTime.Now;
                docTypeDetails.Doc_LastUpdatedDate = DateTime.Now;
                docTypeDetails.Doc_CreatedBy = GetCurrentUserId();

                int docId = ESalesUnityContainer.Container.Resolve<IDocumentTypeService>().SaveCustDocumentTypeInfo(docTypeDetails);
                ucMessageBoxForGrid.ShowMessage(Messages.DocumentTypeSavedSuccessfully);
            }
        }
    }
 protected void grdDocType_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     if (Page.IsValid)
     {            
         DocTypeDTO docTypeDetails = new DocTypeDTO();
         docTypeDetails = ESalesUnityContainer.Container.Resolve<IDocumentTypeService>()
             .GetDocumentTypeListByDocId(Convert.ToInt32(grdDocType.DataKeys[e.RowIndex].Value));
         docTypeDetails.Doc_Name = ((TextBox)grdDocType.Rows[e.RowIndex].FindControl("txtDocType")).Text;
         docTypeDetails.Doc_Acronym = ((TextBox)grdDocType.Rows[e.RowIndex].FindControl("txtDocAcronym")).Text;
         docTypeDetails.Doc_Mandatory = ((CheckBox)grdDocType.Rows[e.RowIndex].FindControl("chkMandatory")).Checked ? true : false;
         docTypeDetails.Doc_IsUnique = ((CheckBox)grdDocType.Rows[e.RowIndex].FindControl("chkUnique")).Checked ? true : false;
         docTypeDetails.Doc_CreatedDate = DateTime.Now;
         docTypeDetails.Doc_LastUpdatedDate = DateTime.Now;
         docTypeDetails.Doc_CreatedBy = GetCurrentUserId();
         
         //To update document type
         int docId = ESalesUnityContainer.Container.Resolve<IDocumentTypeService>()
             .UpdateCustomerDocumentTypeInfo(docTypeDetails);
         ucMessageBoxForGrid.ShowMessage(Messages.DocumentTypeUpdatedSuccessfully);
     }
 }
        /// <summary>
        /// verify Doc type exists or not by groupId,docTypeId and docTypeName
        /// </summary>
        /// <param name="groupId">Int32:groupId</param>
        /// <param name="docTypeId">int32:docTypeId</param>
        /// <param name="docTypeName">String:docTypeName</param>
        /// <returns></returns>
        public bool DocTypeExists(int groupId, int docTypeId, string docTypeName)
        {
            DocTypeDTO docTypeDetails = new DocTypeDTO();
            bool result = false;

            if (docTypeId == 0)
            {
                AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<doctype>>()
                    .GetSingle(item => item.Doc_Group == groupId && item.Doc_Name == docTypeName && item.Doc_IsDeleted == false), docTypeDetails);
            }
            else
            {
                AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<doctype>>()
                    .GetSingle(item => item.Doc_Group == groupId && item.Doc_Id != docTypeId
                        && item.Doc_Name == docTypeName && item.Doc_IsDeleted == false), docTypeDetails);
            }

            if (docTypeDetails.Doc_Id > 0)
            {
                result = true;
            }

            //return the value
            return result;
        }
        /// <summary>
        /// Save Cust Document Type Info
        /// </summary>
        /// <param name="docTypeDetails"></param>
        /// <returns></returns>
        public int SaveCustDocumentTypeInfo(DocTypeDTO docTypeDetails)
        {
            doctype doctypeEntity = new doctype();
            AutoMapper.Mapper.Map(docTypeDetails, doctypeEntity);

            ESalesUnityContainer.Container.Resolve<IGenericRepository<doctype>>().Save(doctypeEntity);

            //return value
            return doctypeEntity.Doc_Id;
        }
        /// <summary>
        /// Get Document Type List By DocId
        /// </summary>
        /// <param name="documentId">Int32:documentId</param>
        /// <returns></returns>
        public DocTypeDTO GetDocumentTypeListByDocId(int documentId)
        {
            DocTypeDTO docTypeDetails = new DocTypeDTO();
            AutoMapper.Mapper.Map(ESalesUnityContainer.Container.Resolve<IGenericRepository<doctype>>().GetSingle(
               item => item.Doc_IsDeleted == false && item.Doc_Id == documentId), docTypeDetails);

            //return the value
            return docTypeDetails;
        }